Browse Source

Import upstream version 3.4.1

Aaron Turner 15 years ago
parent
commit
1bb6d0e15f
100 changed files with 32274 additions and 30117 deletions
  1. BIN
      ._configure.ac
  2. 5 6
      Makefile.am
  3. 20 15
      Makefile.in
  4. 5839 5067
      aclocal.m4
  5. 10 6
      autogen.sh
  6. 543 355
      config/config.guess
  7. 309 92
      config/config.sub
  8. 7512 5396
      config/ltmain.sh
  9. 13712 16666
      configure
  10. 210 244
      configure.ac
  11. BIN
      docs/._CHANGELOG
  12. 38 1
      docs/CHANGELOG
  13. 11 1
      docs/CREDIT
  14. 13 16
      docs/Makefile.am
  15. 29 23
      docs/Makefile.in
  16. 17 10
      lib/Makefile.in
  17. 17 14
      libopts/Makefile.am
  18. 34 24
      libopts/Makefile.in
  19. 129 0
      libopts/ag-char-map.h
  20. 55 23
      libopts/autoopts.c
  21. 8 6
      libopts/autoopts.h
  22. 202 130
      libopts/autoopts/options.h
  23. 176 139
      libopts/autoopts/usage-txt.h
  24. 12 3
      libopts/boolean.c
  25. 13 3
      libopts/compat/compat.h
  26. 171 201
      libopts/configfile.c
  27. 33 70
      libopts/cook.c
  28. 104 66
      libopts/enumeration.c
  29. 4 3
      libopts/environment.c
  30. 170 0
      libopts/file.c
  31. 62 56
      libopts/genshell.c
  32. 37 18
      libopts/genshell.h
  33. 8 0
      libopts/libopts.c
  34. 17 16
      libopts/load.c
  35. 36 10
      libopts/m4/libopts.m4
  36. 7 6
      libopts/makeshell.c
  37. 202 69
      libopts/nested.c
  38. 105 10
      libopts/numeric.c
  39. 582 0
      libopts/parse-duration.c
  40. 82 0
      libopts/parse-duration.h
  41. 10 3
      libopts/pgusage.c
  42. 29 8
      libopts/proto.h
  43. 26 17
      libopts/putshell.c
  44. 128 0
      libopts/reset.c
  45. 3 2
      libopts/restore.c
  46. 388 86
      libopts/save.c
  47. 4 3
      libopts/sort.c
  48. 27 8
      libopts/stack.c
  49. 6 3
      libopts/streqvcmp.c
  50. 3 2
      libopts/text_mmap.c
  51. 89 0
      libopts/time.c
  52. 11 11
      libopts/tokenize.c
  53. 32 15
      libopts/usage.c
  54. 123 0
      libopts/value-type.c
  55. 25 0
      libopts/value-type.h
  56. 7 10
      libopts/version.c
  57. 114 0
      libopts/xat-attribute.c
  58. 22 0
      libopts/xat-attribute.h
  59. 0 6
      scripts/Makefile.am
  60. 35 139
      scripts/Makefile.in
  61. 0 628
      scripts/man2html.c
  62. BIN
      src/._Makefile.am
  63. BIN
      src/._bridge.c
  64. BIN
      src/._send_packets.c
  65. BIN
      src/._sleep.c
  66. BIN
      src/._tcpbridge.c
  67. BIN
      src/._tcpbridge.h
  68. BIN
      src/._tcpprep.c
  69. BIN
      src/._tcpreplay.c
  70. BIN
      src/._tcpreplay.h
  71. BIN
      src/._tcpreplay_opts.def
  72. BIN
      src/._tree.c
  73. 28 29
      src/Makefile.am
  74. 140 74
      src/Makefile.in
  75. 246 88
      src/bridge.c
  76. 3 2
      src/bridge.h
  77. BIN
      src/common/._cidr.c
  78. BIN
      src/common/._dlt_names.h
  79. BIN
      src/common/._fakepoll.c
  80. BIN
      src/common/._fakepoll.h
  81. BIN
      src/common/._interface.c
  82. BIN
      src/common/._interface.h
  83. BIN
      src/common/._sendpacket.c
  84. 1 1
      src/common/Makefile.am
  85. 18 11
      src/common/Makefile.in
  86. 16 16
      src/common/cache.c
  87. 2 2
      src/common/cidr.c
  88. 3 74
      src/common/err.c
  89. 44 26
      src/common/err.h
  90. 3 3
      src/common/fakepcapnav.c
  91. 3 4
      src/common/get.c
  92. 8 3
      src/common/interface.c
  93. 2 2
      src/common/list.c
  94. 93 47
      src/common/sendpacket.c
  95. 22 3
      src/common/sendpacket.h
  96. 4 4
      src/common/services.c
  97. 1 1
      src/common/svn_version.c
  98. 19 19
      src/common/tcpdump.c
  99. 2 2
      src/common/timer.c
  100. 0 0
      src/common/timer.h

BIN
._configure.ac


+ 5 - 6
Makefile.am

@@ -1,6 +1,8 @@
 # $Id$
 # $Id$
 AUTOMAKE_OPTIONS = foreign
 AUTOMAKE_OPTIONS = foreign
 
 
+ACLOCAL_AMFLAGS = -I m4
+
 if NEED_LIBOPTS
 if NEED_LIBOPTS
 SUBDIRS = scripts lib $(LIBOPTS_DIR) src
 SUBDIRS = scripts lib $(LIBOPTS_DIR) src
 else
 else
@@ -18,8 +20,8 @@ update:
 
 
 DOCS_DIR = $(top_builddir)/docs
 DOCS_DIR = $(top_builddir)/docs
 
 
-man2html:
-	cd scripts && make man2html
+manpages:
+	cd src && make manpages
 
 
 docs: manpages
 docs: manpages
 	echo Making docs in $(DOCS_DIR)
 	echo Making docs in $(DOCS_DIR)
@@ -28,12 +30,9 @@ docs: manpages
 clean-docs:
 clean-docs:
 	cd $(DOCS_DIR) && make clean-docs
 	cd $(DOCS_DIR) && make clean-docs
 
 
-postweb: manpages doxygen
+postweb: docs doxygen
 	cd $(DOCS_DIR) && make postweb
 	cd $(DOCS_DIR) && make postweb
 
 
-manpages: man2html
-	cd src && make manpages
-
 TEST_DIR = $(top_builddir)/test
 TEST_DIR = $(top_builddir)/test
 
 
 autoopts:
 autoopts:

+ 20 - 15
Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -40,7 +40,8 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	config/install-sh config/ltmain.sh config/missing \
 	config/install-sh config/ltmain.sh config/missing \
 	config/mkinstalldirs
 	config/mkinstalldirs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -95,20 +96,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -118,10 +121,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -129,8 +131,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -154,7 +160,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -186,6 +192,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -212,6 +219,7 @@ top_srcdir = @top_srcdir@
 
 
 # $Id$
 # $Id$
 AUTOMAKE_OPTIONS = foreign
 AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I m4
 @NEED_LIBOPTS_FALSE@SUBDIRS = scripts lib src
 @NEED_LIBOPTS_FALSE@SUBDIRS = scripts lib src
 @NEED_LIBOPTS_TRUE@SUBDIRS = scripts lib $(LIBOPTS_DIR) src
 @NEED_LIBOPTS_TRUE@SUBDIRS = scripts lib $(LIBOPTS_DIR) src
 DIST_SUBDIRS = scripts lib libopts src docs test
 DIST_SUBDIRS = scripts lib libopts src docs test
@@ -267,7 +275,7 @@ clean-libtool:
 	-rm -rf .libs _libs
 	-rm -rf .libs _libs
 
 
 distclean-libtool:
 distclean-libtool:
-	-rm -f libtool
+	-rm -f libtool config.lt
 
 
 # This directory's subdirectories are mostly independent; you can cd
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
 # into them and run `make' without going through this Makefile.
@@ -344,7 +352,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 	mkid -fID $$unique
 tags: TAGS
 tags: TAGS
@@ -666,8 +674,8 @@ dist-hook: version manpages update
 update:
 update:
 	svn update
 	svn update
 
 
-man2html:
-	cd scripts && make man2html
+manpages:
+	cd src && make manpages
 
 
 docs: manpages
 docs: manpages
 	echo Making docs in $(DOCS_DIR)
 	echo Making docs in $(DOCS_DIR)
@@ -676,12 +684,9 @@ docs: manpages
 clean-docs:
 clean-docs:
 	cd $(DOCS_DIR) && make clean-docs
 	cd $(DOCS_DIR) && make clean-docs
 
 
-postweb: manpages doxygen
+postweb: docs doxygen
 	cd $(DOCS_DIR) && make postweb
 	cd $(DOCS_DIR) && make postweb
 
 
-manpages: man2html
-	cd src && make manpages
-
 autoopts:
 autoopts:
 	cd src && make autoopts
 	cd src && make autoopts
 
 

File diff suppressed because it is too large
+ 5839 - 5067
aclocal.m4


+ 10 - 6
autogen.sh

@@ -1,10 +1,14 @@
 #!/bin/sh
 #!/bin/sh
-
+rm -f config/config.guess config/config.sub config/ltmain.sh 2>/dev/null
 rm -f aclocal.m4 2>/dev/null
 rm -f aclocal.m4 2>/dev/null
-aclocal 
-# aclocal doesn't pick up libopts.m4 so we do it manually
-cat libopts/m4/libopts.m4 libopts/m4/liboptschk.m4  >> aclocal.m4
-autoconf
-automake
+aclocal  -I libopts/m4/
+if test -x "`which libtoolize`" ; then
+    libtoolize --copy
+else
+    # Necessary under OS X
+    glibtoolize --copy
+fi
+autoheader
+automake --add-missing --copy
 autoconf
 autoconf
 
 

File diff suppressed because it is too large
+ 543 - 355
config/config.guess


+ 309 - 92
config/config.sub

@@ -1,9 +1,10 @@
 #! /bin/sh
 #! /bin/sh
 # Configuration validation subroutine script.
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
 
-timestamp='2002-07-03'
+timestamp='2008-09-08'
 
 
 # This file is (in principle) common to ALL GNU software.
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 # The presence of a machine in this file suggests that SOME GNU software
@@ -21,14 +22,15 @@ timestamp='2002-07-03'
 #
 #
 # You should have received a copy of the GNU General Public License
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
 # As a special exception to the GNU General Public License, if you
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 # the same distribution terms that you use for the rest of that program.
 
 
+
 # Please send patches to <config-patches@gnu.org>.  Submit a context
 # Please send patches to <config-patches@gnu.org>.  Submit a context
 # diff and a properly formatted ChangeLog entry.
 # diff and a properly formatted ChangeLog entry.
 #
 #
@@ -70,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 version="\
 GNU config.sub ($timestamp)
 GNU config.sub ($timestamp)
 
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
-Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 
 This is free software; see the source for copying conditions.  There is NO
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -83,11 +85,11 @@ Try \`$me --help' for more information."
 while test $# -gt 0 ; do
 while test $# -gt 0 ; do
   case $1 in
   case $1 in
     --time-stamp | --time* | -t )
     --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit 0 ;;
+       echo "$timestamp" ; exit ;;
     --version | -v )
     --version | -v )
-       echo "$version" ; exit 0 ;;
+       echo "$version" ; exit ;;
     --help | --h* | -h )
     --help | --h* | -h )
-       echo "$usage"; exit 0 ;;
+       echo "$usage"; exit ;;
     -- )     # Stop option processing
     -- )     # Stop option processing
        shift; break ;;
        shift; break ;;
     - )	# Use stdin as input.
     - )	# Use stdin as input.
@@ -99,7 +101,7 @@ while test $# -gt 0 ; do
     *local*)
     *local*)
        # First pass through any local machine types.
        # First pass through any local machine types.
        echo $1
        echo $1
-       exit 0;;
+       exit ;;
 
 
     * )
     * )
        break ;;
        break ;;
@@ -118,7 +120,9 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
 case $maybe_os in
-  nto-qnx* | linux-gnu* | freebsd*-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*)
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
     ;;
@@ -144,7 +148,7 @@ case $os in
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis)
+	-apple | -axis | -knuth | -cray)
 		os=
 		os=
 		basic_machine=$1
 		basic_machine=$1
 		;;
 		;;
@@ -169,6 +173,10 @@ case $os in
 	-hiux*)
 	-hiux*)
 		os=-hiuxwe2
 		os=-hiuxwe2
 		;;
 		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
 	-sco5)
 	-sco5)
 		os=-sco3.2v5
 		os=-sco3.2v5
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -185,6 +193,10 @@ case $os in
 		# Don't forget version if it is 3.2v4 or newer.
 		# Don't forget version if it is 3.2v4 or newer.
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
 		;;
+	-sco5v6*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
 	-sco*)
 	-sco*)
 		os=-sco3.2v2
 		os=-sco3.2v2
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -228,40 +240,55 @@ case $basic_machine in
 	| a29k \
 	| a29k \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+	| bfin \
 	| c4x | clipper \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
 	| d10v | d30v | dlx | dsp16xx \
-	| fr30 | frv \
+	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
 	| i370 | i860 | i960 | ia64 \
-	| ip2k \
-	| m32r | m68000 | m68k | m88k | mcore \
+	| ip2k | iq2000 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips16 \
 	| mips64 | mips64el \
 	| mips64 | mips64el \
+	| mips64octeon | mips64octeonel \
 	| mips64orion | mips64orionel \
 	| mips64orion | mips64orionel \
+	| mips64r5900 | mips64r5900el \
+	| mips64vr | mips64vrel \
 	| mips64vr4100 | mips64vr4100el \
 	| mips64vr4100 | mips64vr4100el \
 	| mips64vr4300 | mips64vr4300el \
 	| mips64vr4300 | mips64vr4300el \
 	| mips64vr5000 | mips64vr5000el \
 	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
 	| mipsisa32 | mipsisa32el \
 	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipstx39 | mipstx39el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
 	| mn10200 | mn10300 \
+	| mt \
+	| msp430 \
+	| nios | nios2 \
 	| ns16k | ns32k \
 	| ns16k | ns32k \
-	| openrisc | or32 \
+	| or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| pyramid \
 	| pyramid \
-	| sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sh64 | sh64le \
-	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
-	| strongarm \
-	| tahoe | thumb | tic80 | tron \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
 	| v850 | v850e \
 	| v850 | v850e \
 	| we32k \
 	| we32k \
-	| x86 | xscale | xstormy16 | xtensa \
-	| z8k)
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| z8k | z80)
 		basic_machine=$basic_machine-unknown
 		basic_machine=$basic_machine-unknown
 		;;
 		;;
 	m6811 | m68hc11 | m6812 | m68hc12)
 	m6811 | m68hc11 | m6812 | m68hc12)
@@ -271,6 +298,9 @@ case $basic_machine in
 		;;
 		;;
 	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
 	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
 		;;
 		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
 
 
 	# We use `pc' rather than `unknown'
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# because (1) that's what they normally are, and
@@ -290,48 +320,66 @@ case $basic_machine in
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-	| avr-* \
-	| bs2000-* \
-	| c[123]* | c30-* | [cjt]90-* | c54x-* \
-	| clipper-* | cydra-* \
+	| avr-* | avr32-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| elxsi-* \
-	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
-	| ip2k-* \
-	| m32r-* \
+	| ip2k-* | iq2000-* \
+	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | mcore-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
 	| mips64-* | mips64el-* \
+	| mips64octeon-* | mips64octeonel-* \
 	| mips64orion-* | mips64orionel-* \
 	| mips64orion-* | mips64orionel-* \
+	| mips64r5900-* | mips64r5900el-* \
+	| mips64vr-* | mips64vrel-* \
 	| mips64vr4100-* | mips64vr4100el-* \
 	| mips64vr4100-* | mips64vr4100el-* \
 	| mips64vr4300-* | mips64vr4300el-* \
 	| mips64vr4300-* | mips64vr4300el-* \
 	| mips64vr5000-* | mips64vr5000el-* \
 	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
 	| mipsisa32-* | mipsisa32el-* \
 	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
-	| mipstx39 | mipstx39el \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nios-* | nios2-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| orion-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
 	| pyramid-* \
 	| pyramid-* \
 	| romp-* | rs6000-* \
 	| romp-* | rs6000-* \
-	| sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
-	| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
-	| tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+	| tron-* \
 	| v850-* | v850e-* | vax-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
-	| xtensa-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa*-* \
 	| ymp-* \
 	| ymp-* \
-	| z8k-*)
+	| z8k-* | z80-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
 		;;
 		;;
 	# Recognize the various machine names and aliases which stand
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
 	# for a CPU type and a company and sometimes even an OS.
@@ -349,6 +397,9 @@ case $basic_machine in
 		basic_machine=a29k-amd
 		basic_machine=a29k-amd
 		os=-udi
 		os=-udi
 		;;
 		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
 	adobe68k)
 	adobe68k)
 		basic_machine=m68010-adobe
 		basic_machine=m68010-adobe
 		os=-scout
 		os=-scout
@@ -363,6 +414,12 @@ case $basic_machine in
 		basic_machine=a29k-none
 		basic_machine=a29k-none
 		os=-bsd
 		os=-bsd
 		;;
 		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	amdahl)
 	amdahl)
 		basic_machine=580-amdahl
 		basic_machine=580-amdahl
 		os=-sysv
 		os=-sysv
@@ -394,10 +451,22 @@ case $basic_machine in
 		basic_machine=ns32k-sequent
 		basic_machine=ns32k-sequent
 		os=-dynix
 		os=-dynix
 		;;
 		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	c90)
 	c90)
 		basic_machine=c90-cray
 		basic_machine=c90-cray
 		os=-unicos
 		os=-unicos
 		;;
 		;;
+        cegcc)
+		basic_machine=arm-unknown
+		os=-cegcc
+		;;
 	convex-c1)
 	convex-c1)
 		basic_machine=c1-convex
 		basic_machine=c1-convex
 		os=-bsd
 		os=-bsd
@@ -422,12 +491,27 @@ case $basic_machine in
 		basic_machine=j90-cray
 		basic_machine=j90-cray
 		os=-unicos
 		os=-unicos
 		;;
 		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16)
+		basic_machine=cr16-unknown
+		os=-elf
+		;;
 	crds | unos)
 	crds | unos)
 		basic_machine=m68k-crds
 		basic_machine=m68k-crds
 		;;
 		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
 	cris | cris-* | etrax*)
 	cris | cris-* | etrax*)
 		basic_machine=cris-axis
 		basic_machine=cris-axis
 		;;
 		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
 	da30 | da30-*)
 	da30 | da30-*)
 		basic_machine=m68k-da30
 		basic_machine=m68k-da30
 		;;
 		;;
@@ -450,6 +534,14 @@ case $basic_machine in
 		basic_machine=m88k-motorola
 		basic_machine=m88k-motorola
 		os=-sysv3
 		os=-sysv3
 		;;
 		;;
+	dicos)
+		basic_machine=i686-pc
+		os=-dicos
+		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
 	dpx20 | dpx20-*)
 	dpx20 | dpx20-*)
 		basic_machine=rs6000-bull
 		basic_machine=rs6000-bull
 		os=-bosx
 		os=-bosx
@@ -600,6 +692,14 @@ case $basic_machine in
 		basic_machine=m68k-isi
 		basic_machine=m68k-isi
 		os=-sysv
 		os=-sysv
 		;;
 		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	m88k-omron*)
 	m88k-omron*)
 		basic_machine=m88k-omron
 		basic_machine=m88k-omron
 		;;
 		;;
@@ -615,6 +715,10 @@ case $basic_machine in
 		basic_machine=i386-pc
 		basic_machine=i386-pc
 		os=-mingw32
 		os=-mingw32
 		;;
 		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
 	miniframe)
 	miniframe)
 		basic_machine=m68000-convergent
 		basic_machine=m68000-convergent
 		;;
 		;;
@@ -628,10 +732,6 @@ case $basic_machine in
 	mips3*)
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
 		;;
-	mmix*)
-		basic_machine=mmix-knuth
-		os=-mmixware
-		;;
 	monitor)
 	monitor)
 		basic_machine=m68k-rom68k
 		basic_machine=m68k-rom68k
 		os=-coff
 		os=-coff
@@ -644,6 +744,9 @@ case $basic_machine in
 		basic_machine=i386-pc
 		basic_machine=i386-pc
 		os=-msdos
 		os=-msdos
 		;;
 		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
 	mvs)
 	mvs)
 		basic_machine=i370-ibm
 		basic_machine=i370-ibm
 		os=-mvs
 		os=-mvs
@@ -719,9 +822,12 @@ case $basic_machine in
 		basic_machine=hppa1.1-oki
 		basic_machine=hppa1.1-oki
 		os=-proelf
 		os=-proelf
 		;;
 		;;
-	or32 | or32-*)
+	openrisc | openrisc-*)
 		basic_machine=or32-unknown
 		basic_machine=or32-unknown
-		os=-coff
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
 		;;
 		;;
 	OSE68000 | ose68000)
 	OSE68000 | ose68000)
 		basic_machine=m68000-ericsson
 		basic_machine=m68000-ericsson
@@ -739,55 +845,75 @@ case $basic_machine in
 		basic_machine=i860-intel
 		basic_machine=i860-intel
 		os=-osf
 		os=-osf
 		;;
 		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
 	pbd)
 	pbd)
 		basic_machine=sparc-tti
 		basic_machine=sparc-tti
 		;;
 		;;
 	pbb)
 	pbb)
 		basic_machine=m68k-tti
 		basic_machine=m68k-tti
 		;;
 		;;
-        pc532 | pc532-*)
+	pc532 | pc532-*)
 		basic_machine=ns32k-pc532
 		basic_machine=ns32k-pc532
 		;;
 		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	pentium | p5 | k5 | k6 | nexgen | viac3)
 	pentium | p5 | k5 | k6 | nexgen | viac3)
 		basic_machine=i586-pc
 		basic_machine=i586-pc
 		;;
 		;;
-	pentiumpro | p6 | 6x86 | athlon)
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
 		basic_machine=i686-pc
 		basic_machine=i686-pc
 		;;
 		;;
-	pentiumii | pentium2)
+	pentiumii | pentium2 | pentiumiii | pentium3)
 		basic_machine=i686-pc
 		basic_machine=i686-pc
 		;;
 		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
 	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
 	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
 	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
-	pentiumii-* | pentium2-*)
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
+	pentium4-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	pn)
 	pn)
 		basic_machine=pn-gould
 		basic_machine=pn-gould
 		;;
 		;;
 	power)	basic_machine=power-ibm
 	power)	basic_machine=power-ibm
 		;;
 		;;
 	ppc)	basic_machine=powerpc-unknown
 	ppc)	basic_machine=powerpc-unknown
-	        ;;
+		;;
 	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
 		basic_machine=powerpcle-unknown
-	        ;;
+		;;
 	ppcle-* | powerpclittle-*)
 	ppcle-* | powerpclittle-*)
 		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
 		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
 	ppc64)	basic_machine=powerpc64-unknown
 	ppc64)	basic_machine=powerpc64-unknown
-	        ;;
+		;;
 	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
 	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
 	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
 	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
 		basic_machine=powerpc64le-unknown
 		basic_machine=powerpc64le-unknown
-	        ;;
+		;;
 	ppc64le-* | powerpc64little-*)
 	ppc64le-* | powerpc64little-*)
 		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
 		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 		;;
@@ -798,6 +924,10 @@ case $basic_machine in
 		basic_machine=i586-unknown
 		basic_machine=i586-unknown
 		os=-pw32
 		os=-pw32
 		;;
 		;;
+	rdos)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
 	rom68k)
 	rom68k)
 		basic_machine=m68k-rom68k
 		basic_machine=m68k-rom68k
 		os=-coff
 		os=-coff
@@ -818,6 +948,20 @@ case $basic_machine in
 		basic_machine=a29k-amd
 		basic_machine=a29k-amd
 		os=-udi
 		os=-udi
 		;;
 		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
 	sequent)
 	sequent)
 		basic_machine=i386-sequent
 		basic_machine=i386-sequent
 		;;
 		;;
@@ -825,6 +969,12 @@ case $basic_machine in
 		basic_machine=sh-hitachi
 		basic_machine=sh-hitachi
 		os=-hms
 		os=-hms
 		;;
 		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
 	sparclite-wrs | simso-wrs)
 	sparclite-wrs | simso-wrs)
 		basic_machine=sparclite-wrs
 		basic_machine=sparclite-wrs
 		os=-vxworks
 		os=-vxworks
@@ -883,7 +1033,7 @@ case $basic_machine in
 	sun386 | sun386i | roadrunner)
 	sun386 | sun386i | roadrunner)
 		basic_machine=i386-sun
 		basic_machine=i386-sun
 		;;
 		;;
-        sv1)
+	sv1)
 		basic_machine=sv1-cray
 		basic_machine=sv1-cray
 		os=-unicos
 		os=-unicos
 		;;
 		;;
@@ -891,10 +1041,6 @@ case $basic_machine in
 		basic_machine=i386-sequent
 		basic_machine=i386-sequent
 		os=-dynix
 		os=-dynix
 		;;
 		;;
-	t3d)
-		basic_machine=alpha-cray
-		os=-unicos
-		;;
 	t3e)
 	t3e)
 		basic_machine=alphaev5-cray
 		basic_machine=alphaev5-cray
 		os=-unicos
 		os=-unicos
@@ -907,6 +1053,18 @@ case $basic_machine in
 		basic_machine=tic54x-unknown
 		basic_machine=tic54x-unknown
 		os=-coff
 		os=-coff
 		;;
 		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+	tile*)
+		basic_machine=tile-unknown
+		os=-linux-gnu
+		;;
 	tx39)
 	tx39)
 		basic_machine=mipstx39-unknown
 		basic_machine=mipstx39-unknown
 		;;
 		;;
@@ -920,6 +1078,10 @@ case $basic_machine in
 	tower | tower-32)
 	tower | tower-32)
 		basic_machine=m68k-ncr
 		basic_machine=m68k-ncr
 		;;
 		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
 	udi29k)
 	udi29k)
 		basic_machine=a29k-amd
 		basic_machine=a29k-amd
 		os=-udi
 		os=-udi
@@ -941,8 +1103,8 @@ case $basic_machine in
 		os=-vms
 		os=-vms
 		;;
 		;;
 	vpp*|vx|vx-*)
 	vpp*|vx|vx-*)
-               basic_machine=f301-fujitsu
-               ;;
+		basic_machine=f301-fujitsu
+		;;
 	vxworks960)
 	vxworks960)
 		basic_machine=i960-wrs
 		basic_machine=i960-wrs
 		os=-vxworks
 		os=-vxworks
@@ -963,11 +1125,11 @@ case $basic_machine in
 		basic_machine=hppa1.1-winbond
 		basic_machine=hppa1.1-winbond
 		os=-proelf
 		os=-proelf
 		;;
 		;;
-	windows32)
-		basic_machine=i386-pc
-		os=-windows32-msvcrt
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
 		;;
 		;;
-        xps | xps100)
+	xps | xps100)
 		basic_machine=xps100-honeywell
 		basic_machine=xps100-honeywell
 		;;
 		;;
 	ymp)
 	ymp)
@@ -978,6 +1140,10 @@ case $basic_machine in
 		basic_machine=z8k-unknown
 		basic_machine=z8k-unknown
 		os=-sim
 		os=-sim
 		;;
 		;;
+	z80-*-coff)
+		basic_machine=z80-unknown
+		os=-sim
+		;;
 	none)
 	none)
 		basic_machine=none-none
 		basic_machine=none-none
 		os=-none
 		os=-none
@@ -997,6 +1163,9 @@ case $basic_machine in
 	romp)
 	romp)
 		basic_machine=romp-ibm
 		basic_machine=romp-ibm
 		;;
 		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
 	rs6000)
 	rs6000)
 		basic_machine=rs6000-ibm
 		basic_machine=rs6000-ibm
 		;;
 		;;
@@ -1013,16 +1182,13 @@ case $basic_machine in
 	we32k)
 	we32k)
 		basic_machine=we32k-att
 		basic_machine=we32k-att
 		;;
 		;;
-	sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
+	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
 		basic_machine=sh-unknown
 		basic_machine=sh-unknown
 		;;
 		;;
-	sh64)
-		basic_machine=sh64-unknown
-		;;
-	sparc | sparcv9 | sparcv9b)
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
 		basic_machine=sparc-sun
 		basic_machine=sparc-sun
 		;;
 		;;
-        cydra)
+	cydra)
 		basic_machine=cydra-cydrome
 		basic_machine=cydra-cydrome
 		;;
 		;;
 	orion)
 	orion)
@@ -1037,10 +1203,6 @@ case $basic_machine in
 	pmac | pmac-mpw)
 	pmac | pmac-mpw)
 		basic_machine=powerpc-apple
 		basic_machine=powerpc-apple
 		;;
 		;;
-	c4x*)
-		basic_machine=c4x-none
-		os=-coff
-		;;
 	*-unknown)
 	*-unknown)
 		# Make sure to match an already-canonicalized machine name.
 		# Make sure to match an already-canonicalized machine name.
 		;;
 		;;
@@ -1096,18 +1258,23 @@ case $os in
 	      | -aos* \
 	      | -aos* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
-	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -openbsd* | -solidbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -chorusos* | -chorusrdb* \
+	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* | -powermax*)
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 		;;
 	-qnx*)
 	-qnx*)
@@ -1119,16 +1286,21 @@ case $os in
 			;;
 			;;
 		esac
 		esac
 		;;
 		;;
+	-nto-qnx*)
+		;;
 	-nto*)
 	-nto*)
-		os=-nto-qnx
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
 		;;
 		;;
 	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
 	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
 	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 		;;
 		;;
 	-mac*)
 	-mac*)
 		os=`echo $os | sed -e 's|mac|macos|'`
 		os=`echo $os | sed -e 's|mac|macos|'`
 		;;
 		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
 	-linux*)
 	-linux*)
 		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		;;
 		;;
@@ -1141,6 +1313,9 @@ case $os in
 	-opened*)
 	-opened*)
 		os=-openedition
 		os=-openedition
 		;;
 		;;
+        -os400*)
+		os=-os400
+		;;
 	-wince*)
 	-wince*)
 		os=-wince
 		os=-wince
 		;;
 		;;
@@ -1162,6 +1337,9 @@ case $os in
 	-atheos*)
 	-atheos*)
 		os=-atheos
 		os=-atheos
 		;;
 		;;
+	-syllable*)
+		os=-syllable
+		;;
 	-386bsd)
 	-386bsd)
 		os=-bsd
 		os=-bsd
 		;;
 		;;
@@ -1172,7 +1350,7 @@ case $os in
 		os=-rtmk-nova
 		os=-rtmk-nova
 		;;
 		;;
 	-ns2 )
 	-ns2 )
-	        os=-nextstep2
+		os=-nextstep2
 		;;
 		;;
 	-nsk*)
 	-nsk*)
 		os=-nsk
 		os=-nsk
@@ -1184,6 +1362,9 @@ case $os in
 	-sinix*)
 	-sinix*)
 		os=-sysv4
 		os=-sysv4
 		;;
 		;;
+        -tpf*)
+		os=-tpf
+		;;
 	-triton*)
 	-triton*)
 		os=-sysv3
 		os=-sysv3
 		;;
 		;;
@@ -1211,8 +1392,20 @@ case $os in
 	-xenix)
 	-xenix)
 		os=-xenix
 		os=-xenix
 		;;
 		;;
-        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-	        os=-mint
+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+		os=-mint
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-dicos*)
+		os=-dicos
 		;;
 		;;
 	-none)
 	-none)
 		;;
 		;;
@@ -1236,6 +1429,12 @@ else
 # system, and we'll never get to this point.
 # system, and we'll never get to this point.
 
 
 case $basic_machine in
 case $basic_machine in
+        score-*)
+		os=-elf
+		;;
+        spu-*)
+		os=-elf
+		;;
 	*-acorn)
 	*-acorn)
 		os=-riscix1.2
 		os=-riscix1.2
 		;;
 		;;
@@ -1245,11 +1444,14 @@ case $basic_machine in
 	arm*-semi)
 	arm*-semi)
 		os=-aout
 		os=-aout
 		;;
 		;;
+        c4x-* | tic4x-*)
+        	os=-coff
+		;;
 	# This must come before the *-dec entry.
 	# This must come before the *-dec entry.
 	pdp10-*)
 	pdp10-*)
 		os=-tops20
 		os=-tops20
 		;;
 		;;
-        pdp11-*)
+	pdp11-*)
 		os=-none
 		os=-none
 		;;
 		;;
 	*-dec | vax-*)
 	*-dec | vax-*)
@@ -1270,6 +1472,9 @@ case $basic_machine in
 	m68*-cisco)
 	m68*-cisco)
 		os=-aout
 		os=-aout
 		;;
 		;;
+        mep-*)
+		os=-elf
+		;;
 	mips*-cisco)
 	mips*-cisco)
 		os=-elf
 		os=-elf
 		;;
 		;;
@@ -1288,9 +1493,15 @@ case $basic_machine in
 	*-be)
 	*-be)
 		os=-beos
 		os=-beos
 		;;
 		;;
+	*-haiku)
+		os=-haiku
+		;;
 	*-ibm)
 	*-ibm)
 		os=-aix
 		os=-aix
 		;;
 		;;
+    	*-knuth)
+		os=-mmixware
+		;;
 	*-wec)
 	*-wec)
 		os=-proelf
 		os=-proelf
 		;;
 		;;
@@ -1342,19 +1553,19 @@ case $basic_machine in
 	*-next)
 	*-next)
 		os=-nextstep3
 		os=-nextstep3
 		;;
 		;;
-        *-gould)
+	*-gould)
 		os=-sysv
 		os=-sysv
 		;;
 		;;
-        *-highlevel)
+	*-highlevel)
 		os=-bsd
 		os=-bsd
 		;;
 		;;
 	*-encore)
 	*-encore)
 		os=-bsd
 		os=-bsd
 		;;
 		;;
-        *-sgi)
+	*-sgi)
 		os=-irix
 		os=-irix
 		;;
 		;;
-        *-siemens)
+	*-siemens)
 		os=-sysv4
 		os=-sysv4
 		;;
 		;;
 	*-masscomp)
 	*-masscomp)
@@ -1423,9 +1634,15 @@ case $basic_machine in
 			-mvs* | -opened*)
 			-mvs* | -opened*)
 				vendor=ibm
 				vendor=ibm
 				;;
 				;;
+			-os400*)
+				vendor=ibm
+				;;
 			-ptx*)
 			-ptx*)
 				vendor=sequent
 				vendor=sequent
 				;;
 				;;
+			-tpf*)
+				vendor=ibm
+				;;
 			-vxsim* | -vxworks* | -windiss*)
 			-vxsim* | -vxworks* | -windiss*)
 				vendor=wrs
 				vendor=wrs
 				;;
 				;;
@@ -1450,7 +1667,7 @@ case $basic_machine in
 esac
 esac
 
 
 echo $basic_machine$os
 echo $basic_machine$os
-exit 0
+exit
 
 
 # Local variables:
 # Local variables:
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # eval: (add-hook 'write-file-hooks 'time-stamp)

File diff suppressed because it is too large
+ 7512 - 5396
config/ltmain.sh


File diff suppressed because it is too large
+ 13712 - 16666
configure


+ 210 - 244
configure.ac

@@ -1,5 +1,5 @@
 
 
-dnl $Id: configure.ac 2050 2008-05-23 05:00:04Z aturner $
+dnl $Id: configure.ac 2196 2009-02-04 21:18:09Z aturner $
 
 
 AC_INIT(tcpreplay)
 AC_INIT(tcpreplay)
 AC_CONFIG_SRCDIR(src/tcpreplay.c)
 AC_CONFIG_SRCDIR(src/tcpreplay.c)
@@ -10,12 +10,14 @@ AM_WITH_DMALLOC
 
 
 dnl People building from SVN need the same version of Autogen as I'm using
 dnl People building from SVN need the same version of Autogen as I'm using
 dnl or specify --disable-local-libopts
 dnl or specify --disable-local-libopts
-MAINTAINER_AUTOGEN_VERSION=5.9.2
+MAINTAINER_AUTOGEN_VERSION=5.9.7
+
+AC_CONFIG_MACRO_DIR([m4])
 
 
 dnl Set version info here!
 dnl Set version info here!
 MAJOR_VERSION=3
 MAJOR_VERSION=3
-MINOR_VERSION=3
-MICRO_VERSION=2
+MINOR_VERSION=4
+MICRO_VERSION=1
 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 
 
 dnl Release is only used for the RPM spec file
 dnl Release is only used for the RPM spec file
@@ -37,10 +39,12 @@ AC_SUBST(host)
 AC_SUBST(build)
 AC_SUBST(build)
 AC_SUBST(target)
 AC_SUBST(target)
 
 
+have_cygwin=no
 AC_MSG_CHECKING([for cygwin development environment])
 AC_MSG_CHECKING([for cygwin development environment])
 if test `echo $target | grep -c cygwin` -gt 0 ; then
 if test `echo $target | grep -c cygwin` -gt 0 ; then
-   AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
-   AC_MSG_RESULT(yes)
+   	AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
+   	AC_MSG_RESULT(yes)
+	have_cygwin=yes
 else
 else
    AC_MSG_RESULT(no)
    AC_MSG_RESULT(no)
 fi
 fi
@@ -56,7 +60,7 @@ AC_PROG_CC_STDC
 AC_PROG_CXX
 AC_PROG_CXX
 AC_PROG_CPP
 AC_PROG_CPP
 AC_PROG_LN_S
 AC_PROG_LN_S
-AC_PROG_RANLIB
+LT_INIT
 AC_PROG_AWK
 AC_PROG_AWK
 AC_PROG_SED
 AC_PROG_SED
 AC_PROG_MAKE_SET
 AC_PROG_MAKE_SET
@@ -65,6 +69,7 @@ AC_PATH_PROG(PRINTF, printf)
 AC_PATH_PROG(ECHO, echo)
 AC_PATH_PROG(ECHO, echo)
 AC_PATH_PROG(CUT, cut)
 AC_PATH_PROG(CUT, cut)
 AC_PATH_PROG(AUTOGEN, autogen)
 AC_PATH_PROG(AUTOGEN, autogen)
+AC_PATH_PROG(GROFF, groff)
 
 
 dnl check autogen version
 dnl check autogen version
 AUTOGEN_VERSION=unknown
 AUTOGEN_VERSION=unknown
@@ -83,7 +88,7 @@ if test -n "${AUTOGEN}" ; then
 	rm -f autogen.version
 	rm -f autogen.version
 	
 	
 	dnl Compare the installed version with the maintainer version if building from SVN and not using system libopts
 	dnl Compare the installed version with the maintainer version if building from SVN and not using system libopts
-    if test ! -f src/tcpreplay_opts.c && test $enable_local_libopts == yes ; then
+    if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
         if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
         if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
             AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION)  Either install the correct version or specify --disable-local-libopts])
             AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION)  Either install the correct version or specify --disable-local-libopts])
         fi
         fi
@@ -95,7 +100,7 @@ else
 fi
 fi
 AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
 AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
 
 
-if test $enable_local_libopts == yes ; then
+if test "x$enable_local_libopts" = "xyes" ; then
     AC_MSG_NOTICE([Using included libopts tearoff])
     AC_MSG_NOTICE([Using included libopts tearoff])
 else
 else
     AC_MSG_NOTICE([Using system libopts])
     AC_MSG_NOTICE([Using system libopts])
@@ -281,9 +286,9 @@ AC_ARG_ENABLE(force-pf,
 	AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
 	AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
 	[ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
 	[ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
 
 
-AC_ARG_ENABLE(force-libnet,
-	AC_HELP_STRING([--enable-force-libnet], [Force using libnet for sending packets]),
-	[ AC_DEFINE([FORCE_INJECT_LIBNET], [1], [Force using libnet for sending packets])])
+AC_ARG_ENABLE(force-libdnet,
+	AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
+	[ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
 		
 		
 AC_ARG_ENABLE(force-inject,
 AC_ARG_ENABLE(force-inject,
 	AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
 	AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
@@ -293,16 +298,6 @@ AC_ARG_ENABLE(force-sendpacket,
 	AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
 	AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
 	[ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
 	[ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
 
 
-tcpreplay_edit=no
-AC_ARG_ENABLE(tcpreplay-edit,
-	AC_HELP_STRING([--enable-tcpreplay-edit], [Link packet editing code with tcpreplay]),
-	[ AC_DEFINE([TCPREPLAY_EDIT], [1], [Link packet editing code with tcpreplay])
-	tcpreplay_edit=yes
-	])
-
-AM_CONDITIONAL([ENABLE_TCPREPLAY_EDIT], [test x$tcpreplay_edit = xyes])
-
-
 dnl Dynamic link libraries
 dnl Dynamic link libraries
 dynamic_link=no
 dynamic_link=no
 AC_ARG_ENABLE(dynamic-link,
 AC_ARG_ENABLE(dynamic-link,
@@ -340,145 +335,6 @@ if test x$inet_addr = no ; then
     AC_MSG_ERROR([We need inet_addr.  See bug 26])
     AC_MSG_ERROR([We need inet_addr.  See bug 26])
 fi
 fi
 
 
-dnl ##################################################
-dnl Checks for libnet IFF you specify --enable-libnet.
-dnl We no longer by default use libnet unless you tell me to.
-dnl ##################################################
-foundnet=no
-trynetdir=no
-have_libnet=no
-use_libnet=no
-
-AC_ARG_ENABLE(libnet,
-	AC_HELP_STRING([--enable-libnet], [Enable using the libnet 1.1.x library (deprecated)]),
-	[ if test x$enableval = xyes; then
-		use_libnet=yes
-		AC_MSG_WARN([Due to bugs in libnet, it is no longer officially supported])
-	  fi]
-)
-
-AC_ARG_WITH(libnet,
-    AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
-    [trynetdir=$withval])
-
-if test x$use_libnet = xyes ; then
-	AC_MSG_CHECKING(for libnet)
-
-	for testdir in $trynetdir /usr/local /opt/local /usr ; do 
-    	if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
-        	LNETINC="${testdir}/include/libnet.h"
-	        LNETINCDIR="${testdir}/include"
-	        if test $dynamic_link = yes; then
-				if test -f "${testdir}/lib64/libnet${shrext_cmds}" ; then
-		            LNETLIB="-L${testdir}/lib64 -lnet"
-				elif test -f "${testdir}/lib/libnet${shrext_cmds}" ; then
-					LNETLIB="-L${testdir}/lib -lnet"
-				else
-					AC_ERROR([Unable to find libnet in ${testdir}])
-				fi
-	        elif test -f "${testdir}/lib64/libnet.${libext}" ; then
-	            LNETLIB="${testdir}/lib64/libnet.${libext}"
-	        elif test -f "${testdir}/lib/libnet.${libext}" ; then
-	            LNETLIB="${testdir}/lib/libnet.${libext}"
-		 	else
-				AC_ERROR([Unable to find matching library for header file in ${testdir}])
-			fi
-        	foundnet=$testdir
-     	fi
-	done
-	
-
-	if test x$foundnet = xno ; then
-	    AC_MSG_RESULT(no)
-	else
-	    AC_MSG_RESULT($foundnet)
-		have_libnet=yes
-		AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
-	fi
-
-fi
-
-
-AC_SUBST(LNETINC)
-AC_SUBST(LNETLIB)
-
-if test $foundnet != no ; then
-	OLDLIBS="$LIBS"
-	OLDCFLAGS="$CFLAGS"
-	LIBS="$LNETLIB"
-	CFLAGS="$CFLAGS -I$LNETINCDIR"
-
-
-	dnl Check to see what version of libnet
-	dnl this code has been reduced a lot, but probably still could be
-	dnl reduced quite a bit more if we chose too
-	AC_MSG_CHECKING(for libnet version)
-
-	AC_TRY_RUN([
-#include <string.h>
-#define LIBNET_LIL_ENDIAN 1
-#include "$LNETINC"
-#define LIB_TEST "1.0"
-	/* 
-	 * simple proggy to test the version of libnet
-	 * returns zero if it's 1.0.x 
-	 * or one otherwise
-	 */
-	int
-	main (int argc, char *argv[])
-	{
-	        if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
-	                exit(0);
-	        exit(1);
-	}],
-	        libnet_ver_10=yes
-	        AC_MSG_RESULT(1.0.x), 
-	        libnet_ver_10=no,
-	        libnet_ver_10=no
-	        )
-
-	AC_TRY_RUN([
-#include <string.h>
-#include "$LNETINC"
-#define LIB_TEST "1.1"
-	/* 
-	 * simple proggy to test the version of libnet
-	 * returns zero if it's 1.0.x 
-	 * or one otherwise
-	 */
-	int
-	main (int argc, char *argv[])
-	{
-	        if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
-	                exit(0);
-	        exit(1);
-	}],
-	        libnet_ver_11=yes
-	        AC_MSG_RESULT(1.1.x), 
-	        libnet_ver_11=no,
-	        libnet_ver_11=no
-	        )
-
-
-	if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
-	        AC_MSG_RESULT(unknown)
-	        AC_MSG_ERROR(Unable to determine version of libnet)
-	fi
-
-	if test $libnet_ver_10 = yes ; then
-	          AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
-	                Please upgrade to 1.1.0 or better)
-	fi
-
-
-	dnl restore LIBS & CFLAGS
-	LIBS="$OLDLIBS"
-	CFLAGS="$OLDCFLAGS"
-
-fi 
-
-dnl END OF if test $foundnet = yes
-
 dnl #####################################################
 dnl #####################################################
 dnl Checks for libpcap
 dnl Checks for libpcap
 dnl #####################################################
 dnl #####################################################
@@ -531,7 +387,6 @@ OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
 LIBS="$LPCAPLIB"
 LIBS="$LPCAPLIB"
 CFLAGS="$CFLAGS -I$LPCAPINCDIR"
 CFLAGS="$CFLAGS -I$LPCAPINCDIR"
 
 
-
 dnl Check to see what version of libpcap
 dnl Check to see what version of libpcap
 dnl this code has been reduced a lot, but probably still could be
 dnl this code has been reduced a lot, but probably still could be
 dnl reduced quite a bit more if we chose too
 dnl reduced quite a bit more if we chose too
@@ -628,6 +483,32 @@ elif test $libcap_ver7 = yes ; then
     libpcap_version=">= 0.7.0"
     libpcap_version=">= 0.7.0"
 fi
 fi
 
 
+dnl Check for pcap_setnonblock()
+AC_MSG_CHECKING(for pcap_setnonblock)
+AC_LINK_IFELSE(AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+]],[[
+    pcap_t *p;
+    char *errbuf;
+    
+    pcap_setnonblock(p, 1, errbuf);
+    exit(0);
+]]), [
+    have_pcap_setnonblock=yes
+    AC_MSG_RESULT(yes)
+], [
+    have_pcap_setnonblock=no
+    AC_MSG_RESULT(no)
+])
+
+if test $have_pcap_setnonblock = yes ; then
+    AC_DEFINE([HAVE_PCAP_SETNONBLOCK], [1], 
+              [Does libpcap have pcap_setnonblock?])
+fi
+
 dnl Check to see if we've got pcap_datalink_val_to_name()
 dnl Check to see if we've got pcap_datalink_val_to_name()
 AC_MSG_CHECKING(for pcap_datalink_val_to_description)
 AC_MSG_CHECKING(for pcap_datalink_val_to_description)
 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
@@ -649,9 +530,38 @@ AC_LINK_IFELSE(AC_LANG_PROGRAM([[
 
 
 if test $have_dlt_to_desc = yes ; then
 if test $have_dlt_to_desc = yes ; then
     AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1], 
     AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1], 
-              [Does libpcap have dlt_val_to_desc?])
+              [Does libpcap have pcap_datalink_val_to_description?])
+fi
+
+dnl Check for pcap_get_selectable_fd()
+AC_MSG_CHECKING(for pcap_get_selectable_fd)
+AC_LINK_IFELSE(AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+]], [[
+    int f;
+    pcap_t *p;
+    f = pcap_get_selectable_fd(p);
+    exit(0);
+]]), [
+    have_pcap_get_selectable_fd=yes
+    AC_MSG_RESULT(yes)
+], [
+    have_pcap_get_selectable_fd=no
+    AC_MSG_RESULT(no)
+])
+
+if test x$have_pcap_get_selectable_fd = xyes ; then
+    AC_DEFINE([HAVE_PCAP_GET_SELECTABLE_FD], [1], 
+        [Does libpcap have pcap_get_selectable_fd?])
 fi
 fi
 
 
+dnl Important: winpcap apparently defines functions in it's header files
+dnl which aren't actually in the library.  Totally fucked up.  Hence, we
+dnl must actually LINK the code, not just compile it.
+
 dnl Check to see if we've got pcap_dump_fopen()
 dnl Check to see if we've got pcap_dump_fopen()
 AC_MSG_CHECKING(for pcap_dump_fopen)
 AC_MSG_CHECKING(for pcap_dump_fopen)
 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
@@ -682,24 +592,74 @@ fi
 have_pcap_inject=no
 have_pcap_inject=no
 dnl Check to see if we've got pcap_inject()
 dnl Check to see if we've got pcap_inject()
 AC_MSG_CHECKING(for pcap_inject sending support)
 AC_MSG_CHECKING(for pcap_inject sending support)
-AC_TRY_COMPILE([
+AC_LINK_IFELSE(AC_LANG_PROGRAM([[
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #include "$LPCAPINC"
 #include "$LPCAPINC"
-],[
+]],[[
 	pcap_t *pcap;
 	pcap_t *pcap;
 	char *buf;
 	char *buf;
     pcap_inject(pcap, (void *)buf, 0);
     pcap_inject(pcap, (void *)buf, 0);
-],[
-	AC_DEFINE([HAVE_PCAP_INJECT], [1], 
-              [Does libpcap have pcap_inject?])
-	AC_MSG_RESULT(yes)
-	have_pcap_inject=yes
-],[
-	AC_MSG_RESULT(no)
+]]),[
+    have_pcap_inject=yes
+    AC_MSG_RESULT(yes)
+], [
+    have_pcap_inject=no
+    AC_MSG_RESULT(no)
+])
+
+if test $have_pcap_inject = yes ; then
+	AC_DEFINE([HAVE_PCAP_INJECT], [1], [Does libpcap have pcap_inject?])
+fi
+
+have_pcap_sendpacket=no
+dnl Check to see if we've got pcap_sendpacket()
+AC_MSG_CHECKING(for pcap_sendpacket sending support)
+AC_LINK_IFELSE(AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+]],[[
+	pcap_t *pcap;
+	u_char *buf;
+    pcap_sendpacket(pcap, buf, 0);
+]]),[
+    have_pcap_sendpacket=yes
+    AC_MSG_RESULT(yes)
+], [
+    have_pcap_sendpacket=no
+    AC_MSG_RESULT(no)
 ])
 ])
 
 
+if test $have_pcap_sendpacket = yes ; then
+	AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], [Does libpcap have pcap_sendpacket?])
+fi
+
+have_pcap_breakloop=no
+AC_MSG_CHECKING(for pcap_breakloop)
+AC_LINK_IFELSE(AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+]],[[
+	pcap_t *pcap;
+    pcap_sendpacket(pcap);
+]]),[
+    have_pcap_breakloop=yes
+    AC_MSG_RESULT(yes)
+], [
+    have_pcap_breakloop=no
+    AC_MSG_RESULT(no)
+])
+
+if test $have_pcap_breakloop = yes ; then
+	AC_DEFINE([HAVE_PCAP_BREAKLOOP], [1], [Does libpcap have pcap_breakloop?])
+fi
+
+
 have_pcap_version=no
 have_pcap_version=no
 dnl Check to see if we have pcap_version[]
 dnl Check to see if we have pcap_version[]
 AC_MSG_CHECKING(for pcap_version[])
 AC_MSG_CHECKING(for pcap_version[])
@@ -718,26 +678,29 @@ extern char pcap_version[];
 	AC_MSG_RESULT(no)
 	AC_MSG_RESULT(no)
 ])
 ])
 
 
-have_pcap_sendpacket=no
-dnl Check to see if we've got pcap_sendpacket()
-AC_MSG_CHECKING(for pcap_sendpacket sending support)
-AC_TRY_COMPILE([
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "$LPCAPINC"
-],[
-	pcap_t *pcap;
-	u_char *buf;
-    pcap_sendpacket(pcap, buf, 0);
-],[
-	AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], 
-              [Does libpcap have pcap_sendpacket?])
-	AC_MSG_RESULT(yes)
-	have_pcap_sendpacket=yes
-],[
-	AC_MSG_RESULT(no)
-])
+
+# Tcpbridge requires libpcap and pcap_sendpacket()
+enable_tcpbridge=no
+if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then
+
+    # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems
+    if test x$have_bpf = xno; then
+        AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
+    	enable_tcpbridge=yes
+    	AC_MSG_NOTICE([Building tcpbridge])
+    	
+    # BPF systems need to also have pcap_setnonblock()
+    elif test x$have_pcap_setnonblock = xyes ; then
+        AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
+    	enable_tcpbridge=yes
+    	AC_MSG_NOTICE([Building tcpbridge])    
+    else
+    	AC_MSG_WARN([Unable to build tcpbridge.  Try installing latest libpcap!])
+    fi
+fi
+AM_CONDITIONAL(COMPILE_TCPBRIDGE, [test x$enable_tcpbridge = xyes ])
+
+
 
 
 have_pf=no
 have_pf=no
 dnl Check for linux PF_PACKET support
 dnl Check for linux PF_PACKET support
@@ -801,23 +764,61 @@ main(int argc, char *argv[]) {
 	])
 	])
 
 
 
 
+dnl ##################################################
+dnl # Check for libdnet, but only if not Cygwin! 
+dnl ##################################################
+founddnet=no
+have_libdnet=no
+libdnet_version=
+enable_fragroute=no
+trydnetdir=/usr/local
+
+if test $have_cygwin == no ; then
+	AC_MSG_CHECKING(for libdnet)
+	AC_ARG_WITH(libdnet,
+	    AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
+	    [trydnetdir=$withval])
+ 
+	for testdir in $trydnetdir /usr/local /opt/local /usr ; do 
+	   	if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
+	           LDNETINC="`$testdir/bin/dnet-config --cflags`"
+	           LDNETLIB="`$testdir/bin/dnet-config --libs`"
+	           libdnet_version="`$testdir/bin/dnet-config --version`"
+	       	founddnet=$testdir
+	    	fi
+	done
+
+	if test $founddnet = no ; then
+		AC_MSG_RESULT(no)
+		AC_MSG_WARN([libdnet not found, disabling fragroute feature])
+	else
+		AC_MSG_RESULT($founddnet)
+		enable_fragroute=yes
+		have_libdnet=yes
+	    AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?])
+	fi
+
+else
+	AC_MSG_NOTICE([Skipping libdnet check under Cygwin for compatibility reasons])
+fi
+
+
+AC_SUBST(LDNETINC)
+AC_SUBST(LDNETLIB)
+AC_DEFINE_UNQUOTED([LIBDNET_VERSION], "$libdnet_version", [Version of libdnet])
+
+AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno])
+if test x$founddnet != xno ; then
+    AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module])
+fi
+
+
 dnl Make sure we have a valid packet injection mechanisim
 dnl Make sure we have a valid packet injection mechanisim
 if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
 if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
 	-a $have_libdnet = no -a $have_pf = no ; then
 	-a $have_libdnet = no -a $have_pf = no ; then
 	AC_MSG_ERROR([Unable to find a supported method to send packets.  Please upgrade your libpcap or enable libdnet])
 	AC_MSG_ERROR([Unable to find a supported method to send packets.  Please upgrade your libpcap or enable libdnet])
 fi
 fi
 
 
-dnl Libpcap support doesn't give us a method to get the hardware address of the
-dnl interfaces which prevents us from doing proper filtering to prevent bridging loops
-enable_tcpbridge=yes
-if test $have_bpf = no -a $have_libdnet = no -a $have_pf = no ; then
-	AC_MSG_NOTICE([tcpbridge support disabled without BPF, Libdnet or Linux PF_PACKET])
-	enable_tcpbridge=no
-fi
-
-# ADT: Commented for now
-# AM_CONDITIONAL(ENABLE_TCPBRIDGE, [test $enable_tcpbridge = yes])
-
 dnl Older versions of libpcap are missing some DLT types
 dnl Older versions of libpcap are missing some DLT types
 dnl If doesn't exist, we'll define them in src/common/fakepcap.h
 dnl If doesn't exist, we'll define them in src/common/fakepcap.h
 AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
 AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
@@ -888,42 +889,6 @@ dnl restore LIBS & CFLAGS
 LIBS="$OLDLIBS"
 LIBS="$OLDLIBS"
 CFLAGS="$OLDCFLAGS"
 CFLAGS="$OLDCFLAGS"
 
 
-dnl ##################################################
-dnl # Check for libdnet
-dnl ##################################################
-founddnet=no
-enable_fragroute=no
-trydnetdir=/usr/local
-AC_MSG_CHECKING(for libdnet)
-AC_ARG_WITH(libdnet,
-    AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
-    [trydnetdir=$withval])
- 
-	for testdir in $trydnetdir /usr/local /opt/local /usr ; do 
-    	if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
-            LDNETINC="`$testdir/bin/dnet-config --cflags`"
-            LDNETLIB="`$testdir/bin/dnet-config --libs`"
-
-        	founddnet=$testdir
-     	fi
-	done
-
-	if test $founddnet = no ; then
-		AC_MSG_RESULT(no)
-		AC_MSG_WARN([libdnet not found, disabling fragroute feature])
-	else
-		AC_MSG_RESULT($founddnet)
-		enable_fragroute=yes
-	    AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?])
-	fi
-
-AC_SUBST(LDNETINC)
-AC_SUBST(LDNETLIB)
-AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno])
-if test x$founddnet != xno ; then
-    AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module])
-fi
-
 
 
 dnl ##################################################
 dnl ##################################################
 dnl # Check for pcapnav
 dnl # Check for pcapnav
@@ -1134,6 +1099,7 @@ case $host in
     fi
     fi
     AC_DEFINE([HAVE_ABSOLUTE_TIME], [1], [Have OS X UpTime()/AbsoluteTime high-precision timing])
     AC_DEFINE([HAVE_ABSOLUTE_TIME], [1], [Have OS X UpTime()/AbsoluteTime high-precision timing])
     osx_frameworks=yes
     osx_frameworks=yes
+    AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin])
 	AC_MSG_RESULT(Apple OS X)
 	AC_MSG_RESULT(Apple OS X)
 	;;
 	;;
 
 
@@ -1213,24 +1179,24 @@ AC_MSG_RESULT(
              TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
              TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
 ##########################################################################
 ##########################################################################
 libpcap:                    ${foundpcap} (${libpcap_version})
 libpcap:                    ${foundpcap} (${libpcap_version})
-libnet:                     ${foundnet}
-libdnet:                    ${founddnet}
+libdnet:                    ${founddnet} (${libdnet_version})
 autogen:                    ${AUTOGEN} (${AUTOGEN_VERSION})
 autogen:                    ${AUTOGEN} (${AUTOGEN_VERSION})
 Use libopts tearoff:        ${enable_local_libopts}
 Use libopts tearoff:        ${enable_local_libopts}
 64bit counter support:      ${use64bit_counters}
 64bit counter support:      ${use64bit_counters}
 tcpdump binary path:        ${tcpdump_path}
 tcpdump binary path:        ${tcpdump_path}
 tcpreplay edit support:     ${tcpreplay_edit}
 tcpreplay edit support:     ${tcpreplay_edit}
-tcpbridge support:          ${enable_tcpbridge}
 fragroute support:          ${enable_fragroute}
 fragroute support:          ${enable_fragroute}
+tcpbridge support:          ${enable_tcpbridge}
 
 
 Supported Packet Injection Methods (*):
 Supported Packet Injection Methods (*):
 Linux PF_PACKET:            ${have_pf}
 Linux PF_PACKET:            ${have_pf}
 BSD BPF:                    ${have_bpf}
 BSD BPF:                    ${have_bpf}
-libnet:                     ${have_libnet}
+libdnet:                    ${have_libdnet}
 pcap_inject:                ${have_pcap_inject}
 pcap_inject:                ${have_pcap_inject}
-pcap_sendpacket:            ${have_pcap_sendpacket}
+pcap_sendpacket:            ${have_pcap_sendpacket} **
 
 
 * In order of preference; see configure --help to override
 * In order of preference; see configure --help to override
+** Required for tcpbridge
 )
 )
 
 
 
 

BIN
docs/._CHANGELOG


+ 38 - 1
docs/CHANGELOG

@@ -1,4 +1,41 @@
-$Id: CHANGELOG 2063 2008-06-20 16:03:22Z aturner $
+$Id: CHANGELOG 2215 2009-02-18 04:46:51Z aturner $
+
+02/18/2009: Version 3.4.1
+    - Sendpacket method did not match documentation (#361)
+    - Fix compile issue on systems without err.h (#363)
+    - Fix tcpprep --mac not processing non-IPv4 packets (#369)
+    - Always build tcpreplay w/ editing features as tcpreplay-edit (#372)
+    - Fix potential tcpbridge issues under OS X & *BSD (#373)
+    - Fix crash on 4 byte strictly aligned systems (#377)
+    - Add MTU truncation to tcprewrite/tcpreplay-edit (#379)
+
+01/15/2009: Version 3.4.0
+    - Add libdnet and remove libnet support for sending packets (#302)
+    - Fix numerous 802.11 decoder bugs (#325)
+    - Fix compile issue under Linux (#326)
+    - Fix Mbps/sec nonsense (#327)
+    - Fix tcprewrite crash when packets have no L3+ data (#328)
+    - Clean up err.c/err.h code and improve performance for non-debug builds (#331)
+    - Fix timesdiv() timer code (#332)
+    - Improve high-performance packet sending via multiple packets/interval (#334)
+    - Fix statistics report errors (#335)
+    - Fix BPF filters not being used in tcpbridge (#336)
+    - Improve tcpbridge performance (#337)
+    - Only use two libpcap handles for tcpbridge (#338)
+    - Fix autotools usage errors (#340)
+    - Clean up 'make test' results (#341)
+    - Update to AutoGen/AutoOpts 5.9.7 (#342)
+    - Fix compiler warnings from GCC 4.2 (#344)
+    - Fix numerous memory corruption bugs in libtcpedit DLT plugin code (#345)
+    - Add support for editing IPv4 TOS/DiffServ/ECN (#348)
+    - Update autotools to more recent versions (#349)
+    - Report injection method via -V (#352)
+    - Fix DLT_USER l2len check bug (#353)
+    - Replace man2html w/ groff (#354)
+    - Fix false pcap_inject() detection under Windows/Winpcap (#355)
+    - tcpbridge now builds under Win32/Cygwin
+    - libdnet is no longer an option for Win32/Cygwin (#57)
+    - tcpbridge now supports --listnics (#357)
 
 
 06/20/2008: Version 3.3.2
 06/20/2008: Version 3.3.2
     - Fix (again) tcpbridge --unidir assert error (#308)
     - Fix (again) tcpbridge --unidir assert error (#308)

+ 11 - 1
docs/CREDIT

@@ -1,4 +1,4 @@
-$Id: CREDIT 1782 2007-04-02 04:21:30Z aturner $ 
+$Id: CREDIT 2101 2009-01-04 22:42:57Z aturner $ 
 
 
 tcpreplay and it's associated utilities (tcpprep, tcprewrite and flowreplay)
 tcpreplay and it's associated utilities (tcpprep, tcprewrite and flowreplay)
 were designed and written by Aaron Turner.
 were designed and written by Aaron Turner.
@@ -43,3 +43,13 @@ Denis McLaughlin <denism@cyberus.ca>
 Andrew Edgecombe <andrew.edgecombe@nec.com.au>
 Andrew Edgecombe <andrew.edgecombe@nec.com.au>
 	- Patch to support caching pcap files in memory when looping
 	- Patch to support caching pcap files in memory when looping
 	  which provides a significant performance improvement
 	  which provides a significant performance improvement
+    - Patch to fix issue with -M option
+
+Joerg Mayer  <jmayer@loplof.de>
+   - Patch for auto* to fix various warnings & errors
+
+Jim West <jim_west@agilent.com>
+   - Patch to fix Solaris compiling issues
+
+Bojan Smojver <bojan@rexursive.com>
+   - For maintaining the RPM package and helping with portability issues

+ 13 - 16
docs/Makefile.am

@@ -2,34 +2,31 @@ MAKEFLAGS=-s
 
 
 .PHONY: manpages
 .PHONY: manpages
 
 
-MAN2HTML = ../scripts/man2html
-
-docs: manpages
-
+docs: clean-docs manpages
 
 
 web/tcpreplay.html:
 web/tcpreplay.html:
-	$(MAN2HTML) < ../src/tcpreplay.1 > web/tcpreplay.html
+	@GROFF@ -Thtml -mman ../src/tcpreplay.1 > web/tcpreplay.html
 
 
 web/tcpprep.html:
 web/tcpprep.html:
-	$(MAN2HTML) < ../src/tcpprep.1 > web/tcpprep.html
-
-web/flowreplay.html:
-	$(MAN2HTML) < ../src/flowreplay.1 > web/flowreplay.html
+	@GROFF@ -Thtml -mman ../src/tcpprep.1 > web/tcpprep.html
 
 
 web/tcprewrite.html:
 web/tcprewrite.html:
-	$(MAN2HTML) < ../src/tcprewrite.1 > web/tcprewrite.html
+	@GROFF@ -Thtml -mman ../src/tcprewrite.1 > web/tcprewrite.html
 
 
 web/tcpbridge.html:
 web/tcpbridge.html:
-	$(MAN2HTML) < ../src/tcpbridge.1 > web/tcpbridge.html
+	@GROFF@ -Thtml -mman ../src/tcpbridge.1 > web/tcpbridge.html
+
+web/tcpreplay-edit.html:
+	@GROFF@ -Thtml -mman ../src/tcpreplay-edit.1 > web/tcpreplay-edit.html
 
 
-manpages: web/tcpreplay.html web/tcpprep.html web/flowreplay.html \
-	web/tcprewrite.html web/tcpbridge.html 
+manpages: web/tcpreplay.html web/tcpprep.html web/tcprewrite.html \
+    web/tcpbridge.html web/tcpreplay-edit.html
 
 
 postweb: manpages
 postweb: manpages
-	rsync -e ssh --exclude '.svn/' --exclude '/**/.svn/' --exclude '/**~' \
+	rsync -qe ssh --exclude '.svn/' --exclude '/**/.svn/' --exclude '/**~' \
 	--exclude '*~' -avz web/ \
 	--exclude '*~' -avz web/ \
-	aturner@voigner.synfin.net:/var/www-vhosts/tcpreplay/
-	scp CHANGELOG TODO aturner@voigner.synfin.net:/var/www-vhosts/tcpreplay/
+	aturner@malbec.synfin.net:/var/vhosts/tcpreplay/
+	scp CHANGELOG TODO aturner@malbec.synfin.net:/var/vhosts/tcpreplay/
 
 
 
 
 EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE 
 EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE 

+ 29 - 23
docs/Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -35,7 +35,8 @@ target_triplet = @target@
 subdir = docs
 subdir = docs
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in INSTALL TODO
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in INSTALL TODO
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
@@ -67,20 +68,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -90,10 +93,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -101,8 +103,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -126,7 +132,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -158,6 +164,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -182,7 +189,6 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 top_srcdir = @top_srcdir@
 MAKEFLAGS = -s
 MAKEFLAGS = -s
-MAN2HTML = ../scripts/man2html
 EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE 
 EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE 
 MAINTAINERCLEANFILES = Makefile.in 
 MAINTAINERCLEANFILES = Makefile.in 
 all: all-am
 all: all-am
@@ -192,8 +198,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	@for dep in $?; do \
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	      exit 1;; \
 	  esac; \
 	  esac; \
 	done; \
 	done; \
@@ -357,31 +363,31 @@ uninstall-am:
 
 
 .PHONY: manpages
 .PHONY: manpages
 
 
-docs: manpages
+docs: clean-docs manpages
 
 
 web/tcpreplay.html:
 web/tcpreplay.html:
-	$(MAN2HTML) < ../src/tcpreplay.1 > web/tcpreplay.html
+	@GROFF@ -Thtml -mman ../src/tcpreplay.1 > web/tcpreplay.html
 
 
 web/tcpprep.html:
 web/tcpprep.html:
-	$(MAN2HTML) < ../src/tcpprep.1 > web/tcpprep.html
-
-web/flowreplay.html:
-	$(MAN2HTML) < ../src/flowreplay.1 > web/flowreplay.html
+	@GROFF@ -Thtml -mman ../src/tcpprep.1 > web/tcpprep.html
 
 
 web/tcprewrite.html:
 web/tcprewrite.html:
-	$(MAN2HTML) < ../src/tcprewrite.1 > web/tcprewrite.html
+	@GROFF@ -Thtml -mman ../src/tcprewrite.1 > web/tcprewrite.html
 
 
 web/tcpbridge.html:
 web/tcpbridge.html:
-	$(MAN2HTML) < ../src/tcpbridge.1 > web/tcpbridge.html
+	@GROFF@ -Thtml -mman ../src/tcpbridge.1 > web/tcpbridge.html
+
+web/tcpreplay-edit.html:
+	@GROFF@ -Thtml -mman ../src/tcpreplay-edit.1 > web/tcpreplay-edit.html
 
 
-manpages: web/tcpreplay.html web/tcpprep.html web/flowreplay.html \
-	web/tcprewrite.html web/tcpbridge.html 
+manpages: web/tcpreplay.html web/tcpprep.html web/tcprewrite.html \
+    web/tcpbridge.html web/tcpreplay-edit.html
 
 
 postweb: manpages
 postweb: manpages
-	rsync -e ssh --exclude '.svn/' --exclude '/**/.svn/' --exclude '/**~' \
+	rsync -qe ssh --exclude '.svn/' --exclude '/**/.svn/' --exclude '/**~' \
 	--exclude '*~' -avz web/ \
 	--exclude '*~' -avz web/ \
-	aturner@voigner.synfin.net:/var/www-vhosts/tcpreplay/
-	scp CHANGELOG TODO aturner@voigner.synfin.net:/var/www-vhosts/tcpreplay/
+	aturner@malbec.synfin.net:/var/vhosts/tcpreplay/
+	scp CHANGELOG TODO aturner@malbec.synfin.net:/var/vhosts/tcpreplay/
 
 
 clean-docs: clean
 clean-docs: clean
 	-rm -f web/*.html
 	-rm -f web/*.html

+ 17 - 10
lib/Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -38,7 +38,8 @@ subdir = lib
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
 	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
@@ -91,20 +92,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -114,10 +117,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -125,8 +127,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -150,7 +156,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -182,6 +188,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -218,8 +225,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	@for dep in $?; do \
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	      exit 1;; \
 	  esac; \
 	  esac; \
 	done; \
 	done; \
@@ -292,7 +299,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 	mkid -fID $$unique
 tags: TAGS
 tags: TAGS

+ 17 - 14
libopts/Makefile.am

@@ -7,19 +7,22 @@ noinst_LTLIBRARIES      = libopts.la
 endif
 endif
 libopts_la_SOURCES      = libopts.c
 libopts_la_SOURCES      = libopts.c
 libopts_la_CPPFLAGS     = -I$(top_srcdir)
 libopts_la_CPPFLAGS     = -I$(top_srcdir)
-libopts_la_LDFLAGS      = -version-info  30:0:5
+libopts_la_LDFLAGS      = -version-info  32:0:7
 EXTRA_DIST              = \
 EXTRA_DIST              = \
     COPYING.gplv3           COPYING.lgplv3          COPYING.mbsd  \
     COPYING.gplv3           COPYING.lgplv3          COPYING.mbsd  \
-    MakeDefs.inc            README                  autoopts/options.h  \
-    autoopts/usage-txt.h    autoopts.c              autoopts.h  \
-    boolean.c               compat/compat.h         compat/pathfind.c  \
-    compat/snprintf.c       compat/strchr.c         compat/strdup.c  \
-    compat/windows-config.h 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
+    MakeDefs.inc            README                  ag-char-map.h  \
+    autoopts/options.h      autoopts/usage-txt.h    autoopts.c  \
+    autoopts.h              boolean.c               compat/compat.h  \
+    compat/pathfind.c       compat/snprintf.c       compat/strchr.c  \
+    compat/strdup.c         compat/windows-config.h configfile.c  \
+    cook.c                  enumeration.c           environment.c  \
+    file.c                  genshell.c              genshell.h  \
+    load.c                  m4/libopts.m4           m4/liboptschk.m4  \
+    makeshell.c             nested.c                numeric.c  \
+    parse-duration.c        parse-duration.h        pgusage.c  \
+    proto.h                 putshell.c              reset.c  \
+    restore.c               save.c                  sort.c  \
+    stack.c                 streqvcmp.c             text_mmap.c  \
+    time.c                  tokenize.c              usage.c  \
+    value-type.c            value-type.h            version.c  \
+    xat-attribute.c         xat-attribute.h

+ 34 - 24
libopts/Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -36,7 +36,8 @@ target_triplet = @target@
 subdir = libopts
 subdir = libopts
 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
@@ -99,20 +100,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -122,10 +125,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -133,8 +135,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -158,7 +164,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -190,6 +196,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -218,22 +225,25 @@ MAINTAINERCLEANFILES = Makefile.in
 @INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
 @INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
 libopts_la_SOURCES = libopts.c
 libopts_la_SOURCES = libopts.c
 libopts_la_CPPFLAGS = -I$(top_srcdir)
 libopts_la_CPPFLAGS = -I$(top_srcdir)
-libopts_la_LDFLAGS = -version-info  30:0:5
+libopts_la_LDFLAGS = -version-info  32:0:7
 EXTRA_DIST = \
 EXTRA_DIST = \
     COPYING.gplv3           COPYING.lgplv3          COPYING.mbsd  \
     COPYING.gplv3           COPYING.lgplv3          COPYING.mbsd  \
-    MakeDefs.inc            README                  autoopts/options.h  \
-    autoopts/usage-txt.h    autoopts.c              autoopts.h  \
-    boolean.c               compat/compat.h         compat/pathfind.c  \
-    compat/snprintf.c       compat/strchr.c         compat/strdup.c  \
-    compat/windows-config.h 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
+    MakeDefs.inc            README                  ag-char-map.h  \
+    autoopts/options.h      autoopts/usage-txt.h    autoopts.c  \
+    autoopts.h              boolean.c               compat/compat.h  \
+    compat/pathfind.c       compat/snprintf.c       compat/strchr.c  \
+    compat/strdup.c         compat/windows-config.h configfile.c  \
+    cook.c                  enumeration.c           environment.c  \
+    file.c                  genshell.c              genshell.h  \
+    load.c                  m4/libopts.m4           m4/liboptschk.m4  \
+    makeshell.c             nested.c                numeric.c  \
+    parse-duration.c        parse-duration.h        pgusage.c  \
+    proto.h                 putshell.c              reset.c  \
+    restore.c               save.c                  sort.c  \
+    stack.c                 streqvcmp.c             text_mmap.c  \
+    time.c                  tokenize.c              usage.c  \
+    value-type.c            value-type.h            version.c  \
+    xat-attribute.c         xat-attribute.h
 
 
 all: all-am
 all: all-am
 
 
@@ -243,8 +253,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	@for dep in $?; do \
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	      exit 1;; \
 	  esac; \
 	  esac; \
 	done; \
 	done; \
@@ -354,7 +364,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 	mkid -fID $$unique
 tags: TAGS
 tags: TAGS

+ 129 - 0
libopts/ag-char-map.h

@@ -0,0 +1,129 @@
+/*
+ *   Character mapping generated 12/31/08 19:07:31
+ *
+ *  This file contains the character classifications
+ *  used by AutoGen and AutoOpts for identifying tokens.
+ */
+#ifndef AG_CHAR_MAP_H_GUARD
+#define AG_CHAR_MAP_H_GUARD 1
+
+#ifdef HAVE_CONFIG_H
+# if defined(HAVE_INTTYPES_H)
+#  include <inttypes.h>
+# elif defined(HAVE_STDINT_H)
+#  include <stdint.h>
+# else
+#  error "no int-types header."
+#  choke-me-now.
+# endif
+#else
+# ifdef __sun
+#  include <inttypes.h>
+# else
+#  include <stdint.h>
+# endif
+#endif
+
+#if 0 /* mapping specification source (from autogen.map) */
+// 
+// %guard          autoopts_internal
+// %file           ag-char-map.h
+// %table          opt-char-cat
+// 
+// %comment
+//         This file contains the character classifications
+//         used by AutoGen and AutoOpts for identifying tokens.
+// %
+// 
+// lower-case      "a-z"
+// upper-case      "A-Z"
+// alphabetic      +lower-case   +upper-case
+// oct-digit       "0-7"
+// dec-digit       "89"          +oct-digit
+// hex-digit       "a-fA-F"      +dec-digit
+// alphanumeric    +alphabetic   +dec-digit
+// var-first       "_"           +alphabetic
+// variable-name   +var-first    +dec-digit
+// option-name     "^-"          +variable-name
+// value-name      ":"           +option-name
+// horiz-white     "\t "
+// compound-name   "[.]"         +value-name   +horiz-white
+// whitespace      "\v\f\r\n\b"  +horiz-white
+// unquotable      "!-~"         -"\"#(),;<=>[\\]`{}?*'"
+// end-xml-token   "/>"          +whitespace
+// graphic         "!-~"
+// plus-n-space    "+"           +whitespace
+// punctuation     "!-~"         -alphanumeric -"_"
+// suffix          "-._"         +alphanumeric
+// suffix-fmt      "%/"          +suffix     
+// false-type      "nNfF0\x00"
+//
+#endif /* 0 -- mapping spec. source */
+
+typedef uint32_t opt_char_cat_mask_t;
+extern opt_char_cat_mask_t const opt_char_cat[128];
+
+static inline int is_opt_char_cat_char(char ch, opt_char_cat_mask_t mask) {
+    unsigned int ix = (unsigned char)ch;
+    return ((ix < 0x7F) && ((opt_char_cat[ix] & mask) != 0)); }
+
+#define IS_LOWER_CASE_CHAR(_c)     is_opt_char_cat_char((_c), 0x00001)
+#define IS_UPPER_CASE_CHAR(_c)     is_opt_char_cat_char((_c), 0x00002)
+#define IS_ALPHABETIC_CHAR(_c)     is_opt_char_cat_char((_c), 0x00003)
+#define IS_OCT_DIGIT_CHAR(_c)      is_opt_char_cat_char((_c), 0x00004)
+#define IS_DEC_DIGIT_CHAR(_c)      is_opt_char_cat_char((_c), 0x0000C)
+#define IS_HEX_DIGIT_CHAR(_c)      is_opt_char_cat_char((_c), 0x0001C)
+#define IS_ALPHANUMERIC_CHAR(_c)   is_opt_char_cat_char((_c), 0x0000F)
+#define IS_VAR_FIRST_CHAR(_c)      is_opt_char_cat_char((_c), 0x00023)
+#define IS_VARIABLE_NAME_CHAR(_c)  is_opt_char_cat_char((_c), 0x0002F)
+#define IS_OPTION_NAME_CHAR(_c)    is_opt_char_cat_char((_c), 0x0006F)
+#define IS_VALUE_NAME_CHAR(_c)     is_opt_char_cat_char((_c), 0x000EF)
+#define IS_HORIZ_WHITE_CHAR(_c)    is_opt_char_cat_char((_c), 0x00100)
+#define IS_COMPOUND_NAME_CHAR(_c)  is_opt_char_cat_char((_c), 0x003EF)
+#define IS_WHITESPACE_CHAR(_c)     is_opt_char_cat_char((_c), 0x00500)
+#define IS_UNQUOTABLE_CHAR(_c)     is_opt_char_cat_char((_c), 0x00800)
+#define IS_END_XML_TOKEN_CHAR(_c)  is_opt_char_cat_char((_c), 0x01500)
+#define IS_GRAPHIC_CHAR(_c)        is_opt_char_cat_char((_c), 0x02000)
+#define IS_PLUS_N_SPACE_CHAR(_c)   is_opt_char_cat_char((_c), 0x04500)
+#define IS_PUNCTUATION_CHAR(_c)    is_opt_char_cat_char((_c), 0x08000)
+#define IS_SUFFIX_CHAR(_c)         is_opt_char_cat_char((_c), 0x1000F)
+#define IS_SUFFIX_FMT_CHAR(_c)     is_opt_char_cat_char((_c), 0x3000F)
+#define IS_FALSE_TYPE_CHAR(_c)     is_opt_char_cat_char((_c), 0x40000)
+
+#ifdef AUTOOPTS_INTERNAL
+opt_char_cat_mask_t const opt_char_cat[128] = {
+  /*x00*/ 0x40000, /*x01*/ 0x00000, /*x02*/ 0x00000, /*x03*/ 0x00000,
+  /*x04*/ 0x00000, /*x05*/ 0x00000, /*x06*/ 0x00000, /*\a */ 0x00000,
+  /*\b */ 0x00400, /*\t */ 0x00100, /*\n */ 0x00400, /*\v */ 0x00400,
+  /*\f */ 0x00400, /*\r */ 0x00400, /*x0E*/ 0x00000, /*x0F*/ 0x00000,
+  /*x10*/ 0x00000, /*x11*/ 0x00000, /*x12*/ 0x00000, /*x13*/ 0x00000,
+  /*x14*/ 0x00000, /*x15*/ 0x00000, /*x16*/ 0x00000, /*x17*/ 0x00000,
+  /*x18*/ 0x00000, /*x19*/ 0x00000, /*x1A*/ 0x00000, /*x1B*/ 0x00000,
+  /*x1C*/ 0x00000, /*x1D*/ 0x00000, /*x1E*/ 0x00000, /*x1F*/ 0x00000,
+  /*   */ 0x00100, /* ! */ 0x0A800, /* " */ 0x0A000, /* # */ 0x0A000,
+  /* $ */ 0x0A800, /* % */ 0x2A800, /* & */ 0x0A800, /* ' */ 0x0A000,
+  /* ( */ 0x0A000, /* ) */ 0x0A000, /* * */ 0x0A000, /* + */ 0x0E800,
+  /* , */ 0x0A000, /* - */ 0x1A840, /* . */ 0x1AA00, /* / */ 0x2B800,
+  /* 0 */ 0x42804, /* 1 */ 0x02804, /* 2 */ 0x02804, /* 3 */ 0x02804,
+  /* 4 */ 0x02804, /* 5 */ 0x02804, /* 6 */ 0x02804, /* 7 */ 0x02804,
+  /* 8 */ 0x02808, /* 9 */ 0x02808, /* : */ 0x0A880, /* ; */ 0x0A000,
+  /* < */ 0x0A000, /* = */ 0x0A000, /* > */ 0x0B000, /* ? */ 0x0A000,
+  /* @ */ 0x0A800, /* A */ 0x02812, /* B */ 0x02812, /* C */ 0x02812,
+  /* D */ 0x02812, /* E */ 0x02812, /* F */ 0x42812, /* G */ 0x02802,
+  /* H */ 0x02802, /* I */ 0x02802, /* J */ 0x02802, /* K */ 0x02802,
+  /* L */ 0x02802, /* M */ 0x02802, /* N */ 0x42802, /* O */ 0x02802,
+  /* P */ 0x02802, /* Q */ 0x02802, /* R */ 0x02802, /* S */ 0x02802,
+  /* T */ 0x02802, /* U */ 0x02802, /* V */ 0x02802, /* W */ 0x02802,
+  /* X */ 0x02802, /* Y */ 0x02802, /* Z */ 0x02802, /* [ */ 0x0A200,
+  /* \ */ 0x0A000, /* ] */ 0x0A200, /* ^ */ 0x0A840, /* _ */ 0x12820,
+  /* ` */ 0x0A000, /* a */ 0x02811, /* b */ 0x02811, /* c */ 0x02811,
+  /* d */ 0x02811, /* e */ 0x02811, /* f */ 0x42811, /* g */ 0x02801,
+  /* h */ 0x02801, /* i */ 0x02801, /* j */ 0x02801, /* k */ 0x02801,
+  /* l */ 0x02801, /* m */ 0x02801, /* n */ 0x42801, /* o */ 0x02801,
+  /* p */ 0x02801, /* q */ 0x02801, /* r */ 0x02801, /* s */ 0x02801,
+  /* t */ 0x02801, /* u */ 0x02801, /* v */ 0x02801, /* w */ 0x02801,
+  /* x */ 0x02801, /* y */ 0x02801, /* z */ 0x02801, /* { */ 0x0A000,
+  /* | */ 0x0A800, /* } */ 0x0A000, /* ~ */ 0x0A800, /*x7F*/ 0x00000
+};
+#endif /* AUTOOPTS_INTERNAL */
+#endif /* AG_CHAR_MAP_H_GUARD */

+ 55 - 23
libopts/autoopts.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: autoopts.c,v 4.27 2007/07/04 21:36:36 bkorb Exp $
- *  Time-stamp:      "2007-07-04 14:33:39 bkorb"
+ *  $Id: autoopts.c,v 4.36 2008/12/20 18:35:26 bkorb Exp $
+ *  Time-stamp:      "2008-12-16 14:52:28 bkorb"
  *
  *
  *  This file contains all of the routines that must be linked into
  *  This file contains all of the routines that must be linked into
  *  an executable to use the generated option processing.  The optional
  *  an executable to use the generated option processing.  The optional
@@ -10,7 +10,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -32,7 +33,7 @@
 static char const zNil[] = "";
 static char const zNil[] = "";
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static tSuccess
 static tSuccess
 findOptDesc( tOptions* pOpts, tOptState* pOptState );
 findOptDesc( tOptions* pOpts, tOptState* pOptState );
 
 
@@ -261,15 +262,21 @@ longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState )
     int        matchCt  = 0;
     int        matchCt  = 0;
     int        matchIdx = 0;
     int        matchIdx = 0;
     int        nameLen;
     int        nameLen;
+    char       opt_name_buf[128];
 
 
     /*
     /*
      *  IF the value is attached to the name,
      *  IF the value is attached to the name,
-     *  THEN clip it off.
-     *  Either way, figure out how long our name is
+     *  copy it off so we can NUL terminate.
      */
      */
     if (pzEq != NULL) {
     if (pzEq != NULL) {
         nameLen = (int)(pzEq - pzOptName);
         nameLen = (int)(pzEq - pzOptName);
-        *pzEq = NUL;
+        if (nameLen >= sizeof(opt_name_buf))
+            return FAILURE;
+        memcpy(opt_name_buf, pzOptName, nameLen);
+        opt_name_buf[nameLen] = NUL;
+        pzOptName = opt_name_buf;
+        pzEq++;
+
     } else nameLen = strlen( pzOptName );
     } else nameLen = strlen( pzOptName );
 
 
     do  {
     do  {
@@ -325,9 +332,6 @@ longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState )
 
 
     } while (pOD++, (++idx < idxLim));
     } while (pOD++, (++idx < idxLim));
 
 
-    if (pzEq != NULL)
-        *(pzEq++) = '=';
-
     /*
     /*
      *  Make sure we either found an exact match or found only one partial
      *  Make sure we either found an exact match or found only one partial
      */
      */
@@ -366,8 +370,8 @@ longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState )
      *  THEN call the usage procedure.
      *  THEN call the usage procedure.
      */
      */
     if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
     if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
-        fprintf( stderr, zIllOptStr, pOpts->pzProgPath,
-                 (matchCt == 0) ? zIllegal : zAmbiguous, pzOptName );
+        fprintf(stderr, (matchCt == 0) ? zIllOptStr : zAmbigOptStr,
+                pOpts->pzProgPath, pzOptName);
         (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
         (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
     }
     }
 
 
@@ -418,7 +422,7 @@ shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState )
      *  THEN the result is the "option" itself and the
      *  THEN the result is the "option" itself and the
      *       option is the specially marked "number" option.
      *       option is the specially marked "number" option.
      */
      */
-    if (  isdigit( optValue )
+    if (  IS_DEC_DIGIT_CHAR(optValue)
        && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) {
        && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) {
         pOptState->pOD = \
         pOptState->pOD = \
         pRes           = pOpts->pOptDesc + pOpts->specOptIdx.number_option;
         pRes           = pOpts->pOptDesc + pOpts->specOptIdx.number_option;
@@ -465,16 +469,28 @@ findOptDesc( tOptions* pOpts, tOptState* pOptState )
      *  IF all arguments must be named options, ...
      *  IF all arguments must be named options, ...
      */
      */
     if (NAMED_OPTS(pOpts)) {
     if (NAMED_OPTS(pOpts)) {
-        char* pz = pOpts->pzCurOpt;
+        char *   pz  = pOpts->pzCurOpt;
+        int      def;
+        tSuccess res; 
+        tAoUS *  def_opt;
+
         pOpts->curOptIdx++;
         pOpts->curOptIdx++;
 
 
+        if (*pz != '-')
+            return longOptionFind(pOpts, pz, pOptState);
+
         /*
         /*
-         *  Skip over any flag/option markers.
-         *  In this mode, they are not required.
+         *  The name is prefixed with one or more hyphens.  Strip them off
+         *  and disable the "default_opt" setting.  Use heavy recasting to
+         *  strip off the "const" quality of the "default_opt" field.
          */
          */
-        while (*pz == '-') pz++;
-
-        return longOptionFind( pOpts, pz, pOptState );
+        while (*(++pz) == '-')   ;
+        def_opt = (void *)&(pOpts->specOptIdx.default_opt);
+        def = *def_opt;
+        *def_opt = NO_EQUIVALENT;
+        res = longOptionFind(pOpts, pz, pOptState);
+        *def_opt = def;
+        return res;
     }
     }
 
 
     /*
     /*
@@ -669,8 +685,8 @@ nextOption( tOptions* pOpts, tOptState* pOptState )
 
 
         default:
         default:
         case TOPT_DEFAULT:
         case TOPT_DEFAULT:
-            fputs( "AutoOpts lib error: defaulted to option with optional arg\n",
-                   stderr );
+            fputs("AutoOpts lib error: defaulted to option with optional arg\n",
+                  stderr );
             exit( EX_SOFTWARE );
             exit( EX_SOFTWARE );
         }
         }
 
 
@@ -814,7 +830,8 @@ doPresets( tOptions* pOpts )
      *  has a --load-opts option.  See if a command line option has disabled
      *  has a --load-opts option.  See if a command line option has disabled
      *  option presetting.
      *  option presetting.
      */
      */
-    if (pOpts->specOptIdx.save_opts != 0) {
+    if (  (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
+       && (pOpts->specOptIdx.save_opts != 0)) {
         pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
         pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
         if (DISABLED_OPT(pOD))
         if (DISABLED_OPT(pOD))
             return SUCCESS;
             return SUCCESS;
@@ -1041,6 +1058,20 @@ optionProcess(
         if (! SUCCESSFUL( doPresets( pOpts )))
         if (! SUCCESSFUL( doPresets( pOpts )))
             return 0;
             return 0;
 
 
+        /*
+         *  IF option name conversion was suppressed but it is not suppressed
+         *  for the command line, then it's time to translate option names.
+         *  Usage text will not get retranslated.
+         */
+        if (  ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
+           && (pOpts->pTransProc != NULL)
+           && ((pOpts->fOptSet & OPTPROC_NO_XLAT_MASK)
+              == OPTPROC_NXLAT_OPT_CFG)  )  {
+
+            pOpts->fOptSet &= ~OPTPROC_NXLAT_OPT_CFG;
+            (*pOpts->pTransProc)();
+        }
+
         if ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
         if ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
             optionSort( pOpts );
             optionSort( pOpts );
 
 
@@ -1067,7 +1098,8 @@ optionProcess(
      *  THEN do that now before testing for conflicts.
      *  THEN do that now before testing for conflicts.
      *       (conflicts are ignored in preset options)
      *       (conflicts are ignored in preset options)
      */
      */
-    if (pOpts->specOptIdx.save_opts != 0) {
+    if (  (pOpts->specOptIdx.save_opts != NO_EQUIVALENT)
+       && (pOpts->specOptIdx.save_opts != 0)) {
         tOptDesc*  pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts;
         tOptDesc*  pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts;
 
 
         if (SELECTED_OPT( pOD )) {
         if (SELECTED_OPT( pOD )) {

+ 8 - 6
libopts/autoopts.h

@@ -1,15 +1,16 @@
 
 
 /*
 /*
- *  Time-stamp:      "2007-07-04 11:33:08 bkorb"
+ *  Time-stamp:      "2008-11-01 20:08:06 bkorb"
  *
  *
- *  autoopts.h  $Id: autoopts.h,v 4.25 2007/07/04 21:36:36 bkorb Exp $
+ *  autoopts.h  $Id: autoopts.h,v 4.29 2008/11/02 18:51:26 bkorb Exp $
  *
  *
  *  This file defines all the global structures and special values
  *  This file defines all the global structures and special values
  *  used in the automated option processing library.
  *  used in the automated option processing library.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -32,6 +33,7 @@
 #define AUTOGEN_AUTOOPTS_H
 #define AUTOGEN_AUTOOPTS_H
 
 
 #include "compat/compat.h"
 #include "compat/compat.h"
+#include "ag-char-map.h"
 
 
 #define AO_NAME_LIMIT           127
 #define AO_NAME_LIMIT           127
 #define AO_NAME_SIZE            ((size_t)(AO_NAME_LIMIT + 1))
 #define AO_NAME_SIZE            ((size_t)(AO_NAME_LIMIT + 1))
@@ -86,8 +88,6 @@ typedef int tDirection;
 #define PROCESSING(d)           ((d)>0)
 #define PROCESSING(d)           ((d)>0)
 #define PRESETTING(d)           ((d)<0)
 #define PRESETTING(d)           ((d)<0)
 
 
-#define ISNAMECHAR( c )         (isalnum(c) || ((c) == '_') || ((c) == '-'))
-
 /*
 /*
  *  Procedure success codes
  *  Procedure success codes
  *
  *
@@ -198,6 +198,7 @@ typedef struct {
     tCC*    pzStr;
     tCC*    pzStr;
     tCC*    pzReq;
     tCC*    pzReq;
     tCC*    pzNum;
     tCC*    pzNum;
+    tCC*    pzFile;
     tCC*    pzKey;
     tCC*    pzKey;
     tCC*    pzKeyL;
     tCC*    pzKeyL;
     tCC*    pzBool;
     tCC*    pzBool;
@@ -208,11 +209,12 @@ typedef struct {
     tCC*    pzNoF;
     tCC*    pzNoF;
     tCC*    pzSpc;
     tCC*    pzSpc;
     tCC*    pzOptFmt;
     tCC*    pzOptFmt;
+    tCC*    pzTime;
 } arg_types_t;
 } arg_types_t;
 
 
 #define AGALOC( c, w )          ao_malloc((size_t)c)
 #define AGALOC( c, w )          ao_malloc((size_t)c)
 #define AGREALOC( p, c, w )     ao_realloc((void*)p, (size_t)c)
 #define AGREALOC( p, c, w )     ao_realloc((void*)p, (size_t)c)
-#define AGFREE( p )             ao_free((void*)p)
+#define AGFREE(_p)              do{void*X=(void*)_p;ao_free(X);}while(0)
 #define AGDUPSTR( p, s, w )     (p = ao_strdup(s))
 #define AGDUPSTR( p, s, w )     (p = ao_strdup(s))
 
 
 static void *
 static void *

+ 202 - 130
libopts/autoopts/options.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (options.h)
  *  DO NOT EDIT THIS FILE   (options.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday July 28, 2007 at 01:01:42 PM PDT
+ *  It has been AutoGen-ed  Wednesday December 31, 2008 at 07:07:15 PM PST
  *  From the definitions    funcs.def
  *  From the definitions    funcs.def
  *  and the template file   options_h
  *  and the template file   options_h
  *
  *
@@ -27,6 +27,7 @@
 #ifndef AUTOOPTS_OPTIONS_H_GUARD
 #ifndef AUTOOPTS_OPTIONS_H_GUARD
 #define AUTOOPTS_OPTIONS_H_GUARD 1
 #define AUTOOPTS_OPTIONS_H_GUARD 1
 #include <sys/types.h>
 #include <sys/types.h>
+#include <stdio.h>
 
 
 #if defined(HAVE_STDINT_H)
 #if defined(HAVE_STDINT_H)
 # include <stdint.h>
 # include <stdint.h>
@@ -65,8 +66,8 @@
  *  values for "opt_name" are available.
  *  values for "opt_name" are available.
  */
  */
 
 
-#define  OPTIONS_STRUCT_VERSION  122880
-#define  OPTIONS_VERSION_STRING  "30:0:5"
+#define  OPTIONS_STRUCT_VERSION  131072
+#define  OPTIONS_VERSION_STRING  "32:0:7"
 #define  OPTIONS_MINIMUM_VERSION 102400
 #define  OPTIONS_MINIMUM_VERSION 102400
 #define  OPTIONS_MIN_VER_STRING  "25:0:0"
 #define  OPTIONS_MIN_VER_STRING  "25:0:0"
 
 
@@ -77,7 +78,9 @@ typedef enum {
     OPARG_TYPE_BOOLEAN          = 3,    /* opt arg is boolean-valued         */
     OPARG_TYPE_BOOLEAN          = 3,    /* opt arg is boolean-valued         */
     OPARG_TYPE_MEMBERSHIP       = 4,    /* opt arg sets set membership bits  */
     OPARG_TYPE_MEMBERSHIP       = 4,    /* opt arg sets set membership bits  */
     OPARG_TYPE_NUMERIC          = 5,    /* opt arg has numeric value         */
     OPARG_TYPE_NUMERIC          = 5,    /* opt arg has numeric value         */
-    OPARG_TYPE_HIERARCHY        = 6     /* option arg is hierarchical value  */
+    OPARG_TYPE_HIERARCHY        = 6,    /* option arg is hierarchical value  */
+    OPARG_TYPE_FILE             = 7,    /* option arg names a file           */
+    OPARG_TYPE_TIME             = 8     /* opt arg is a time duration        */
 } teOptArgType;
 } teOptArgType;
 
 
 typedef struct optionValue {
 typedef struct optionValue {
@@ -93,6 +96,22 @@ typedef struct optionValue {
     } v;
     } v;
 } tOptionValue;
 } tOptionValue;
 
 
+typedef enum {
+    FTYPE_MODE_MAY_EXIST        = 0x00,
+    FTYPE_MODE_MUST_EXIST       = 0x01,
+    FTYPE_MODE_MUST_NOT_EXIST   = 0x02,
+    FTYPE_MODE_EXIST_MASK       = 0x03,
+    FTYPE_MODE_NO_OPEN          = 0x00,
+    FTYPE_MODE_OPEN_FD          = 0x10,
+    FTYPE_MODE_FOPEN_FP         = 0x20,
+    FTYPE_MODE_OPEN_MASK        = 0x30
+} teOptFileType;
+
+typedef union {
+    int             file_flags;
+    char const *    file_mode;
+} tuFileMode;
+
 /*
 /*
  *  Bits in the fOptState option descriptor field.
  *  Bits in the fOptState option descriptor field.
  */
  */
@@ -100,6 +119,7 @@ typedef enum {
     OPTST_SET_ID             =   0, /* Set via the "SET_OPT()" macro */
     OPTST_SET_ID             =   0, /* Set via the "SET_OPT()" macro */
     OPTST_PRESET_ID          =   1, /* Set via an RC/INI file        */
     OPTST_PRESET_ID          =   1, /* Set via an RC/INI file        */
     OPTST_DEFINED_ID         =   2, /* Set via a command line option */
     OPTST_DEFINED_ID         =   2, /* Set via a command line option */
+    OPTST_RESET_ID           =   3, /* Reset via command line option */
     OPTST_EQUIVALENCE_ID     =   4, /* selected by equiv'ed option   */
     OPTST_EQUIVALENCE_ID     =   4, /* selected by equiv'ed option   */
     OPTST_DISABLED_ID        =   5, /* option is in disabled state   */
     OPTST_DISABLED_ID        =   5, /* option is in disabled state   */
     OPTST_ALLOC_ARG_ID       =   6, /* pzOptArg was allocated        */
     OPTST_ALLOC_ARG_ID       =   6, /* pzOptArg was allocated        */
@@ -118,13 +138,15 @@ typedef enum {
     OPTST_MUST_SET_ID        =  20, /* must be set or pre-set        */
     OPTST_MUST_SET_ID        =  20, /* must be set or pre-set        */
     OPTST_DOCUMENT_ID        =  21, /* opt is for doc only           */
     OPTST_DOCUMENT_ID        =  21, /* opt is for doc only           */
     OPTST_TWICE_ID           =  22, /* process opt twice - imm + reg */
     OPTST_TWICE_ID           =  22, /* process opt twice - imm + reg */
-    OPTST_DISABLE_TWICE_ID   =  23  /* process disabled option twice */
+    OPTST_DISABLE_TWICE_ID   =  23, /* process disabled option twice */
+    OPTST_SCALED_NUM_ID      =  24  /* scaled integer value          */
 } opt_state_enum_t;
 } opt_state_enum_t;
 
 
 #define OPTST_INIT           0U
 #define OPTST_INIT           0U
 #define OPTST_SET            (1U << OPTST_SET_ID)
 #define OPTST_SET            (1U << OPTST_SET_ID)
 #define OPTST_PRESET         (1U << OPTST_PRESET_ID)
 #define OPTST_PRESET         (1U << OPTST_PRESET_ID)
 #define OPTST_DEFINED        (1U << OPTST_DEFINED_ID)
 #define OPTST_DEFINED        (1U << OPTST_DEFINED_ID)
+#define OPTST_RESET          (1U << OPTST_RESET_ID)
 #define OPTST_EQUIVALENCE    (1U << OPTST_EQUIVALENCE_ID)
 #define OPTST_EQUIVALENCE    (1U << OPTST_EQUIVALENCE_ID)
 #define OPTST_DISABLED       (1U << OPTST_DISABLED_ID)
 #define OPTST_DISABLED       (1U << OPTST_DISABLED_ID)
 #define OPTST_ALLOC_ARG      (1U << OPTST_ALLOC_ARG_ID)
 #define OPTST_ALLOC_ARG      (1U << OPTST_ALLOC_ARG_ID)
@@ -144,16 +166,19 @@ typedef enum {
 #define OPTST_DOCUMENT       (1U << OPTST_DOCUMENT_ID)
 #define OPTST_DOCUMENT       (1U << OPTST_DOCUMENT_ID)
 #define OPTST_TWICE          (1U << OPTST_TWICE_ID)
 #define OPTST_TWICE          (1U << OPTST_TWICE_ID)
 #define OPTST_DISABLE_TWICE  (1U << OPTST_DISABLE_TWICE_ID)
 #define OPTST_DISABLE_TWICE  (1U << OPTST_DISABLE_TWICE_ID)
-#define OPT_STATE_MASK       0x00FFFF77U
+#define OPTST_SCALED_NUM     (1U << OPTST_SCALED_NUM_ID)
+#define OPT_STATE_MASK       0x01FFFF7FU
 
 
 #define OPTST_SET_MASK       (  \
 #define OPTST_SET_MASK       (  \
         OPTST_SET | \
         OPTST_SET | \
         OPTST_PRESET | \
         OPTST_PRESET | \
+        OPTST_RESET | \
         OPTST_DEFINED )
         OPTST_DEFINED )
 
 
 #define OPTST_MUTABLE_MASK   (  \
 #define OPTST_MUTABLE_MASK   (  \
         OPTST_SET | \
         OPTST_SET | \
         OPTST_PRESET | \
         OPTST_PRESET | \
+        OPTST_RESET | \
         OPTST_DEFINED | \
         OPTST_DEFINED | \
         OPTST_EQUIVALENCE | \
         OPTST_EQUIVALENCE | \
         OPTST_DISABLED | \
         OPTST_DISABLED | \
@@ -169,6 +194,11 @@ typedef enum {
         OPTST_ARG_TYPE_3 | \
         OPTST_ARG_TYPE_3 | \
         OPTST_ARG_TYPE_4 )
         OPTST_ARG_TYPE_4 )
 
 
+#define OPTST_DO_NOT_SAVE_MASK   (  \
+        OPTST_NO_INIT | \
+        OPTST_DOCUMENT | \
+        OPTST_OMITTED )
+
 #ifdef NO_OPTIONAL_OPT_ARGS
 #ifdef NO_OPTIONAL_OPT_ARGS
 # undef  OPTST_ARG_OPTIONAL
 # undef  OPTST_ARG_OPTIONAL
 # define OPTST_ARG_OPTIONAL   0
 # define OPTST_ARG_OPTIONAL   0
@@ -176,13 +206,12 @@ typedef enum {
 
 
 #define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
 #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)
+#define SELECTED_OPT(_od)     ((_od)->fOptState  & OPTST_SELECTED_MASK)
+#define UNUSED_OPT(  _od)     (((_od)->fOptState & OPTST_SET_MASK) == 0)
+#define DISABLED_OPT(_od)     ((_od)->fOptState  & OPTST_DISABLED)
+#define OPTION_STATE(_od)     ((_od)->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
  *  PRIVATE INTERFACES
@@ -196,42 +225,50 @@ typedef enum {
  *  Define the processing state flags
  *  Define the processing state flags
  */
  */
 typedef enum {
 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_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 inits 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 args after options     */
+    OPTPROC_REORDER_ID         =  11, /* reorder operands after opts    */
+    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_NXLAT_OPT_CFG_ID   =  16, /* suppress for config only       */
+    OPTPROC_NXLAT_OPT_ID       =  17, /* suppress xlation always        */
+    OPTPROC_PRESETTING_ID      =  19  /* opt processing in preset state */
 } optproc_state_enum_t;
 } 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 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_NXLAT_OPT_CFG  (1U << OPTPROC_NXLAT_OPT_CFG_ID)
+#define OPTPROC_NXLAT_OPT      (1U << OPTPROC_NXLAT_OPT_ID)
+#define OPTPROC_PRESETTING     (1U << OPTPROC_PRESETTING_ID)
+#define OPTPROC_STATE_MASK     0x000B7FFFU
+
+#define OPTPROC_NO_XLAT_MASK   (  \
+        OPTPROC_NXLAT_OPT_CFG | \
+        OPTPROC_NXLAT_OPT )
 
 
 #define STMTS(s)  do { s; } while (0)
 #define STMTS(s)  do { s; } while (0)
 
 
@@ -262,19 +299,23 @@ typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool;
 typedef struct options  tOptions;
 typedef struct options  tOptions;
 typedef struct optDesc  tOptDesc;
 typedef struct optDesc  tOptDesc;
 typedef struct optNames tOptNames;
 typedef struct optNames tOptNames;
+#define OPTPROC_EMIT_USAGE      ((tOptions *)0x01UL)
+#define OPTPROC_EMIT_SHELL      ((tOptions *)0x02UL)
+#define OPTPROC_RETURN_VALNAME  ((tOptions *)0x03UL)
+#define OPTPROC_EMIT_LIMIT      ((tOptions *)0x0FUL)
 
 
 /*
 /*
  *  The option procedures do the special processing for each
  *  The option procedures do the special processing for each
  *  option flag that needs it.
  *  option flag that needs it.
  */
  */
-typedef void (tOptProc)( tOptions*  pOpts, tOptDesc* pOptDesc );
+typedef void (tOptProc)(tOptions*  pOpts, tOptDesc* pOptDesc);
 typedef tOptProc*  tpOptProc;
 typedef tOptProc*  tpOptProc;
 
 
 /*
 /*
  *  The usage procedure will never return.  It calls "exit(2)"
  *  The usage procedure will never return.  It calls "exit(2)"
  *  with the "exitCode" argument passed to it.
  *  with the "exitCode" argument passed to it.
  */
  */
-typedef void (tUsageProc)( tOptions* pOpts, int exitCode );
+typedef void (tUsageProc)(tOptions* pOpts, int exitCode);
 typedef tUsageProc* tpUsageProc;
 typedef tUsageProc* tpUsageProc;
 
 
 /*
 /*
@@ -308,6 +349,8 @@ typedef union {
     long            argInt;
     long            argInt;
     unsigned long   argUint;
     unsigned long   argUint;
     unsigned int    argBool;
     unsigned int    argBool;
+    FILE*           argFp;
+    int             argFd;
 } optArgBucket_t;
 } optArgBucket_t;
 
 
 /*
 /*
@@ -331,15 +374,15 @@ struct optDesc {
 #   define          pzLastArg   optArg.argString
 #   define          pzLastArg   optArg.argString
     void*           optCookie;        /* PUBLIC */
     void*           optCookie;        /* PUBLIC */
 
 
-    const int *     pOptMust;
-    const int *     pOptCant;
-    tpOptProc       pOptProc;
-    char const*     pzText;
+    int const * const   pOptMust;
+    int const * const   pOptCant;
+    tpOptProc   const   pOptProc;
+    char const* const   pzText;
 
 
-    char const*     pz_NAME;
-    char const*     pz_Name;
-    char const*     pz_DisableName;
-    char const*     pz_DisablePfx;
+    char const* const   pz_NAME;
+    char const* const   pz_Name;
+    char const* const   pz_DisableName;
+    char const* const   pz_DisablePfx;
 };
 };
 
 
 /*
 /*
@@ -367,19 +410,19 @@ struct options {
     unsigned int        curOptIdx;
     unsigned int        curOptIdx;
     char*               pzCurOpt;
     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*         pzProgPath;         /* PUBLIC */
+    char const*         pzProgName;         /* PUBLIC */
+    char const* const   pzPROGNAME;         /* PUBLIC */
+    char const* const   pzRcName;           /* PUBLIC */
+    char const* const   pzCopyright;        /* PUBLIC */
+    char const* const   pzCopyNotice;       /* PUBLIC */
+    char const* const   pzFullVersion;      /* PUBLIC */
     char const* const* const papzHomeList;
     char const* const* const papzHomeList;
     char const* const   pzUsageTitle;
     char const* const   pzUsageTitle;
     char const* const   pzExplain;
     char const* const   pzExplain;
     char const* const   pzDetail;
     char const* const   pzDetail;
-    tOptDesc*   const   pOptDesc;
-    char const* const   pzBugAddr;
+    tOptDesc*   const   pOptDesc;           /* PUBLIC */
+    char const* const   pzBugAddr;          /* PUBLIC */
 
 
     void*               pExtensions;
     void*               pExtensions;
     void*               pSavedState;
     void*               pSavedState;
@@ -392,9 +435,20 @@ struct options {
     int const           presetOptCt;
     int const           presetOptCt;
     char const *        pzFullUsage;
     char const *        pzFullUsage;
     char const *        pzShortUsage;
     char const *        pzShortUsage;
+    /* PUBLIC: */
+    optArgBucket_t const * const originalOptArgArray;
+    void * const * const originalOptArgCookie;
 };
 };
 
 
 /*
 /*
+ *  Versions where in various fields first appear:
+ *  ($AO_CURRENT * 4096 + $AO_REVISION, but $AO_REVISION must be zero)
+ */
+#define originalOptArgArray_STRUCT_VERSION  131072 /* AO_CURRENT = 32 */
+#define HAS_originalOptArgArray(_opt) \
+    ((_opt)->structVersion >= originalOptArgArray_STRUCT_VERSION)
+
+/*
  *  "token list" structure returned by "string_tokenize()"
  *  "token list" structure returned by "string_tokenize()"
  */
  */
 typedef struct {
 typedef struct {
@@ -487,10 +541,10 @@ extern "C" {
  *  Double quote strings are formed according to the rules of string
  *  Double quote strings are formed according to the rules of string
  *  constants in ANSI-C programs.
  *  constants in ANSI-C programs.
  */
  */
-extern token_list_t* ao_string_tokenize( char const* );
+extern token_list_t* ao_string_tokenize(char const*);
 
 
 
 
-/* From: configfile.c line 90
+/* From: configfile.c line 86
  *
  *
  * configFileLoad - parse a configuration file
  * configFileLoad - parse a configuration file
  *
  *
@@ -507,10 +561,10 @@ extern token_list_t* ao_string_tokenize( char const* );
  *  @code{optionGetValue()}, @code{optionNextValue()} and
  *  @code{optionGetValue()}, @code{optionNextValue()} and
  *  @code{optionUnloadNested()}.
  *  @code{optionUnloadNested()}.
  */
  */
-extern const tOptionValue* configFileLoad( char const* );
+extern const tOptionValue* configFileLoad(char const*);
 
 
 
 
-/* From: configfile.c line 860
+/* From: configfile.c line 883
  *
  *
  * optionFileLoad - Load the locatable config files, in order
  * optionFileLoad - Load the locatable config files, in order
  *
  *
@@ -537,10 +591,10 @@ extern const tOptionValue* configFileLoad( char const* );
  *  
  *  
  *  Configuration files not found or not decipherable are simply ignored.
  *  Configuration files not found or not decipherable are simply ignored.
  */
  */
-extern int optionFileLoad( tOptions*, char const* );
+extern int optionFileLoad(tOptions*, char const*);
 
 
 
 
-/* From: configfile.c line 222
+/* From: configfile.c line 218
  *
  *
  * optionFindNextValue - find a hierarcicaly valued option instance
  * optionFindNextValue - find a hierarcicaly valued option instance
  *
  *
@@ -556,10 +610,10 @@ extern int optionFileLoad( tOptions*, char const* );
  *  configurable.  It will search through the list and return the next entry
  *  configurable.  It will search through the list and return the next entry
  *  that matches the criteria.
  *  that matches the criteria.
  */
  */
-extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionValue*, char const*, char const* );
+extern const tOptionValue* optionFindNextValue(const tOptDesc*, const tOptionValue*, char const*, char const*);
 
 
 
 
-/* From: configfile.c line 148
+/* From: configfile.c line 144
  *
  *
  * optionFindValue - find a hierarcicaly valued option instance
  * optionFindValue - find a hierarcicaly valued option instance
  *
  *
@@ -573,10 +627,10 @@ extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionVa
  *  This routine will find an entry in a nested value option or configurable.
  *  This routine will find an entry in a nested value option or configurable.
  *  It will search through the list and return a matching entry.
  *  It will search through the list and return a matching entry.
  */
  */
-extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char const* );
+extern const tOptionValue* optionFindValue(const tOptDesc*, char const*, char const*);
 
 
 
 
-/* From: restore.c line 165
+/* From: restore.c line 166
  *
  *
  * optionFree - free allocated option processing memory
  * optionFree - free allocated option processing memory
  *
  *
@@ -586,10 +640,10 @@ extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char c
  *  AutoOpts sometimes allocates memory and puts pointers to it in the
  *  AutoOpts sometimes allocates memory and puts pointers to it in the
  *  option state structures.  This routine deallocates all such memory.
  *  option state structures.  This routine deallocates all such memory.
  */
  */
-extern void optionFree( tOptions* );
+extern void optionFree(tOptions*);
 
 
 
 
-/* From: configfile.c line 291
+/* From: configfile.c line 287
  *
  *
  * optionGetValue - get a specific value from a hierarcical list
  * optionGetValue - get a specific value from a hierarcical list
  *
  *
@@ -604,10 +658,10 @@ extern void optionFree( tOptions* );
  *  the first entry with a name that exactly matches the argument will be
  *  the first entry with a name that exactly matches the argument will be
  *  returned.
  *  returned.
  */
  */
-extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );
+extern const tOptionValue* optionGetValue(const tOptionValue*, char const*);
 
 
 
 
-/* From: load.c line 498
+/* From: load.c line 499
  *
  *
  * optionLoadLine - process a string for an option name and value
  * optionLoadLine - process a string for an option name and value
  *
  *
@@ -628,10 +682,10 @@ extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );
  *  formation used in AutoGen definition files (@pxref{basic expression}),
  *  formation used in AutoGen definition files (@pxref{basic expression}),
  *  except that you may not use backquotes.
  *  except that you may not use backquotes.
  */
  */
-extern void optionLoadLine( tOptions*, char const* );
+extern void optionLoadLine(tOptions*, char const*);
 
 
 
 
-/* From: configfile.c line 350
+/* From: configfile.c line 346
  *
  *
  * optionNextValue - get the next value from a hierarchical list
  * optionNextValue - get the next value from a hierarchical list
  *
  *
@@ -647,10 +701,10 @@ extern void optionLoadLine( tOptions*, char const* );
  *  The "@var{pOldValue}" must have been gotten from a prior call to this
  *  The "@var{pOldValue}" must have been gotten from a prior call to this
  *  routine or to "@code{opitonGetValue()}".
  *  routine or to "@code{opitonGetValue()}".
  */
  */
-extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionValue* );
+extern const tOptionValue* optionNextValue(const tOptionValue*, const tOptionValue*);
 
 
 
 
-/* From: usage.c line 107
+/* From: usage.c line 108
  *
  *
  * optionOnlyUsage - Print usage text for just the options
  * optionOnlyUsage - Print usage text for just the options
  *
  *
@@ -662,10 +716,10 @@ extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionVa
  *  This function may be used when the emitted usage must incorporate
  *  This function may be used when the emitted usage must incorporate
  *  information not available to AutoOpts.
  *  information not available to AutoOpts.
  */
  */
-extern void optionOnlyUsage( tOptions*, int );
+extern void optionOnlyUsage(tOptions*, int);
 
 
 
 
-/* From: autoopts.c line 989
+/* From: autoopts.c line 1006
  *
  *
  * optionProcess - this is the main option processing routine
  * optionProcess - this is the main option processing routine
  *
  *
@@ -692,10 +746,10 @@ extern void optionOnlyUsage( tOptions*, int );
  *  is treated as an operand.  Encountering an operand stops option
  *  is treated as an operand.  Encountering an operand stops option
  *  processing.
  *  processing.
  */
  */
-extern int optionProcess( tOptions*, int, char** );
+extern int optionProcess(tOptions*, int, char**);
 
 
 
 
-/* From: restore.c line 122
+/* From: restore.c line 123
  *
  *
  * optionRestore - restore option state from memory copy
  * optionRestore - restore option state from memory copy
  *
  *
@@ -709,10 +763,10 @@ extern int optionProcess( tOptions*, int, char** );
  *  to optionProcess(3AO), then you may change the contents of the
  *  to optionProcess(3AO), then you may change the contents of the
  *  argc/argv parameters to optionProcess.
  *  argc/argv parameters to optionProcess.
  */
  */
-extern void optionRestore( tOptions* );
+extern void optionRestore(tOptions*);
 
 
 
 
-/* From: save.c line 311
+/* From: save.c line 671
  *
  *
  * optionSaveFile - saves the option state to a file
  * optionSaveFile - saves the option state to a file
  *
  *
@@ -725,11 +779,19 @@ extern void optionRestore( tOptions* );
  *  @code{homerc} attribute.  If no @code{rcfile} attribute was specified, it
  *  @code{homerc} attribute.  If no @code{rcfile} attribute was specified, it
  *  will default to @code{.@i{programname}rc}.  If you wish to specify another
  *  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.
  *  file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
+ *  
+ *  The recommend usage is as follows:
+ *  @example
+ *  optionProcess(&progOptions, argc, argv);
+ *  if (i_want_a_non_standard_place_for_this)
+ *  SET_OPT_SAVE_OPTS("myfilename");
+ *  optionSaveFile(&progOptions);
+ *  @end example
  */
  */
-extern void optionSaveFile( tOptions* );
+extern void optionSaveFile(tOptions*);
 
 
 
 
-/* From: restore.c line 70
+/* From: restore.c line 71
  *
  *
  * optionSaveState - saves the option state to memory
  * optionSaveState - saves the option state to memory
  *
  *
@@ -748,10 +810,10 @@ extern void optionSaveFile( tOptions* );
  *  restoring of stacked string arguments and hierarchical values is
  *  restoring of stacked string arguments and hierarchical values is
  *  disabled.  The values are not saved.
  *  disabled.  The values are not saved.
  */
  */
-extern void optionSaveState( tOptions* );
+extern void optionSaveState(tOptions*);
 
 
 
 
-/* From: nested.c line 537
+/* From: nested.c line 570
  *
  *
  * optionUnloadNested - Deallocate the memory for a nested value
  * optionUnloadNested - Deallocate the memory for a nested value
  *
  *
@@ -762,10 +824,10 @@ extern void optionSaveState( tOptions* );
  *  have been gotten from a call to @code{configFileLoad()} (See
  *  have been gotten from a call to @code{configFileLoad()} (See
  *  @pxref{libopts-configFileLoad}).
  *  @pxref{libopts-configFileLoad}).
  */
  */
-extern void optionUnloadNested( tOptionValue const * );
+extern void optionUnloadNested(tOptionValue const *);
 
 
 
 
-/* From: version.c line 41
+/* From: version.c line 38
  *
  *
  * optionVersion - return the compiled AutoOpts version number
  * optionVersion - return the compiled AutoOpts version number
  *
  *
@@ -774,7 +836,7 @@ extern void optionUnloadNested( tOptionValue const * );
  *  Returns the full version string compiled into the library.
  *  Returns the full version string compiled into the library.
  *  The returned string cannot be modified.
  *  The returned string cannot be modified.
  */
  */
-extern char const* optionVersion( void );
+extern char const* optionVersion(void);
 
 
 
 
 /* From: ../compat/pathfind.c line 33
 /* From: ../compat/pathfind.c line 33
@@ -817,11 +879,11 @@ extern char const* optionVersion( void );
  *  @end example
  *  @end example
  */
  */
 #ifndef HAVE_PATHFIND
 #ifndef HAVE_PATHFIND
-extern char* pathfind( char const*, char const*, char const* );
+extern char* pathfind(char const*, char const*, char const*);
 #endif /* HAVE_PATHFIND */
 #endif /* HAVE_PATHFIND */
 
 
 
 
-/* From: streqvcmp.c line 208
+/* From: streqvcmp.c line 209
  *
  *
  * strequate - map a list of characters to the same value
  * strequate - map a list of characters to the same value
  *
  *
@@ -833,10 +895,10 @@ extern char* pathfind( char const*, char const*, char const* );
  *  This function name is mapped to option_strequate so as to not conflict
  *  This function name is mapped to option_strequate so as to not conflict
  *  with the POSIX name space.
  *  with the POSIX name space.
  */
  */
-extern void strequate( char const* );
+extern void strequate(char const*);
 
 
 
 
-/* From: streqvcmp.c line 118
+/* From: streqvcmp.c line 119
  *
  *
  * streqvcmp - compare two strings with an equivalence mapping
  * streqvcmp - compare two strings with an equivalence mapping
  *
  *
@@ -852,10 +914,10 @@ extern void strequate( char const* );
  *  This function name is mapped to option_streqvcmp so as to not conflict
  *  This function name is mapped to option_streqvcmp so as to not conflict
  *  with the POSIX name space.
  *  with the POSIX name space.
  */
  */
-extern int streqvcmp( char const*, char const* );
+extern int streqvcmp(char const*, char const*);
 
 
 
 
-/* From: streqvcmp.c line 155
+/* From: streqvcmp.c line 156
  *
  *
  * streqvmap - Set the character mappings for the streqv functions
  * streqvmap - Set the character mappings for the streqv functions
  *
  *
@@ -880,10 +942,10 @@ extern int streqvcmp( char const*, char const* );
  *  This function name is mapped to option_streqvmap so as to not conflict
  *  This function name is mapped to option_streqvmap so as to not conflict
  *  with the POSIX name space.
  *  with the POSIX name space.
  */
  */
-extern void streqvmap( char, char, int );
+extern void streqvmap(char, char, int);
 
 
 
 
-/* From: streqvcmp.c line 77
+/* From: streqvcmp.c line 78
  *
  *
  * strneqvcmp - compare two strings with an equivalence mapping
  * strneqvcmp - compare two strings with an equivalence mapping
  *
  *
@@ -901,10 +963,10 @@ extern void streqvmap( char, char, int );
  *  This function name is mapped to option_strneqvcmp so as to not conflict
  *  This function name is mapped to option_strneqvcmp so as to not conflict
  *  with the POSIX name space.
  *  with the POSIX name space.
  */
  */
-extern int strneqvcmp( char const*, char const*, int );
+extern int strneqvcmp(char const*, char const*, int);
 
 
 
 
-/* From: streqvcmp.c line 234
+/* From: streqvcmp.c line 235
  *
  *
  * strtransform - convert a string into its mapped-to value
  * strtransform - convert a string into its mapped-to value
  *
  *
@@ -916,55 +978,65 @@ extern int strneqvcmp( char const*, char const*, int );
  *  character is put into the output.
  *  character is put into the output.
  *  This function name is mapped to option_strtransform so as to not conflict
  *  This function name is mapped to option_strtransform so as to not conflict
  *  with the POSIX name space.
  *  with the POSIX name space.
+ *  
+ *  The source and destination may be the same.
  */
  */
-extern void strtransform( char*, char const* );
+extern void strtransform(char*, char const*);
 
 
 /*  AutoOpts PRIVATE FUNCTIONS:  */
 /*  AutoOpts PRIVATE FUNCTIONS:  */
 tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
 tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
 
 
-extern char* ao_string_cook( char*, int* );
+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 unsigned int ao_string_cook_escape_char( char const*, char*, unsigned int );
+extern uintptr_t optionEnumerationVal(tOptions*, tOptDesc*, char const * const *, unsigned int);
 
 
-extern void export_options_to_guile( tOptions* );
+extern void optionFileCheck(tOptions*, tOptDesc*, teOptFileType, tuFileMode);
 
 
-extern void genshelloptUsage( tOptions*, int );
+extern char const* optionKeywordName(tOptDesc*, unsigned int);
 
 
-extern void optionBooleanVal( tOptions*, tOptDesc* );
+extern void optionLoadOpt(tOptions*, tOptDesc*);
 
 
-extern uintptr_t optionEnumerationVal( tOptions*, tOptDesc*, char const * const *, unsigned int );
+extern ag_bool optionMakePath(char*, int, char const*, char const*);
 
 
-extern char const* optionKeywordName( tOptDesc*, unsigned int );
+extern void optionNestedVal(tOptions*, tOptDesc*);
 
 
-extern void optionLoadOpt( tOptions*, tOptDesc* );
+extern void optionNumericVal(tOptions*, tOptDesc*);
 
 
-extern ag_bool optionMakePath( char*, int, char const*, char const* );
+extern void optionPagedUsage(tOptions*, tOptDesc*);
 
 
-extern void optionNestedVal( tOptions*, tOptDesc* );
+extern void optionParseShell(tOptions*);
 
 
-extern void optionNumericVal( tOptions*, tOptDesc* );
+extern void optionPrintVersion(tOptions*, tOptDesc*);
 
 
-extern void optionPagedUsage( tOptions*, tOptDesc* );
+extern void optionPutShell(tOptions*);
 
 
-extern void optionParseShell( tOptions* );
+extern void optionResetOpt(tOptions*, tOptDesc*);
 
 
-extern void optionPrintVersion( tOptions*, tOptDesc* );
+extern void optionSetMembers(tOptions*, tOptDesc*, char const * const *, unsigned int);
 
 
-extern void optionPutShell( tOptions* );
+extern void optionShowRange(tOptions*, tOptDesc*, void *, int);
 
 
-extern void optionSetMembers( tOptions*, tOptDesc*, char const * const *, unsigned int );
+extern void optionStackArg(tOptions*, tOptDesc*);
 
 
-extern void optionStackArg( tOptions*, tOptDesc* );
+extern void optionTimeVal(tOptions*, tOptDesc*);
 
 
-extern void optionUnstackArg( tOptions*, tOptDesc* );
+extern void optionUnstackArg(tOptions*, tOptDesc*);
 
 
-extern void optionUsage( tOptions*, int );
+extern void optionUsage(tOptions*, int);
 
 
-extern void optionVersionStderr( tOptions*, tOptDesc* );
+extern void optionVersionStderr(tOptions*, tOptDesc*);
 
 
-extern void* text_mmap( char const*, int, int, tmap_info_t* );
+extern void* text_mmap(char const*, int, int, tmap_info_t*);
 
 
-extern int text_munmap( tmap_info_t* );
+extern int text_munmap(tmap_info_t*);
 
 
 CPLUSPLUS_CLOSER
 CPLUSPLUS_CLOSER
 #endif /* AUTOOPTS_OPTIONS_H_GUARD */
 #endif /* AUTOOPTS_OPTIONS_H_GUARD */

+ 176 - 139
libopts/autoopts/usage-txt.h

@@ -2,12 +2,12 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (usage-txt.h)
  *  DO NOT EDIT THIS FILE   (usage-txt.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday July 28, 2007 at 01:01:39 PM PDT
+ *  It has been AutoGen-ed  Wednesday December 31, 2008 at 07:07:15 PM PST
  *  From the definitions    usage-txt.def
  *  From the definitions    usage-txt.def
  *  and the template file   usage-txt.tpl
  *  and the template file   usage-txt.tpl
  *
  *
  *  This file handles all the bookkeeping required for tracking all the little
  *  This file handles all the bookkeeping required for tracking all the little
- *  tiny strings used by the AutoOpts library.  There are 113
+ *  tiny strings used by the AutoOpts library.  There are 128
  *  of them.  This is not versioned because it is entirely internal to the
  *  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:
  *  library and accessed by client code only in a very well-controlled way:
  *  they may substitute translated strings using a procedure that steps through
  *  they may substitute translated strings using a procedure that steps through
@@ -39,10 +39,12 @@ typedef struct {
   int       field_ct;
   int       field_ct;
   char*     utpz_GnuBoolArg;
   char*     utpz_GnuBoolArg;
   char*     utpz_GnuKeyArg;
   char*     utpz_GnuKeyArg;
+  char*     utpz_GnuFileArg;
   char*     utpz_GnuKeyLArg;
   char*     utpz_GnuKeyLArg;
+  char*     utpz_GnuTimeArg;
   char*     utpz_GnuNumArg;
   char*     utpz_GnuNumArg;
   char*     utpz_GnuStrArg;
   char*     utpz_GnuStrArg;
-  cch_t*    apz_str[ 108 ];
+  cch_t*    apz_str[ 121 ];
 } usage_text_t;
 } usage_text_t;
 
 
 /*
 /*
@@ -59,54 +61,56 @@ extern usage_text_t option_usage_text;
 #define zAO_Big               (option_usage_text.apz_str[  1])
 #define zAO_Big               (option_usage_text.apz_str[  1])
 #define zAO_Err               (option_usage_text.apz_str[  2])
 #define zAO_Err               (option_usage_text.apz_str[  2])
 #define zAO_Sml               (option_usage_text.apz_str[  3])
 #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 zAO_Ver               (option_usage_text.apz_str[  4])
+#define zAll                  (option_usage_text.apz_str[  5])
+#define zAlt                  (option_usage_text.apz_str[  6])
+#define zAmbigKey             (option_usage_text.apz_str[  7])
+#define zAmbigOptStr          (option_usage_text.apz_str[  8])
+#define zArgsMust             (option_usage_text.apz_str[  9])
+#define zAtMost               (option_usage_text.apz_str[ 10])
+#define zAuto                 (option_usage_text.apz_str[ 11])
+#define zBadPipe              (option_usage_text.apz_str[ 12])
+#define zBadVerArg            (option_usage_text.apz_str[ 13])
+#define zCantFmt              (option_usage_text.apz_str[ 14])
+#define zCantSave             (option_usage_text.apz_str[ 15])
+#define zDefaultOpt           (option_usage_text.apz_str[ 16])
+#define zDis                  (option_usage_text.apz_str[ 17])
+#define zEnab                 (option_usage_text.apz_str[ 18])
+#define zEquiv                (option_usage_text.apz_str[ 19])
+#define zErrOnly              (option_usage_text.apz_str[ 20])
+#define zExamineFmt           (option_usage_text.apz_str[ 21])
+#define zFiveSpaces           (option_usage_text.apz_str[ 22])
+#define zFlagOkay             (option_usage_text.apz_str[ 23])
+#define zFmtFmt               (option_usage_text.apz_str[ 24])
+#define zForkFail             (option_usage_text.apz_str[ 25])
+#define zFSErrOptLoad         (option_usage_text.apz_str[ 26])
+#define zFSErrReadFile        (option_usage_text.apz_str[ 27])
+#define zFSOptError           (option_usage_text.apz_str[ 28])
+#define zFSOptErrMayExist     (option_usage_text.apz_str[ 29])
+#define zFSOptErrMustExist    (option_usage_text.apz_str[ 30])
+#define zFSOptErrNoExist      (option_usage_text.apz_str[ 31])
+#define zFSOptErrOpen         (option_usage_text.apz_str[ 32])
+#define zFSOptErrFopen        (option_usage_text.apz_str[ 33])
+#define zFileCannotExist      (option_usage_text.apz_str[ 34])
+#define zFileMustExist        (option_usage_text.apz_str[ 35])
+#define zGenshell             (option_usage_text.apz_str[ 36])
 #define zGnuBoolArg           (option_usage_text.utpz_GnuBoolArg)
 #define zGnuBoolArg           (option_usage_text.utpz_GnuBoolArg)
-#define zGnuBreak             (option_usage_text.apz_str[ 28])
+#define zGnuBreak             (option_usage_text.apz_str[ 37])
 #define zGnuKeyArg            (option_usage_text.utpz_GnuKeyArg)
 #define zGnuKeyArg            (option_usage_text.utpz_GnuKeyArg)
+#define zGnuFileArg           (option_usage_text.utpz_GnuFileArg)
 #define zGnuKeyLArg           (option_usage_text.utpz_GnuKeyLArg)
 #define zGnuKeyLArg           (option_usage_text.utpz_GnuKeyLArg)
-#define zGnuNestArg           (option_usage_text.apz_str[ 29])
+#define zGnuTimeArg           (option_usage_text.utpz_GnuTimeArg)
+#define zGnuNestArg           (option_usage_text.apz_str[ 38])
 #define zGnuNumArg            (option_usage_text.utpz_GnuNumArg)
 #define zGnuNumArg            (option_usage_text.utpz_GnuNumArg)
-#define zGnuOptArg            (option_usage_text.apz_str[ 30])
-#define zGnuOptFmt            (option_usage_text.apz_str[ 31])
+#define zGnuOptArg            (option_usage_text.apz_str[ 39])
+#define zGnuOptFmt            (option_usage_text.apz_str[ 40])
 #define zGnuStrArg            (option_usage_text.utpz_GnuStrArg)
 #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 zIllOptChr            (option_usage_text.apz_str[ 41])
+#define zIllOptStr            (option_usage_text.apz_str[ 42])
+#define zIllegal              (option_usage_text.apz_str[ 43])
+#define zIntRange             (option_usage_text.apz_str[ 44])
+#define zInvalOptDesc         (option_usage_text.apz_str[ 45])
+#define zLowerBits            (option_usage_text.apz_str[ 46])
 #define zMembers              (option_usage_text.apz_str[ 47])
 #define zMembers              (option_usage_text.apz_str[ 47])
 #define zMisArg               (option_usage_text.apz_str[ 48])
 #define zMisArg               (option_usage_text.apz_str[ 48])
 #define zMultiEquiv           (option_usage_text.apz_str[ 49])
 #define zMultiEquiv           (option_usage_text.apz_str[ 49])
@@ -119,55 +123,68 @@ extern usage_text_t option_usage_text;
 #define zNoKey                (option_usage_text.apz_str[ 56])
 #define zNoKey                (option_usage_text.apz_str[ 56])
 #define zNoLim                (option_usage_text.apz_str[ 57])
 #define zNoLim                (option_usage_text.apz_str[ 57])
 #define zNoPreset             (option_usage_text.apz_str[ 58])
 #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])
+#define zNoResetArg           (option_usage_text.apz_str[ 59])
+#define zNoRq_NoShrtTtl       (option_usage_text.apz_str[ 60])
+#define zNoRq_ShrtTtl         (option_usage_text.apz_str[ 61])
+#define zNoStat               (option_usage_text.apz_str[ 62])
+#define zNoState              (option_usage_text.apz_str[ 63])
+#define zNone                 (option_usage_text.apz_str[ 64])
+#define zNotDef               (option_usage_text.apz_str[ 65])
+#define zNotEnough            (option_usage_text.apz_str[ 66])
+#define zNotFile              (option_usage_text.apz_str[ 67])
+#define zNotNumber            (option_usage_text.apz_str[ 68])
+#define zNrmOptFmt            (option_usage_text.apz_str[ 69])
+#define zNumberOpt            (option_usage_text.apz_str[ 70])
+#define zOneSpace             (option_usage_text.apz_str[ 71])
+#define zOnlyOne              (option_usage_text.apz_str[ 72])
+#define zOptsOnly             (option_usage_text.apz_str[ 73])
+#define zPathFmt              (option_usage_text.apz_str[ 74])
+#define zPlsSendBugs          (option_usage_text.apz_str[ 75])
+#define zPreset               (option_usage_text.apz_str[ 76])
+#define zPresetFile           (option_usage_text.apz_str[ 77])
+#define zPresetIntro          (option_usage_text.apz_str[ 78])
+#define zProg                 (option_usage_text.apz_str[ 79])
+#define zProhib               (option_usage_text.apz_str[ 80])
+#define zReorder              (option_usage_text.apz_str[ 81])
+#define zRange                (option_usage_text.apz_str[ 82])
+#define zRangeAbove           (option_usage_text.apz_str[ 83])
+#define zRangeLie             (option_usage_text.apz_str[ 84])
+#define zRangeBadLie          (option_usage_text.apz_str[ 85])
+#define zRangeOnly            (option_usage_text.apz_str[ 86])
+#define zRangeOr              (option_usage_text.apz_str[ 87])
+#define zRangeErr             (option_usage_text.apz_str[ 88])
+#define zRangeExact           (option_usage_text.apz_str[ 89])
+#define zRangeScaled          (option_usage_text.apz_str[ 90])
+#define zRangeUpto            (option_usage_text.apz_str[ 91])
+#define zResetNotConfig       (option_usage_text.apz_str[ 92])
+#define zReqFmt               (option_usage_text.apz_str[ 93])
+#define zReqOptFmt            (option_usage_text.apz_str[ 94])
+#define zReqThese             (option_usage_text.apz_str[ 95])
+#define zReq_NoShrtTtl        (option_usage_text.apz_str[ 96])
+#define zReq_ShrtTtl          (option_usage_text.apz_str[ 97])
+#define zSepChars             (option_usage_text.apz_str[ 98])
+#define zSetMemberSettings    (option_usage_text.apz_str[ 99])
+#define zShrtGnuOptFmt        (option_usage_text.apz_str[100])
+#define zSixSpaces            (option_usage_text.apz_str[101])
+#define zStdBoolArg           (option_usage_text.apz_str[102])
+#define zStdBreak             (option_usage_text.apz_str[103])
+#define zStdFileArg           (option_usage_text.apz_str[104])
+#define zStdKeyArg            (option_usage_text.apz_str[105])
+#define zStdKeyLArg           (option_usage_text.apz_str[106])
+#define zStdTimeArg           (option_usage_text.apz_str[107])
+#define zStdNestArg           (option_usage_text.apz_str[108])
+#define zStdNoArg             (option_usage_text.apz_str[109])
+#define zStdNumArg            (option_usage_text.apz_str[110])
+#define zStdOptArg            (option_usage_text.apz_str[111])
+#define zStdReqArg            (option_usage_text.apz_str[112])
+#define zStdStrArg            (option_usage_text.apz_str[113])
+#define zTabHyp               (option_usage_text.apz_str[114])
+#define zTabHypAnd            (option_usage_text.apz_str[115])
+#define zTabout               (option_usage_text.apz_str[116])
+#define zThreeSpaces          (option_usage_text.apz_str[117])
+#define zTwoSpaces            (option_usage_text.apz_str[118])
+#define zUpTo                 (option_usage_text.apz_str[119])
+#define zValidKeys            (option_usage_text.apz_str[120])
 
 
   /*
   /*
    *  First, set up the strings.  Some of these are writable.  These are all in
    *  First, set up the strings.  Some of these are writable.  These are all in
@@ -177,19 +194,23 @@ extern usage_text_t option_usage_text;
 
 
   static char    eng_zGnuBoolArg[] = "=T/F";
   static char    eng_zGnuBoolArg[] = "=T/F";
   static char    eng_zGnuKeyArg[] = "=KWd";
   static char    eng_zGnuKeyArg[] = "=KWd";
+  static char    eng_zGnuFileArg[] = "=file";
   static char    eng_zGnuKeyLArg[] = "=Mbr";
   static char    eng_zGnuKeyLArg[] = "=Mbr";
+  static char    eng_zGnuTimeArg[] = "=Tim";
   static char    eng_zGnuNumArg[] = "=num";
   static char    eng_zGnuNumArg[] = "=num";
   static char    eng_zGnuStrArg[] = "=str";
   static char    eng_zGnuStrArg[] = "=str";
-static char const usage_txt[3208] =
+static char const usage_txt[3927] =
     "AutoOpts function called without option descriptor\n\0"
     "AutoOpts function called without option descriptor\n\0"
     "\tThis exceeds the compiled library version:  \0"
     "\tThis exceeds the compiled library version:  \0"
     "Automated Options Processing Error!\n"
     "Automated Options Processing Error!\n"
     "\t%s called AutoOpts function with structure version %d:%d:%d.\n\0"
     "\t%s called AutoOpts function with structure version %d:%d:%d.\n\0"
     "\tThis is less than the minimum library version:  \0"
     "\tThis is less than the minimum library version:  \0"
+    "Automated Options version %s\n"
+    "\tcopyright (c) 1999-2008 Bruce Korb - all rights reserved\n\0"
     "all\0"
     "all\0"
     "\t\t\t\t- an alternate for %s\n\0"
     "\t\t\t\t- an alternate for %s\n\0"
     "%s error:  the keyword `%s' is ambiguous for %s\n\0"
     "%s error:  the keyword `%s' is ambiguous for %s\n\0"
-    "ambiguous\0"
+    "%s: ambiguous option -- %s\n\0"
     "%s: Command line arguments required\n\0"
     "%s: Command line arguments required\n\0"
     "%d %s%s options allowed\n\0"
     "%d %s%s options allowed\n\0"
     "version and help options:\0"
     "version and help options:\0"
@@ -213,6 +234,14 @@ static char const usage_txt[3208] =
     "fs error %d (%s) on fork - cannot obtain %s usage\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"
     "File error %d (%s) opening %s for loading options\n\0"
     "fs error %d (%s) reading file %s\n\0"
     "fs error %d (%s) reading file %s\n\0"
+    "fs error %d (%s) on %s %s for option %s\n\0"
+    "stat-ing for directory\0"
+    "stat-ing for regular file\0"
+    "stat-ing for non-existant file\0"
+    "open-ing file\0"
+    "fopen-ing file\0"
+    "\t\t\t\t- file must not pre-exist\n\0"
+    "\t\t\t\t- file must pre-exist\n\0"
     "\n"
     "\n"
     "= = = = = = = =\n\n"
     "= = = = = = = =\n\n"
     "This incarnation of genshell will produce\n"
     "This incarnation of genshell will produce\n"
@@ -223,20 +252,11 @@ static char const usage_txt[3208] =
     "[=arg]\0"
     "[=arg]\0"
     "--%2$s%1$s\0"
     "--%2$s%1$s\0"
     "%s: illegal option -- %c\n\0"
     "%s: illegal option -- %c\n\0"
-    "%s: %s option -- %s\n\0"
+    "%s: illegal option -- %s\n\0"
     "illegal\0"
     "illegal\0"
+    "  or an integer from %d through %d\n\0"
     "AutoOpts ERROR:  invalid option descriptor for %s\n\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"
+    "  or an integer mask with any of the lower %d bits set\n\0"
     "\t\t\t\t- is a set membership option\n\0"
     "\t\t\t\t- is a set membership option\n\0"
     "%s: option `%s' requires an argument\n\0"
     "%s: option `%s' requires an argument\n\0"
     "Equivalenced option '%s' was equivalenced to both\n"
     "Equivalenced option '%s' was equivalenced to both\n"
@@ -250,6 +270,7 @@ static char const usage_txt[3208] =
     "%s error:  `%s' does not match any %s keywords\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 appear multiple times\n\0"
     "\t\t\t\t- may not be preset\n\0"
     "\t\t\t\t- may not be preset\n\0"
+    "The 'reset-option' option requires an argument\n\0"
     "   Arg Option-Name    Description\n\0"
     "   Arg Option-Name    Description\n\0"
     "  Flg Arg Option-Name    Description\n\0"
     "  Flg Arg Option-Name    Description\n\0"
     "error %d (%s) stat-ing %s\n\0"
     "error %d (%s) stat-ing %s\n\0"
@@ -275,13 +296,23 @@ static char const usage_txt[3208] =
     "program\0"
     "program\0"
     "prohibits these options:\n\0"
     "prohibits these options:\n\0"
     "Operands and options may be intermixed.  They will be reordered.\n\0"
     "Operands and options may be intermixed.  They will be reordered.\n\0"
+    "%s%ld to %ld\0"
+    "%sgreater than or equal to %ld\0"
+    "%sIt must lie in one of the ranges:\n\0"
+    "%sThis option must lie in one of the ranges:\n\0"
+    "%sit must be:  \0"
+    ", or\n\0"
+    "%s error:  %s option value ``%s'' is out of range.\n\0"
+    "%s%ld exactly\0"
+    "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0"
+    "%sless than or equal to %ld\0"
+    "The --reset-option has not been configured.\n\0"
     "ERROR:  %s option requires the %s option\n\0"
     "ERROR:  %s option requires the %s option\n\0"
     " %3s %-14s %s\0"
     " %3s %-14s %s\0"
     "requires these options:\n\0"
     "requires these options:\n\0"
     "   Arg Option-Name   Req?  Description\n\0"
     "   Arg Option-Name   Req?  Description\n\0"
     "  Flg Arg Option-Name   Req?  Description\n\0"
     "  Flg Arg Option-Name   Req?  Description\n\0"
     "-_^\0"
     "-_^\0"
-    "members=\0"
     "or you may use a numeric representation.  Preceding these with a '!' will\n"
     "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"
     "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"
     "all.  Multiple entries may be passed as an option argument list.\n\0"
@@ -291,8 +322,10 @@ static char const usage_txt[3208] =
     "\n"
     "\n"
     "%s\n\n"
     "%s\n\n"
     "%s\0"
     "%s\0"
+    "Fil\0"
     "KWd\0"
     "KWd\0"
     "Mbr\0"
     "Mbr\0"
+    "Tim\0"
     "Cpx\0"
     "Cpx\0"
     "no \0"
     "no \0"
     "Num\0"
     "Num\0"
@@ -314,37 +347,41 @@ static char const usage_txt[3208] =
    *  Aren't you glad you don't maintain this by hand?
    *  Aren't you glad you don't maintain this by hand?
    */
    */
   usage_text_t option_usage_text = {
   usage_text_t option_usage_text = {
-    113,
-    eng_zGnuBoolArg, eng_zGnuKeyArg,  eng_zGnuKeyLArg, eng_zGnuNumArg,
-    eng_zGnuStrArg,
+    128,
+    eng_zGnuBoolArg, eng_zGnuKeyArg,  eng_zGnuFileArg, eng_zGnuKeyLArg,
+    eng_zGnuTimeArg, eng_zGnuNumArg,  eng_zGnuStrArg,
     {
     {
       usage_txt +   0, usage_txt +  52, usage_txt +  98, usage_txt + 197,
       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
+      usage_txt + 247, usage_txt + 335, usage_txt + 339, usage_txt + 366,
+      usage_txt + 415, usage_txt + 443, usage_txt + 480, usage_txt + 505,
+      usage_txt + 531, usage_txt + 571, usage_txt + 708, usage_txt + 756,
+      usage_txt + 810, usage_txt + 852, usage_txt + 876, usage_txt + 902,
+      usage_txt + 915, usage_txt + 929, usage_txt + 976, usage_txt + 982,
+      usage_txt +1085, usage_txt +1097, usage_txt +1148, usage_txt +1199,
+      usage_txt +1233, usage_txt +1274, usage_txt +1297, usage_txt +1323,
+      usage_txt +1354, usage_txt +1368, usage_txt +1383, usage_txt +1414,
+      usage_txt +1441, usage_txt +1547, usage_txt +1553, usage_txt +1559,
+      usage_txt +1566, usage_txt +1577, usage_txt +1603, usage_txt +1629,
+      usage_txt +1637, usage_txt +1673, usage_txt +1724, usage_txt +1780,
+      usage_txt +1814, usage_txt +1852, usage_txt +1917, usage_txt +1960,
+      usage_txt +1995, usage_txt +2036, usage_txt +2076, usage_txt +2103,
+      usage_txt +2170, usage_txt +2218, usage_txt +2251, usage_txt +2276,
+      usage_txt +2324, usage_txt +2359, usage_txt +2397, usage_txt +2424,
+      usage_txt +2473, usage_txt +2478, usage_txt +2496, usage_txt +2540,
+      usage_txt +2594, usage_txt +2640, usage_txt +2648, usage_txt +2696,
+      usage_txt +2698, usage_txt +2723, usage_txt +2757, usage_txt +2776,
+      usage_txt +2810, usage_txt +2846, usage_txt +2884, usage_txt +2940,
+      usage_txt +2948, usage_txt +2974, usage_txt +3040, usage_txt +3053,
+      usage_txt +3084, usage_txt +3121, usage_txt +3167, usage_txt +3183,
+      usage_txt +3189, usage_txt +3241, usage_txt +3255, usage_txt +3301,
+      usage_txt +3329, usage_txt +3374, usage_txt +3416, usage_txt +3430,
+      usage_txt +3455, usage_txt +3495, usage_txt +3538, usage_txt +3542,
+      usage_txt +3761, usage_txt +3764, usage_txt +3771, usage_txt +3775,
+      usage_txt +3783, usage_txt +3787, usage_txt +3791, usage_txt +3795,
+      usage_txt +3799, usage_txt +3803, usage_txt +3807, usage_txt +3811,
+      usage_txt +3815, usage_txt +3819, usage_txt +3823, usage_txt +3830,
+      usage_txt +3842, usage_txt +3850, usage_txt +3854, usage_txt +3857,
+      usage_txt +3890
     }
     }
   };
   };
 
 

+ 12 - 3
libopts/boolean.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: boolean.c,v 4.12 2007/07/04 21:36:37 bkorb Exp $
- * Time-stamp:      "2007-07-04 11:33:18 bkorb"
+ *  $Id: boolean.c,v 4.15 2008/08/04 01:01:52 bkorb Exp $
+ * Time-stamp:      "2008-08-03 13:06:02 bkorb"
  *
  *
  *   Automated Options Paged Usage module.
  *   Automated Options Paged Usage module.
  *
  *
@@ -10,7 +10,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -47,6 +48,14 @@ optionBooleanVal( tOptions* pOpts, tOptDesc* pOD )
     char* pz;
     char* pz;
     ag_bool  res = AG_TRUE;
     ag_bool  res = AG_TRUE;
 
 
+    if ((pOD->fOptState & OPTST_RESET) != 0)
+        return;
+
+    if (pOD->optArg.argString == NULL) {
+        pOD->optArg.argBool = AG_FALSE;
+        return;
+    }
+
     switch (*(pOD->optArg.argString)) {
     switch (*(pOD->optArg.argString)) {
     case '0':
     case '0':
     {
     {

+ 13 - 3
libopts/compat/compat.h

@@ -2,14 +2,15 @@
 
 
 /* compat.h --- fake the preprocessor into handlng portability
 /* compat.h --- fake the preprocessor into handlng portability
  *
  *
- *  Time-stamp:      "2007-07-04 09:51:34 bkorb"
+ *  Time-stamp:      "2008-06-14 09:36:25 bkorb"
  *
  *
- * $Id: compat.h,v 4.17 2007/07/04 20:51:18 bkorb Exp $
+ * $Id: compat.h,v 4.20 2008/06/14 22:24:22 bkorb Exp $
  *
  *
  *  compat.h is free software.
  *  compat.h is free software.
  *  This file is part of AutoGen.
  *  This file is part of AutoGen.
  *
  *
- *  AutoGen copyright (c) 1992-2007 Bruce Korb - all rights reserved
+ *  AutoGen copyright (c) 1992-2008 Bruce Korb - all rights reserved
+ *  AutoGen copyright (c) 1992-2008 Bruce Korb - all rights reserved
  *
  *
  *  AutoGen is free software: you can redistribute it and/or modify it
  *  AutoGen is free software: you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License as published by the
  *  under the terms of the GNU General Public License as published by the
@@ -305,6 +306,15 @@
 #ifndef HAVE_UINTPTR_T
 #ifndef HAVE_UINTPTR_T
   typedef unsigned long uintptr_t;
   typedef unsigned long uintptr_t;
 #endif
 #endif
+#ifndef HAVE_SIZE_T
+  typedef unsigned int  size_t;
+#endif
+#ifndef HAVE_WINT_T
+  typedef unsigned int  wint_t;
+#endif
+#ifndef HAVE_PID_T
+  typedef signed int    pid_t;
+#endif
 
 
 /* redefine these for BSD style string libraries */
 /* redefine these for BSD style string libraries */
 #ifndef HAVE_STRCHR
 #ifndef HAVE_STRCHR

+ 171 - 201
libopts/configfile.c

@@ -1,12 +1,13 @@
 /*
 /*
- *  $Id: configfile.c,v 1.23 2007/07/04 21:36:37 bkorb Exp $
- *  Time-stamp:      "2007-07-04 11:33:27 bkorb"
+ *  $Id: configfile.c,v 1.32 2008/08/04 01:01:52 bkorb Exp $
+ *  Time-stamp:      "2008-08-03 11:00:30 bkorb"
  *
  *
  *  configuration/rc/ini file handling.
  *  configuration/rc/ini file handling.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -26,7 +27,7 @@
  */
  */
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 filePreset(
 filePreset(
     tOptions*     pOpts,
     tOptions*     pOpts,
@@ -67,11 +68,6 @@ parseKeyWordType(
     tOptionValue* pType );
     tOptionValue* pType );
 
 
 static char*
 static char*
-parseLoadMode(
-    char*               pzText,
-    tOptionLoadMode*    pMode );
-
-static char*
 parseSetMemType(
 parseSetMemType(
     tOptions*     pOpts,
     tOptions*     pOpts,
     char*         pzText,
     char*         pzText,
@@ -421,7 +417,7 @@ filePreset(
     int           direction )
     int           direction )
 {
 {
     tmap_info_t   cfgfile;
     tmap_info_t   cfgfile;
-    tOptState     st = OPTSTATE_INITIALIZER(PRESET);
+    tOptState     optst = OPTSTATE_INITIALIZER(PRESET);
     char*         pzFileText =
     char*         pzFileText =
         text_mmap( pzFileName, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile );
         text_mmap( pzFileName, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile );
 
 
@@ -429,8 +425,8 @@ filePreset(
         return;
         return;
 
 
     if (direction == DIRECTION_CALLED) {
     if (direction == DIRECTION_CALLED) {
-        st.flags  = OPTST_DEFINED;
-        direction = DIRECTION_PROCESS;
+        optst.flags = OPTST_DEFINED;
+        direction   = DIRECTION_PROCESS;
     }
     }
 
 
     /*
     /*
@@ -440,18 +436,19 @@ filePreset(
      *  and we consider stuff set herein to be "set" by the client program.
      *  and we consider stuff set herein to be "set" by the client program.
      */
      */
     if ((pOpts->fOptSet & OPTPROC_PRESETTING) == 0)
     if ((pOpts->fOptSet & OPTPROC_PRESETTING) == 0)
-        st.flags = OPTST_SET;
+        optst.flags = OPTST_SET;
 
 
     do  {
     do  {
-        while (isspace( (int)*pzFileText ))  pzFileText++;
+        while (IS_WHITESPACE_CHAR(*pzFileText))  pzFileText++;
 
 
-        if (isalpha( (int)*pzFileText )) {
-            pzFileText = handleConfig( pOpts, &st, pzFileText, direction );
+        if (IS_VAR_FIRST_CHAR(*pzFileText)) {
+            pzFileText = handleConfig(pOpts, &optst, pzFileText, direction);
 
 
         } else switch (*pzFileText) {
         } else switch (*pzFileText) {
         case '<':
         case '<':
-            if (isalpha( (int)pzFileText[1] ))
-                pzFileText = handleStructure(pOpts, &st, pzFileText, direction);
+            if (IS_VAR_FIRST_CHAR(pzFileText[1]))
+                pzFileText =
+                    handleStructure(pOpts, &optst, pzFileText, direction);
 
 
             else switch (pzFileText[1]) {
             else switch (pzFileText[1]) {
             case '?':
             case '?':
@@ -526,8 +523,8 @@ handleConfig(
     if (pzEnd == NULL)
     if (pzEnd == NULL)
         return pzText + strlen(pzText);
         return pzText + strlen(pzText);
 
 
-    while (ISNAMECHAR( (int)*pzText ))  pzText++;
-    while (isspace( (int)*pzText )) pzText++;
+    while (IS_VALUE_NAME_CHAR(*pzText)) pzText++;
+    while (IS_WHITESPACE_CHAR(*pzText)) pzText++;
     if (pzText > pzEnd) {
     if (pzText > pzEnd) {
     name_only:
     name_only:
         *pzEnd++ = NUL;
         *pzEnd++ = NUL;
@@ -541,10 +538,10 @@ handleConfig(
      *  is an invalid format and we give up parsing the text.
      *  is an invalid format and we give up parsing the text.
      */
      */
     if ((*pzText == '=') || (*pzText == ':')) {
     if ((*pzText == '=') || (*pzText == ':')) {
-        while (isspace( (int)*++pzText ))   ;
+        while (IS_WHITESPACE_CHAR(*++pzText))   ;
         if (pzText > pzEnd)
         if (pzText > pzEnd)
             goto name_only;
             goto name_only;
-    } else if (! isspace((int)pzText[-1]))
+    } else if (! IS_WHITESPACE_CHAR(pzText[-1]))
         return NULL;
         return NULL;
 
 
     /*
     /*
@@ -608,7 +605,7 @@ handleDirective(
     size_t name_len;
     size_t name_len;
 
 
     if (  (strncmp( pzText+2, zProg, title_len ) != 0)
     if (  (strncmp( pzText+2, zProg, title_len ) != 0)
-       || (! isspace( (int)pzText[title_len+2] )) )  {
+       || (! IS_WHITESPACE_CHAR(pzText[title_len+2])) )  {
         pzText = strchr( pzText+2, '>' );
         pzText = strchr( pzText+2, '>' );
         if (pzText != NULL)
         if (pzText != NULL)
             pzText++;
             pzText++;
@@ -622,8 +619,8 @@ handleDirective(
     do  {
     do  {
         pzText += title_len;
         pzText += title_len;
 
 
-        if (isspace((int)*pzText)) {
-            while (isspace((int)*pzText))  pzText++;
+        if (IS_WHITESPACE_CHAR(*pzText)) {
+            while (IS_WHITESPACE_CHAR(*++pzText))  ;
             if (  (strneqvcmp( pzText, pOpts->pzProgName, (int)name_len) == 0)
             if (  (strneqvcmp( pzText, pOpts->pzProgName, (int)name_len) == 0)
                && (pzText[name_len] == '>'))  {
                && (pzText[name_len] == '>'))  {
                 pzText += name_len + 1;
                 pzText += name_len + 1;
@@ -683,13 +680,13 @@ handleStructure(
     int           direction )
     int           direction )
 {
 {
     tOptionLoadMode mode = option_load_mode;
     tOptionLoadMode mode = option_load_mode;
-    tOptionValue     valu;
+    tOptionValue    valu;
 
 
     char* pzName = ++pzText;
     char* pzName = ++pzText;
     char* pzData;
     char* pzData;
     char* pcNulPoint;
     char* pcNulPoint;
 
 
-    while (ISNAMECHAR( *pzText ))  pzText++;
+    while (IS_VALUE_NAME_CHAR(*pzText))  pzText++;
     pcNulPoint = pzText;
     pcNulPoint = pzText;
     valu.valType = OPARG_TYPE_STRING;
     valu.valType = OPARG_TYPE_STRING;
 
 
@@ -756,6 +753,32 @@ handleStructure(
      */
      */
     memset(pcNulPoint, ' ', pzData - pcNulPoint);
     memset(pcNulPoint, ' ', pzData - pcNulPoint);
 
 
+    if ((pOS->pOD->fOptState & OPTST_ARG_TYPE_MASK) == OPARG_TYPE_STRING) {
+        char * pzSrc = pzData;
+        char * pzDst = pzData;
+        char bf[4];
+        bf[2] = NUL;
+
+        for (;;) {
+            int ch = ((int)*(pzSrc++)) & 0xFF;
+            switch (ch) {
+            case NUL: goto string_fixup_done;
+
+            case '%':
+                bf[0] = *(pzSrc++);
+                bf[1] = *(pzSrc++);
+                if ((bf[0] == NUL) || (bf[1] == NUL))
+                    goto string_fixup_done;
+                ch = strtoul(bf, NULL, 16);
+                /* FALLTHROUGH */
+
+            default:
+                *(pzDst++) = ch;
+            }
+        } string_fixup_done:;
+        *pzDst = NUL;
+    }
+
     /*
     /*
      *  "pzName" points to what looks like text for one option/configurable.
      *  "pzName" points to what looks like text for one option/configurable.
      *  It is NUL terminated.  Process it.
      *  It is NUL terminated.  Process it.
@@ -916,35 +939,38 @@ optionFileLoad( tOptions* pOpts, char const* pzProgram )
 void
 void
 optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
 optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
 {
 {
+    struct stat sb;
+
     /*
     /*
      *  IF the option is not being disabled, THEN load the file.  There must
      *  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
      *  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
      *  already took place.  It must be done to suppress preloading of ini/rc
      *  files.)
      *  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 (  DISABLED_OPT(pOptDesc)
+       || ((pOptDesc->fOptState & OPTST_RESET) != 0))
+        return;
 
 
-        if (! S_ISREG( sb.st_mode )) {
-            if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
-                return;
+    if (stat( pOptDesc->optArg.argString, &sb ) != 0) {
+        if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+            return;
 
 
-            fprintf( stderr, zNotFile, pOptDesc->optArg.argString );
-            exit(EX_NOINPUT);
-            /* NOT REACHED */
-        }
+        fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ),
+                 pOptDesc->optArg.argString );
+        exit(EX_NOINPUT);
+        /* NOT REACHED */
+    }
 
 
-        filePreset(pOpts, pOptDesc->optArg.argString, DIRECTION_CALLED);
+    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);
 }
 }
 
 
 
 
@@ -959,45 +985,65 @@ parseAttributes(
     tOptionLoadMode*    pMode,
     tOptionLoadMode*    pMode,
     tOptionValue*       pType )
     tOptionValue*       pType )
 {
 {
-    size_t lenLoadType = strlen( zLoadType );
-    size_t lenKeyWords = strlen( zKeyWords );
-    size_t lenSetMem   = strlen( zSetMembers );
+    size_t len;
 
 
     do  {
     do  {
-        switch (*pzText) {
-        case '/': pType->valType = OPARG_TYPE_NONE;
-        case '>': return pzText;
+        if (! IS_WHITESPACE_CHAR(*pzText))
+            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':
+            default:
+            case NUL: return NULL;
+            }
+
+        while (IS_WHITESPACE_CHAR(*++pzText))     ;
+        len = 0;
+        while (IS_LOWER_CASE_CHAR(pzText[len]))   len++;
+
+        switch (find_xat_attribute_id(pzText, len)) {
+        case XAT_KWD_TYPE:
+            pzText = parseValueType( pzText+len, pType );
+            break;
+
+        case XAT_KWD_WORDS:
+            pzText = parseKeyWordType( pOpts, pzText+len, pType );
             break;
             break;
-        }
 
 
-        while (isspace( (int)*++pzText ))   ;
+        case XAT_KWD_MEMBERS:
+            pzText = parseSetMemType( pOpts, pzText+len, pType );
+            break;
 
 
-        if (strncmp( pzText, zLoadType, lenLoadType ) == 0) {
-            pzText = parseValueType( pzText+lenLoadType, pType );
-            continue;
-        }
+        case XAT_KWD_COOKED:
+            pzText += len;
+            if (! IS_END_XML_TOKEN_CHAR(*pzText))
+                goto invalid_kwd;
 
 
-        if (strncmp( pzText, zKeyWords, lenKeyWords ) == 0) {
-            pzText = parseKeyWordType( pOpts, pzText+lenKeyWords, pType );
-            continue;
-        }
+            *pMode = OPTION_LOAD_COOKED;
+            break;
 
 
-        if (strncmp( pzText, zSetMembers, lenSetMem ) == 0) {
-            pzText = parseSetMemType( pOpts, pzText+lenSetMem, pType );
-            continue;
-        }
+        case XAT_KWD_UNCOOKED:
+            pzText += len;
+            if (! IS_END_XML_TOKEN_CHAR(*pzText))
+                goto invalid_kwd;
+
+            *pMode = OPTION_LOAD_UNCOOKED;
+            break;
+
+        case XAT_KWD_KEEP:
+            pzText += len;
+            if (! IS_END_XML_TOKEN_CHAR(*pzText))
+                goto invalid_kwd;
+
+            *pMode = OPTION_LOAD_KEEP;
+            break;
 
 
-        pzText = parseLoadMode( pzText, pMode );
+        default:
+        case XAT_KWD_INVALID:
+        invalid_kwd:
+            pType->valType = OPARG_TYPE_NONE;
+            return skipUnknown( pzText );
+        }
     } while (pzText != NULL);
     } while (pzText != NULL);
 
 
     return pzText;
     return pzText;
@@ -1019,61 +1065,6 @@ parseKeyWordType(
 }
 }
 
 
 
 
-/*  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
 /*  parseSetMemType
  *
  *
  *  "pzText" points to the character after "members="
  *  "pzText" points to the character after "members="
@@ -1099,75 +1090,52 @@ parseValueType(
     char*         pzText,
     char*         pzText,
     tOptionValue* pType )
     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 = 0;
 
 
-    {
-        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;
-        }
-    }
+    if (*(pzText++) != '=')
+        goto woops;
 
 
-    {
-        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;
-        }
-    }
+    while (IS_OPTION_NAME_CHAR(pzText[len]))  len++;
+    pzText += len;
 
 
-    {
-        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;
-        }
+    if ((len == 0) || (! IS_END_XML_TOKEN_CHAR(*pzText))) {
+    woops:
+        pType->valType = OPARG_TYPE_NONE;
+        return skipUnknown( pzText );
     }
     }
 
 
-    {
-        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;
-        }
-    }
+    switch (find_value_type_id(pzText - len, len)) {
+    default:
+    case VTP_KWD_INVALID: goto woops;
 
 
-    {
-        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;
-        }
+    case VTP_KWD_STRING:
+        pType->valType = OPARG_TYPE_STRING;
+        break;
+
+    case VTP_KWD_INTEGER:
+        pType->valType = OPARG_TYPE_NUMERIC;
+        break;
+
+    case VTP_KWD_BOOL:
+    case VTP_KWD_BOOLEAN:
+        pType->valType = OPARG_TYPE_BOOLEAN;
+        break;
+
+    case VTP_KWD_KEYWORD:
+        pType->valType = OPARG_TYPE_ENUMERATION;
+        break;
+
+    case VTP_KWD_SET:
+    case VTP_KWD_SET_MEMBERSHIP:
+        pType->valType = OPARG_TYPE_MEMBERSHIP;
+        break;
+
+    case VTP_KWD_NESTED:
+    case VTP_KWD_HIERARCHY:
+        pType->valType = OPARG_TYPE_HIERARCHY;
     }
     }
 
 
-  unknown:
-    pType->valType = OPARG_TYPE_NONE;
-    return skipUnknown( pzText );
+    return pzText;
 }
 }
 
 
 
 
@@ -1179,12 +1147,8 @@ static char*
 skipUnknown( char* pzText )
 skipUnknown( char* pzText )
 {
 {
     for (;; pzText++) {
     for (;; pzText++) {
-        if (isspace( (int)*pzText ))  return pzText;
-        switch (*pzText) {
-        case NUL: return NULL;
-        case '/':
-        case '>': return pzText;
-        }
+        if (IS_END_XML_TOKEN_CHAR(*pzText))  return pzText;
+        if (*pzText == NUL) return NULL;
     }
     }
 }
 }
 
 
@@ -1210,7 +1174,14 @@ validateOptionsStruct( tOptions* pOpts, char const* pzProgram )
      *  is available, then go do it.
      *  is available, then go do it.
      */
      */
     if (  ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
     if (  ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
-       && (pOpts->pTransProc != 0) ) {
+       && (pOpts->pTransProc != NULL) ) {
+        /*
+         *  If option names are not to be translated at all, then do not do
+         *  it for configuration parsing either.  (That is the bit that really
+         *  gets tested anyway.)
+         */
+        if ((pOpts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT)
+            pOpts->fOptSet |= OPTPROC_NXLAT_OPT_CFG;
         (*pOpts->pTransProc)();
         (*pOpts->pTransProc)();
         pOpts->fOptSet &= ~OPTPROC_TRANSLATE;
         pOpts->fOptSet &= ~OPTPROC_TRANSLATE;
     }
     }
@@ -1225,8 +1196,7 @@ validateOptionsStruct( tOptions* pOpts, char const* pzProgram )
           || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION )
           || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION )
        )  )  {
        )  )  {
 
 
-        fprintf( stderr, zAO_Err, pzProgram,
-                 NUM_TO_VER( pOpts->structVersion ));
+        fprintf(stderr, zAO_Err, pzProgram, NUM_TO_VER(pOpts->structVersion));
         if (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
         if (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
             fputs( zAO_Big, stderr );
             fputs( zAO_Big, stderr );
         else
         else

+ 33 - 70
libopts/cook.c

@@ -1,14 +1,14 @@
-
 /*
 /*
- *  $Id: cook.c,v 4.12 2007/07/04 21:36:37 bkorb Exp $
- *  Time-stamp:      "2007-07-04 11:33:34 bkorb"
+ *  $Id: cook.c,v 4.16 2008/01/23 00:36:04 bkorb Exp $
+ *  Time-stamp:      "2007-11-16 22:49:11 bkorb"
  *
  *
  *  This file contains the routines that deal with processing quoted strings
  *  This file contains the routines that deal with processing quoted strings
  *  into an internal format.
  *  into an internal format.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -28,7 +28,7 @@
  */
  */
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 /* = = = END-STATIC-FORWARD = = = */
 /* = = = END-STATIC-FORWARD = = = */
 
 
 /*=export_func  ao_string_cook_escape_char
 /*=export_func  ao_string_cook_escape_char
@@ -82,79 +82,42 @@ ao_string_cook_escape_char( char const* pzIn, char* pRes, u_int nl )
     case 't': *pRes = '\t'; break;
     case 't': *pRes = '\t'; break;
     case 'v': *pRes = '\v'; 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';
+    case 'x':
+    case 'X':         /* HEX Escape       */
+        if (IS_HEX_DIGIT_CHAR(*pzIn))  {
+            char z[4], *pz = z;
 
 
-            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;
+            do *(pz++) = *(pzIn++);
+            while (IS_HEX_DIGIT_CHAR(*pzIn) && (pz < z + 2));
+            *pz = NUL;
+            *pRes = (unsigned char)strtoul(z, NULL, 16);
+            res += pz - z;
         }
         }
         break;
         break;
 
 
-    default:
+    case '0': case '1': case '2': case '3':
+    case '4': case '5': case '6': case '7':
+    {
         /*
         /*
          *  IF the character copied was an octal digit,
          *  IF the character copied was an octal digit,
          *  THEN set the output character to an octal value
          *  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;
-            }
+        char z[4], *pz = z + 1;
+        unsigned long val;
+        z[0] = *pRes;
+
+        while (IS_OCT_DIGIT_CHAR(*pzIn) && (pz < z + 3))
+            *(pz++) = *(pzIn++);
+        *pz = NUL;
+        val = strtoul(z, NULL, 8);
+        if (val > 0xFF)
+            val = 0xFF;
+        *pRes = (unsigned char)val;
+        res = pz - z;
+        break;
+    }
 
 
-            *pRes = val;
-            break;
-        }
+    default: ;
     }
     }
 
 
     return res;
     return res;
@@ -216,7 +179,7 @@ ao_string_cook( char* pzScan, int* pLineCt )
             pzS++;
             pzS++;
 
 
         scan_for_quote:
         scan_for_quote:
-            while (isspace((int)*pzS))
+            while (IS_WHITESPACE_CHAR(*pzS))
                 if (*(pzS++) == '\n')
                 if (*(pzS++) == '\n')
                     (*pLineCt)++;
                     (*pLineCt)++;
 
 

+ 104 - 66
libopts/enumeration.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: enumeration.c,v 4.19 2007/07/04 21:36:37 bkorb Exp $
- * Time-stamp:      "2007-07-04 11:33:42 bkorb"
+ *  $Id: enumeration.c,v 4.24 2008/07/28 04:51:29 bkorb Exp $
+ * Time-stamp:      "2008-07-27 12:28:01 bkorb"
  *
  *
  *   Automated Options Paged Usage module.
  *   Automated Options Paged Usage module.
  *
  *
@@ -10,7 +10,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -32,7 +33,7 @@
 tSCC*  pz_enum_err_fmt;
 tSCC*  pz_enum_err_fmt;
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 enumError(
 enumError(
     tOptions*     pOpts,
     tOptions*     pOpts,
@@ -58,16 +59,27 @@ enumError(
 {
 {
     size_t max_len = 0;
     size_t max_len = 0;
     size_t ttl_len = 0;
     size_t ttl_len = 0;
+    int    ct_down = name_ct;
+    int    hidden  = 0;
 
 
-    if (pOpts != NULL)
-        fprintf( option_usage_fp, pz_enum_err_fmt, pOpts->pzProgName,
-                 pOD->optArg.argString, pOD->pz_Name );
+    /*
+     *  A real "pOpts" pointer means someone messed up.  Give a real error.
+     */
+    if (pOpts > OPTPROC_EMIT_LIMIT)
+        fprintf(option_usage_fp, pz_enum_err_fmt, pOpts->pzProgName,
+                pOD->optArg.argString, pOD->pz_Name);
 
 
-    fprintf( option_usage_fp, zValidKeys, pOD->pz_Name );
+    fprintf(option_usage_fp, zValidKeys, pOD->pz_Name);
 
 
+    /*
+     *  If the first name starts with this funny character, then we have
+     *  a first value with an unspellable name.  You cannot specify it.
+     *  So, we don't list it either.
+     */
     if (**paz_names == 0x7F) {
     if (**paz_names == 0x7F) {
         paz_names++;
         paz_names++;
-        name_ct--;
+        hidden  = 1;
+        ct_down = --name_ct;
     }
     }
 
 
     /*
     /*
@@ -76,14 +88,15 @@ enumError(
      */
      */
     {
     {
         tCC * const * paz = paz_names;
         tCC * const * paz = paz_names;
-        int   ct  = name_ct;
 
 
         do  {
         do  {
             size_t len = strlen( *(paz++) ) + 1;
             size_t len = strlen( *(paz++) ) + 1;
             if (len > max_len)
             if (len > max_len)
                 max_len = len;
                 max_len = len;
             ttl_len += len;
             ttl_len += len;
-        } while (--ct > 0);
+        } while (--ct_down > 0);
+
+        ct_down = name_ct;
     }
     }
 
 
     /*
     /*
@@ -92,7 +105,7 @@ enumError(
     if (max_len > 35) {
     if (max_len > 35) {
         do  {
         do  {
             fprintf( option_usage_fp, "  %s\n", *(paz_names++) );
             fprintf( option_usage_fp, "  %s\n", *(paz_names++) );
-        } while (--name_ct > 0);
+        } while (--ct_down > 0);
     }
     }
 
 
     /*
     /*
@@ -103,7 +116,7 @@ enumError(
         do  {
         do  {
             fputc( ' ', option_usage_fp );
             fputc( ' ', option_usage_fp );
             fputs( *(paz_names++), option_usage_fp );
             fputs( *(paz_names++), option_usage_fp );
-        } while (--name_ct > 0);
+        } while (--ct_down > 0);
         fputc( '\n', option_usage_fp );
         fputc( '\n', option_usage_fp );
     }
     }
 
 
@@ -121,7 +134,8 @@ enumError(
         /*
         /*
          *  Loop through all but the last entry
          *  Loop through all but the last entry
          */
          */
-        while (--name_ct > 0) {
+        ct_down = name_ct;
+        while (--ct_down > 0) {
             if (++ent_no == max_len) {
             if (++ent_no == max_len) {
                 /*
                 /*
                  *  Last entry on a line.  Start next line, too.
                  *  Last entry on a line.  Start next line, too.
@@ -131,19 +145,25 @@ enumError(
             }
             }
 
 
             else
             else
-                fprintf( option_usage_fp, zFmt, *(paz_names++) );
+                fprintf(option_usage_fp, zFmt, *(paz_names++) );
         }
         }
-        fprintf( option_usage_fp, "%s\n", *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)
+    if (pOpts > OPTPROC_EMIT_LIMIT) {
+        fprintf(option_usage_fp, zIntRange, hidden, name_ct - 1 + hidden);
+
         (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE );
         (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE );
-    if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP)
-        fputs( zSetMemberSettings, option_usage_fp );
+        /* NOTREACHED */
+    }
+
+
+    if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) {
+        fprintf(option_usage_fp, zLowerBits, name_ct);
+        fputs(zSetMemberSettings, option_usage_fp);
+    } else {
+        fprintf(option_usage_fp, zIntRange, hidden, name_ct - 1 + hidden);
+    }
 }
 }
 
 
 
 
@@ -155,9 +175,23 @@ findName(
     tCC* const *  paz_names,
     tCC* const *  paz_names,
     unsigned int  name_ct )
     unsigned int  name_ct )
 {
 {
+    /*
+     *  Return the matching index as a pointer sized integer.
+     *  The result gets stashed in a char* pointer.
+     */
     uintptr_t     res = name_ct;
     uintptr_t     res = name_ct;
     size_t        len = strlen( (char*)pzName );
     size_t        len = strlen( (char*)pzName );
     uintptr_t     idx;
     uintptr_t     idx;
+
+    if (IS_DEC_DIGIT_CHAR(*pzName)) {
+        char * pz = (char *)(void *)pzName;
+        unsigned long val = strtoul(pz, &pz, 0);
+        if ((*pz == NUL) && (val < name_ct))
+            return (uintptr_t)val;
+        enumError(pOpts, pOD, paz_names, (int)name_ct);
+        return name_ct;
+    }
+
     /*
     /*
      *  Look for an exact match, but remember any partial matches.
      *  Look for an exact match, but remember any partial matches.
      *  Multiple partial matches means we have an ambiguous match.
      *  Multiple partial matches means we have an ambiguous match.
@@ -167,29 +201,17 @@ findName(
             if (paz_names[idx][len] == NUL)
             if (paz_names[idx][len] == NUL)
                 return idx;  /* full match */
                 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 */
+            res = (res != name_ct) ? ~0 : 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 );
-    }
+    if (res < name_ct)
+        return res; /* partial match */
 
 
-    /*
-     *  Return the matching index as a char* pointer.
-     *  The result gets stashed in a char* pointer, so it will have to fit.
-     */
-    return res;
+    pz_enum_err_fmt = (res == name_ct) ? zNoKey : zAmbigKey;
+    option_usage_fp = stderr;
+    enumError(pOpts, pOD, paz_names, (int)name_ct);
+    return name_ct;
 }
 }
 
 
 
 
@@ -213,7 +235,7 @@ optionKeywordName(
     tOptDesc od;
     tOptDesc od;
 
 
     od.optArg.argEnum = enum_val;
     od.optArg.argEnum = enum_val;
-    (*(pOD->pOptProc))( (void*)(2UL), &od );
+    (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, &od );
     return od.optArg.argString;
     return od.optArg.argString;
 }
 }
 
 
@@ -250,14 +272,14 @@ optionEnumerationVal(
      *  then it is some sort of special request.
      *  then it is some sort of special request.
      */
      */
     switch ((uintptr_t)pOpts) {
     switch ((uintptr_t)pOpts) {
-    case 0UL:
+    case (uintptr_t)OPTPROC_EMIT_USAGE:
         /*
         /*
          *  print the list of enumeration names.
          *  print the list of enumeration names.
          */
          */
-        enumError( pOpts, pOD, paz_names, (int)name_ct );
+        enumError(pOpts, pOD, paz_names, (int)name_ct);
         break;
         break;
 
 
-    case 1UL:
+    case (uintptr_t)OPTPROC_EMIT_SHELL:
     {
     {
         unsigned int ix = pOD->optArg.argEnum;
         unsigned int ix = pOD->optArg.argEnum;
         /*
         /*
@@ -271,7 +293,7 @@ optionEnumerationVal(
         break;
         break;
     }
     }
 
 
-    case 2UL:
+    case (uintptr_t)OPTPROC_RETURN_VALNAME:
     {
     {
         tSCC zInval[] = "*INVALID*";
         tSCC zInval[] = "*INVALID*";
         unsigned int ix = pOD->optArg.argEnum;
         unsigned int ix = pOD->optArg.argEnum;
@@ -281,12 +303,12 @@ optionEnumerationVal(
         if (ix >= name_ct)
         if (ix >= name_ct)
             return (uintptr_t)zInval;
             return (uintptr_t)zInval;
 
 
-        res = (uintptr_t)paz_names[ ix ];
+        pOD->optArg.argString = paz_names[ix];
         break;
         break;
     }
     }
 
 
     default:
     default:
-        res = findName( pOD->optArg.argString, pOpts, pOD, paz_names, name_ct );
+        res = findName(pOD->optArg.argString, pOpts, pOD, paz_names, name_ct);
 
 
         if (pOD->fOptState & OPTST_ALLOC_ARG) {
         if (pOD->fOptState & OPTST_ALLOC_ARG) {
             AGFREE(pOD->optArg.argString);
             AGFREE(pOD->optArg.argString);
@@ -327,39 +349,43 @@ optionSetMembers(
      *  then it is some sort of special request.
      *  then it is some sort of special request.
      */
      */
     switch ((uintptr_t)pOpts) {
     switch ((uintptr_t)pOpts) {
-    case 0UL:
+    case (uintptr_t)OPTPROC_EMIT_USAGE:
         /*
         /*
          *  print the list of enumeration names.
          *  print the list of enumeration names.
          */
          */
-        enumError( pOpts, pOD, paz_names, (int)name_ct );
+        enumError(OPTPROC_EMIT_USAGE, pOD, paz_names, (int)name_ct );
         return;
         return;
 
 
-    case 1UL:
+    case (uintptr_t)OPTPROC_EMIT_SHELL:
     {
     {
         /*
         /*
          *  print the name string.
          *  print the name string.
          */
          */
+        int       ix   =  0;
         uintptr_t bits = (uintptr_t)pOD->optCookie;
         uintptr_t bits = (uintptr_t)pOD->optCookie;
-        uintptr_t res  = 0;
         size_t    len  = 0;
         size_t    len  = 0;
 
 
+        bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
+
         while (bits != 0) {
         while (bits != 0) {
             if (bits & 1) {
             if (bits & 1) {
                 if (len++ > 0) fputs( " | ", stdout );
                 if (len++ > 0) fputs( " | ", stdout );
-                fputs( paz_names[ res ], stdout );
+                fputs(paz_names[ix], stdout);
             }
             }
-            if (++res >= name_ct) break;
+            if (++ix >= name_ct) break;
             bits >>= 1;
             bits >>= 1;
         }
         }
         return;
         return;
     }
     }
 
 
-    case 2UL:
+    case (uintptr_t)OPTPROC_RETURN_VALNAME:
     {
     {
         char*     pz;
         char*     pz;
         uintptr_t bits = (uintptr_t)pOD->optCookie;
         uintptr_t bits = (uintptr_t)pOD->optCookie;
-        uintptr_t res  = 0;
-        size_t    len  = 0;
+        int       ix   = 0;
+        size_t    len  = 5;
+
+        bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
 
 
         /*
         /*
          *  Replace the enumeration value with the name string.
          *  Replace the enumeration value with the name string.
@@ -367,12 +393,12 @@ optionSetMembers(
          */
          */
         while (bits != 0) {
         while (bits != 0) {
             if (bits & 1)
             if (bits & 1)
-                len += strlen( paz_names[ res ]) + 8;
-            if (++res >= name_ct) break;
+                len += strlen( paz_names[ix]) + 8;
+            if (++ix >= name_ct) break;
             bits >>= 1;
             bits >>= 1;
         }
         }
 
 
-        pOD->optArg.argString = pz = AGALOC( len, "enum name" );
+        pOD->optArg.argString = pz = AGALOC(len, "enum name");
 
 
         /*
         /*
          *  Start by clearing all the bits.  We want to turn off any defaults
          *  Start by clearing all the bits.  We want to turn off any defaults
@@ -382,14 +408,16 @@ optionSetMembers(
         strcpy( pz, "none" );
         strcpy( pz, "none" );
         pz += 4;
         pz += 4;
         bits = (uintptr_t)pOD->optCookie;
         bits = (uintptr_t)pOD->optCookie;
-        res = 0;
+        bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1;
+        ix = 0;
+
         while (bits != 0) {
         while (bits != 0) {
             if (bits & 1) {
             if (bits & 1) {
                 strcpy( pz, " + " );
                 strcpy( pz, " + " );
-                strcpy( pz+3, paz_names[ res ]);
-                pz += strlen( paz_names[ res ]) + 3;
+                strcpy( pz+3, paz_names[ix]);
+                pz += strlen( paz_names[ix]) + 3;
             }
             }
-            if (++res >= name_ct) break;
+            if (++ix >= name_ct) break;
             bits >>= 1;
             bits >>= 1;
         }
         }
         return;
         return;
@@ -399,6 +427,9 @@ optionSetMembers(
         break;
         break;
     }
     }
 
 
+    if ((pOD->fOptState & OPTST_RESET) != 0)
+        return;
+
     {
     {
         tCC*      pzArg = pOD->optArg.argString;
         tCC*      pzArg = pOD->optArg.argString;
         uintptr_t res;
         uintptr_t res;
@@ -437,6 +468,8 @@ optionSetMembers(
                 if (pz != pzArg + len) {
                 if (pz != pzArg + len) {
                     char z[ AO_NAME_SIZE ];
                     char z[ AO_NAME_SIZE ];
                     tCC* p;
                     tCC* p;
+                    int  shift_ct;
+
                     if (*pz != NUL) {
                     if (*pz != NUL) {
                         if (len >= AO_NAME_LIMIT)
                         if (len >= AO_NAME_LIMIT)
                             break;
                             break;
@@ -447,7 +480,12 @@ optionSetMembers(
                         p = pzArg;
                         p = pzArg;
                     }
                     }
 
 
-                    bit = 1UL << findName(p, pOpts, pOD, paz_names, name_ct);
+                    shift_ct = findName(p, pOpts, pOD, paz_names, name_ct);
+                    if (shift_ct >= name_ct) {
+                        pOD->optCookie = (void*)0;
+                        return;
+                    }
+                    bit = 1UL << shift_ct;
                 }
                 }
                 if (iv)
                 if (iv)
                      res &= ~bit;
                      res &= ~bit;

+ 4 - 3
libopts/environment.c

@@ -1,6 +1,6 @@
 
 
 /*
 /*
- *  $Id: environment.c,v 4.15 2007/07/04 21:36:37 bkorb Exp $
+ *  $Id: environment.c,v 4.17 2008/06/14 22:24:22 bkorb Exp $
  * Time-stamp:      "2007-07-04 11:33:50 bkorb"
  * Time-stamp:      "2007-07-04 11:33:50 bkorb"
  *
  *
  *  This file contains all of the routines that must be linked into
  *  This file contains all of the routines that must be linked into
@@ -10,7 +10,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -30,7 +31,7 @@
  */
  */
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 checkEnvOpt(tOptState * os, char * env_name,
 checkEnvOpt(tOptState * os, char * env_name,
             tOptions* pOpts, teEnvPresetType type);
             tOptions* pOpts, teEnvPresetType type);

+ 170 - 0
libopts/file.c

@@ -0,0 +1,170 @@
+
+/*
+ *  $Id: file.c,v 1.6 2008/12/20 18:35:27 bkorb Exp $
+ *  Time-stamp:      "2008-12-06 10:15:33 bkorb"
+ *
+ *  This file is part of AutoOpts, a companion to AutoGen.
+ *  AutoOpts is free software.
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *
+ *  AutoOpts is available under any one of two licenses.  The license
+ *  in use must be one of these two and the choice is under the control
+ *  of the user of the license.
+ *
+ *   The GNU Lesser General Public License, version 3 or later
+ *      See the files "COPYING.lgplv3" and "COPYING.gplv3"
+ *
+ *   The Modified Berkeley Software Distribution License
+ *      See the file "COPYING.mbsd"
+ *
+ *  These files have the following md5sums:
+ *
+ *  239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3
+ *  fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3
+ *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+ */
+
+/*=export_func  optionFileCheck
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions*     + pOpts    + program options descriptor  +
+ * arg:   + tOptDesc*     + pOptDesc + the descriptor for this arg +
+ * arg:   + teOptFileType + ftype    + File handling type          +
+ * arg:   + tuFileMode    + mode     + file open mode (if needed)  +
+ *
+ * doc:
+ *   Make sure the named file conforms with the file type mode.
+ *   The mode specifies if the file must exist, must not exist or may
+ *   (or may not) exist.  The mode may also specify opening the
+ *   file: don't, open just the descriptor (fd), or open as a stream
+ *   (FILE* pointer).
+=*/
+void
+optionFileCheck(tOptions* pOpts, tOptDesc* pOD,
+                teOptFileType ftype, tuFileMode mode)
+{
+    if (pOpts <= OPTPROC_EMIT_LIMIT) {
+        if (pOpts != OPTPROC_EMIT_USAGE)
+            return;
+
+        switch (ftype & FTYPE_MODE_EXIST_MASK) {
+        case FTYPE_MODE_MUST_NOT_EXIST:
+            fputs(zFileCannotExist, option_usage_fp);
+            break;
+
+        case FTYPE_MODE_MUST_EXIST:
+            fputs(zFileMustExist, option_usage_fp);
+            break;
+        }
+        return;
+    }
+
+    if ((pOD->fOptState & OPTST_RESET) != 0) {
+        if (pOD->optCookie != NULL)
+            AGFREE(pOD->optCookie);
+        return;
+    }
+
+    {
+        struct stat sb;
+
+        errno = 0;
+
+        switch (ftype & FTYPE_MODE_EXIST_MASK) {
+        case FTYPE_MODE_MUST_NOT_EXIST:
+            if (  (stat(pOD->optArg.argString, &sb) == 0)
+               || (errno != ENOENT) ){
+                if (errno == 0)
+                    errno = EINVAL;
+                fprintf(stderr, zFSOptError, errno, strerror(errno),
+                        zFSOptErrNoExist, pOD->optArg.argString, pOD->pz_Name);
+                pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+                /* NOTREACHED */
+            }
+            /* FALLTHROUGH */
+
+        default:
+        case FTYPE_MODE_MAY_EXIST:
+        {
+            char * p = strrchr(pOD->optArg.argString, DIRCH);
+            if (p != NULL)
+                *p = NUL;
+            if (  (stat(pOD->optArg.argString, &sb) != 0)
+               || (errno = EINVAL, ! S_ISDIR(sb.st_mode)) ){
+                fprintf(stderr, zFSOptError, errno, strerror(errno),
+                        zFSOptErrMayExist, pOD->optArg.argString, pOD->pz_Name);
+                pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+                /* NOTREACHED */
+            }
+            *p = '/';
+            break;
+        }
+
+        case FTYPE_MODE_MUST_EXIST:
+            if (  (stat(pOD->optArg.argString, &sb) != 0)
+               || (errno = EINVAL, ! S_ISREG(sb.st_mode)) ){
+                fprintf(stderr, zFSOptError, errno, strerror(errno),
+                        zFSOptErrMustExist, pOD->optArg.argString,
+                        pOD->pz_Name);
+                pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+                /* NOTREACHED */
+            }
+            break;
+        }
+    }
+
+    switch (ftype & FTYPE_MODE_OPEN_MASK) {
+    default:
+    case FTYPE_MODE_NO_OPEN:
+        break;
+
+    case FTYPE_MODE_OPEN_FD:
+    {
+        int fd = open(pOD->optArg.argString, mode.file_flags);
+        if (fd < 0) {
+            fprintf(stderr, zFSOptError, errno, strerror(errno),
+                    zFSOptErrOpen, pOD->optArg.argString, pOD->pz_Name);
+            pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+            /* NOTREACHED */
+        }
+
+        if ((pOD->fOptState & OPTST_ALLOC_ARG) != 0)
+            pOD->optCookie = (void *)pOD->optArg.argString;
+        else
+            AGDUPSTR(pOD->optCookie, pOD->optArg.argString, "file name");
+
+        pOD->optArg.argFd = fd;
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+        break;
+    }
+
+    case FTYPE_MODE_FOPEN_FP:
+    {
+        FILE* fp = fopen(pOD->optArg.argString, mode.file_mode);
+        if (fp == NULL) {
+            fprintf(stderr, zFSOptError, errno, strerror(errno),
+                    zFSOptErrFopen, pOD->optArg.argString, pOD->pz_Name);
+            pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+            /* NOTREACHED */
+        }
+
+        if ((pOD->fOptState & OPTST_ALLOC_ARG) != 0)
+            pOD->optCookie = (void *)pOD->optArg.argString;
+        else
+            AGDUPSTR(pOD->optCookie, pOD->optArg.argString, "file name");
+
+        pOD->optArg.argFp = fp;
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+        break;
+    }
+    }
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/file.c */

+ 62 - 56
libopts/genshell.c

@@ -2,11 +2,11 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (genshell.c)
  *  DO NOT EDIT THIS FILE   (genshell.c)
  *  
  *  
- *  It has been AutoGen-ed  Saturday July 28, 2007 at 01:01:44 PM PDT
+ *  It has been AutoGen-ed  Wednesday December 31, 2008 at 07:07:16 PM PST
  *  From the definitions    genshell.def
  *  From the definitions    genshell.def
  *  and the template file   options
  *  and the template file   options
  *
  *
- * Generated from AutoOpts 30:0:5 templates.
+ * Generated from AutoOpts 32:0:7 templates.
  */
  */
 
 
 /*
 /*
@@ -36,8 +36,10 @@
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 
 
-
+#include <sys/types.h>
 #include <limits.h>
 #include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 
 #define OPTION_CODE_COMPILE 1
 #define OPTION_CODE_COMPILE 1
 #include "genshell.h"
 #include "genshell.h"
@@ -45,19 +47,22 @@
 #ifdef  __cplusplus
 #ifdef  __cplusplus
 extern "C" {
 extern "C" {
 #endif
 #endif
+
+/* TRANSLATORS: choose the translation for option names wisely because you
+                cannot ever change your mind. */
 tSCC zCopyright[] =
 tSCC zCopyright[] =
        "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
        "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
-tSCC zCopyrightNotice[] =
-       "genshellopt is free software: you can redistribute it and/or modify it\n\
-under the terms of the GNU General Public License as published by the\n\
-Free Software Foundation, either version 3 of the License, or\n\
-(at your option) any later version.\n\n\
-genshellopt is distributed in the hope that it will be useful, but\n\
-WITHOUT ANY WARRANTY; without even the implied warranty of\n\
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-See the GNU General Public License for more details.\n\n\
-You should have received a copy of the GNU General Public License along\n\
-with this program.  If not, see <http://www.gnu.org/licenses/>.";
+tSCC zCopyrightNotice[610] =
+"genshellopt is free software: you can redistribute it and/or modify it under\n\
+the terms of the GNU General Public License as published by the Free Software\n\
+Foundation, either version 3 of the License, or (at your option) any later\n\
+version.\n\n\
+genshellopt is distributed in the hope that it will be useful, but WITHOUT ANY\n\
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n\
+PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\n\
+You should have received a copy of the GNU General Public License along with\n\
+this program.  If not, see <http://www.gnu.org/licenses/>.";
+
 extern tUsageProc genshelloptUsage;
 extern tUsageProc genshelloptUsage;
 
 
 #ifndef NULL
 #ifndef NULL
@@ -94,14 +99,12 @@ tSCC    zNotShell_Pfx[]            = "no";
 /*
 /*
  *  Help/More_Help/Version option descriptions:
  *  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";
+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
  *  Declare option callback procedures
  */
  */
@@ -207,7 +210,7 @@ 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\
 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";
 by the newly generated text.  The first `#!' line will be regenerated.\n";
 tSCC    zFullVersion[] = GENSHELLOPT_FULL_VERSION;
 tSCC    zFullVersion[] = GENSHELLOPT_FULL_VERSION;
-/* extracted from optcode.tpl near line 428 */
+/* extracted from optcode.tpl near line 496 */
 
 
 #if defined(ENABLE_NLS)
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE
 # define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -217,6 +220,7 @@ tSCC    zFullVersion[] = GENSHELLOPT_FULL_VERSION;
 # define translate_option_strings NULL
 # define translate_option_strings NULL
 #endif /* ENABLE_NLS */
 #endif /* ENABLE_NLS */
 
 
+
 #define genshellopt_full_usage NULL
 #define genshellopt_full_usage NULL
 #define genshellopt_short_usage NULL
 #define genshellopt_short_usage NULL
 tOptions genshelloptOptions = {
 tOptions genshelloptOptions = {
@@ -241,13 +245,14 @@ tOptions genshelloptOptions = {
     /*
     /*
      *  Indexes to special options
      *  Indexes to special options
      */
      */
-    { INDEX_OPT_MORE_HELP,
-       0 /* no option state saving */,
-      NO_EQUIVALENT /* index of '-#' option */,
+    { INDEX_OPT_MORE_HELP, /* more-help option index */
+      NO_EQUIVALENT, /* save option index */
+      NO_EQUIVALENT, /* '-#' option index */
       NO_EQUIVALENT /* index of default opt */
       NO_EQUIVALENT /* index of default opt */
     },
     },
     5 /* full option count */, 2 /* user option count */,
     5 /* full option count */, 2 /* user option count */,
-    genshellopt_full_usage, genshellopt_short_usage
+    genshellopt_full_usage, genshellopt_short_usage,
+    NULL, NULL
 };
 };
 
 
 /*
 /*
@@ -260,7 +265,7 @@ doUsageOpt(
 {
 {
     USAGE( EXIT_SUCCESS );
     USAGE( EXIT_SUCCESS );
 }
 }
-/* extracted from optcode.tpl near line 537 */
+/* extracted from optcode.tpl near line 629 */
 
 
 #if ENABLE_NLS
 #if ENABLE_NLS
 #include <stdio.h>
 #include <stdio.h>
@@ -303,44 +308,45 @@ translate_option_strings( void )
      *  Guard against re-translation.  It won't work.  The strings will have
      *  Guard against re-translation.  It won't work.  The strings will have
      *  been changed by the first pass through this code.  One shot only.
      *  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;
+    if (option_usage_text.field_ct != 0) {
+
+        /*
+         *  Do the translations.  The first pointer follows the field count
+         *  field.  The field count field is the size of a pointer.
+         */
+        tOptDesc* pOD = genshelloptOptions.pOptDesc;
+        char**    ppz = (char**)(void*)&(option_usage_text);
+        int       ix  = option_usage_text.field_ct;
 
 
         do {
         do {
             ppz++;
             ppz++;
             *ppz = AO_gettext(*ppz);
             *ppz = AO_gettext(*ppz);
         } while (--ix > 0);
         } while (--ix > 0);
+
+        COERSION(pzCopyright);
+        COERSION(pzCopyNotice);
+        COERSION(pzFullVersion);
+        COERSION(pzUsageTitle);
+        COERSION(pzExplain);
+        COERSION(pzDetail);
+        option_usage_text.field_ct = 0;
+
+        for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++)
+            coerce_it((void*)&(pOD->pzText));
     }
     }
-    option_usage_text.field_ct = 0;
 
 
-    {
+    if ((genshelloptOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
         tOptDesc* pOD = genshelloptOptions.pOptDesc;
         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++;
+        int       ix;
+
+        for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++) {
+            coerce_it((void*)&(pOD->pz_Name));
+            coerce_it((void*)&(pOD->pz_DisableName));
+            coerce_it((void*)&(pOD->pz_DisablePfx));
         }
         }
+        /* prevent re-translation */
+        genshelloptOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
     }
     }
-    COERSION(pzCopyright);
-    COERSION(pzCopyNotice);
-    COERSION(pzFullVersion);
-    COERSION(pzUsageTitle);
-    COERSION(pzExplain);
-    COERSION(pzDetail);
 }
 }
 
 
 #endif /* ENABLE_NLS */
 #endif /* ENABLE_NLS */

+ 37 - 18
libopts/genshell.h

@@ -2,11 +2,11 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (genshell.h)
  *  DO NOT EDIT THIS FILE   (genshell.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday July 28, 2007 at 01:01:44 PM PDT
+ *  It has been AutoGen-ed  Wednesday December 31, 2008 at 07:07:16 PM PST
  *  From the definitions    genshell.def
  *  From the definitions    genshell.def
  *  and the template file   options
  *  and the template file   options
  *
  *
- * Generated from AutoOpts 30:0:5 templates.
+ * Generated from AutoOpts 32:0:7 templates.
  */
  */
 
 
 /*
 /*
@@ -52,7 +52,7 @@
  *  tolerable version is at least as old as what was current when the header
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  *  template was released.
  */
  */
-#define AO_TEMPLATE_VERSION 122880
+#define AO_TEMPLATE_VERSION 131072
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
 # error option template version mismatches autoopts/options.h header
@@ -95,12 +95,12 @@ typedef enum {
                     DESC(n).fOptState |= OPTST_DISABLED; \
                     DESC(n).fOptState |= OPTST_DISABLED; \
                 DESC(n).optCookie = NULL )
                 DESC(n).optCookie = NULL )
 
 
-/*
+/* * * * * *
+ *
  *  Interface defines for specific options.
  *  Interface defines for specific options.
  */
  */
 #define VALUE_OPT_SCRIPT         'o'
 #define VALUE_OPT_SCRIPT         'o'
 #define VALUE_OPT_SHELL          's'
 #define VALUE_OPT_SHELL          's'
-
 #define VALUE_OPT_HELP          '?'
 #define VALUE_OPT_HELP          '?'
 #define VALUE_OPT_MORE_HELP     '!'
 #define VALUE_OPT_MORE_HELP     '!'
 #define VALUE_OPT_VERSION       'v'
 #define VALUE_OPT_VERSION       'v'
@@ -114,7 +114,7 @@ typedef enum {
                 genshelloptOptions.pzCurOpt  = NULL )
                 genshelloptOptions.pzCurOpt  = NULL )
 #define START_OPT       RESTART_OPT(1)
 #define START_OPT       RESTART_OPT(1)
 #define USAGE(c)        (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c )
 #define USAGE(c)        (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c )
-/* extracted from opthead.tpl near line 380 */
+/* extracted from opthead.tpl near line 415 */
 
 
 /* * * * * *
 /* * * * * *
  *
  *
@@ -126,18 +126,37 @@ extern "C" {
 
 
 extern tOptions   genshelloptOptions;
 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
+#if defined(ENABLE_NLS)
+# ifndef _
+#   include <stdio.h>
+    static inline char* aoGetsText( char const* pz ) {
+        if (pz == NULL) return NULL;
+        return (char*)gettext( pz );
+    }
+#   define _(s)  aoGetsText(s)
+# endif /* _() */
+
+# define OPT_NO_XLAT_CFG_NAMES  STMTS(genshelloptOptions.fOptSet |= \
+                                    OPTPROC_NXLAT_OPT_CFG;)
+# define OPT_NO_XLAT_OPT_NAMES  STMTS(genshelloptOptions.fOptSet |= \
+                                    OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;)
+
+# define OPT_XLAT_CFG_NAMES     STMTS(genshelloptOptions.fOptSet &= \
+                                  ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);)
+# define OPT_XLAT_OPT_NAMES     STMTS(genshelloptOptions.fOptSet &= \
+                                  ~OPTPROC_NXLAT_OPT;)
+
+#else   /* ENABLE_NLS */
+# define OPT_NO_XLAT_CFG_NAMES
+# define OPT_NO_XLAT_OPT_NAMES
+
+# define OPT_XLAT_CFG_NAMES
+# define OPT_XLAT_OPT_NAMES
+
+# ifndef _
+#   define _(_s)  _s
+# endif
+#endif  /* ENABLE_NLS */
 
 
 #ifdef  __cplusplus
 #ifdef  __cplusplus
 }
 }

+ 8 - 0
libopts/libopts.c

@@ -4,14 +4,20 @@
 #include "autoopts/options.h"
 #include "autoopts/options.h"
 #include "autoopts/usage-txt.h"
 #include "autoopts/usage-txt.h"
 #include "genshell.h"
 #include "genshell.h"
+#include "xat-attribute.h"
+#include "value-type.h"
+#include "ag-char-map.h"
 #include "autoopts.h"
 #include "autoopts.h"
 #include "proto.h"
 #include "proto.h"
+#include "value-type.c"
+#include "xat-attribute.c"
 #include "autoopts.c"
 #include "autoopts.c"
 #include "boolean.c"
 #include "boolean.c"
 #include "configfile.c"
 #include "configfile.c"
 #include "cook.c"
 #include "cook.c"
 #include "enumeration.c"
 #include "enumeration.c"
 #include "environment.c"
 #include "environment.c"
+#include "file.c"
 #include "genshell.c"
 #include "genshell.c"
 #include "load.c"
 #include "load.c"
 #include "makeshell.c"
 #include "makeshell.c"
@@ -19,6 +25,7 @@
 #include "numeric.c"
 #include "numeric.c"
 #include "pgusage.c"
 #include "pgusage.c"
 #include "putshell.c"
 #include "putshell.c"
+#include "reset.c"
 #include "restore.c"
 #include "restore.c"
 #include "save.c"
 #include "save.c"
 #include "sort.c"
 #include "sort.c"
@@ -26,5 +33,6 @@
 #include "streqvcmp.c"
 #include "streqvcmp.c"
 #include "text_mmap.c"
 #include "text_mmap.c"
 #include "tokenize.c"
 #include "tokenize.c"
+#include "time.c"
 #include "usage.c"
 #include "usage.c"
 #include "version.c"
 #include "version.c"

+ 17 - 16
libopts/load.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: load.c,v 4.22 2007/07/04 21:36:37 bkorb Exp $
- *  Time-stamp:      "2007-07-04 10:22:44 bkorb"
+ *  $Id: load.c,v 4.27 2008/12/20 18:35:27 bkorb Exp $
+ *  Time-stamp:      "2008-12-06 10:16:05 bkorb"
  *
  *
  *  This file contains the routines that deal with processing text strings
  *  This file contains the routines that deal with processing text strings
  *  for options, either from a NUL-terminated string passed in or from an
  *  for options, either from a NUL-terminated string passed in or from an
@@ -9,7 +9,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -31,7 +32,7 @@
 tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
 tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static ag_bool
 static ag_bool
 insertProgramPath(
 insertProgramPath(
     char*   pzBuf,
     char*   pzBuf,
@@ -63,8 +64,8 @@ assembleArgValue( char* pzTxt, tOptionLoadMode mode );
  * ret-desc: AG_TRUE if the name was handled, otherwise AG_FALSE.
  * ret-desc: AG_TRUE if the name was handled, otherwise AG_FALSE.
  *           If the name does not start with ``$'', then it is handled
  *           If the name does not start with ``$'', then it is handled
  *           simply by copying the input name to the output buffer and
  *           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)}.
+ *           resolving the name with either
+ *           @code{canonicalize_file_name(3GLIBC)} or @code{realpath(3C)}.
  *
  *
  * doc:
  * doc:
  *
  *
@@ -254,7 +255,7 @@ insertProgramPath(
      *  allocated and we need to deallocate it.
      *  allocated and we need to deallocate it.
      */
      */
     if (pzPath != pzProgPath)
     if (pzPath != pzProgPath)
-        free( (void*)pzPath );
+        AGFREE(pzPath);
     return AG_TRUE;
     return AG_TRUE;
 }
 }
 
 
@@ -270,7 +271,7 @@ insertEnvVal(
 
 
     for (;;) {
     for (;;) {
         int ch = (int)*++pzName;
         int ch = (int)*++pzName;
-        if (! ISNAMECHAR( ch ))
+        if (! IS_VALUE_NAME_CHAR(ch))
             break;
             break;
         *(pzDir++) = (char)ch;
         *(pzDir++) = (char)ch;
     }
     }
@@ -304,16 +305,16 @@ mungeString( char* pzTxt, tOptionLoadMode mode )
     if (mode == OPTION_LOAD_KEEP)
     if (mode == OPTION_LOAD_KEEP)
         return;
         return;
 
 
-    if (isspace( (int)*pzTxt )) {
+    if (IS_WHITESPACE_CHAR(*pzTxt)) {
         char* pzS = pzTxt;
         char* pzS = pzTxt;
         char* pzD = pzTxt;
         char* pzD = pzTxt;
-        while (isspace( (int)*++pzS ))  ;
+        while (IS_WHITESPACE_CHAR(*++pzS))  ;
         while ((*(pzD++) = *(pzS++)) != NUL)   ;
         while ((*(pzD++) = *(pzS++)) != NUL)   ;
         pzE = pzD-1;
         pzE = pzD-1;
     } else
     } else
         pzE = pzTxt + strlen( pzTxt );
         pzE = pzTxt + strlen( pzTxt );
 
 
-    while ((pzE > pzTxt) && isspace( (int)pzE[-1] ))  pzE--;
+    while ((pzE > pzTxt) && IS_WHITESPACE_CHAR(pzE[-1]))  pzE--;
     *pzE = NUL;
     *pzE = NUL;
 
 
     if (mode == OPTION_LOAD_UNCOOKED)
     if (mode == OPTION_LOAD_UNCOOKED)
@@ -338,7 +339,7 @@ mungeString( char* pzTxt, tOptionLoadMode mode )
 static char*
 static char*
 assembleArgValue( char* pzTxt, tOptionLoadMode mode )
 assembleArgValue( char* pzTxt, tOptionLoadMode mode )
 {
 {
-    tSCC zBrk[] = " \t:=";
+    tSCC zBrk[] = " \t\n:=";
     char* pzEnd = strpbrk( pzTxt, zBrk );
     char* pzEnd = strpbrk( pzTxt, zBrk );
     int   space_break;
     int   space_break;
 
 
@@ -363,11 +364,11 @@ assembleArgValue( char* pzTxt, tOptionLoadMode mode )
      *  because we'll have to skip over an immediately following ':' or '='
      *  because we'll have to skip over an immediately following ':' or '='
      *  (and the white space following *that*).
      *  (and the white space following *that*).
      */
      */
-    space_break = isspace((int)*pzEnd);
+    space_break = IS_WHITESPACE_CHAR(*pzEnd);
     *(pzEnd++) = NUL;
     *(pzEnd++) = NUL;
-    while (isspace((int)*pzEnd))  pzEnd++;
+    while (IS_WHITESPACE_CHAR(*pzEnd))  pzEnd++;
     if (space_break && ((*pzEnd == ':') || (*pzEnd == '=')))
     if (space_break && ((*pzEnd == ':') || (*pzEnd == '=')))
-        while (isspace((int)*++pzEnd))  ;
+        while (IS_WHITESPACE_CHAR(*++pzEnd))  ;
 
 
     return pzEnd;
     return pzEnd;
 }
 }
@@ -387,7 +388,7 @@ loadOptionLine(
     tDirection  direction,
     tDirection  direction,
     tOptionLoadMode   load_mode )
     tOptionLoadMode   load_mode )
 {
 {
-    while (isspace( (int)*pzLine ))  pzLine++;
+    while (IS_WHITESPACE_CHAR(*pzLine))  pzLine++;
 
 
     {
     {
         char* pzArg = assembleArgValue( pzLine, load_mode );
         char* pzArg = assembleArgValue( pzLine, load_mode );

+ 36 - 10
libopts/m4/libopts.m4

@@ -2,7 +2,7 @@ dnl  -*- buffer-read-only: t -*- vi: set ro:
 dnl 
 dnl 
 dnl DO NOT EDIT THIS FILE   (libopts.m4)
 dnl DO NOT EDIT THIS FILE   (libopts.m4)
 dnl 
 dnl 
-dnl It has been AutoGen-ed  Saturday July 28, 2007 at 01:01:51 PM PDT
+dnl It has been AutoGen-ed  Wednesday December 31, 2008 at 07:07:17 PM PST
 dnl From the definitions    libopts.def
 dnl From the definitions    libopts.def
 dnl and the template file   conftest.tpl
 dnl and the template file   conftest.tpl
 dnl
 dnl
@@ -27,6 +27,34 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
     sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
     sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
     utime.h sysexits.h)
     utime.h sysexits.h)
   
   
+    AC_CHECK_TYPES(size_t)
+
+
+# ----------------------------------------------------------------------
+# check for various programs used during the build.
+# On OS/X, "wchar.h" needs "runetype.h" to work properly.
+# ----------------------------------------------------------------------
+    AC_CHECK_HEADERS([runetype.h wchar.h], [], [],[
+    AC_INCLUDES_DEFAULT
+#if HAVE_RUNETYPE_H
+# include <runetype.h>
+#endif
+    ])
+
+# ----------------------------------------------------------------------
+# Checks for typedefs
+# ----------------------------------------------------------------------
+    AC_CHECK_TYPES(wchar_t)
+    AC_CHECK_TYPES(wint_t, [], [], [
+    AC_INCLUDES_DEFAULT
+#if HAVE_RUNETYPE_H
+# include <runetype.h>
+#endif
+#if HAVE_WCHAR_H
+# include <wchar.h>
+#endif
+    ])
+
   # --------------------------------------------
   # --------------------------------------------
   # Verify certain entries from AC_CHECK_HEADERS
   # Verify certain entries from AC_CHECK_HEADERS
   # --------------------------------------------
   # --------------------------------------------
@@ -66,15 +94,12 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
   # ...and int types headers
   # ...and int types headers
   # ========================
   # ========================
   AC_CHECK_HEADERS(stdint.h inttypes.h, break)
   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])
+  AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, 
+    intptr_t, uintptr_t, uint_t, pid_t])
   
   
-  # ====================
-  # uintptr type & sizes
-  # ====================
-  AC_CHECK_TYPES([uintptr_t], ,
-         [AC_DEFINE([uintptr_t], unsigned long,
-                    [Alternate uintptr_t for systems without it.])])
+  # =====
+  # sizes
+  # =====
   AC_CHECK_SIZEOF(char*, 4)
   AC_CHECK_SIZEOF(char*, 4)
   AC_CHECK_SIZEOF(int,   4)
   AC_CHECK_SIZEOF(int,   4)
   AC_CHECK_SIZEOF(long,  4)
   AC_CHECK_SIZEOF(long,  4)
@@ -85,7 +110,8 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
   # ----------------------------------------------------------------------
   # ----------------------------------------------------------------------
   AC_CHECK_LIB(gen, pathfind)
   AC_CHECK_LIB(gen, pathfind)
   AC_FUNC_VPRINTF
   AC_FUNC_VPRINTF
-  AC_CHECK_FUNCS([strsignal mmap canonicalize_file_name snprintf strdup strchr strrchr])
+  AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
+                 strrchr strsignal])
 [  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
 [  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
 fi]])
 fi]])
 
 

+ 7 - 6
libopts/makeshell.c

@@ -1,14 +1,15 @@
 
 
 /*
 /*
- *  $Id: makeshell.c,v 4.22 2007/07/04 21:36:37 bkorb Exp $
- * Time-stamp:      "2007-07-04 10:22:32 bkorb"
+ *  $Id: makeshell.c,v 4.27 2008/07/28 04:51:29 bkorb Exp $
+ * Time-stamp:      "2008-07-26 16:10:51 bkorb"
  *
  *
  *  This module will interpret the options set in the tOptions
  *  This module will interpret the options set in the tOptions
  *  structure and create a Bourne shell script capable of parsing them.
  *  structure and create a Bourne shell script capable of parsing them.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -341,7 +342,7 @@ static char*  pzLeader  = NULL;
 static char*  pzTrailer = NULL;
 static char*  pzTrailer = NULL;
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD );
 textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD );
 
 
@@ -672,7 +673,7 @@ emitSetup( tOptions* pOpts )
          */
          */
         switch (OPTST_GET_ARGTYPE(pOptDesc->fOptState)) {
         switch (OPTST_GET_ARGTYPE(pOptDesc->fOptState)) {
         case OPARG_TYPE_ENUMERATION:
         case OPARG_TYPE_ENUMERATION:
-            (*(pOptDesc->pOptProc))( (tOptions*)2UL, pOptDesc );
+            (*(pOptDesc->pOptProc))(OPTPROC_EMIT_SHELL, pOptDesc );
             pzDefault = pOptDesc->optArg.argString;
             pzDefault = pOptDesc->optArg.argString;
             break;
             break;
 
 
@@ -792,7 +793,7 @@ emitFlag( tOptions* pOpts )
         if (SKIP_OPT(pOptDesc))
         if (SKIP_OPT(pOptDesc))
             continue;
             continue;
 
 
-        if (isprint( pOptDesc->optValue )) {
+        if (IS_GRAPHIC_CHAR(pOptDesc->optValue)) {
             printf( zOptionFlag, pOptDesc->optValue );
             printf( zOptionFlag, pOptDesc->optValue );
             printOptionAction( pOpts, pOptDesc );
             printOptionAction( pOpts, pOptDesc );
         }
         }

+ 202 - 69
libopts/nested.c

@@ -1,13 +1,14 @@
 
 
 /*
 /*
- *  $Id: nested.c,v 4.16 2007/07/04 21:36:37 bkorb Exp $
- *  Time-stamp:      "2007-07-04 10:22:17 bkorb"
+ *  $Id: nested.c,v 4.26 2008/08/02 16:10:07 bkorb Exp $
+ *  Time-stamp:      "2008-07-28 19:18:28 bkorb"
  *
  *
  *   Automated Options Nested Values module.
  *   Automated Options Nested Values module.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -26,10 +27,24 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
  */
 
 
+typedef struct {
+    int     xml_ch;
+    int     xml_len;
+    char    xml_txt[8];
+} xml_xlate_t;
+
+static xml_xlate_t const xml_xlate[] = {
+    { '&', 4, "amp;"  },
+    { '<', 3, "lt;"   },
+    { '>', 3, "gt;"   },
+    { '"', 5, "quot;" },
+    { '\'',5, "apos;" }
+};
+
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
-removeBackslashes( char* pzSrc );
+removeLineContinue( char* pzSrc );
 
 
 static char const*
 static char const*
 scanQuotedString( char const* pzTxt );
 scanQuotedString( char const* pzTxt );
@@ -63,27 +78,42 @@ static void
 sortNestedList( tArgList* pAL );
 sortNestedList( tArgList* pAL );
 /* = = = END-STATIC-FORWARD = = = */
 /* = = = END-STATIC-FORWARD = = = */
 
 
-/*  removeBackslashes
+/*  removeLineContinue
  *
  *
- *  This function assumes that all newline characters were preceeded by
- *  backslashes that need removal.
+ *  Backslashes are used for line continuations.  We keep the newline
+ *  characters, but trim out the backslash:
  */
  */
 static void
 static void
-removeBackslashes( char* pzSrc )
+removeLineContinue( char* pzSrc )
 {
 {
-    char* pzD = strchr(pzSrc, '\n');
+    char* pzD;
 
 
-    if (pzD == NULL)
-        return;
-    *--pzD = '\n';
+    do  {
+        while (*pzSrc == '\n')  pzSrc++;
+        pzD = strchr(pzSrc, '\n');
+        if (pzD == NULL)
+            return;
 
 
+        /*
+         *  pzD has skipped at least one non-newline character and now
+         *  points to a newline character.  It now becomes the source and
+         *  pzD goes to the previous character.
+         */
+        pzSrc = pzD--;
+        if (*pzD != '\\')
+            pzD++;
+    } while (pzD == pzSrc);
+
+    /*
+     *  Start shifting text.
+     */
     for (;;) {
     for (;;) {
         char ch = ((*pzD++) = *(pzSrc++));
         char ch = ((*pzD++) = *(pzSrc++));
         switch (ch) {
         switch (ch) {
-        case '\n': *--pzD = ch; break;
         case NUL:  return;
         case NUL:  return;
-        default:
-            ;
+        case '\\':
+            if (*pzSrc == '\n')
+                --pzD; /* rewrite on next iteration */
         }
         }
     }
     }
 }
 }
@@ -148,9 +178,24 @@ addStringValue( void** pp, char const* pzName, size_t nameLen,
 
 
     } else {
     } else {
         pNV->valType = OPARG_TYPE_STRING;
         pNV->valType = OPARG_TYPE_STRING;
-        if (dataLen > 0)
-            memcpy( pNV->v.strVal, pzValue, dataLen );
-        pNV->v.strVal[dataLen] = NUL;
+        if (dataLen > 0) {
+            char const * pzSrc = pzValue;
+            char * pzDst = pNV->v.strVal;
+            int    ct    = dataLen;
+            do  {
+                int ch = *(pzSrc++) & 0xFF;
+                if (ch == NUL) goto data_copy_done;
+                if (ch == '&')
+                    ch = get_special_char(&pzSrc, &ct);
+                *(pzDst++) = ch;
+            } while (--ct > 0);
+        data_copy_done:
+            *pzDst = NUL;
+
+        } else {
+            pNV->v.strVal[0] = NUL;
+        }
+
         pNV->pzName = pNV->v.strVal + dataLen + 1;
         pNV->pzName = pNV->v.strVal + dataLen + 1;
     }
     }
 
 
@@ -175,22 +220,16 @@ addBoolValue( void** pp, char const* pzName, size_t nameLen,
     pNV = AGALOC( sz, "option name/bool value pair" );
     pNV = AGALOC( sz, "option name/bool value pair" );
     if (pNV == NULL)
     if (pNV == NULL)
         return NULL;
         return NULL;
-    while (isspace( (int)*pzValue ) && (dataLen > 0)) {
+    while (IS_WHITESPACE_CHAR(*pzValue) && (dataLen > 0)) {
         dataLen--; pzValue++;
         dataLen--; pzValue++;
     }
     }
     if (dataLen == 0)
     if (dataLen == 0)
         pNV->v.boolVal = 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;
-    }
+
+    else if (IS_DEC_DIGIT_CHAR(*pzValue))
+        pNV->v.boolVal = atoi(pzValue);
+
+    else pNV->v.boolVal = ! IS_FALSE_TYPE_CHAR(*pzValue);
 
 
     pNV->valType = OPARG_TYPE_BOOLEAN;
     pNV->valType = OPARG_TYPE_BOOLEAN;
     pNV->pzName = (char*)(pNV + 1);
     pNV->pzName = (char*)(pNV + 1);
@@ -215,16 +254,16 @@ addNumberValue( void** pp, char const* pzName, size_t nameLen,
     pNV = AGALOC( sz, "option name/bool value pair" );
     pNV = AGALOC( sz, "option name/bool value pair" );
     if (pNV == NULL)
     if (pNV == NULL)
         return NULL;
         return NULL;
-    while (isspace( (int)*pzValue ) && (dataLen > 0)) {
+    while (IS_WHITESPACE_CHAR(*pzValue) && (dataLen > 0)) {
         dataLen--; pzValue++;
         dataLen--; pzValue++;
     }
     }
     if (dataLen == 0)
     if (dataLen == 0)
-        pNV->v.boolVal = 0;
+        pNV->v.longVal = 0;
     else
     else
-        pNV->v.boolVal = atoi( pzValue );
+        pNV->v.longVal = strtol(pzValue, 0, 0);
 
 
     pNV->valType = OPARG_TYPE_NUMERIC;
     pNV->valType = OPARG_TYPE_NUMERIC;
-    pNV->pzName = (char*)(pNV + 1);
+    pNV->pzName  = (char*)(pNV + 1);
     memcpy( pNV->pzName, pzName, nameLen );
     memcpy( pNV->pzName, pzName, nameLen );
     pNV->pzName[ nameLen ] = NUL;
     pNV->pzName[ nameLen ] = NUL;
     addArgListEntry( pp, pNV );
     addArgListEntry( pp, pNV );
@@ -273,46 +312,39 @@ static char const*
 scanNameEntry(char const* pzName, tOptionValue* pRes)
 scanNameEntry(char const* pzName, tOptionValue* pRes)
 {
 {
     tOptionValue* pNV;
     tOptionValue* pNV;
-    char const * pzScan = pzName+1;
+    char const * pzScan = pzName+1; /* we know first char is a name char */
     char const * pzVal;
     char const * pzVal;
     size_t       nameLen = 1;
     size_t       nameLen = 1;
     size_t       dataLen = 0;
     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;
-        }
-    }
+    /*
+     *  Scan over characters that name a value.  These names may not end
+     *  with a colon, but they may contain colons.
+     */
+    while (IS_VALUE_NAME_CHAR(*pzScan))   { pzScan++; nameLen++; }
+    if (pzScan[-1] == ':')                { pzScan--; nameLen--; }
+    while (IS_HORIZ_WHITE_CHAR(*pzScan))    pzScan++;
 
 
+re_switch:
     switch (*pzScan) {
     switch (*pzScan) {
     case '=':
     case '=':
     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;
-        }
+        while (IS_HORIZ_WHITE_CHAR( (int)*++pzScan ))  ;
+        if ((*pzScan == '=') || (*pzScan == ':'))
+            goto default_char;
+        goto re_switch;
 
 
+    case '\n':
     case ',':
     case ',':
-    comma_char:
         pzScan++;
         pzScan++;
         /* FALLTHROUGH */
         /* FALLTHROUGH */
 
 
     case NUL:
     case NUL:
-    nul_byte:
         addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
         addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
         break;
         break;
 
 
     case '"':
     case '"':
     case '\'':
     case '\'':
-    quote_char:
         pzVal = pzScan;
         pzVal = pzScan;
         pzScan = scanQuotedString( pzScan );
         pzScan = scanQuotedString( pzScan );
         dataLen = pzScan - pzVal;
         dataLen = pzScan - pzVal;
@@ -351,7 +383,7 @@ scanNameEntry(char const* pzName, tOptionValue* pRes)
                 pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen,
                 pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen,
                                       pzVal, dataLen );
                                       pzVal, dataLen );
                 if (pNV != NULL)
                 if (pNV != NULL)
-                    removeBackslashes( pNV->v.strVal );
+                    removeLineContinue( pNV->v.strVal );
                 goto leave_scan_name;
                 goto leave_scan_name;
             }
             }
         }
         }
@@ -378,7 +410,7 @@ scanXmlEntry( char const* pzName, tOptionValue* pRes )
     tOptionValue* pNewVal;
     tOptionValue* pNewVal;
     tOptionLoadMode save_mode = option_load_mode;
     tOptionLoadMode save_mode = option_load_mode;
 
 
-    if (! isalpha((int)*pzName)) {
+    if (! IS_VAR_FIRST_CHAR(*pzName)) {
         switch (*pzName) {
         switch (*pzName) {
         default:
         default:
             pzName = NULL;
             pzName = NULL;
@@ -399,7 +431,8 @@ scanXmlEntry( char const* pzName, tOptionValue* pRes )
         return pzName;
         return pzName;
     }
     }
 
 
-    while (isalpha( (int)*++pzScan ))  nameLen++;
+    pzScan++;
+    while (IS_VALUE_NAME_CHAR( (int)*pzScan ))  { pzScan++; nameLen++; }
     if (nameLen > 64)
     if (nameLen > 64)
         return NULL;
         return NULL;
     valu.valType = OPARG_TYPE_STRING;
     valu.valType = OPARG_TYPE_STRING;
@@ -427,7 +460,7 @@ scanXmlEntry( char const* pzName, tOptionValue* pRes )
         }
         }
         addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
         addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
         option_load_mode = save_mode;
         option_load_mode = save_mode;
-        return pzScan+2;
+        return pzScan+1;
 
 
     default:
     default:
         option_load_mode = save_mode;
         option_load_mode = save_mode;
@@ -462,7 +495,7 @@ scanXmlEntry( char const* pzName, tOptionValue* pRes )
         }
         }
         valLen = (pzScan - pzVal);
         valLen = (pzScan - pzVal);
         pzScan += nameLen + 3;
         pzScan += nameLen + 3;
-        while (isspace(  (int)*pzScan ))  pzScan++;
+        while (IS_WHITESPACE_CHAR(*pzScan))  pzScan++;
     }
     }
 
 
     switch (valu.valType) {
     switch (valu.valType) {
@@ -629,7 +662,7 @@ optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
         errno = EINVAL;
         errno = EINVAL;
         return NULL;
         return NULL;
     }
     }
-    while (isspace( (int)*pzTxt ))  pzTxt++;
+    while (IS_WHITESPACE_CHAR(*pzTxt))  pzTxt++;
     if (*pzTxt == NUL) {
     if (*pzTxt == NUL) {
         errno = ENOENT;
         errno = ENOENT;
         return NULL;
         return NULL;
@@ -657,13 +690,14 @@ optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
      *  Scan until we hit a NUL.
      *  Scan until we hit a NUL.
      */
      */
     do  {
     do  {
-        while (isspace( (int)*pzTxt ))  pzTxt++;
-        if (isalpha( (int)*pzTxt )) {
+        while (IS_WHITESPACE_CHAR( (int)*pzTxt ))  pzTxt++;
+        if (IS_VAR_FIRST_CHAR( (int)*pzTxt )) {
             pzTxt = scanNameEntry( pzTxt, pRes );
             pzTxt = scanNameEntry( pzTxt, pRes );
         }
         }
         else switch (*pzTxt) {
         else switch (*pzTxt) {
         case NUL: goto scan_done;
         case NUL: goto scan_done;
         case '<': pzTxt = scanXmlEntry( pzTxt, pRes );
         case '<': pzTxt = scanXmlEntry( pzTxt, pRes );
+                  if (pzTxt == NULL) goto woops;
                   if (*pzTxt == ',') pzTxt++;     break;
                   if (*pzTxt == ',') pzTxt++;     break;
         case '#': pzTxt = strchr( pzTxt, '\n' );  break;
         case '#': pzTxt = strchr( pzTxt, '\n' );  break;
         default:  goto woops;
         default:  goto woops;
@@ -694,14 +728,113 @@ optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
  *  Nested value was found on the command line
  *  Nested value was found on the command line
 =*/
 =*/
 void
 void
-optionNestedVal( tOptions* pOpts, tOptDesc* pOD )
+optionNestedVal(tOptions* pOpts, tOptDesc* pOD)
 {
 {
-    tOptionValue* pOV = optionLoadNested(
-        pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name));
+    if (pOpts < OPTPROC_EMIT_LIMIT)
+        return;
 
 
-    if (pOV != NULL)
-        addArgListEntry( &(pOD->optCookie), (void*)pOV );
+    if (pOD->fOptState & OPTST_RESET) {
+        tArgList* pAL = pOD->optCookie;
+        int       ct;
+        tCC **    av;
+
+        if (pAL == NULL)
+            return;
+        ct = pAL->useCt;
+        av = pAL->apzArgs;
+
+        while (--ct >= 0) {
+            void * p = (void *)*(av++);
+            optionUnloadNested((tOptionValue const *)p);
+        }
+
+        AGFREE(pOD->optCookie);
+
+    } else {
+        tOptionValue* pOV = optionLoadNested(
+            pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name));
+
+        if (pOV != NULL)
+            addArgListEntry( &(pOD->optCookie), (void*)pOV );
+    }
 }
 }
+
+
+/*
+ * get_special_char
+ */
+LOCAL int
+get_special_char(char const ** ppz, int * ct)
+{
+    char const * pz = *ppz;
+
+    if (*ct < 3)
+        return '&';
+
+    if (*pz == '#') {
+        int base = 10;
+        int retch;
+
+        pz++;
+        if (*pz == 'x') {
+            base = 16;
+            pz++;
+        }
+        retch = (int)strtoul(pz, (char **)&pz, base);
+        if (*pz != ';')
+            return '&';
+        base = ++pz - *ppz;
+        if (base > *ct)
+            return '&';
+
+        *ct -= base;
+        *ppz = pz;
+        return retch;
+    }
+
+    {
+        int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]);
+        xml_xlate_t const * xlatp = xml_xlate;
+
+        for (;;) {
+            if (  (*ct >= xlatp->xml_len)
+               && (strncmp(pz, xlatp->xml_txt, xlatp->xml_len) == 0)) {
+                *ppz += xlatp->xml_len;
+                *ct  -= xlatp->xml_len;
+                return xlatp->xml_ch;
+            }
+
+            if (--ctr <= 0)
+                break;
+            xlatp++;
+        }
+    }
+    return '&';
+}
+
+
+/*
+ * emit_special_char
+ */
+LOCAL void
+emit_special_char(FILE * fp, int ch)
+{
+    int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]);
+    xml_xlate_t const * xlatp = xml_xlate;
+
+    putc('&', fp);
+    for (;;) {
+        if (ch == xlatp->xml_ch) {
+            fputs(xlatp->xml_txt, fp);
+            return;
+        }
+        if (--ctr <= 0)
+            break;
+        xlatp++;
+    }
+    fprintf(fp, "#x%02X;", (ch & 0xFF));
+}
+
 /*
 /*
  * Local Variables:
  * Local Variables:
  * mode: C
  * mode: C

+ 105 - 10
libopts/numeric.c

@@ -1,11 +1,12 @@
 
 
 /*
 /*
- *  $Id: numeric.c,v 4.13 2007/07/04 21:36:37 bkorb Exp $
- *  Time-stamp:      "2007-07-04 10:21:59 bkorb"
+ *  $Id: numeric.c,v 4.19 2008/11/02 18:51:26 bkorb Exp $
+ *  Time-stamp:      "2008-11-01 14:28:56 bkorb"
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -24,10 +25,74 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
  */
 
 
+/*=export_func  optionShowRange
+ * private:
+ *
+ * what:  
+ * arg:   + tOptions* + pOpts     + program options descriptor  +
+ * arg:   + tOptDesc* + pOptDesc  + the descriptor for this arg +
+ * arg:   + void *    + rng_table + the value range tables      +
+ * arg:   + int       + rng_count + the number of entries       +
+ *
+ * doc:
+ *   Show information about a numeric option with range constraints.
+=*/
+void
+optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct)
+{
+    const struct {long const rmin, rmax;} * rng = rng_table;
+    char const * pz_indent =
+        (pOpts != OPTPROC_EMIT_USAGE) ? "\t" : "\t\t\t\t  ";
+
+    if ((pOpts == OPTPROC_EMIT_USAGE) || (pOpts > OPTPROC_EMIT_LIMIT)) {
+        char const * lie_in_range = zRangeLie;
+
+        if (pOpts > OPTPROC_EMIT_LIMIT) {
+            fprintf(option_usage_fp, zRangeErr,
+                    pOpts->pzProgName, pOD->pz_Name, pOD->optArg.argString);
+            fprintf(option_usage_fp, "The %s option:\n", pOD->pz_Name);
+            lie_in_range = zRangeBadLie;
+            pz_indent = "";
+        }
+
+        if (pOD->fOptState & OPTST_SCALED_NUM)
+            fprintf(option_usage_fp, zRangeScaled, pz_indent);
+
+        if (rng_ct > 1)
+            fprintf(option_usage_fp, lie_in_range, pz_indent);
+        else {
+            fprintf(option_usage_fp, zRangeOnly, pz_indent);
+        }
+
+        for (;;) {
+            if (rng->rmax == LONG_MIN)
+                fprintf(option_usage_fp, zRangeExact, pz_indent, rng->rmin);
+            else if (rng->rmin == LONG_MIN)
+                fprintf(option_usage_fp, zRangeUpto, pz_indent, rng->rmax);
+            else if (rng->rmax == LONG_MAX)
+                fprintf(option_usage_fp, zRangeAbove, pz_indent, rng->rmin);
+            else
+                fprintf(option_usage_fp, zRange, pz_indent, rng->rmin,
+                        rng->rmax);
+
+            if  (--rng_ct <= 0) {
+                fputc('\n', option_usage_fp);
+                break;
+            }
+            fputs(zRangeOr, option_usage_fp);
+            rng++;
+        }
+
+        if (pOpts > OPTPROC_EMIT_LIMIT)
+            pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+    }
+}
+
+
 /*=export_func  optionNumericVal
 /*=export_func  optionNumericVal
  * private:
  * private:
  *
  *
- * what:  Decipher a boolean value
+ * what:  process an option with a numeric value.
  * arg:   + tOptions* + pOpts    + program options descriptor +
  * arg:   + tOptions* + pOpts    + program options descriptor +
  * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
  * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
  *
  *
@@ -35,11 +100,14 @@
  *  Decipher a numeric value.
  *  Decipher a numeric value.
 =*/
 =*/
 void
 void
-optionNumericVal( tOptions* pOpts, tOptDesc* pOD )
+optionNumericVal(tOptions* pOpts, tOptDesc* pOD )
 {
 {
     char* pz;
     char* pz;
     long  val;
     long  val;
 
 
+    if ((pOD->fOptState & OPTST_RESET) != 0)
+        return;
+
     /*
     /*
      *  Numeric options may have a range associated with it.
      *  Numeric options may have a range associated with it.
      *  If it does, the usage procedure requests that it be
      *  If it does, the usage procedure requests that it be
@@ -48,11 +116,29 @@ optionNumericVal( tOptions* pOpts, tOptDesc* pOD )
     if ((pOD == NULL) || (pOD->optArg.argString == NULL))
     if ((pOD == NULL) || (pOD->optArg.argString == NULL))
         return;
         return;
 
 
-    val = strtol( pOD->optArg.argString, &pz, 0 );
-    if (*pz != NUL) {
-        fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString );
-        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
-    }
+    errno = 0;
+    val = strtol(pOD->optArg.argString, &pz, 0);
+    if ((pz == pOD->optArg.argString) || (errno != 0))
+        goto bad_number;
+
+    if ((pOD->fOptState & OPTST_SCALED_NUM) != 0)
+        switch (*(pz++)) {
+        case '\0': pz--; break;
+        case 't':  val *= 1000;
+        case 'g':  val *= 1000;
+        case 'm':  val *= 1000;
+        case 'k':  val *= 1000; break;
+
+        case 'T':  val *= 1024;
+        case 'G':  val *= 1024;
+        case 'M':  val *= 1024;
+        case 'K':  val *= 1024; break;
+
+        default:   goto bad_number;
+        }
+
+    if (*pz != NUL)
+        goto bad_number;
 
 
     if (pOD->fOptState & OPTST_ALLOC_ARG) {
     if (pOD->fOptState & OPTST_ALLOC_ARG) {
         AGFREE(pOD->optArg.argString);
         AGFREE(pOD->optArg.argString);
@@ -60,7 +146,16 @@ optionNumericVal( tOptions* pOpts, tOptDesc* pOD )
     }
     }
 
 
     pOD->optArg.argInt = val;
     pOD->optArg.argInt = val;
+    return;
+
+bad_number:
+    fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString );
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+
+    pOD->optArg.argInt = ~0;
 }
 }
+
 /*
 /*
  * Local Variables:
  * Local Variables:
  * mode: C
  * mode: C

+ 582 - 0
libopts/parse-duration.c

@@ -0,0 +1,582 @@
+/* Parse a time duration and return a seconds count
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruce Korb <bkorb@gnu.org>, 2008.
+
+   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 3 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/>.  */
+
+#include <config.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "parse-duration.h"
+
+#ifndef _
+#define _(_s)  _s
+#endif
+
+#ifndef NUL
+#define NUL '\0'
+#endif
+
+#define cch_t char const
+
+typedef enum {
+  NOTHING_IS_DONE,
+  YEAR_IS_DONE,
+  MONTH_IS_DONE,
+  WEEK_IS_DONE,
+  DAY_IS_DONE,
+  HOUR_IS_DONE,
+  MINUTE_IS_DONE,
+  SECOND_IS_DONE
+} whats_done_t;
+
+#define SEC_PER_MIN     60
+#define SEC_PER_HR      (SEC_PER_MIN * 60)
+#define SEC_PER_DAY     (SEC_PER_HR  * 24)
+#define SEC_PER_WEEK    (SEC_PER_DAY * 7)
+#define SEC_PER_MONTH   (SEC_PER_DAY * 30)
+#define SEC_PER_YEAR    (SEC_PER_DAY * 365)
+
+#define TIME_MAX        0x7FFFFFFF
+
+static unsigned long inline
+str_const_to_ul (cch_t * str, cch_t ** ppz, int base)
+{
+  return strtoul (str, (char **)ppz, base);
+}
+
+static long inline
+str_const_to_l (cch_t * str, cch_t ** ppz, int base)
+{
+  return strtol (str, (char **)ppz, base);
+}
+
+static time_t inline
+scale_n_add (time_t base, time_t val, int scale)
+{
+  if (base == BAD_TIME)
+    {
+      if (errno == 0)
+        errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  if (val > TIME_MAX / scale)
+    {
+      errno = ERANGE;
+      return BAD_TIME;
+    }
+
+  val *= scale;
+  if (base > TIME_MAX - val)
+    {
+      errno = ERANGE;
+      return BAD_TIME;
+    }
+
+  return base + val;
+}
+
+static time_t
+parse_hr_min_sec (time_t start, cch_t * pz)
+{
+  int lpct = 0;
+
+  errno = 0;
+
+  /* For as long as our scanner pointer points to a colon *AND*
+     we've not looped before, then keep looping.  (two iterations max) */
+  while ((*pz == ':') && (lpct++ <= 1))
+    {
+      unsigned long v = str_const_to_ul (pz+1, &pz, 10);
+
+      if (errno != 0)
+        return BAD_TIME;
+
+      start = scale_n_add (v, start, 60);
+
+      if (errno != 0)
+        return BAD_TIME;
+    }
+
+  /* allow for trailing spaces */
+  while (isspace ((unsigned char)*pz))   pz++;
+  if (*pz != NUL)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  return start;
+}
+
+static time_t
+parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale)
+{
+  cch_t * pz = *ppz;
+  time_t val;
+
+  if (base == BAD_TIME)
+    return base;
+
+  errno = 0;
+  val = str_const_to_ul (pz, &pz, 10);
+  if (errno != 0)
+    return BAD_TIME;
+  while (isspace ((unsigned char)*pz))   pz++;
+  if (pz != endp)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  *ppz =  pz;
+  return scale_n_add (base, val, scale);
+}
+
+static time_t
+parse_year_month_day (cch_t * pz, cch_t * ps)
+{
+  time_t res = 0;
+
+  res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR);
+
+  ps = strchr (++pz, '-');
+  if (ps == NULL)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+  res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH);
+
+  pz++;
+  ps = pz + strlen (pz);
+  return parse_scaled_value (res, &pz, ps, SEC_PER_DAY);
+}
+
+static time_t
+parse_yearmonthday (cch_t * in_pz)
+{
+  time_t res = 0;
+  char   buf[8];
+  cch_t * pz;
+
+  if (strlen (in_pz) != 8)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  memcpy (buf, in_pz, 4);
+  buf[4] = NUL;
+  pz = buf;
+  res = parse_scaled_value (0, &pz, buf + 4, SEC_PER_YEAR);
+
+  memcpy (buf, in_pz + 4, 2);
+  buf[2] = NUL;
+  pz =   buf;
+  res = parse_scaled_value (res, &pz, buf + 2, SEC_PER_MONTH);
+
+  memcpy (buf, in_pz + 6, 2);
+  buf[2] = NUL;
+  pz =   buf;
+  return parse_scaled_value (res, &pz, buf + 2, SEC_PER_DAY);
+}
+
+static time_t
+parse_YMWD (cch_t * pz)
+{
+  time_t res = 0;
+  cch_t * ps = strchr (pz, 'Y');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR);
+      pz++;
+    }
+
+  ps = strchr (pz, 'M');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH);
+      pz++;
+    }
+
+  ps = strchr (pz, 'W');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (res, &pz, ps, SEC_PER_WEEK);
+      pz++;
+    }
+
+  ps = strchr (pz, 'D');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (res, &pz, ps, SEC_PER_DAY);
+      pz++;
+    }
+
+  while (isspace ((unsigned char)*pz))   pz++;
+  if (*pz != NUL)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  return res;
+}
+
+static time_t
+parse_hour_minute_second (cch_t * pz, cch_t * ps)
+{
+  time_t res = 0;
+
+  res = parse_scaled_value (0, &pz, ps, SEC_PER_HR);
+
+  ps = strchr (++pz, ':');
+  if (ps == NULL)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN);
+
+  pz++;
+  ps = pz + strlen (pz);
+  return parse_scaled_value (res, &pz, ps, 1);
+}
+
+static time_t
+parse_hourminutesecond (cch_t * in_pz)
+{
+  time_t res = 0;
+  char   buf[4];
+  cch_t * pz;
+
+  if (strlen (in_pz) != 6)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  memcpy (buf, in_pz, 2);
+  buf[2] = NUL;
+  pz = buf;
+  res = parse_scaled_value (0, &pz, buf + 2, SEC_PER_HR);
+
+  memcpy (buf, in_pz + 2, 2);
+  buf[2] = NUL;
+  pz =   buf;
+  res = parse_scaled_value (res, &pz, buf + 2, SEC_PER_MIN);
+
+  memcpy (buf, in_pz + 4, 2);
+  buf[2] = NUL;
+  pz =   buf;
+  return parse_scaled_value (res, &pz, buf + 2, 1);
+}
+
+static time_t
+parse_HMS (cch_t * pz)
+{
+  time_t res = 0;
+  cch_t * ps = strchr (pz, 'H');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (0, &pz, ps, SEC_PER_HR);
+      pz++;
+    }
+
+  ps = strchr (pz, 'M');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN);
+      pz++;
+    }
+
+  ps = strchr (pz, 'S');
+  if (ps != NULL)
+    {
+      res = parse_scaled_value (res, &pz, ps, 1);
+      pz++;
+    }
+
+  while (isspace ((unsigned char)*pz))   pz++;
+  if (*pz != NUL)
+    {
+      errno = EINVAL;
+      return BAD_TIME;
+    }
+
+  return res;
+}
+
+static time_t
+parse_time (cch_t * pz)
+{
+  cch_t * ps;
+  time_t  res = 0;
+
+  /*
+   *  Scan for a hyphen
+   */
+  ps = strchr (pz, ':');
+  if (ps != NULL)
+    {
+      res = parse_hour_minute_second (pz, ps);
+    }
+
+  /*
+   *  Try for a 'H', 'M' or 'S' suffix
+   */
+  else if (ps = strpbrk (pz, "HMS"),
+           ps == NULL)
+    {
+      /* Its a YYYYMMDD format: */
+      res = parse_hourminutesecond (pz);
+    }
+
+  else
+    res = parse_HMS (pz);
+
+  return res;
+}
+
+static char *
+trim(char * pz)
+{
+  /* trim leading white space */
+  while (isspace ((unsigned char)*pz))  pz++;
+
+  /* trim trailing white space */
+  {
+    char * pe = pz + strlen (pz);
+    while ((pe > pz) && isspace ((unsigned char)pe[-1])) pe--;
+    *pe = NUL;
+  }
+
+  return pz;
+}
+
+/*
+ *  Parse the year/months/days of a time period
+ */
+static time_t
+parse_period (cch_t * in_pz)
+{
+  char * pz   = xstrdup (in_pz);
+  char * pT   = strchr (pz, 'T');
+  char * ps;
+  void * fptr = pz;
+  time_t res  = 0;
+
+  if (pT != NUL)
+    {
+      *(pT++) = NUL;
+      pz = trim (pz);
+      pT = trim (pT);
+    }
+
+  /*
+   *  Scan for a hyphen
+   */
+  ps = strchr (pz, '-');
+  if (ps != NULL)
+    {
+      res = parse_year_month_day (pz, ps);
+    }
+
+  /*
+   *  Try for a 'Y', 'M' or 'D' suffix
+   */
+  else if (ps = strpbrk (pz, "YMWD"),
+           ps == NULL)
+    {
+      /* Its a YYYYMMDD format: */
+      res = parse_yearmonthday (pz);
+    }
+
+  else
+    res = parse_YMWD (pz);
+
+  if ((errno == 0) && (pT != NULL))
+    {
+      time_t val = parse_time (pT);
+      res = scale_n_add (res, val, 1);
+    }
+
+  free (fptr);
+  return res;
+}
+
+static time_t
+parse_non_iso8601(cch_t * pz)
+{
+  whats_done_t whatd_we_do = NOTHING_IS_DONE;
+
+  time_t res = 0;
+
+  do  {
+    time_t val;
+
+    errno = 0;
+    val = str_const_to_l (pz, &pz, 10);
+    if (errno != 0)
+      goto bad_time;
+
+    /*  IF we find a colon, then we're going to have a seconds value.
+        We will not loop here any more.  We cannot already have parsed
+        a minute value and if we've parsed an hour value, then the result
+        value has to be less than an hour. */
+    if (*pz == ':')
+      {
+        if (whatd_we_do >= MINUTE_IS_DONE)
+          break;
+
+        val = parse_hr_min_sec (val, pz);
+
+        if ((whatd_we_do == HOUR_IS_DONE) && (val >= SEC_PER_HR))
+          break;
+
+        return scale_n_add (res, val, 1);
+      }
+
+    {
+      unsigned int mult;
+
+      /*  Skip over white space following the number we just parsed. */
+      while (isspace ((unsigned char)*pz))   pz++;
+
+      switch (*pz)
+        {
+        default:  goto bad_time;
+        case NUL:
+          return scale_n_add (res, val, 1);
+
+        case 'y': case 'Y':
+          if (whatd_we_do >= YEAR_IS_DONE)
+            goto bad_time;
+          mult = SEC_PER_YEAR;
+          whatd_we_do = YEAR_IS_DONE;
+          break;
+
+        case 'M':
+          if (whatd_we_do >= MONTH_IS_DONE)
+            goto bad_time;
+          mult = SEC_PER_MONTH;
+          whatd_we_do = MONTH_IS_DONE;
+          break;
+
+        case 'W':
+          if (whatd_we_do >= WEEK_IS_DONE)
+            goto bad_time;
+          mult = SEC_PER_WEEK;
+          whatd_we_do = WEEK_IS_DONE;
+          break;
+
+        case 'd': case 'D':
+          if (whatd_we_do >= DAY_IS_DONE)
+            goto bad_time;
+          mult = SEC_PER_DAY;
+          whatd_we_do = DAY_IS_DONE;
+          break;
+
+        case 'h':
+          if (whatd_we_do >= HOUR_IS_DONE)
+            goto bad_time;
+          mult = SEC_PER_HR;
+          whatd_we_do = HOUR_IS_DONE;
+          break;
+
+        case 'm':
+          if (whatd_we_do >= MINUTE_IS_DONE)
+            goto bad_time;
+          mult = SEC_PER_MIN;
+          whatd_we_do = MINUTE_IS_DONE;
+          break;
+
+        case 's':
+          mult = 1;
+          whatd_we_do = SECOND_IS_DONE;
+          break;
+        }
+
+      res = scale_n_add (res, val, mult);
+
+      while (isspace ((unsigned char)*++pz))   ;
+      if (*pz == NUL)
+        return res;
+
+      if (! isdigit ((unsigned char)*pz))
+        break;
+    }
+
+  } while (whatd_we_do < SECOND_IS_DONE);
+
+ bad_time:
+  errno = EINVAL;
+  return BAD_TIME;
+}
+
+time_t
+parse_duration (char const * pz)
+{
+  time_t res = 0;
+
+  while (isspace ((unsigned char)*pz)) pz++;
+
+  do {
+    if (*pz == 'P')
+      {
+        res = parse_period (pz + 1);
+        if ((errno != 0) || (res == BAD_TIME))
+          break;
+        return res;
+      }
+
+    if (*pz == 'T')
+      {
+        res = parse_time (pz + 1);
+        if ((errno != 0) || (res == BAD_TIME))
+          break;
+        return res;
+      }
+
+    if (! isdigit ((unsigned char)*pz))
+      break;
+
+    res = parse_non_iso8601 (pz);
+    if ((errno == 0) && (res != BAD_TIME))
+      return res;
+
+  } while (0);
+
+  fprintf (stderr, _("Invalid time duration:  %s\n"), pz);
+  if (errno == 0)
+    errno = EINVAL;
+  return BAD_TIME;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "gnu"
+ * indent-tabs-mode: nil
+ * End:
+ * end of parse-duration.c */

+ 82 - 0
libopts/parse-duration.h

@@ -0,0 +1,82 @@
+/* Parse a time duration and return a seconds count
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruce Korb <bkorb@gnu.org>, 2008.
+
+   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 3 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/>.  */
+
+/*
+
+  Readers and users of this function are referred to the ISO-8601
+  specification, with particular attention to "Durations".
+
+  At the time of writing, this worked:
+
+  http://en.wikipedia.org/wiki/ISO_8601#Durations
+
+  The string must start with a 'P', 'T' or a digit.
+
+  ==== if it is a digit
+
+  the string may contain:  NNN d NNN h NNN m NNN s
+  This represents NNN days, NNN hours, NNN minutes and NNN seconds.
+  The embeded white space is optional.
+  These terms must appear in this order.
+  The final "s" is optional.
+  All of the terms ("NNN" plus designator) are optional.
+  Minutes and seconds may optionally be represented as NNN:NNN.
+  Also, hours, minute and seconds may be represented as NNN:NNN:NNN.
+  There is no limitation on the value of any of the terms, except
+  that the final result must fit in a time_t value.
+
+  ==== if it is a 'P' or 'T', please see ISO-8601 for a rigorous definition.
+
+  The 'P' term may be followed by any of three formats:
+    yyyymmdd
+    yy-mm-dd
+    yy Y mm M ww W dd D
+
+  or it may be empty and followed by a 'T'.  The "yyyymmdd" must be eight
+  digits long.  Note:  months are always 30 days and years are always 365
+  days long.  5 years is always 1825, not 1826 or 1827 depending on leap
+  year considerations.  3 months is always 90 days.  There is no consideration
+  for how many days are in the current, next or previous months.
+
+  For the final format:
+  *  Embedded white space is allowed, but it is optional.
+  *  All of the terms are optional.  Any or all-but-one may be omitted.
+  *  The meanings are yy years, mm months, ww weeks and dd days.
+  *  The terms must appear in this order.
+
+  ==== The 'T' term may be followed by any of these formats:
+
+    hhmmss
+    hh:mm:ss
+    hh H mm M ss S
+
+  For the final format:
+  *  Embedded white space is allowed, but it is optional.
+  *  All of the terms are optional.  Any or all-but-one may be omitted.
+  *  The terms must appear in this order.
+
+ */
+#ifndef GNULIB_PARSE_DURATION_H
+#define GNULIB_PARSE_DURATION_H
+
+#include <time.h>
+
+#define BAD_TIME        ((time_t)~0)
+
+extern time_t parse_duration(char const * in_pz);
+
+#endif /* GNULIB_PARSE_DURATION_H */

+ 10 - 3
libopts/pgusage.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: pgusage.c,v 4.14 2007/07/04 21:36:38 bkorb Exp $
- * Time-stamp:      "2007-07-04 11:34:23 bkorb"
+ *  $Id: pgusage.c,v 4.16 2008/07/28 04:51:30 bkorb Exp $
+ * Time-stamp:      "2008-07-27 21:08:42 bkorb"
  *
  *
  *   Automated Options Paged Usage module.
  *   Automated Options Paged Usage module.
  *
  *
@@ -10,7 +10,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -46,6 +47,9 @@ void
 optionPagedUsage( tOptions* pOptions, tOptDesc* pOD )
 optionPagedUsage( tOptions* pOptions, tOptDesc* pOD )
 {
 {
 #if defined(__windows__) && !defined(__CYGWIN__)
 #if defined(__windows__) && !defined(__CYGWIN__)
+    if ((pOD->fOptState & OPTST_RESET) != 0)
+        return;
+
     (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS );
     (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS );
 #else
 #else
     static pid_t     my_pid;
     static pid_t     my_pid;
@@ -59,6 +63,9 @@ optionPagedUsage( tOptions* pOptions, tOptDesc* pOD )
     switch (pagerState) {
     switch (pagerState) {
     case PAGER_STATE_INITIAL:
     case PAGER_STATE_INITIAL:
     {
     {
+        if ((pOD->fOptState & OPTST_RESET) != 0)
+            return;
+
         my_pid  = getpid();
         my_pid  = getpid();
 #ifdef HAVE_SNPRINTF
 #ifdef HAVE_SNPRINTF
         snprintf(zPageUsage, sizeof(zPageUsage), "/tmp/use.%lu", (tAoUL)my_pid);
         snprintf(zPageUsage, sizeof(zPageUsage), "/tmp/use.%lu", (tAoUL)my_pid);

+ 29 - 8
libopts/proto.h

@@ -1,17 +1,20 @@
 /* -*- buffer-read-only: t -*- vi: set ro:
 /* -*- buffer-read-only: t -*- vi: set ro:
  *
  *
  * Prototypes for autoopts
  * Prototypes for autoopts
- * Generated Sat Jul 28 13:01:46 PDT 2007
+ * Generated Wed Dec 31 19:07:16 PST 2008
  */
  */
 #ifndef AUTOOPTS_PROTO_H_GUARD
 #ifndef AUTOOPTS_PROTO_H_GUARD
 #define AUTOOPTS_PROTO_H_GUARD 1
 #define AUTOOPTS_PROTO_H_GUARD 1
+
 #ifndef LOCAL
 #ifndef LOCAL
 #  define LOCAL extern
 #  define LOCAL extern
 #  define REDEF_LOCAL 1
 #  define REDEF_LOCAL 1
 #else
 #else
 #  undef  REDEF_LOCAL
 #  undef  REDEF_LOCAL
 #endif
 #endif
-/*\n *  Extracted from autoopts.c\n */
+/*
+ *  Extracted from autoopts.c
+ */
 LOCAL void *
 LOCAL void *
 ao_malloc( size_t sz );
 ao_malloc( size_t sz );
 
 
@@ -39,7 +42,9 @@ doImmediateOpts( tOptions* pOpts );
 LOCAL tSuccess
 LOCAL tSuccess
 doRegularOpts( tOptions* pOpts );
 doRegularOpts( tOptions* pOpts );
 
 
-/*\n *  Extracted from configfile.c\n */
+/*
+ *  Extracted from configfile.c
+ */
 LOCAL void
 LOCAL void
 internalFileLoad( tOptions* pOpts );
 internalFileLoad( tOptions* pOpts );
 
 
@@ -53,14 +58,18 @@ parseAttributes(
 LOCAL tSuccess
 LOCAL tSuccess
 validateOptionsStruct( tOptions* pOpts, char const* pzProgram );
 validateOptionsStruct( tOptions* pOpts, char const* pzProgram );
 
 
-/*\n *  Extracted from environment.c\n */
+/*
+ *  Extracted from environment.c
+ */
 LOCAL void
 LOCAL void
 doPrognameEnv( tOptions* pOpts, teEnvPresetType type );
 doPrognameEnv( tOptions* pOpts, teEnvPresetType type );
 
 
 LOCAL void
 LOCAL void
 doEnvPresets( tOptions* pOpts, teEnvPresetType type );
 doEnvPresets( tOptions* pOpts, teEnvPresetType type );
 
 
-/*\n *  Extracted from load.c\n */
+/*
+ *  Extracted from load.c
+ */
 LOCAL void
 LOCAL void
 mungeString( char* pzTxt, tOptionLoadMode mode );
 mungeString( char* pzTxt, tOptionLoadMode mode );
 
 
@@ -72,15 +81,27 @@ loadOptionLine(
     tDirection  direction,
     tDirection  direction,
     tOptionLoadMode   load_mode );
     tOptionLoadMode   load_mode );
 
 
-/*\n *  Extracted from nested.c\n */
+/*
+ *  Extracted from nested.c
+ */
 LOCAL tOptionValue*
 LOCAL tOptionValue*
 optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen);
 optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen);
 
 
-/*\n *  Extracted from sort.c\n */
+LOCAL int
+get_special_char(char const ** ppz, int * ct);
+
+LOCAL void
+emit_special_char(FILE * fp, int ch);
+
+/*
+ *  Extracted from sort.c
+ */
 LOCAL void
 LOCAL void
 optionSort( tOptions* pOpts );
 optionSort( tOptions* pOpts );
 
 
-/*\n *  Extracted from stack.c\n */
+/*
+ *  Extracted from stack.c
+ */
 LOCAL void
 LOCAL void
 addArgListEntry( void** ppAL, void* entry );
 addArgListEntry( void** ppAL, void* entry );
 
 

+ 26 - 17
libopts/putshell.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: putshell.c,v 4.20 2007/07/04 21:36:38 bkorb Exp $
- * Time-stamp:      "2007-07-04 11:34:33 bkorb"
+ *  $Id: putshell.c,v 4.25 2008/07/28 04:51:30 bkorb Exp $
+ * Time-stamp:      "2008-07-27 12:14:38 bkorb"
  *
  *
  *  This module will interpret the options set in the tOptions
  *  This module will interpret the options set in the tOptions
  *  structure and print them to standard out in a fashion that
  *  structure and print them to standard out in a fashion that
@@ -9,7 +9,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -29,7 +30,7 @@
  */
  */
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 putQuotedStr( tCC* pzStr );
 putQuotedStr( tCC* pzStr );
 /* = = = END-STATIC-FORWARD = = = */
 /* = = = END-STATIC-FORWARD = = = */
@@ -158,7 +159,7 @@ optionPutShell( tOptions* pOpts )
             printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
             printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
                     (int)(uintptr_t)(pOD->optCookie) );
                     (int)(uintptr_t)(pOD->optCookie) );
             pOD->optCookie = (void*)(uintptr_t)~0UL;
             pOD->optCookie = (void*)(uintptr_t)~0UL;
-            (*(pOD->pOptProc))( (tOptions*)2UL, pOD );
+            (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
 
 
             /*
             /*
              *  We are building the typeset list.  The list returned starts with
              *  We are building the typeset list.  The list returned starts with
@@ -167,15 +168,15 @@ optionPutShell( tOptions* pOpts )
             pz = pOD->optArg.argString + 7;
             pz = pOD->optArg.argString + 7;
             while (*pz != NUL) {
             while (*pz != NUL) {
                 printf( "typeset -x -i %s_", pOD->pz_NAME );
                 printf( "typeset -x -i %s_", pOD->pz_NAME );
-                pz += strspn( pz, " +\t\n\f" );
+                while (IS_PLUS_N_SPACE_CHAR(*pz))  pz++;
+
                 for (;;) {
                 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 );
+                  int ch = *(pz++);
+                       if (IS_LOWER_CASE_CHAR(ch))   fputc(toupper(ch), stdout);
+                  else if (IS_UPPER_CASE_CHAR(ch))   fputc(ch, stdout);
+                  else if (IS_PLUS_N_SPACE_CHAR(ch)) goto name_done;
+                  else if (ch == NUL)        { pz--; goto name_done; }
+                  else fputc( '_', stdout );
                 } name_done:;
                 } name_done:;
                 printf( "=%1$lu # 0x%1$lX\n", (unsigned long)val );
                 printf( "=%1$lu # 0x%1$lX\n", (unsigned long)val );
                 val <<= 1;
                 val <<= 1;
@@ -244,11 +245,19 @@ optionPutShell( tOptions* pOpts )
          *  to emit the value corresponding to the "optArg" number.
          *  to emit the value corresponding to the "optArg" number.
          */
          */
         else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_ENUMERATION) {
         else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_ENUMERATION) {
+            uintptr_t e_val = pOD->optArg.argEnum;
             printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME );
             printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME );
-            fputc( '\'', stdout );
-            (*(pOD->pOptProc))( (tOptions*)1UL, pOD );
-            fputc( '\'', stdout );
-            printf( zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME );
+
+            /*
+             *  Convert value to string, print that and restore numeric value.
+             */
+            (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
+            printf("'%s'", pOD->optArg.argString);
+            if (pOD->fOptState & OPTST_ALLOC_ARG)
+                AGFREE(pOD->optArg.argString);
+            pOD->optArg.argEnum = e_val;
+
+            printf(zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME);
         }
         }
 
 
         /*
         /*

+ 128 - 0
libopts/reset.c

@@ -0,0 +1,128 @@
+
+/*
+ *  $Id: reset.c,v 4.2 2008/08/02 22:50:30 bkorb Exp $
+ *  Time-stamp:      "2008-08-02 12:25:18 bkorb"
+ *
+ *  This file is part of AutoOpts, a companion to AutoGen.
+ *  AutoOpts is free software.
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *
+ *  AutoOpts is available under any one of two licenses.  The license
+ *  in use must be one of these two and the choice is under the control
+ *  of the user of the license.
+ *
+ *   The GNU Lesser General Public License, version 3 or later
+ *      See the files "COPYING.lgplv3" and "COPYING.gplv3"
+ *
+ *   The Modified Berkeley Software Distribution License
+ *      See the file "COPYING.mbsd"
+ *
+ *  These files have the following md5sums:
+ *
+ *  239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3
+ *  fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3
+ *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+ */
+
+static void
+optionReset( tOptions* pOpts, tOptDesc* pOD )
+{
+    pOD->fOptState &= OPTST_PERSISTENT_MASK;
+    pOD->fOptState |= OPTST_RESET;
+    if (pOD->pOptProc != NULL)
+        pOD->pOptProc(pOpts, pOD);
+    pOD->optArg.argString =
+        pOpts->originalOptArgArray[ pOD->optIndex ].argString;
+    pOD->optCookie = pOpts->originalOptArgCookie[ pOD->optIndex ];
+    pOD->fOptState &= OPTST_PERSISTENT_MASK;
+}
+
+
+static void
+optionResetEverything(tOptions * pOpts)
+{
+    tOptDesc * pOD = pOpts->pOptDesc;
+    int        ct  = pOpts->presetOptCt;
+
+    for (;;) {
+        optionReset(pOpts, pOD);
+
+        if (--ct <= 0)
+            break;
+        pOD++;
+    }
+}
+
+
+/*=export_func  optionResetOpt
+ * private:
+ *
+ * what:  Reset the value of an option
+ * arg:   + tOptions* + pOpts    + program options descriptor  +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  This code will cause another option to be reset to its initial state.
+ *  For example, --reset=foo will cause the --foo option to be reset.
+=*/
+void
+optionResetOpt( tOptions* pOpts, tOptDesc* pOD )
+{
+    static ag_bool reset_active = AG_FALSE;
+
+    tOptState opt_state = OPTSTATE_INITIALIZER(DEFINED);
+    char const * pzArg = pOD->optArg.argString;
+    tSuccess     succ;
+
+    if (reset_active)
+        return;
+
+    if (  (! HAS_originalOptArgArray(pOpts))
+       || (pOpts->originalOptArgCookie == NULL)) {
+        fputs(zResetNotConfig, stderr);
+        _exit(EX_SOFTWARE);
+    }
+
+    if ((pzArg == NULL) || (*pzArg == NUL)) {
+        fputs(zNoResetArg, stderr);
+        pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+    }
+
+    reset_active = AG_TRUE;
+
+    if (pzArg[1] == NUL) {
+        if (*pzArg == '*') {
+            optionResetEverything(pOpts);
+            reset_active = AG_FALSE;
+            return;
+        }
+
+        succ = shortOptionFind(pOpts, (tAoUC)*pzArg, &opt_state);
+        if (! SUCCESSFUL(succ)) {
+            fprintf(stderr, zIllOptChr, pOpts->pzProgPath, *pzArg);
+            pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+        }
+    } else {
+        succ = longOptionFind(pOpts, (char *)pzArg, &opt_state);
+        if (! SUCCESSFUL(succ)) {
+            fprintf(stderr, zIllOptStr, pOpts->pzProgPath, pzArg);
+            pOpts->pUsageProc(pOpts, EXIT_FAILURE);
+        }
+    }
+
+    /*
+     *  We've found the indicated option.  Turn off all non-persistent
+     *  flags because we're forcing the option back to its initialized state.
+     *  Call any callout procedure to handle whatever it needs to.
+     *  Finally, clear the reset flag, too.
+     */
+    optionReset(pOpts, opt_state.pOD);
+    reset_active = AG_FALSE;
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/reset.c */

+ 3 - 2
libopts/restore.c

@@ -1,6 +1,6 @@
 
 
 /*
 /*
- *  restore.c  $Id: restore.c,v 4.12 2007/07/04 21:36:38 bkorb Exp $
+ *  restore.c  $Id: restore.c,v 4.13 2008/01/23 00:36:05 bkorb Exp $
  * Time-stamp:      "2007-07-04 11:34:40 bkorb"
  * Time-stamp:      "2007-07-04 11:34:40 bkorb"
  *
  *
  *  This module's routines will save the current option state to memory
  *  This module's routines will save the current option state to memory
@@ -9,7 +9,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control

+ 388 - 86
libopts/save.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  save.c  $Id: save.c,v 4.20 2007/07/04 21:36:38 bkorb Exp $
- * Time-stamp:      "2007-07-04 11:34:46 bkorb"
+ *  save.c  $Id: save.c,v 4.28 2008/09/28 23:23:36 bkorb Exp $
+ * Time-stamp:      "2008-09-23 14:24:58 bkorb"
  *
  *
  *  This module's routines will take the currently set options and
  *  This module's routines will take the currently set options and
  *  store them into an ".rc" file for re-interpretation the next
  *  store them into an ".rc" file for re-interpretation the next
@@ -9,7 +9,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -28,10 +29,11 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
  */
 
 
-tSCC  zWarn[] = "%s WARNING:  cannot save options - ";
+static char const  zWarn[] = "%s WARNING:  cannot save options - ";
+static char const close_xml[] = "</%s>\n";
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static tCC*
 static tCC*
 findDirName( tOptions* pOpts, int* p_free );
 findDirName( tOptions* pOpts, int* p_free );
 
 
@@ -43,6 +45,36 @@ printEntry(
     FILE *     fp,
     FILE *     fp,
     tOptDesc * p,
     tOptDesc * p,
     tCC*       pzLA );
     tCC*       pzLA );
+
+static void
+print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp);
+
+static void
+print_a_string(FILE * fp, char const * name, char const * pz);
+
+static void
+printValueList(FILE * fp, char const * name, tArgList * al);
+
+static void
+printHierarchy(FILE * fp, tOptDesc * p);
+
+static FILE *
+openSaveFile( tOptions* pOpts );
+
+static void
+printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD);
+
+static void
+printStringArg(FILE * fp, tOptDesc * pOD);
+
+static void
+printEnumArg(FILE * fp, tOptDesc * pOD);
+
+static void
+printSetMemberArg(FILE * fp, tOptDesc * pOD);
+
+static void
+printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts);
 /* = = = END-STATIC-FORWARD = = = */
 /* = = = END-STATIC-FORWARD = = = */
 
 
 static tCC*
 static tCC*
@@ -308,39 +340,194 @@ printEntry(
 }
 }
 
 
 
 
-/*=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 )
+static void
+print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
+{
+    static char const bool_atr[]  = "<%1$s type=boolean>%2$s</%1$s>\n";
+    static char const numb_atr[]  = "<%1$s type=integer>0x%2$lX</%1$s>\n";
+    static char const type_atr[]  = "<%s type=%s>";
+    static char const null_atr[]  = "<%s/>\n";
+
+    while (--depth >= 0)
+        putc(' ', fp), putc(' ', fp);
+
+    switch (ovp->valType) {
+    default:
+    case OPARG_TYPE_NONE:
+        fprintf(fp, null_atr, ovp->pzName);
+        break;
+
+    case OPARG_TYPE_STRING:
+        print_a_string(fp, ovp->pzName, ovp->v.strVal);
+        break;
+
+    case OPARG_TYPE_ENUMERATION:
+    case OPARG_TYPE_MEMBERSHIP:
+        if (pOD != NULL) {
+            tAoUI     opt_state = pOD->fOptState;
+            uintptr_t val = pOD->optArg.argEnum;
+            char const * typ = (ovp->valType == OPARG_TYPE_ENUMERATION)
+                ? "keyword" : "set-membership";
+
+            fprintf(fp, type_atr, ovp->pzName, typ);
+
+            /*
+             *  This is a magic incantation that will convert the
+             *  bit flag values back into a string suitable for printing.
+             */
+            (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD );
+            if (pOD->optArg.argString != NULL) {
+                fputs(pOD->optArg.argString, fp);
+
+                if (ovp->valType != OPARG_TYPE_ENUMERATION) {
+                    /*
+                     *  set membership strings get allocated
+                     */
+                    AGFREE( (void*)pOD->optArg.argString );
+                }
+            }
+
+            pOD->optArg.argEnum = val;
+            pOD->fOptState = opt_state;
+            fprintf(fp, close_xml, ovp->pzName);
+            break;
+        }
+        /* FALLTHROUGH */
+
+    case OPARG_TYPE_NUMERIC:
+        fprintf(fp, numb_atr, ovp->pzName, ovp->v.longVal);
+        break;
+
+    case OPARG_TYPE_BOOLEAN:
+        fprintf(fp, bool_atr, ovp->pzName,
+                ovp->v.boolVal ? "true" : "false");
+        break;
+
+    case OPARG_TYPE_HIERARCHY:
+        printValueList(fp, ovp->pzName, ovp->v.nestVal);
+        break;
+    }
+}
+
+
+static void
+print_a_string(FILE * fp, char const * name, char const * pz)
+{
+    static char const open_atr[]  = "<%s>";
+
+    fprintf(fp, open_atr, name);
+    for (;;) {
+        int ch = ((int)*(pz++)) & 0xFF;
+
+        switch (ch) {
+        case NUL: goto string_done;
+
+        case '&':
+        case '<':
+        case '>':
+#if __GNUC__ >= 4
+        case 1 ... (' ' - 1):
+        case ('~' + 1) ... 0xFF:
+#endif
+            emit_special_char(fp, ch);
+            break;
+
+        default:
+#if __GNUC__ < 4
+            if (  ((ch >= 1) && (ch <= (' ' - 1)))
+               || ((ch >= ('~' + 1)) && (ch <= 0xFF)) ) {
+                emit_special_char(fp, ch);
+                break;
+            }
+#endif
+            putc(ch, fp);
+        }
+    } string_done:;
+    fprintf(fp, close_xml, name);
+}
+
+
+static void
+printValueList(FILE * fp, char const * name, tArgList * al)
+{
+    static int depth = 1;
+
+    int sp_ct;
+    int opt_ct;
+    void ** opt_list;
+
+    if (al == NULL)
+        return;
+    opt_ct   = al->useCt;
+    opt_list = (void **)al->apzArgs;
+
+    if (opt_ct <= 0) {
+        fprintf(fp, "<%s/>\n", name);
+        return;
+    }
+
+    fprintf(fp, "<%s type=nested>\n", name);
+
+    depth++;
+    while (--opt_ct >= 0) {
+        tOptionValue const * ovp = *(opt_list++);
+
+        print_a_value(fp, depth, NULL, ovp);
+    }
+    depth--;
+
+    for (sp_ct = depth; --sp_ct >= 0;)
+        putc(' ', fp), putc(' ', fp);
+    fprintf(fp, "</%s>\n", name);
+}
+
+
+static void
+printHierarchy(FILE * fp, tOptDesc * p)
+{
+    int opt_ct;
+    tArgList * al = p->optCookie;
+    void ** opt_list;
+
+    if (al == NULL)
+        return;
+
+    opt_ct   = al->useCt;
+    opt_list = (void **)al->apzArgs;
+
+    if (opt_ct <= 0)
+        return;
+
+    do  {
+        tOptionValue const * base = *(opt_list++);
+        tOptionValue const * ovp = optionGetValue(base, NULL);
+
+        if (ovp == NULL)
+            continue;
+
+        fprintf(fp, "<%s type=nested>\n", p->pz_Name);
+
+        do  {
+            print_a_value(fp, 1, p, ovp);
+
+        } while (ovp = optionNextValue(base, ovp),
+                 ovp != NULL);
+
+        fprintf(fp, "</%s>\n", p->pz_Name);
+    } while (--opt_ct > 0);
+}
+
+
+static FILE *
+openSaveFile( tOptions* pOpts )
 {
 {
-    tOptDesc* pOD;
-    int       ct;
     FILE*     fp;
     FILE*     fp;
 
 
     {
     {
         int   free_name = 0;
         int   free_name = 0;
         tCC*  pzFName = findFileName( pOpts, &free_name );
         tCC*  pzFName = findFileName( pOpts, &free_name );
         if (pzFName == NULL)
         if (pzFName == NULL)
-            return;
+            return NULL;
 
 
         fp = fopen( pzFName, "w" FOPEN_BINARY_FLAG );
         fp = fopen( pzFName, "w" FOPEN_BINARY_FLAG );
         if (fp == NULL) {
         if (fp == NULL) {
@@ -348,7 +535,7 @@ optionSaveFile( tOptions* pOpts )
             fprintf( stderr, zNoCreat, errno, strerror( errno ), pzFName );
             fprintf( stderr, zNoCreat, errno, strerror( errno ), pzFName );
             if (free_name)
             if (free_name)
                 AGFREE((void*) pzFName );
                 AGFREE((void*) pzFName );
-            return;
+            return fp;
         }
         }
 
 
         if (free_name)
         if (free_name)
@@ -376,13 +563,156 @@ optionSaveFile( tOptions* pOpts )
 #endif
 #endif
     }
     }
 
 
+    return fp;
+}
+
+static void
+printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD)
+{
+    /*
+     * The aliased to argument indicates whether or not the option
+     * is "disabled".  However, the original option has the name
+     * string, so we get that there, not with "p".
+     */
+    char const * pznm =
+        (DISABLED_OPT( p )) ? pOD->pz_DisableName : pOD->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 = pOD->pz_Name;
+
+    fprintf(fp, "%s\n", pznm);
+}
+
+static void
+printStringArg(FILE * fp, tOptDesc * pOD)
+{
+    if (pOD->fOptState & OPTST_STACKED) {
+        tArgList*  pAL = (tArgList*)pOD->optCookie;
+        int        uct = pAL->useCt;
+        tCC**      ppz = pAL->apzArgs;
+
+        /*
+         *  un-disable multiple copies of disabled options.
+         */
+        if (uct > 1)
+            pOD->fOptState &= ~OPTST_DISABLED;
+
+        while (uct-- > 0)
+            printEntry( fp, pOD, *(ppz++) );
+    } else {
+        printEntry( fp, pOD, pOD->optArg.argString );
+    }
+}
+
+static void
+printEnumArg(FILE * fp, tOptDesc * pOD)
+{
+    uintptr_t val = pOD->optArg.argEnum;
+
+    /*
+     *  This is a magic incantation that will convert the
+     *  bit flag values back into a string suitable for printing.
+     */
+    (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
+    printEntry( fp, pOD, (void*)(pOD->optArg.argString));
+
+    pOD->optArg.argEnum = val;
+}
+
+static void
+printSetMemberArg(FILE * fp, tOptDesc * pOD)
+{
+    uintptr_t val = pOD->optArg.argEnum;
+
+    /*
+     *  This is a magic incantation that will convert the
+     *  bit flag values back into a string suitable for printing.
+     */
+    (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);
+    printEntry( fp, pOD, (void*)(pOD->optArg.argString));
+
+    if (pOD->optArg.argString != NULL) {
+        /*
+         *  set membership strings get allocated
+         */
+        AGFREE( (void*)pOD->optArg.argString );
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+
+    pOD->optArg.argEnum = val;
+}
+
+static void
+printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts)
+{
+    /*
+     *  If the cookie is not NULL, then it has the file name, period.
+     *  Otherwise, if we have a non-NULL string argument, then....
+     */
+    if (pOD->optCookie != NULL)
+        printEntry(fp, pOD, pOD->optCookie);
+
+    else if (HAS_originalOptArgArray(pOpts)) {
+        char const * orig =
+            pOpts->originalOptArgArray[pOD->optIndex].argString;
+
+        if (pOD->optArg.argString == orig)
+            return;
+
+        printEntry(fp, pOD, pOD->optArg.argString);
+    }
+}
+
+
+/*=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.
+ *
+ * The recommend usage is as follows:
+ * @example
+ *    optionProcess(&progOptions, argc, argv);
+ *    if (i_want_a_non_standard_place_for_this)
+ *        SET_OPT_SAVE_OPTS("myfilename");
+ *    optionSaveFile(&progOptions);
+ * @end example
+ *
+ * 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 = openSaveFile(pOpts);
+
+    if (fp == NULL)
+        return;
+
     /*
     /*
      *  FOR each of the defined options, ...
      *  FOR each of the defined options, ...
      */
      */
     ct  = pOpts->presetOptCt;
     ct  = pOpts->presetOptCt;
     pOD = pOpts->pOptDesc;
     pOD = pOpts->pOptDesc;
     do  {
     do  {
-        int arg_state;
         tOptDesc*  p;
         tOptDesc*  p;
 
 
         /*
         /*
@@ -390,89 +720,61 @@ optionSaveFile( tOptions* pOpts )
          *     OR it does not take an initialization value
          *     OR it does not take an initialization value
          *     OR it is equivalenced to another option
          *     OR it is equivalenced to another option
          *  THEN continue (ignore it)
          *  THEN continue (ignore it)
+         *
+         *  Equivalenced options get picked up when the equivalenced-to
+         *  option is processed.
          */
          */
         if (UNUSED_OPT( pOD ))
         if (UNUSED_OPT( pOD ))
             continue;
             continue;
 
 
-        if ((pOD->fOptState & (OPTST_NO_INIT|OPTST_DOCUMENT|OPTST_OMITTED))
-            != 0)
+        if ((pOD->fOptState & OPTST_DO_NOT_SAVE_MASK) != 0)
             continue;
             continue;
 
 
         if (  (pOD->optEquivIndex != NO_EQUIVALENT)
         if (  (pOD->optEquivIndex != NO_EQUIVALENT)
-              && (pOD->optEquivIndex != pOD->optIndex))
+           && (pOD->optEquivIndex != pOD->optIndex))
             continue;
             continue;
 
 
         /*
         /*
-         *  Set a temporary pointer to the real option description
-         *  (i.e. account for equivalencing)
+         *  The option argument data are found at the equivalenced-to option,
+         *  but the actual option argument type comes from the original
+         *  option descriptor.  Be careful!
          */
          */
         p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0)
         p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0)
             ? (pOpts->pOptDesc + pOD->optActualIndex) : pOD;
             ? (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) {
-            fprintf( fp, "%s\n",
-                     (DISABLED_OPT( p )) ? p->pz_DisableName : p->pz_Name );
-            continue;
-        }
+        switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_NONE:
+            printNoArgOpt(fp, p, pOD);
+            break;
 
 
-        arg_state = OPTST_GET_ARGTYPE(p->fOptState);
-        switch (arg_state) {
-        case 0:
         case OPARG_TYPE_NUMERIC:
         case OPARG_TYPE_NUMERIC:
             printEntry( fp, p, (void*)(p->optArg.argInt));
             printEntry( fp, p, (void*)(p->optArg.argInt));
             break;
             break;
 
 
         case OPARG_TYPE_STRING:
         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 );
-            }
+            printStringArg(fp, p);
             break;
             break;
 
 
         case OPARG_TYPE_ENUMERATION:
         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;
-            }
+            printEnumArg(fp, p);
+            break;
 
 
-            p->optArg.argEnum = val;
+        case OPARG_TYPE_MEMBERSHIP:
+            printSetMemberArg(fp, p);
             break;
             break;
-        }
 
 
         case OPARG_TYPE_BOOLEAN:
         case OPARG_TYPE_BOOLEAN:
             printEntry( fp, p, p->optArg.argBool ? "true" : "false" );
             printEntry( fp, p, p->optArg.argBool ? "true" : "false" );
             break;
             break;
 
 
+        case OPARG_TYPE_HIERARCHY:
+            printHierarchy(fp, p);
+            break;
+
+        case OPARG_TYPE_FILE:
+            printFileArg(fp, p, pOpts);
+            break;
+
         default:
         default:
             break; /* cannot handle - skip it */
             break; /* cannot handle - skip it */
         }
         }

+ 4 - 3
libopts/sort.c

@@ -1,13 +1,14 @@
 
 
 /*
 /*
- *  sort.c  $Id: sort.c,v 4.12 2007/07/04 21:36:38 bkorb Exp $
+ *  sort.c  $Id: sort.c,v 4.14 2008/06/14 22:24:22 bkorb Exp $
  * Time-stamp:      "2007-07-04 11:34:52 bkorb"
  * Time-stamp:      "2007-07-04 11:34:52 bkorb"
  *
  *
  *  This module implements argument sorting.
  *  This module implements argument sorting.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -27,7 +28,7 @@
  */
  */
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static tSuccess
 static tSuccess
 mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
 mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
                char** ppzOpts, int* pOptsIdx );
                char** ppzOpts, int* pOptsIdx );

+ 27 - 8
libopts/stack.c

@@ -1,15 +1,16 @@
 
 
 /*
 /*
  *  stack.c
  *  stack.c
- *  $Id: stack.c,v 4.15 2007/07/04 21:36:38 bkorb Exp $
- *  Time-stamp:      "2007-07-04 11:34:57 bkorb"
+ *  $Id: stack.c,v 4.17 2008/08/02 16:10:07 bkorb Exp $
+ *  Time-stamp:      "2008-07-30 16:56:32 bkorb"
  *
  *
  *  This is a special option processing routine that will save the
  *  This is a special option processing routine that will save the
  *  argument to an option in a FIFO queue.
  *  argument to an option in a FIFO queue.
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -49,7 +50,12 @@ optionUnstackArg(
 {
 {
     int       res;
     int       res;
 
 
-    tArgList* pAL = (tArgList*)pOptDesc->optCookie;
+    tArgList* pAL;
+
+    if ((pOptDesc->fOptState & OPTST_RESET) != 0)
+        return;
+    pAL = (tArgList*)pOptDesc->optCookie;
+
     /*
     /*
      *  IF we don't have any stacked options,
      *  IF we don't have any stacked options,
      *  THEN indicate that we don't have any of these options
      *  THEN indicate that we don't have any of these options
@@ -231,11 +237,24 @@ optionStackArg(
 {
 {
     char * pz;
     char * pz;
 
 
-    if (pOD->optArg.argString == NULL)
-        return;
+    if ((pOD->fOptState & OPTST_RESET) != 0) {
+        tArgList* pAL = (void*)pOD->optCookie;
+        int ix;
+        if (pAL == NULL)
+            return;
+
+        ix = pAL->useCt;
+        while (--ix >= 0)
+            AGFREE(pAL->apzArgs[ix]);
+        AGFREE(pAL);
 
 
-    AGDUPSTR(pz, pOD->optArg.argString, "stack arg");
-    addArgListEntry( &(pOD->optCookie), (void*)pz );
+    } else {
+        if (pOD->optArg.argString == NULL)
+            return;
+
+        AGDUPSTR(pz, pOD->optArg.argString, "stack arg");
+        addArgListEntry( &(pOD->optCookie), (void*)pz );
+    }
 }
 }
 /*
 /*
  * Local Variables:
  * Local Variables:

+ 6 - 3
libopts/streqvcmp.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  $Id: streqvcmp.c,v 4.12 2007/07/04 21:36:38 bkorb Exp $
- * Time-stamp:      "2007-07-04 11:35:12 bkorb"
+ *  $Id: streqvcmp.c,v 4.14 2008/12/29 06:14:25 bkorb Exp $
+ * Time-stamp:      "2008-12-26 10:15:46 bkorb"
  *
  *
  *  String Equivalence Comparison
  *  String Equivalence Comparison
  *
  *
@@ -12,7 +12,8 @@
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -245,6 +246,8 @@ strequate( char const* s )
  * This function name is mapped to option_strtransform so as to not conflict
  * This function name is mapped to option_strtransform so as to not conflict
  * with the POSIX name space.
  * with the POSIX name space.
  *
  *
+ * The source and destination may be the same.
+ *
  * err:  none.
  * err:  none.
 =*/
 =*/
 void
 void

+ 3 - 2
libopts/text_mmap.c

@@ -1,11 +1,12 @@
 /*
 /*
- * $Id: text_mmap.c,v 4.17 2007/07/04 21:36:38 bkorb Exp $
+ * $Id: text_mmap.c,v 4.18 2008/01/23 00:36:05 bkorb Exp $
  *
  *
  * Time-stamp:      "2007-07-04 11:35:49 bkorb"
  * Time-stamp:      "2007-07-04 11:35:49 bkorb"
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control

+ 89 - 0
libopts/time.c

@@ -0,0 +1,89 @@
+
+/*
+ *  $Id: time.c,v 4.2 2008/11/16 23:56:59 bkorb Exp $
+ *  Time-stamp:      "2008-11-16 14:51:48 bkorb"
+ *
+ *  This file is part of AutoOpts, a companion to AutoGen.
+ *  AutoOpts is free software.
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *
+ *  AutoOpts is available under any one of two licenses.  The license
+ *  in use must be one of these two and the choice is under the control
+ *  of the user of the license.
+ *
+ *   The GNU Lesser General Public License, version 3 or later
+ *      See the files "COPYING.lgplv3" and "COPYING.gplv3"
+ *
+ *   The Modified Berkeley Software Distribution License
+ *      See the file "COPYING.mbsd"
+ *
+ *  These files have the following md5sums:
+ *
+ *  239588c55c22c60ffe159946a760a33e pkg/libopts/COPYING.gplv3
+ *  fa82ca978890795162346e661b47161a pkg/libopts/COPYING.lgplv3
+ *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
+ */
+
+#ifndef HAVE_PARSE_DURATION
+#include <time.h>
+
+static inline char *
+ao_xstrdup(char const * pz)
+{
+    char * str;
+    AGDUPSTR(str, pz, "time val str");
+    return str;
+}
+
+#define xstrdup(_s) ao_xstrdup(_s)
+
+#include "parse-duration.c"
+
+#undef xstrdup
+#endif
+
+/*=export_func  optionTimeVal
+ * private:
+ *
+ * what:  process an option with a time value.
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Decipher a time duration value.
+=*/
+void
+optionTimeVal(tOptions* pOpts, tOptDesc* pOD )
+{
+    long  val;
+
+    if ((pOD->fOptState & OPTST_RESET) != 0)
+        return;
+
+    val = parse_duration(pOD->optArg.argString);
+    if (errno != 0)
+        goto bad_time;
+
+    if (pOD->fOptState & OPTST_ALLOC_ARG) {
+        AGFREE(pOD->optArg.argString);
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+
+    pOD->optArg.argInt = val;
+    return;
+
+bad_time:
+    fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString );
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+
+    pOD->optArg.argInt = ~0;
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/numeric.c */

+ 11 - 11
libopts/tokenize.c

@@ -1,10 +1,11 @@
 /*
 /*
  *  This file defines the string_tokenize interface
  *  This file defines the string_tokenize interface
- * Time-stamp:      "2007-07-04 10:09:43 bkorb"
+ * Time-stamp:      "2007-11-12 20:40:36 bkorb"
  *
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -23,7 +24,6 @@
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
  */
  */
 
 
-#include <ctype.h>
 #include <errno.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stdlib.h>
 
 
@@ -31,7 +31,7 @@
 #define ch_t   unsigned char
 #define ch_t   unsigned char
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 copy_cooked( ch_t** ppDest, char const ** ppSrc );
 copy_cooked( ch_t** ppDest, char const ** ppSrc );
 
 
@@ -192,7 +192,7 @@ ao_string_tokenize( char const* str )
      *  Trim leading white space.  Use "ENOENT" and a NULL return to indicate
      *  Trim leading white space.  Use "ENOENT" and a NULL return to indicate
      *  an empty string was passed.
      *  an empty string was passed.
      */
      */
-    while (isspace( (ch_t)*str ))  str++;
+    while (IS_WHITESPACE_CHAR(*str))  str++;
     if (*str == NUL) {
     if (*str == NUL) {
     bogus_str:
     bogus_str:
         errno = ENOENT;
         errno = ENOENT;
@@ -209,9 +209,9 @@ ao_string_tokenize( char const* str )
 
 
         do {
         do {
             max_token_ct++;
             max_token_ct++;
-            while (! isspace( *++pz ))
+            while (! IS_WHITESPACE_CHAR(*++pz))
                 if (*pz == NUL) goto found_nul;
                 if (*pz == NUL) goto found_nul;
-            while (isspace( *pz ))  pz++;
+            while (IS_WHITESPACE_CHAR(*pz))  pz++;
         } while (*pz != NUL);
         } while (*pz != NUL);
 
 
     found_nul:
     found_nul:
@@ -235,9 +235,9 @@ ao_string_tokenize( char const* str )
             res->tkn_list[ res->tkn_ct++ ] = pzDest;
             res->tkn_list[ res->tkn_ct++ ] = pzDest;
             for (;;) {
             for (;;) {
                 int ch = (ch_t)*str;
                 int ch = (ch_t)*str;
-                if (isspace( ch )) {
+                if (IS_WHITESPACE_CHAR(ch)) {
                 found_white_space:
                 found_white_space:
-                    while (isspace( (ch_t)*++str ))  ;
+                    while (IS_WHITESPACE_CHAR(*++str))  ;
                     break;
                     break;
                 }
                 }
 
 
@@ -249,7 +249,7 @@ ao_string_tokenize( char const* str )
                         errno = EINVAL;
                         errno = EINVAL;
                         return NULL;
                         return NULL;
                     }
                     }
-                    if (isspace( (ch_t)*str ))
+                    if (IS_WHITESPACE_CHAR(*str))
                         goto found_white_space;
                         goto found_white_space;
                     break;
                     break;
 
 
@@ -260,7 +260,7 @@ ao_string_tokenize( char const* str )
                         errno = EINVAL;
                         errno = EINVAL;
                         return NULL;
                         return NULL;
                     }
                     }
-                    if (isspace( (ch_t)*str ))
+                    if (IS_WHITESPACE_CHAR(*str))
                         goto found_white_space;
                         goto found_white_space;
                     break;
                     break;
 
 

+ 32 - 15
libopts/usage.c

@@ -1,7 +1,7 @@
 
 
 /*
 /*
- *  usage.c  $Id: usage.c,v 4.20 2007/07/16 00:17:31 bkorb Exp $
- * Time-stamp:      "2007-07-15 09:43:04 bkorb"
+ *  usage.c  $Id: usage.c,v 4.28 2008/11/02 18:51:27 bkorb Exp $
+ * Time-stamp:      "2008-11-01 20:09:17 bkorb"
  *
  *
  *  This module implements the default usage procedure for
  *  This module implements the default usage procedure for
  *  Automated Options.  It may be overridden, of course.
  *  Automated Options.  It may be overridden, of course.
@@ -15,7 +15,8 @@
 /*
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -43,7 +44,7 @@ static char    zOptFmtLine[ 16 ];
 static ag_bool displayEnum;
 static ag_bool displayEnum;
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static ag_bool
 static ag_bool
 checkGNUUsage( tOptions* pOpts );
 checkGNUUsage( tOptions* pOpts );
 
 
@@ -321,13 +322,23 @@ printExtendedUsage(
         fprintf( option_usage_fp, zDis, pOD->pz_DisableName );
         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
+     *  Check for argument types that have callbacks with magical properties
      */
      */
-    if (  (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC)
-       && (pOD->pOptProc != NULL)
-       && (pOD->pOptProc != optionNumericVal) ) {
-        (*(pOD->pOptProc))( pOptions, NULL );
+    switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+    case OPARG_TYPE_NUMERIC:
+        /*
+         *  IF the numeric option has a special callback,
+         *  THEN call it, requesting the range or other special info
+         */
+        if (  (pOD->pOptProc != NULL)
+           && (pOD->pOptProc != optionNumericVal) ) {
+            (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD);
+        }
+        break;
+
+    case OPARG_TYPE_FILE:
+        (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD);
+        break;
     }
     }
 
 
     /*
     /*
@@ -469,7 +480,7 @@ printOneUsage(
      */
      */
     if ((pOptions->fOptSet & OPTPROC_SHORTOPT) == 0)
     if ((pOptions->fOptSet & OPTPROC_SHORTOPT) == 0)
         fputs( pAT->pzSpc, option_usage_fp );
         fputs( pAT->pzSpc, option_usage_fp );
-    else if (! isgraph( pOD->optValue)) {
+    else if (! IS_GRAPHIC_CHAR(pOD->optValue)) {
         if (  (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
         if (  (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
            == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
            == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
             fputc( ' ', option_usage_fp );
             fputc( ' ', option_usage_fp );
@@ -495,11 +506,13 @@ printOneUsage(
         } else switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
         } else switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
         case OPARG_TYPE_NONE:        pzArgType = pAT->pzNo;   break;
         case OPARG_TYPE_NONE:        pzArgType = pAT->pzNo;   break;
         case OPARG_TYPE_ENUMERATION: pzArgType = pAT->pzKey;  break;
         case OPARG_TYPE_ENUMERATION: pzArgType = pAT->pzKey;  break;
+        case OPARG_TYPE_FILE       : pzArgType = pAT->pzFile; break;
         case OPARG_TYPE_MEMBERSHIP:  pzArgType = pAT->pzKeyL; break;
         case OPARG_TYPE_MEMBERSHIP:  pzArgType = pAT->pzKeyL; break;
         case OPARG_TYPE_BOOLEAN:     pzArgType = pAT->pzBool; break;
         case OPARG_TYPE_BOOLEAN:     pzArgType = pAT->pzBool; break;
         case OPARG_TYPE_NUMERIC:     pzArgType = pAT->pzNum;  break;
         case OPARG_TYPE_NUMERIC:     pzArgType = pAT->pzNum;  break;
         case OPARG_TYPE_HIERARCHY:   pzArgType = pAT->pzNest; break;
         case OPARG_TYPE_HIERARCHY:   pzArgType = pAT->pzNest; break;
         case OPARG_TYPE_STRING:      pzArgType = pAT->pzStr;  break;
         case OPARG_TYPE_STRING:      pzArgType = pAT->pzStr;  break;
+        case OPARG_TYPE_TIME:        pzArgType = pAT->pzTime; break;
         default:                     goto bogus_desc;
         default:                     goto bogus_desc;
         }
         }
 
 
@@ -558,9 +571,9 @@ printOptionUsage(
          *  THEN document that the remaining options are not user opts
          *  THEN document that the remaining options are not user opts
          */
          */
         if (  (pOpts->presetOptCt == optNo)
         if (  (pOpts->presetOptCt == optNo)
-              && (ex_code == EXIT_SUCCESS)
-              && (docCt > 0)
-              && ((pOD[-1].fOptState & OPTST_DOCUMENT) == 0) )
+           && (ex_code == EXIT_SUCCESS)
+           && (docCt > 0)
+           && ((pOD[-1].fOptState & OPTST_DOCUMENT) == 0) )
             fprintf( option_usage_fp, argTypes.pzBrk, zAuto, pOptTitle );
             fprintf( option_usage_fp, argTypes.pzBrk, zAuto, pOptTitle );
 
 
         printOneUsage( pOpts, pOD, &argTypes );
         printOneUsage( pOpts, pOD, &argTypes );
@@ -619,7 +632,7 @@ printProgramDetails( tOptions* pOptions )
             switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
             switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
             case OPARG_TYPE_ENUMERATION:
             case OPARG_TYPE_ENUMERATION:
             case OPARG_TYPE_MEMBERSHIP:
             case OPARG_TYPE_MEMBERSHIP:
-                (*(pOD->pOptProc))( NULL, pOD );
+                (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD);
             }
             }
         }  while (pOD++, optNo++, (--ct > 0));
         }  while (pOD++, optNo++, (--ct > 0));
     }
     }
@@ -657,6 +670,8 @@ setGnuOptFmts( tOptions* pOpts, tCC** ppT )
     argTypes.pzNum  = zGnuNumArg;
     argTypes.pzNum  = zGnuNumArg;
     argTypes.pzKey  = zGnuKeyArg;
     argTypes.pzKey  = zGnuKeyArg;
     argTypes.pzKeyL = zGnuKeyLArg;
     argTypes.pzKeyL = zGnuKeyLArg;
+    argTypes.pzTime = zGnuTimeArg;
+    argTypes.pzFile = zGnuFileArg;
     argTypes.pzBool = zGnuBoolArg;
     argTypes.pzBool = zGnuBoolArg;
     argTypes.pzNest = zGnuNestArg;
     argTypes.pzNest = zGnuNestArg;
     argTypes.pzOpt  = zGnuOptArg;
     argTypes.pzOpt  = zGnuOptArg;
@@ -694,6 +709,8 @@ setStdOptFmts( tOptions* pOpts, tCC** ppT )
     argTypes.pzNum  = zStdNumArg;
     argTypes.pzNum  = zStdNumArg;
     argTypes.pzKey  = zStdKeyArg;
     argTypes.pzKey  = zStdKeyArg;
     argTypes.pzKeyL = zStdKeyLArg;
     argTypes.pzKeyL = zStdKeyLArg;
+    argTypes.pzTime = zStdTimeArg;
+    argTypes.pzFile = zStdFileArg;
     argTypes.pzBool = zStdBoolArg;
     argTypes.pzBool = zStdBoolArg;
     argTypes.pzNest = zStdNestArg;
     argTypes.pzNest = zStdNestArg;
     argTypes.pzOpt  = zStdOptArg;
     argTypes.pzOpt  = zStdOptArg;

+ 123 - 0
libopts/value-type.c

@@ -0,0 +1,123 @@
+/* ANSI-C code produced by gperf version 3.0.3 */
+
+
+#if 0 /* gperf build options: */
+// %struct-type
+// %language=ANSI-C
+// %includes
+// %global-table
+// %omit-struct-type
+// %readonly-tables
+// %compare-strncmp
+// 
+// %define slot-name               vtp_name
+// %define hash-function-name      value_type_hash
+// %define lookup-function-name    find_value_type_name
+// %define word-array-name         value_type_table
+// %define initializer-suffix      ,VTP_COUNT_KWD
+#endif /* gperf build options: */
+
+#include "value-type.h"
+
+typedef struct {
+    char const *    vtp_name;
+    value_type_enum_t   vtp_id;
+} value_type_map_t;
+#include <string.h>
+
+/* maximum key range = 20, duplicates = 0 */
+
+#ifdef __GNUC__
+#else
+#ifdef __cplusplus
+#endif
+#endif
+inline static unsigned int
+value_type_hash (register const char *str, register unsigned int len)
+{
+  static const unsigned char asso_values[] =
+    {
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 10, 23, 23, 23, 23, 23, 23, 23, 23,
+      23,  5, 23, 23,  5,  0,  0, 23, 15, 23,
+      23, 10, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+      23, 23, 23, 23, 23, 23
+    };
+  return len + asso_values[(unsigned char)str[2]];
+}
+
+static const value_type_map_t value_type_table[] =
+  {
+    {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
+    {"",VTP_COUNT_KWD},
+    {"set",             VTP_KWD_SET},
+    {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
+    {"nested",          VTP_KWD_NESTED},
+    {"integer",         VTP_KWD_INTEGER},
+    {"",VTP_COUNT_KWD},
+    {"bool",            VTP_KWD_BOOL},
+    {"",VTP_COUNT_KWD},
+    {"string",          VTP_KWD_STRING},
+    {"boolean",         VTP_KWD_BOOLEAN},
+    {"",VTP_COUNT_KWD},
+    {"set-membership",  VTP_KWD_SET_MEMBERSHIP},
+    {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
+    {"keyword",         VTP_KWD_KEYWORD},
+    {"",VTP_COUNT_KWD},
+    {"hierarchy",       VTP_KWD_HIERARCHY},
+    {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD},
+    {"invalid",         VTP_KWD_INVALID}
+  };
+
+#ifdef __GNUC__
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+static inline const value_type_map_t *
+find_value_type_name (register const char *str, register unsigned int len)
+{
+  if (len <= 14 && len >= 3)
+    {
+      register int key = value_type_hash (str, len);
+
+      if (key <= 22 && key >= 0)
+        {
+          register const char *s = value_type_table[key].vtp_name;
+
+          if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+            return &value_type_table[key];
+        }
+    }
+  return 0;
+}
+
+
+value_type_enum_t
+find_value_type_id(char const * str, unsigned int len)
+{
+    const value_type_map_t * p =
+        find_value_type_name(str, len);
+    return (p == 0) ? VTP_KWD_INVALID : p->vtp_id;
+}

+ 25 - 0
libopts/value-type.h

@@ -0,0 +1,25 @@
+/*
+ *  Generated header for gperf generated source Wed Dec 31 19:07:31 PST 2008
+ *  This file enumerates the list of names and declares the
+ *  procedure for mapping string names to the enum value.
+ */
+#ifndef AUTOOPTS_VALUE_TYPE_H_GUARD
+#define AUTOOPTS_VALUE_TYPE_H_GUARD 1
+
+typedef enum {
+    VTP_KWD_INVALID,
+    VTP_KWD_STRING,
+    VTP_KWD_INTEGER,
+    VTP_KWD_BOOLEAN,
+    VTP_KWD_BOOL,
+    VTP_KWD_KEYWORD,
+    VTP_KWD_SET,
+    VTP_KWD_SET_MEMBERSHIP,
+    VTP_KWD_NESTED,
+    VTP_KWD_HIERARCHY,
+    VTP_COUNT_KWD
+} value_type_enum_t;
+
+extern value_type_enum_t
+find_value_type_id(char const * str, unsigned int len);
+#endif /* AUTOOPTS_VALUE_TYPE_H_GUARD */

+ 7 - 10
libopts/version.c

@@ -1,19 +1,16 @@
 
 
-/*  $Id: version.c,v 4.12 2007/07/04 21:36:39 bkorb Exp $
- * Time-stamp:      "2007-07-04 13:42:04 bkorb"
+/*  $Id: version.c,v 4.15 2008/07/28 04:51:30 bkorb Exp $
+ * Time-stamp:      "2008-07-27 10:11:30 bkorb"
  *
  *
  *  This module implements the default usage procedure for
  *  This module implements the default usage procedure for
  *  Automated Options.  It may be overridden, of course.
  *  Automated Options.  It may be overridden, of course.
  */
  */
 
 
-static char const zAOV[] =
-    "Automated Options version %s\n"
-    "\tcopyright (c) 1999-2007 Bruce Korb - all rights reserved\n";
-
 /*
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
  *  AutoOpts is free software.
- *  AutoOpts is copyright (c) 1992-2007 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
+ *  AutoOpts is copyright (c) 1992-2008 by Bruce Korb - all rights reserved
  *
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
  *  in use must be one of these two and the choice is under the control
@@ -33,7 +30,7 @@ static char const zAOV[] =
  */
  */
 
 
 /* = = = START-STATIC-FORWARD = = = */
 /* = = = START-STATIC-FORWARD = = = */
-/* static forward declarations maintained by :mkfwd */
+/* static forward declarations maintained by mk-fwd */
 static void
 static void
 printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp );
 printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp );
 /* = = = END-STATIC-FORWARD = = = */
 /* = = = END-STATIC-FORWARD = = = */
@@ -90,7 +87,7 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
             fputs( pOpts->pzCopyright, fp );
             fputs( pOpts->pzCopyright, fp );
             fputc( '\n', fp );
             fputc( '\n', fp );
         }
         }
-        fprintf( fp, zAOV, optionVersion() );
+        fprintf( fp, zAO_Ver, optionVersion() );
         if (pOpts->pzBugAddr != NULL)
         if (pOpts->pzBugAddr != NULL)
             fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
             fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
         break;
         break;
@@ -107,7 +104,7 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
             fputc( '\n', fp );
             fputc( '\n', fp );
         }
         }
 
 
-        fprintf( fp, zAOV, optionVersion() );
+        fprintf( fp, zAO_Ver, optionVersion() );
         if (pOpts->pzBugAddr != NULL)
         if (pOpts->pzBugAddr != NULL)
             fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
             fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
         break;
         break;

+ 114 - 0
libopts/xat-attribute.c

@@ -0,0 +1,114 @@
+/* ANSI-C code produced by gperf version 3.0.3 */
+
+
+#if 0 /* gperf build options: */
+// %struct-type
+// %language=ANSI-C
+// %includes
+// %global-table
+// %omit-struct-type
+// %readonly-tables
+// %compare-strncmp
+// 
+// %define slot-name               xat_name
+// %define hash-function-name      xat_attribute_hash
+// %define lookup-function-name    find_xat_attribute_name
+// %define word-array-name         xat_attribute_table
+// %define initializer-suffix      ,XAT_COUNT_KWD
+#endif /* gperf build options: */
+
+#include "xat-attribute.h"
+
+typedef struct {
+    char const *    xat_name;
+    xat_attribute_enum_t   xat_id;
+} xat_attribute_map_t;
+#include <string.h>
+
+/* maximum key range = 9, duplicates = 0 */
+
+#ifdef __GNUC__
+#else
+#ifdef __cplusplus
+#endif
+#endif
+inline static unsigned int
+xat_attribute_hash (register const char *str, register unsigned int len)
+{
+  static const unsigned char asso_values[] =
+    {
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13,  0,
+      13, 13, 13, 13, 13,  5, 13,  5, 13,  0,
+      13, 13, 13, 13, 13, 13,  0,  0, 13,  0,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+      13, 13, 13, 13, 13, 13
+    };
+  return len + asso_values[(unsigned char)str[0]];
+}
+
+static const xat_attribute_map_t xat_attribute_table[] =
+  {
+    {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
+    {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
+    {"type",            XAT_KWD_TYPE},
+    {"words",           XAT_KWD_WORDS},
+    {"cooked",          XAT_KWD_COOKED},
+    {"members",         XAT_KWD_MEMBERS},
+    {"uncooked",        XAT_KWD_UNCOOKED},
+    {"keep",            XAT_KWD_KEEP},
+    {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD},
+    {"invalid",         XAT_KWD_INVALID}
+  };
+
+#ifdef __GNUC__
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+static inline const xat_attribute_map_t *
+find_xat_attribute_name (register const char *str, register unsigned int len)
+{
+  if (len <= 8 && len >= 4)
+    {
+      register int key = xat_attribute_hash (str, len);
+
+      if (key <= 12 && key >= 0)
+        {
+          register const char *s = xat_attribute_table[key].xat_name;
+
+          if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+            return &xat_attribute_table[key];
+        }
+    }
+  return 0;
+}
+
+
+xat_attribute_enum_t
+find_xat_attribute_id(char const * str, unsigned int len)
+{
+    const xat_attribute_map_t * p =
+        find_xat_attribute_name(str, len);
+    return (p == 0) ? XAT_KWD_INVALID : p->xat_id;
+}

+ 22 - 0
libopts/xat-attribute.h

@@ -0,0 +1,22 @@
+/*
+ *  Generated header for gperf generated source Wed Dec 31 19:07:31 PST 2008
+ *  This file enumerates the list of names and declares the
+ *  procedure for mapping string names to the enum value.
+ */
+#ifndef AUTOOPTS_XAT_ATTRIBUTE_H_GUARD
+#define AUTOOPTS_XAT_ATTRIBUTE_H_GUARD 1
+
+typedef enum {
+    XAT_KWD_INVALID,
+    XAT_KWD_TYPE,
+    XAT_KWD_WORDS,
+    XAT_KWD_MEMBERS,
+    XAT_KWD_COOKED,
+    XAT_KWD_UNCOOKED,
+    XAT_KWD_KEEP,
+    XAT_COUNT_KWD
+} xat_attribute_enum_t;
+
+extern xat_attribute_enum_t
+find_xat_attribute_id(char const * str, unsigned int len);
+#endif /* AUTOOPTS_XAT_ATTRIBUTE_H_GUARD */

+ 0 - 6
scripts/Makefile.am

@@ -1,10 +1,4 @@
 
 
-noinst_PROGRAMS = man2html
-
-man2html_SOURCES = man2html.c
-
 EXTRA_DIST = dlt2name.pl
 EXTRA_DIST = dlt2name.pl
 
 
-MOSTLYCLEANFILES = *~ *.o
-
 MAINTAINERCLEANFILES = Makefile.in
 MAINTAINERCLEANFILES = Makefile.in

+ 35 - 139
scripts/Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -13,7 +13,6 @@
 # PARTICULAR PURPOSE.
 # PARTICULAR PURPOSE.
 
 
 @SET_MAKE@
 @SET_MAKE@
-
 VPATH = @srcdir@
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -33,36 +32,18 @@ POST_UNINSTALL = :
 build_triplet = @build@
 build_triplet = @build@
 host_triplet = @host@
 host_triplet = @host@
 target_triplet = @target@
 target_triplet = @target@
-noinst_PROGRAMS = man2html$(EXEEXT)
 subdir = scripts
 subdir = scripts
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/src/config.h
 CONFIG_HEADER = $(top_builddir)/src/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_FILES =
-PROGRAMS = $(noinst_PROGRAMS)
-am_man2html_OBJECTS = man2html.$(OBJEXT)
-man2html_OBJECTS = $(am_man2html_OBJECTS)
-man2html_LDADD = $(LDADD)
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
-depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
-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 = $(man2html_SOURCES)
-DIST_SOURCES = $(man2html_SOURCES)
-ETAGS = etags
-CTAGS = ctags
+SOURCES =
+DIST_SOURCES =
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AMTAR = @AMTAR@
@@ -87,20 +68,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -110,10 +93,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -121,8 +103,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -146,7 +132,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -178,6 +164,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -201,20 +188,17 @@ tcpdump_path = @tcpdump_path@
 top_build_prefix = @top_build_prefix@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 top_srcdir = @top_srcdir@
-man2html_SOURCES = man2html.c
 EXTRA_DIST = dlt2name.pl
 EXTRA_DIST = dlt2name.pl
-MOSTLYCLEANFILES = *~ *.o
 MAINTAINERCLEANFILES = Makefile.in
 MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 all: all-am
 
 
 .SUFFIXES:
 .SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	      exit 1;; \
 	  esac; \
 	  esac; \
 	done; \
 	done; \
@@ -239,97 +223,17 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
 
-clean-noinstPROGRAMS:
-	@list='$(noinst_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-man2html$(EXEEXT): $(man2html_OBJECTS) $(man2html_DEPENDENCIES) 
-	@rm -f man2html$(EXEEXT)
-	$(LINK) $(man2html_OBJECTS) $(man2html_LDADD) $(LIBS)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/man2html.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	mv -f $(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@	mv -f $(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@	mv -f $(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:
 mostlyclean-libtool:
 	-rm -f *.lo
 	-rm -f *.lo
 
 
 clean-libtool:
 clean-libtool:
 	-rm -rf .libs _libs
 	-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; nonemtpy = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
 tags: TAGS
 tags: TAGS
+TAGS:
 
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	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; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
-	fi
 ctags: CTAGS
 ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	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)$$tags$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+CTAGS:
+
 
 
 distdir: $(DISTFILES)
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -359,7 +263,7 @@ distdir: $(DISTFILES)
 	done
 	done
 check-am: all-am
 check-am: all-am
 check: check-am
 check: check-am
-all-am: Makefile $(PROGRAMS)
+all-am: Makefile
 installdirs:
 installdirs:
 install: install-am
 install: install-am
 install-exec: install-exec-am
 install-exec: install-exec-am
@@ -376,7 +280,6 @@ install-strip:
 	  `test -z '$(STRIP)' || \
 	  `test -z '$(STRIP)' || \
 	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 mostlyclean-generic:
-	-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
 
 
 clean-generic:
 clean-generic:
 
 
@@ -389,14 +292,11 @@ maintainer-clean-generic:
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
 clean: clean-am
 clean: clean-am
 
 
-clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
-	mostlyclean-am
+clean-am: clean-generic clean-libtool mostlyclean-am
 
 
 distclean: distclean-am
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-tags
+distclean-am: clean-am distclean-generic
 
 
 dvi: dvi-am
 dvi: dvi-am
 
 
@@ -427,14 +327,12 @@ install-ps: install-ps-am
 installcheck-am:
 installcheck-am:
 
 
 maintainer-clean: maintainer-clean-am
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
 
 mostlyclean: mostlyclean-am
 mostlyclean: mostlyclean-am
 
 
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
 
 
 pdf: pdf-am
 pdf: pdf-am
 
 
@@ -448,18 +346,16 @@ uninstall-am:
 
 
 .MAKE: install-am install-strip
 .MAKE: 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-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am
+.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-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
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # 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.
 # Otherwise a system limit (for SysV at least) may be exceeded.

+ 0 - 628
scripts/man2html.c

@@ -1,628 +0,0 @@
-/* Copyright (c) 1995 DJ Delorie, 334 North Road, Deerfield NH USA
-   Distributed under the terms of the GNU GPL, version 2 or later.
-   Note: The HTML output of this program is NOT considered a derived
-   work of this program.  */
-
-/*
-   Original work by dj@delorie.com
-
-   Usage: man2html < program.man > program.html
-*/
-
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-int in_tt = 0;
-int next_line_dd = 0;
-int need_undl = 0;
-int got_regular_line = 0;
-int need_re = 0;
-int fill_mode = 1;
-int current_BI = 0;
-int skip_nl = 0;
-
-int process_line(void);
-
-char *
-get_token(char *inp, char *buf)
-{
-  int quoted = 0;
-  /* skip whitespace */
-  while (*inp && isspace(*inp))
-    inp++;
-  if (*inp == 0)
-    return 0;
-
-  while (*inp)
-  {
-    switch (*inp)
-    {
-    case '"':
-      quoted = 1-quoted;
-      break;
-    case '\\':
-      *buf++ = *inp;
-      *buf++ = *++inp;
-      break;
-    default:
-      if (isspace(*inp) && !quoted)
-      {
-	*buf = 0;
-	return inp;
-      }
-      *buf++ = *inp;
-      break;
-    }
-    inp++;
-  }
-  *buf = 0;
-  return inp;
-}
-
-void
-clean(char *cp)
-{
-  char foo[1000];
-  char *rp = foo;
-  char *ocp = cp;
-  if (strncmp(cp, ".if t ", 6) == 0)
-    cp += 6;
-  while (*cp)
-  {
-    switch (*cp)
-    {
-    case '\\':
-      cp++;
-      switch (*cp)
-      {
-      case 'E':
-      case 'F':
-      case 'g':
-      case 'b':
-      case 'r':
-      case 'B':
-	*rp++ = '\\';
-	*rp++ = *cp++;
-	break;
-      case '/':
-      case '-':
-      case '\\':
-      case '+':
-      case '.':
-      case 10:
-      case 0:
-      case ' ':
-      case '=':
-      case '\'':
-      case '`':
-      case '[':
-      case ']':
-      case ':':
-      case '}':
-      case '{':
-	*rp++ = *cp++;
-	break;
-      case '|':
-      case '^':
-      case '"':
-      case 'd':
-      case 'u':
-      case 'n':
-      case '&':
-      case 'w':
-      case '%':
-      case 'v':
-      case 'k':
-	cp++;
-	break;
-      case 't':
-	*rp++ = ' ';
-	cp++;
-	break;
-      case '0':
-	*rp++ = ' ';
-	cp++;
-	break;
-      case 'c':
-	if (cp[1] == '\n')
-	{
-	  skip_nl = 1;
-	  cp++;
-	}
-	cp++;
-	break;
-      case 'e':
-	*rp++ = '\\';
-	cp++;
-	break;
-      case 's':
-	cp++;
-	cp++;
-	while (isdigit(*cp))
-	  cp++;
-	break;
-      case 'f':
-	if (current_BI)
-	{
-	  *rp++ = '<';
-	  *rp++ = '/';
-	  *rp++ = current_BI;
-	  *rp++ = '>';
-	  current_BI = 0;
-	}
-	if (in_tt)
-	{
-	  strcpy(rp, "</tt>");
-	  rp += 5;
-	  in_tt = 0;
-	}
-	switch (*++cp)
-	{
-	case '(':
-	  if (cp[1] == 'C' && cp[2] == 'W')
-	  {
-	    strcpy(rp, "<tt>");
-	    rp += 4;
-	    in_tt = 1;
-	    cp += 2;
-	  }
-	  else
-	    fprintf(stderr, "unknown font %.3s\n", cp);
-	  break;
-	case 'B':
-	  current_BI = 'b';
-	  *rp++ = '<';
-	  *rp++ = 'b';
-	  *rp++ = '>';
-	  break;
-	case 'R':
-	case 'P':
-	  break;
-	case 'I':
-	  current_BI = 'i';
-	  *rp++ = '<';
-	  *rp++ = 'i';
-	  *rp++ = '>';
-	  break;
-	}
-	cp++;
-	break;
-      case '*':
-	cp++;
-	if (cp[0] == '(')
-	{
-	  cp++;
-	  if (cp[0] == 'l' && cp[1] == 'q')
-	    *rp++ = '`';
-	  else if (cp[0] == 'r' && cp[1] == 'q')
-	    *rp++ = '\'';
-	  else
-	  {
-	    sprintf(rp, "[%.2s]", cp);
-	    rp += 4;
-	  }
-	  cp += 2;
-	}
-	else if (cp[0] == 'r')
-	{
-	  cp++;
-	  strcpy(rp, "RCS");
-	  rp += 3;
-	}
-	else
-	{
-	  sprintf(rp, "[%c]", *cp);
-	  rp += 3;
-	}
-	break;
-      case '(':
-	if (cp[1] == 'c' && cp[2] == 'o')
-	  *rp++ = 0xa9;
-	else if (cp[1] == 'b' && cp[2] == 'v')
-	  *rp++ = '|';
-	else if (cp[1] == 'e' && cp[2] == 'm')
-	  *rp++ = ' ';
-	else if (cp[1] == '+' && cp[2] == '-')
-	  *rp++ = 0xb1;
-	else if (cp[1] == 't' && cp[2] == 'i')
-	  *rp++ = '~';
-	else if (cp[1] == 't' && cp[2] == 's')
-	  *rp++ = '"';
-	else if (cp[1] == 'p' && cp[2] == 'l')
-	  *rp++ = '+';
-	else if (cp[1] == 'm' && cp[2] == 'i')
-	  *rp++ = '-';
-	else if (cp[1] == 'f' && cp[2] == 'm')
-	  *rp++ = '\'';
-	else if (cp[1] == 'm' && cp[2] == 'u')
-	  *rp++ = 'x';
-	else if (cp[1] == 'b' && cp[2] == 'u')
-	{
-	  strcpy(rp, "<li>");
-	  rp += 4;
-	}
-	else if (cp[1] == '>' && cp[2] == '=')
-	{
-	  *rp++ = '>';
-	  *rp++ = '=';
-	}
-	else if (cp[1] == '*' && cp[2] == '*')
-	{
-	  *rp++ = '*';
-	  *rp++ = '*';
-	}
-	else
-	  fprintf(stderr, "unknown meta-character (%c%c\n", cp[1], cp[2]);
-	cp += 3;
-	break;
-      default:
-	fprintf(stderr, "unknown escape \\%c (%d)\n", *cp, *cp);
-	break;
-      }
-      break;
-    case '&':
-      *rp++ = '&';
-      *rp++ = 'a';
-      *rp++ = 'm';
-      *rp++ = 'p';
-      *rp++ = ';';
-      cp++;
-      break;
-    case '<':
-      *rp++ = '&';
-      *rp++ = 'l';
-      *rp++ = 't';
-      *rp++ = ';';
-      cp++;
-      break;
-    case '>':
-      *rp++ = '&';
-      *rp++ = 'g';
-      *rp++ = 't';
-      *rp++ = ';';
-      cp++;
-      break;
-    default:
-      *rp++ = *cp++;
-      break;
-    }
-  }
-  *rp = 0;
-  strcpy(ocp, foo);
-}
-
-void
-un_bi(void)
-{
-  if (current_BI)
-  {
-    printf("</%c>", current_BI);
-    current_BI = 0;
-  }
-}
-
-void
-process_line_til_regular(void)
-{
-  got_regular_line = 0;
-  while (!got_regular_line)
-    process_line();
-}
-
-void
-bol(void)
-{
-  got_regular_line = 1;
-  if (next_line_dd)
-    printf("<dd>");
-  next_line_dd = 0;
-}
-
-void
-eol(void)
-{
-  if (!fill_mode)
-    printf("<br>");
-}
-
-void
-twoggle(char *a, char *b, char *l)
-{
-  int first = 1;
-  char *c;
-  char buf[1000];
-  bol();
-  while ((l = get_token(l, buf)))
-  {
-    clean(buf);
-    c = first ? a : b;
-    if (c)
-      printf("<%s>%s</%s>", c, buf, c);
-    else
-      printf("%s", buf);
-    if (a && b && strcmp(a, b) == 0)
-      putchar(' ');
-    first = 1-first;
-  }
-  un_bi();
-  if (!skip_nl)
-    printf("\n");
-  eol();
-  got_regular_line = 1;
-}
-
-int
-process_line(void)
-{
-  char buf[1000], cmd[10];
-  char token[1000];
-  if (fgets(buf, 1000, stdin) == 0)
-    return 0;
-
-  skip_nl = 0;
-  if (buf[0] != '.')
-  {
-    if (strncmp(buf, "'\\\"", 3) == 0)
-      return 1;
-    clean(buf);
-    bol();
-    fputs(buf, stdout);
-    if (buf[0] == 0 || buf[0] == '\n')
-      printf("<p>");
-    eol();
-    return 1;
-  }
-
-  if (sscanf(buf, "%s %[^\n]", cmd, buf) == 1)
-    buf[0] = 0;
-  if (strcmp(cmd, "..") == 0)
-  {
-  }
-  else if (strcmp(cmd, ".B") == 0)
-  {
-    if (buf[0])
-    {
-      twoggle("b", "b", buf);
-    }
-    else
-    {
-      printf("<b>");
-      process_line_til_regular();
-      printf("</b>");
-    }
-  }
-  else if (strcmp(cmd, ".I") == 0)
-  {
-    if (buf[0])
-    {
-      twoggle("i", "i", buf);
-    }
-    else
-    {
-      printf("<i>");
-      process_line_til_regular();
-      printf("</i>");
-    }
-  }
-  else if (strcmp(cmd, ".BI") == 0)
-  {
-    twoggle("b", "i", buf);
-  }
-  else if (strcmp(cmd, ".IB") == 0)
-  {
-    twoggle("i", "b", buf);
-  }
-  else if (strcmp(cmd, ".BR") == 0)
-  {
-    twoggle("b", 0, buf);
-  }
-  else if (strcmp(cmd, ".RB") == 0)
-  {
-    twoggle(0, "b", buf);
-  }
-  else if (strcmp(cmd, ".IR") == 0)
-  {
-    twoggle("i", 0, buf);
-  }
-  else if (strcmp(cmd, ".RI") == 0)
-  {
-    twoggle(0, "i", buf);
-  }
-  else if (strcmp(cmd, ".nf") == 0)
-  {
-    if (fill_mode)
-      printf("<pre>\n");
-    fill_mode = 0;
-  }
-  else if (strcmp(cmd, ".fi") == 0)
-  {
-    if (!fill_mode)
-      printf("</pre>\n");
-    fill_mode = 1;
-  }
-  else if (strcmp(cmd, ".br") == 0
-	   || strcmp(cmd, ".Sp") == 0
-	   || strcmp(cmd, ".ti") == 0)
-  {
-    if (need_undl)
-    {
-      need_undl = 0;
-      printf("</dl>");
-    }
-    printf("<br>\n");
-  }
-  else if (strcmp(cmd, ".LP") == 0
-	   || strcmp(cmd, ".PP") == 0
-	   || strcmp(cmd, ".sp") == 0
-	   || strcmp(cmd, ".P") == 0)
-  {
-    if (need_undl)
-    {
-      need_undl = 0;
-      printf("</dl>");
-    }
-    printf("\n<p>\n");
-  }
-  else if (strcmp(cmd, ".RS") == 0)
-  {
-    printf("<ul>");
-    need_re ++;
-  }
-  else if (strcmp(cmd, ".RE") == 0)
-  {
-    if (need_re)
-    {
-      printf("</ul>");
-      need_re --;
-    }
-  }
-  else if (strcmp(cmd, ".SH") == 0
-	   || strcmp(cmd, ".SS") == 0)
-  {
-    char *cp = buf;
-    int got_token = 0;
-    while (need_re)
-    {
-      printf("</ul>");
-      need_re--;
-    }
-    if (need_undl)
-    {
-      printf("</dl>");
-      need_undl = 0;
-    }
-    printf("\n</ul><H2>");
-    while ((cp = get_token(cp, token)))
-    {
-      got_token = 1;
-      clean(token);
-      printf("%s ", token);
-    }
-    if (!got_token)
-    {
-      if (fgets(buf, 1000, stdin) == 0)
-	return 0;
-      printf("%s", buf);
-    }
-    printf("</H2><ul>\n\n");
-    un_bi();
-    got_regular_line = 1;
-    if (!fill_mode)
-      printf("</pre>");
-    fill_mode = 1;
-  }
-  else if (strcmp(cmd, ".SM") == 0)
-  {
-    if (buf[0])
-    {
-      bol();
-      clean(buf);
-      printf("<code>%s</code>\n", buf);
-      eol();
-    }
-    else
-    {
-      printf("<code>");
-      process_line_til_regular();
-      printf("</code>");
-    }
-  }
-  else if (strcmp(cmd, ".TH") == 0)
-  {
-    int all_upper = 1, i;
-    get_token(buf, buf);
-    for (i=0; buf[i]; i++)
-      if (islower(buf[i]))
-	all_upper = 0;
-    if (all_upper)
-      for (i=0; buf[i]; i++)
-	if (isupper(buf[i]))
-	  buf[i] = tolower(buf[i]);
-    printf("<!--#exec cmd=\"header %s\" -->\n", buf);
-    printf("<ul>");
-  }
-  else if (strcmp(cmd, ".TP") == 0
-	   || strcmp(cmd, ".Tp") == 0)
-  {
-    if (!need_undl)
-    {
-      printf("<p><dl compact>");
-      need_undl = 1;
-    }
-    printf("<dt>");
-    next_line_dd = 0;
-    process_line_til_regular();
-    next_line_dd = 1;
-  }
-  else if (strcmp(cmd, ".IP") == 0)
-  {
-    if (!need_undl)
-    {
-      printf("<p><dl compact>");
-      need_undl = 1;
-    }
-    get_token(buf, buf);
-    clean(buf);
-    printf("<dt>%s", buf);
-    next_line_dd = 1;
-  }
-  else if (strcmp(cmd, ".TQ") == 0)
-  {
-    printf("<dt>");
-    next_line_dd = 0;
-    process_line_til_regular();
-    next_line_dd = 1;
-  }
-  else if (strcmp(cmd, ".FN") == 0)
-  {
-    bol();
-    get_token(buf, buf);
-    printf("<code>%s</code>\n", buf);
-    got_regular_line = 1;
-    eol();
-  }
-  /* Tcl macros */
-  else if (strcmp(cmd, ".AP") == 0)
-  {
-    char *cp = buf;
-    cp = get_token(cp, token);
-    printf("<p>%s", token);
-    cp = get_token(cp, token);
-    printf(" <b>%s</b>", token);
-    cp = get_token(cp, token);
-    printf(" (<i>%s</i>) -\n", token);
-  }
-  else if (strcmp(cmd, ".DS") == 0)
-  {
-    printf("<pre>\n");
-  }
-  else if (strcmp(cmd, ".DE") == 0)
-  {
-    printf("</pre>\n");
-  }
-  /* end of Tcl macros */
-  else if (strcmp(cmd, ".\"") == 0)
-  {
-  }
-  else if (strcmp(cmd, ".de") == 0)
-  {
-    do {
-      if (fgets(buf, 1000, stdin) == 0)
-	return 0;
-    } while (buf[0] != '.' || buf[1] != '.');
-  }
-
-  return 1;
-}
-
-
-int
-main()
-{
-
-  while (process_line());
-  printf("</ul>\n<!--#exec cmd=\"trailer\" -->\n");
-  return 0;
-}

BIN
src/._Makefile.am


BIN
src/._bridge.c


BIN
src/._send_packets.c


BIN
src/._sleep.c


BIN
src/._tcpbridge.c


BIN
src/._tcpbridge.h


BIN
src/._tcpprep.c


BIN
src/._tcpreplay.c


BIN
src/._tcpreplay.h


BIN
src/._tcpreplay_opts.def


BIN
src/._tree.c


+ 28 - 29
src/Makefile.am

@@ -22,13 +22,8 @@ autoopts: tcpreplay_opts.c tcprewrite_opts.c tcpbridge_opts.c manpages \
 
 
 
 
 # Get AutoOpts search path
 # Get AutoOpts search path
-#opts_list=`find tcpedit -type d -not -regex ".*\.svn.*" -not -regex ".*\.deps.*" -exec echo -n "-L {} " \;`
 opts_list=-L tcpedit
 opts_list=-L tcpedit
 
 
-if ENABLE_TCPREPLAY_EDIT
-opts_list += -DTCPREPLAY_EDIT
-endif
-
 tcpprep.1: tcpprep_opts.def
 tcpprep.1: tcpprep_opts.def
 	@AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpprep tcpprep_opts.def
 	@AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpprep tcpprep_opts.def
 
 
@@ -44,39 +39,43 @@ tcpreplay.1: tcpreplay_opts.def
 tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpbridge tcpbridge_opts.def
 	@AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpbridge tcpbridge_opts.def
 
 
-man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1
+man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpreplay-edit.1
 EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1
 EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1
-bin_PROGRAMS = tcpreplay tcpprep tcprewrite tcpbridge
-
-tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPREPLAY
+bin_PROGRAMS = tcpreplay tcpprep tcprewrite tcpreplay-edit
 
 
-if ENABLE_TCPREPLAY_EDIT
-tcpreplay_LDADD = ./tcpedit/libtcpedit.a
-tcpreplay_SOURCES = tcpreplay_edit_opts.c
-else
-tcpreplay_SOURCES = tcpreplay_opts.c
-tcpreplay_LDADD = 
+if COMPILE_TCPBRIDGE
+bin_PROGRAMS += tcpbridge
+man_MANS += tcpbridge.1
 endif
 endif
 
 
-tcpreplay_LDADD += ./common/libcommon.a $(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD)
-tcpreplay_SOURCES += send_packets.c signal_handler.c tcpreplay.c sleep.c
+tcpreplay_edit_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY -DTCPREPLAY_EDIT
+tcpreplay_edit_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD)
+tcpreplay_edit_SOURCES = tcpreplay_edit_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c
+tcpreplay_edit_OBJECTS: tcpreplay_opts.h
+tcpreplay_edit_opts.h: tcpreplay_edit_opts.c
 
 
-if ENABLE_OSX_FRAMEWORKS
-tcpreplay_LDFLAGS = -framework CoreServices -framework Carbon
-endif
+tcpreplay_edit_opts.c: tcpreplay_opts.def
+	@AUTOGEN@ $(opts_list) -DTCPREPLAY_EDIT -b tcpreplay_edit_opts \
+		tcpreplay_opts.def
 
 
+tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY
+tcpreplay_SOURCES = tcpreplay_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c
+tcpreplay_LDADD = ./common/libcommon.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD)
 tcpreplay_OBJECTS: tcpreplay_opts.h
 tcpreplay_OBJECTS: tcpreplay_opts.h
 tcpreplay_opts.h: tcpreplay_opts.c
 tcpreplay_opts.h: tcpreplay_opts.c
-tcpreplay_edit_opts.h: tcpreplay_edit_opts.c
+
 tcpreplay_opts.c: tcpreplay_opts.def
 tcpreplay_opts.c: tcpreplay_opts.def
 	@AUTOGEN@ $(opts_list) tcpreplay_opts.def
 	@AUTOGEN@ $(opts_list) tcpreplay_opts.def
-tcpreplay_edit_opts.c: tcpreplay_opts.def
-	@AUTOGEN@ $(opts_list) -DTCPREPLAY_EDIT -b tcpreplay_edit_opts \
-		tcpreplay_opts.def
+
+if ENABLE_OSX_FRAMEWORKS
+tcpreplay_LDFLAGS = -framework CoreServices -framework Carbon
+tcpreplay_edit_LDFLAGS = -framework CoreServices -framework Carbon
+endif
+
 
 
 tcprewrite_CFLAGS = $(LIBOPTS_CFLAGS) -I.. @LDNETINC@ $(LNAV_CFLAGS) -DTCPREWRITE -DHAVE_CACHEFILE_SUPPORT
 tcprewrite_CFLAGS = $(LIBOPTS_CFLAGS) -I.. @LDNETINC@ $(LNAV_CFLAGS) -DTCPREWRITE -DHAVE_CACHEFILE_SUPPORT
 tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
 tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
-	$(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ \
+	$(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ \
 	$(LIBFRAGROUTE)
 	$(LIBFRAGROUTE)
 tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c 
 tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c 
 tcprewrite_OBJECTS: tcprewrite_opts.h
 tcprewrite_OBJECTS: tcprewrite_opts.h
@@ -85,18 +84,18 @@ tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ $(opts_list) tcprewrite_opts.def
 	@AUTOGEN@ $(opts_list) tcprewrite_opts.def
 
 
 
 
-tcpprep_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPPREP
+tcpprep_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPPREP
 tcpprep_LDADD = ./common/libcommon.a \
 tcpprep_LDADD = ./common/libcommon.a \
-    $(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
+    $(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
 tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c 
 tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c 
 tcpprep_OBJECTS: tcpprep_opts.h
 tcpprep_OBJECTS: tcpprep_opts.h
 tcpprep_opts.h: tcpprep_opts.c
 tcpprep_opts.h: tcpprep_opts.c
 tcpprep_opts.c: tcpprep_opts.def
 tcpprep_opts.c: tcpprep_opts.def
 	@AUTOGEN@ tcpprep_opts.def
 	@AUTOGEN@ tcpprep_opts.def
 
 
-tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPBRIDGE
+tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPBRIDGE
 tcpbridge_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
 tcpbridge_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
-    $(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
+    $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
 if ENABLE_OSX_FRAMEWORKS
 if ENABLE_OSX_FRAMEWORKS
 tcpbridge_LDFLAGS = -framework CoreServices -framework Carbon
 tcpbridge_LDFLAGS = -framework CoreServices -framework Carbon
 endif
 endif

+ 140 - 74
src/Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -34,20 +34,23 @@ POST_UNINSTALL = :
 build_triplet = @build@
 build_triplet = @build@
 host_triplet = @host@
 host_triplet = @host@
 target_triplet = @target@
 target_triplet = @target@
-@ENABLE_TCPREPLAY_EDIT_TRUE@am__append_1 = -DTCPREPLAY_EDIT
 bin_PROGRAMS = tcpreplay$(EXEEXT) tcpprep$(EXEEXT) tcprewrite$(EXEEXT) \
 bin_PROGRAMS = tcpreplay$(EXEEXT) tcpprep$(EXEEXT) tcprewrite$(EXEEXT) \
-	tcpbridge$(EXEEXT)
+	tcpreplay-edit$(EXEEXT) $(am__EXEEXT_1)
+@COMPILE_TCPBRIDGE_TRUE@am__append_1 = tcpbridge
+@COMPILE_TCPBRIDGE_TRUE@am__append_2 = tcpbridge.1
 subdir = src
 subdir = src
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
 	$(srcdir)/defines.h.in
 	$(srcdir)/defines.h.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 CONFIG_HEADER = config.h
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = defines.h
 CONFIG_CLEAN_FILES = defines.h
+@COMPILE_TCPBRIDGE_TRUE@am__EXEEXT_1 = tcpbridge$(EXEEXT)
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
 PROGRAMS = $(bin_PROGRAMS)
@@ -70,31 +73,29 @@ tcpprep_DEPENDENCIES = ./common/libcommon.a $(am__DEPENDENCIES_1) \
 tcpprep_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 tcpprep_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(tcpprep_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	--mode=link $(CCLD) $(tcpprep_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 	$(LDFLAGS) -o $@
-am__tcpreplay_SOURCES_DIST = tcpreplay_opts.c send_packets.c \
-	signal_handler.c tcpreplay.c sleep.c tcpreplay_edit_opts.c
-@ENABLE_TCPREPLAY_EDIT_FALSE@am_tcpreplay_OBJECTS = tcpreplay-tcpreplay_opts.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	tcpreplay-send_packets.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	tcpreplay-signal_handler.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	tcpreplay-tcpreplay.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	tcpreplay-sleep.$(OBJEXT)
-@ENABLE_TCPREPLAY_EDIT_TRUE@am_tcpreplay_OBJECTS = tcpreplay-tcpreplay_edit_opts.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	tcpreplay-send_packets.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	tcpreplay-signal_handler.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	tcpreplay-tcpreplay.$(OBJEXT) \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	tcpreplay-sleep.$(OBJEXT)
+am_tcpreplay_OBJECTS = tcpreplay-tcpreplay_opts.$(OBJEXT) \
+	tcpreplay-send_packets.$(OBJEXT) \
+	tcpreplay-signal_handler.$(OBJEXT) \
+	tcpreplay-tcpreplay.$(OBJEXT) tcpreplay-sleep.$(OBJEXT)
 tcpreplay_OBJECTS = $(am_tcpreplay_OBJECTS)
 tcpreplay_OBJECTS = $(am_tcpreplay_OBJECTS)
-@ENABLE_TCPREPLAY_EDIT_FALSE@tcpreplay_DEPENDENCIES =  \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	./common/libcommon.a \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	$(am__DEPENDENCIES_1) \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	$(am__DEPENDENCIES_2)
-@ENABLE_TCPREPLAY_EDIT_TRUE@tcpreplay_DEPENDENCIES =  \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	./tcpedit/libtcpedit.a \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	./common/libcommon.a \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	$(am__DEPENDENCIES_1) \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	$(am__DEPENDENCIES_2)
+tcpreplay_DEPENDENCIES = ./common/libcommon.a $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2)
 tcpreplay_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 tcpreplay_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcpreplay_CFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcpreplay_CFLAGS) \
 	$(CFLAGS) $(tcpreplay_LDFLAGS) $(LDFLAGS) -o $@
 	$(CFLAGS) $(tcpreplay_LDFLAGS) $(LDFLAGS) -o $@
+am_tcpreplay_edit_OBJECTS =  \
+	tcpreplay_edit-tcpreplay_edit_opts.$(OBJEXT) \
+	tcpreplay_edit-send_packets.$(OBJEXT) \
+	tcpreplay_edit-signal_handler.$(OBJEXT) \
+	tcpreplay_edit-tcpreplay.$(OBJEXT) \
+	tcpreplay_edit-sleep.$(OBJEXT)
+tcpreplay_edit_OBJECTS = $(am_tcpreplay_edit_OBJECTS)
+tcpreplay_edit_DEPENDENCIES = ./tcpedit/libtcpedit.a \
+	./common/libcommon.a $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_2)
+tcpreplay_edit_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcpreplay_edit_CFLAGS) \
+	$(CFLAGS) $(tcpreplay_edit_LDFLAGS) $(LDFLAGS) -o $@
 am_tcprewrite_OBJECTS = tcprewrite-tcprewrite_opts.$(OBJEXT) \
 am_tcprewrite_OBJECTS = tcprewrite-tcprewrite_opts.$(OBJEXT) \
 	tcprewrite-tcprewrite.$(OBJEXT)
 	tcprewrite-tcprewrite.$(OBJEXT)
 tcprewrite_OBJECTS = $(am_tcprewrite_OBJECTS)
 tcprewrite_OBJECTS = $(am_tcprewrite_OBJECTS)
@@ -119,9 +120,10 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 	$(LDFLAGS) -o $@
 SOURCES = $(tcpbridge_SOURCES) $(tcpprep_SOURCES) $(tcpreplay_SOURCES) \
 SOURCES = $(tcpbridge_SOURCES) $(tcpprep_SOURCES) $(tcpreplay_SOURCES) \
-	$(tcprewrite_SOURCES)
+	$(tcpreplay_edit_SOURCES) $(tcprewrite_SOURCES)
 DIST_SOURCES = $(tcpbridge_SOURCES) $(tcpprep_SOURCES) \
 DIST_SOURCES = $(tcpbridge_SOURCES) $(tcpprep_SOURCES) \
-	$(am__tcpreplay_SOURCES_DIST) $(tcprewrite_SOURCES)
+	$(tcpreplay_SOURCES) $(tcpreplay_edit_SOURCES) \
+	$(tcprewrite_SOURCES)
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
 	html-recursive info-recursive install-data-recursive \
 	html-recursive info-recursive install-data-recursive \
 	install-dvi-recursive install-exec-recursive \
 	install-dvi-recursive install-exec-recursive \
@@ -162,20 +164,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -185,10 +189,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -196,8 +199,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -221,7 +228,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -253,6 +260,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -287,39 +295,32 @@ SUBDIRS = common tcpedit $(FRAGROUTE_DIR)
 @SYSTEM_STRLCPY_TRUE@LIBSTRL = 
 @SYSTEM_STRLCPY_TRUE@LIBSTRL = 
 
 
 # Get AutoOpts search path
 # Get AutoOpts search path
-#opts_list=`find tcpedit -type d -not -regex ".*\.svn.*" -not -regex ".*\.deps.*" -exec echo -n "-L {} " \;`
-opts_list = -L tcpedit $(am__append_1)
-man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1
+opts_list = -L tcpedit
+man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpreplay-edit.1 \
+	$(am__append_2)
 EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1
 EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1
-tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPREPLAY
-@ENABLE_TCPREPLAY_EDIT_FALSE@tcpreplay_LDADD = ./common/libcommon.a \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	$(LIBSTRL) @LNETLIB@ @LPCAPLIB@ \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	$(LIBOPTS_LDADD)
-@ENABLE_TCPREPLAY_EDIT_TRUE@tcpreplay_LDADD = ./tcpedit/libtcpedit.a \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	./common/libcommon.a $(LIBSTRL) \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	@LNETLIB@ @LPCAPLIB@ \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	$(LIBOPTS_LDADD)
-@ENABLE_TCPREPLAY_EDIT_FALSE@tcpreplay_SOURCES = tcpreplay_opts.c \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	send_packets.c signal_handler.c \
-@ENABLE_TCPREPLAY_EDIT_FALSE@	tcpreplay.c sleep.c
-@ENABLE_TCPREPLAY_EDIT_TRUE@tcpreplay_SOURCES = tcpreplay_edit_opts.c \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	send_packets.c signal_handler.c \
-@ENABLE_TCPREPLAY_EDIT_TRUE@	tcpreplay.c sleep.c
+tcpreplay_edit_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY -DTCPREPLAY_EDIT
+tcpreplay_edit_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD)
+tcpreplay_edit_SOURCES = tcpreplay_edit_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c
+tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY
+tcpreplay_SOURCES = tcpreplay_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c
+tcpreplay_LDADD = ./common/libcommon.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD)
 @ENABLE_OSX_FRAMEWORKS_TRUE@tcpreplay_LDFLAGS = -framework CoreServices -framework Carbon
 @ENABLE_OSX_FRAMEWORKS_TRUE@tcpreplay_LDFLAGS = -framework CoreServices -framework Carbon
+@ENABLE_OSX_FRAMEWORKS_TRUE@tcpreplay_edit_LDFLAGS = -framework CoreServices -framework Carbon
 tcprewrite_CFLAGS = $(LIBOPTS_CFLAGS) -I.. @LDNETINC@ $(LNAV_CFLAGS) -DTCPREWRITE -DHAVE_CACHEFILE_SUPPORT
 tcprewrite_CFLAGS = $(LIBOPTS_CFLAGS) -I.. @LDNETINC@ $(LNAV_CFLAGS) -DTCPREWRITE -DHAVE_CACHEFILE_SUPPORT
 tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
 tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
-	$(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ \
+	$(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ \
 	$(LIBFRAGROUTE)
 	$(LIBFRAGROUTE)
 
 
 tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c 
 tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c 
-tcpprep_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPPREP
+tcpprep_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPPREP
 tcpprep_LDADD = ./common/libcommon.a \
 tcpprep_LDADD = ./common/libcommon.a \
-    $(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
+    $(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
 
 
 tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c 
 tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c 
-tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPBRIDGE
+tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPBRIDGE
 tcpbridge_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
 tcpbridge_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
-    $(LIBSTRL) @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
+    $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@
 
 
 @ENABLE_OSX_FRAMEWORKS_TRUE@tcpbridge_LDFLAGS = -framework CoreServices -framework Carbon
 @ENABLE_OSX_FRAMEWORKS_TRUE@tcpbridge_LDFLAGS = -framework CoreServices -framework Carbon
 tcpbridge_SOURCES = tcpbridge_opts.c tcpbridge.c bridge.c send_packets.c sleep.c
 tcpbridge_SOURCES = tcpbridge_opts.c tcpbridge.c bridge.c send_packets.c sleep.c
@@ -346,8 +347,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	@for dep in $?; do \
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	      exit 1;; \
 	  esac; \
 	  esac; \
 	done; \
 	done; \
@@ -427,6 +428,9 @@ tcpprep$(EXEEXT): $(tcpprep_OBJECTS) $(tcpprep_DEPENDENCIES)
 tcpreplay$(EXEEXT): $(tcpreplay_OBJECTS) $(tcpreplay_DEPENDENCIES) 
 tcpreplay$(EXEEXT): $(tcpreplay_OBJECTS) $(tcpreplay_DEPENDENCIES) 
 	@rm -f tcpreplay$(EXEEXT)
 	@rm -f tcpreplay$(EXEEXT)
 	$(tcpreplay_LINK) $(tcpreplay_OBJECTS) $(tcpreplay_LDADD) $(LIBS)
 	$(tcpreplay_LINK) $(tcpreplay_OBJECTS) $(tcpreplay_LDADD) $(LIBS)
+tcpreplay-edit$(EXEEXT): $(tcpreplay_edit_OBJECTS) $(tcpreplay_edit_DEPENDENCIES) 
+	@rm -f tcpreplay-edit$(EXEEXT)
+	$(tcpreplay_edit_LINK) $(tcpreplay_edit_OBJECTS) $(tcpreplay_edit_LDADD) $(LIBS)
 tcprewrite$(EXEEXT): $(tcprewrite_OBJECTS) $(tcprewrite_DEPENDENCIES) 
 tcprewrite$(EXEEXT): $(tcprewrite_OBJECTS) $(tcprewrite_DEPENDENCIES) 
 	@rm -f tcprewrite$(EXEEXT)
 	@rm -f tcprewrite$(EXEEXT)
 	$(tcprewrite_LINK) $(tcprewrite_OBJECTS) $(tcprewrite_LDADD) $(LIBS)
 	$(tcprewrite_LINK) $(tcprewrite_OBJECTS) $(tcprewrite_LDADD) $(LIBS)
@@ -449,8 +453,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-signal_handler.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-signal_handler.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-sleep.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-sleep.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-send_packets.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-signal_handler.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-sleep.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po@am__quote@
 
 
@@ -657,19 +665,75 @@ tcpreplay-sleep.obj: sleep.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi`
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi`
 
 
-tcpreplay-tcpreplay_edit_opts.o: tcpreplay_edit_opts.c
-@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-tcpreplay_edit_opts.o -MD -MP -MF $(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Tpo -c -o tcpreplay-tcpreplay_edit_opts.o `test -f 'tcpreplay_edit_opts.c' || echo '$(srcdir)/'`tcpreplay_edit_opts.c
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Tpo $(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='tcpreplay_edit_opts.c' object='tcpreplay-tcpreplay_edit_opts.o' libtool=no @AMDEPBACKSLASH@
+tcpreplay_edit-tcpreplay_edit_opts.o: tcpreplay_edit_opts.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay_edit_opts.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo -c -o tcpreplay_edit-tcpreplay_edit_opts.o `test -f 'tcpreplay_edit_opts.c' || echo '$(srcdir)/'`tcpreplay_edit_opts.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='tcpreplay_edit_opts.c' object='tcpreplay_edit-tcpreplay_edit_opts.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay_edit_opts.o `test -f 'tcpreplay_edit_opts.c' || echo '$(srcdir)/'`tcpreplay_edit_opts.c
+
+tcpreplay_edit-tcpreplay_edit_opts.obj: tcpreplay_edit_opts.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay_edit_opts.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo -c -o tcpreplay_edit-tcpreplay_edit_opts.obj `if test -f 'tcpreplay_edit_opts.c'; then $(CYGPATH_W) 'tcpreplay_edit_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_edit_opts.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='tcpreplay_edit_opts.c' object='tcpreplay_edit-tcpreplay_edit_opts.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay_edit_opts.obj `if test -f 'tcpreplay_edit_opts.c'; then $(CYGPATH_W) 'tcpreplay_edit_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_edit_opts.c'; fi`
+
+tcpreplay_edit-send_packets.o: send_packets.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-send_packets.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-send_packets.Tpo -c -o tcpreplay_edit-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-send_packets.Tpo $(DEPDIR)/tcpreplay_edit-send_packets.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='send_packets.c' object='tcpreplay_edit-send_packets.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c
+
+tcpreplay_edit-send_packets.obj: send_packets.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-send_packets.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-send_packets.Tpo -c -o tcpreplay_edit-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-send_packets.Tpo $(DEPDIR)/tcpreplay_edit-send_packets.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='send_packets.c' object='tcpreplay_edit-send_packets.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi`
+
+tcpreplay_edit-signal_handler.o: signal_handler.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-signal_handler.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo -c -o tcpreplay_edit-signal_handler.o `test -f 'signal_handler.c' || echo '$(srcdir)/'`signal_handler.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo $(DEPDIR)/tcpreplay_edit-signal_handler.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='signal_handler.c' object='tcpreplay_edit-signal_handler.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-signal_handler.o `test -f 'signal_handler.c' || echo '$(srcdir)/'`signal_handler.c
+
+tcpreplay_edit-signal_handler.obj: signal_handler.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-signal_handler.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo -c -o tcpreplay_edit-signal_handler.obj `if test -f 'signal_handler.c'; then $(CYGPATH_W) 'signal_handler.c'; else $(CYGPATH_W) '$(srcdir)/signal_handler.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo $(DEPDIR)/tcpreplay_edit-signal_handler.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='signal_handler.c' object='tcpreplay_edit-signal_handler.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-signal_handler.obj `if test -f 'signal_handler.c'; then $(CYGPATH_W) 'signal_handler.c'; else $(CYGPATH_W) '$(srcdir)/signal_handler.c'; fi`
+
+tcpreplay_edit-tcpreplay.o: tcpreplay.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo -c -o tcpreplay_edit-tcpreplay.o `test -f 'tcpreplay.c' || echo '$(srcdir)/'`tcpreplay.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='tcpreplay.c' object='tcpreplay_edit-tcpreplay.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay.o `test -f 'tcpreplay.c' || echo '$(srcdir)/'`tcpreplay.c
+
+tcpreplay_edit-tcpreplay.obj: tcpreplay.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo -c -o tcpreplay_edit-tcpreplay.obj `if test -f 'tcpreplay.c'; then $(CYGPATH_W) 'tcpreplay.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='tcpreplay.c' object='tcpreplay_edit-tcpreplay.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) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay.obj `if test -f 'tcpreplay.c'; then $(CYGPATH_W) 'tcpreplay.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay.c'; fi`
+
+tcpreplay_edit-sleep.o: sleep.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-sleep.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-sleep.Tpo -c -o tcpreplay_edit-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-sleep.Tpo $(DEPDIR)/tcpreplay_edit-sleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='sleep.c' object='tcpreplay_edit-sleep.o' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-tcpreplay_edit_opts.o `test -f 'tcpreplay_edit_opts.c' || echo '$(srcdir)/'`tcpreplay_edit_opts.c
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c
 
 
-tcpreplay-tcpreplay_edit_opts.obj: tcpreplay_edit_opts.c
-@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-tcpreplay_edit_opts.obj -MD -MP -MF $(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Tpo -c -o tcpreplay-tcpreplay_edit_opts.obj `if test -f 'tcpreplay_edit_opts.c'; then $(CYGPATH_W) 'tcpreplay_edit_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_edit_opts.c'; fi`
-@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Tpo $(DEPDIR)/tcpreplay-tcpreplay_edit_opts.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='tcpreplay_edit_opts.c' object='tcpreplay-tcpreplay_edit_opts.obj' libtool=no @AMDEPBACKSLASH@
+tcpreplay_edit-sleep.obj: sleep.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-sleep.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-sleep.Tpo -c -o tcpreplay_edit-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/tcpreplay_edit-sleep.Tpo $(DEPDIR)/tcpreplay_edit-sleep.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='sleep.c' object='tcpreplay_edit-sleep.obj' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-tcpreplay_edit_opts.obj `if test -f 'tcpreplay_edit_opts.c'; then $(CYGPATH_W) 'tcpreplay_edit_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_edit_opts.c'; fi`
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi`
 
 
 tcprewrite-tcprewrite_opts.o: tcprewrite_opts.c
 tcprewrite-tcprewrite_opts.o: tcprewrite_opts.c
 @am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -MT tcprewrite-tcprewrite_opts.o -MD -MP -MF $(DEPDIR)/tcprewrite-tcprewrite_opts.Tpo -c -o tcprewrite-tcprewrite_opts.o `test -f 'tcprewrite_opts.c' || echo '$(srcdir)/'`tcprewrite_opts.c
 @am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -MT tcprewrite-tcprewrite_opts.o -MD -MP -MF $(DEPDIR)/tcprewrite-tcprewrite_opts.Tpo -c -o tcprewrite-tcprewrite_opts.o `test -f 'tcprewrite_opts.c' || echo '$(srcdir)/'`tcprewrite_opts.c
@@ -715,8 +779,8 @@ install-man1: $(man1_MANS) $(man_MANS)
 	  esac; \
 	  esac; \
 	done; \
 	done; \
 	for i in $$list; do \
 	for i in $$list; do \
-	  if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
-	  else file=$$i; fi; \
+	  if test -f $$i; then file=$$i; \
+	  else file=$(srcdir)/$$i; fi; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
 	  case "$$ext" in \
 	  case "$$ext" in \
 	    1*) ;; \
 	    1*) ;; \
@@ -825,7 +889,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 	mkid -fID $$unique
 tags: TAGS
 tags: TAGS
@@ -1057,15 +1121,17 @@ tcpreplay.1: tcpreplay_opts.def
 
 
 tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpbridge tcpbridge_opts.def
 	@AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpbridge tcpbridge_opts.def
+tcpreplay_edit_OBJECTS: tcpreplay_opts.h
+tcpreplay_edit_opts.h: tcpreplay_edit_opts.c
 
 
+tcpreplay_edit_opts.c: tcpreplay_opts.def
+	@AUTOGEN@ $(opts_list) -DTCPREPLAY_EDIT -b tcpreplay_edit_opts \
+		tcpreplay_opts.def
 tcpreplay_OBJECTS: tcpreplay_opts.h
 tcpreplay_OBJECTS: tcpreplay_opts.h
 tcpreplay_opts.h: tcpreplay_opts.c
 tcpreplay_opts.h: tcpreplay_opts.c
-tcpreplay_edit_opts.h: tcpreplay_edit_opts.c
+
 tcpreplay_opts.c: tcpreplay_opts.def
 tcpreplay_opts.c: tcpreplay_opts.def
 	@AUTOGEN@ $(opts_list) tcpreplay_opts.def
 	@AUTOGEN@ $(opts_list) tcpreplay_opts.def
-tcpreplay_edit_opts.c: tcpreplay_opts.def
-	@AUTOGEN@ $(opts_list) -DTCPREPLAY_EDIT -b tcpreplay_edit_opts \
-		tcpreplay_opts.def
 tcprewrite_OBJECTS: tcprewrite_opts.h
 tcprewrite_OBJECTS: tcprewrite_opts.h
 tcprewrite_opts.h: tcprewrite_opts.c
 tcprewrite_opts.h: tcprewrite_opts.c
 tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def
 tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def

+ 246 - 88
src/bridge.c

@@ -1,4 +1,4 @@
-/* $Id: bridge.c 2040 2008-05-20 22:37:40Z aturner $ */
+/* $Id: bridge.c 2195 2009-02-04 21:17:45Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -42,6 +42,10 @@
 #include <errno.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <stdlib.h>
 
 
+#ifdef HAVE_BPF
+#include <sys/select.h> /* necessary for using select() for BPF devices */
+#endif
+
 #include "tcpbridge.h"
 #include "tcpbridge.h"
 #include "bridge.h"
 #include "bridge.h"
 #include "send_packets.h"
 #include "send_packets.h"
@@ -102,74 +106,99 @@ new_node(void)
 
 
 
 
 /**
 /**
- * main loop for bridging mode or unidir
+ * main loop for bridging in only one direction
+ * optimized to not use poll(), but rather libpcap's builtin pcap_loop()
  */
  */
-void
-do_bridge(tcpedit_t *tcpedit, pcap_t * pcap1, pcap_t * pcap2)
+static void
+do_bridge_unidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
 {
 {
-    struct pollfd polls[2];     /* one for left & right pcap */
-    int pollresult = 0;
-    u_char source1 = PCAP_INT1;
-    u_char source2 = PCAP_INT2;
     struct live_data_t livedata;
     struct live_data_t livedata;
-    int pollcount = 1;          /* default to unidir mode */
-    
-    assert(pcap1); /* must be set */
+    int retcode;
 
 
-    /* define polls */
-    polls[PCAP_INT1].fd = pcap_fileno(pcap1);
-    polls[PCAP_INT1].events = POLLIN | POLLPRI;
-    polls[PCAP_INT1].revents = 0;
+    assert(options);
+    assert(tcpedit);
+    
+    livedata.tcpedit = tcpedit;
+    livedata.source = PCAP_INT1;
+    livedata.pcap = options->pcap1;
+    livedata.options = options;
 
 
-    if (! options.unidir) {
-        assert(pcap2);
-        polls[PCAP_INT2].fd = pcap_fileno(pcap2);
-        polls[PCAP_INT2].events = POLLIN | POLLPRI;
-        polls[PCAP_INT2].revents = 0;
-        pollcount = 2;
+    if ((retcode = pcap_loop(options->pcap1, options->limit_send, 
+            (pcap_handler)live_callback, (u_char *) &livedata)) < 0) {
+        warnx("Error in pcap_loop(): %s", pcap_geterr(options->pcap1));
     }
     }
+    
+}
 
 
-    /* register signals */
-    didsig = 0;
-    (void)signal(SIGINT, catcher);
+#ifndef HAVE_BPF
+/**
+ * main loop for bridging in both directions.  Since we dealing with two handles
+ * we need to poll() on them which isn't the most efficent. 
+ *
+ * Note that this function is only used on systems which do not have a BPF
+ * device because poll() behaves poorly with /dev/bpf
+ */
+static void
+do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
+{
+    struct pollfd polls[2];     /* one for left & right pcap */
+    int pollresult, pollcount, timeout;
+    struct live_data_t livedata;
+    
+    assert(options);
+    assert(tcpedit);
 
 
     livedata.tcpedit = tcpedit;
     livedata.tcpedit = tcpedit;
+    livedata.options = options;
+
 
 
     /* 
     /* 
      * loop until ctrl-C or we've sent enough packets
      * loop until ctrl-C or we've sent enough packets
      * note that if -L wasn't specified, limit_send is
      * note that if -L wasn't specified, limit_send is
      * set to 0 so this will loop infinately
      * set to 0 so this will loop infinately
      */
      */
-    while ((options.limit_send == 0) || (options.limit_send != pkts_sent)) {
-        if (didsig) {
-            packet_stats(&begin, &end, bytes_sent, pkts_sent, failed);
-            exit(1);
-        }
+    while ((options->limit_send == 0) || (options->limit_send > pkts_sent)) {
+        if (didsig)
+            break;
 
 
         dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, 
         dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, 
-            options.limit_send, pkts_sent);
+            options->limit_send, pkts_sent);
+
+        /* reset the result codes */
+        polls[PCAP_INT1].revents = 0;
+        polls[PCAP_INT1].events = POLLIN;
+        polls[PCAP_INT1].fd = pcap_fileno(options->pcap1);
+        
+        polls[PCAP_INT2].revents = 0;
+        polls[PCAP_INT2].events = POLLIN;
+        polls[PCAP_INT2].fd = pcap_fileno(options->pcap2);
+
+        timeout = options->poll_timeout;
+        pollcount = 2;
 
 
         /* poll for a packet on the two interfaces */
         /* poll for a packet on the two interfaces */
-        pollresult = poll(polls, pollcount, options.poll_timeout);
+        pollresult = poll(polls, pollcount, timeout);
 
 
         /* poll has returned, process the result */
         /* poll has returned, process the result */
         if (pollresult > 0) {
         if (pollresult > 0) {
+            dbgx(3, "pollresult: %d", pollresult);
+            
             /* success, got one or more packets */
             /* success, got one or more packets */
             if (polls[PCAP_INT1].revents > 0) {
             if (polls[PCAP_INT1].revents > 0) {
                 dbg(5, "Processing first interface");
                 dbg(5, "Processing first interface");
-                livedata.source = source1;
-                livedata.pcap = pcap1;
-                pcap_dispatch(pcap1, -1, (pcap_handler) live_callback,
-                              (u_char *) & livedata);
+                livedata.source = PCAP_INT1;
+                livedata.pcap = options->pcap1;
+                pcap_dispatch(options->pcap1, -1, (pcap_handler) live_callback,
+                              (u_char *) &livedata);
             }
             }
 
 
             /* check the other interface?? */
             /* check the other interface?? */
-            if (! options.unidir && polls[PCAP_INT2].revents > 0) {
+            if (polls[PCAP_INT2].revents > 0) {
                 dbg(5, "Processing second interface");
                 dbg(5, "Processing second interface");
-                livedata.source = source2;
-                livedata.pcap = pcap2;
-                pcap_dispatch(pcap2, -1, (pcap_handler) live_callback,
-                              (u_char *) & livedata);
+                livedata.source = PCAP_INT2;
+                livedata.pcap = options->pcap2;
+                pcap_dispatch(options->pcap2, -1, (pcap_handler) live_callback,
+                              (u_char *) &livedata);
             }
             }
 
 
         }
         }
@@ -182,30 +211,160 @@ do_bridge(tcpedit_t *tcpedit, pcap_t * pcap1, pcap_t * pcap2)
             warnx("poll() error: %s", strerror(errno));
             warnx("poll() error: %s", strerror(errno));
         }
         }
 
 
+        /* go back to the top of the loop */
+    }
+
+} /* do_bridge_bidirectional() */
+
+#elif defined HAVE_BPF && defined HAVE_PCAP_SETNONBLOCK 
+/**
+ * main loop for bridging in both directions with BPF.  We'll be using
+ * select() because that works better on older *BSD and OSX
+ *
+ * See this for details behind this maddness:
+ * http://article.gmane.org/gmane.network.tcpdump.devel/3581
+ */
+static void
+do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
+{
+    fd_set readfds, writefds, errorfds;
+    struct live_data_t livedata;
+    int fd, nfds, ret;
+    struct timeval timeout = { 0, 100 }; /* default to 100ms timeout */
+    char ebuf[PCAP_ERRBUF_SIZE];
+    
+    assert(options);
+    assert(tcpedit);
+
+    livedata.tcpedit = tcpedit;
+    livedata.options = options;
+
+    /* 
+     * loop until ctrl-C or we've sent enough packets
+     * note that if -L wasn't specified, limit_send is
+     * set to 0 so this will loop infinately
+     */
+    while ((options->limit_send == 0) || (options->limit_send > pkts_sent)) {
+        if (didsig)
+            break;
+
+        dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, 
+            options->limit_send, pkts_sent);
+
         /* reset the result codes */
         /* reset the result codes */
-        polls[PCAP_INT1].revents = 0;
-        if (! options.unidir)
-            polls[PCAP_INT2].revents = 0;
+        FD_ZERO(&readfds);
+        FD_ZERO(&writefds);
+        FD_ZERO(&errorfds);
+
+        /* set for reading */
+#ifdef HAVE_PCAP_GET_SELECTABLE_FD
+        fd = pcap_get_selectable_fd(options->pcap1);
+#else
+        fd = pcap_fileno(options->pcap1);
+#endif
+        if ((pcap_setnonblock(options->pcap1, 1, ebuf)) < 0)
+            errx(1, "Unable to set %s into nonblocking mode: %s", options->intf1, ebuf);
+        FD_SET(fd, &readfds);
+            
+#ifdef HAVE_PCAP_GET_SELECTABLE_FD
+        fd = pcap_get_selectable_fd(options->pcap2);
+#else
+        fd = pcap_fileno(options->pcap2);
+#endif
+        if ((pcap_setnonblock(options->pcap2, 1, ebuf)) < 0)
+            errx(1, "Unable to set %s into nonblocking mode: %s", options->intf2, ebuf);
+        FD_SET(fd, &readfds);
+        
+        nfds = 2;
+
+        /* wait for a packet on the two interfaces */
+        ret = select(nfds, &readfds, &writefds, &errorfds, &timeout);
+
+        /* 
+         * There is a problem with OS X and certian *BSD's when using
+         * select() on a character device like /dev/bpf.  Hence we always
+         * must attempt to read off each fd after the timeout.  This is why
+         * we put the fd's in nonblocking mode above!
+         */
+         
+        dbg(5, "Processing first interface");
+        livedata.source = PCAP_INT1;
+        livedata.pcap = options->pcap1;
+        pcap_dispatch(options->pcap1, -1, (pcap_handler) live_callback,
+                      (u_char *) &livedata);
+         
+        dbg(5, "Processing second interface");
+        livedata.source = PCAP_INT2;
+        livedata.pcap = options->pcap2;
+        pcap_dispatch(options->pcap2, -1, (pcap_handler) live_callback,
+                      (u_char *) &livedata);
 
 
         /* go back to the top of the loop */
         /* go back to the top of the loop */
+    }    
+} 
+#else
+#error "Your system needs a libpcap with pcap_setnonblock().  Please upgrade libpcap."
+#endif
+
+/**
+ * Main entry point to bridging.  Does some initial setup and then calls the 
+ * correct loop (unidirectional or bidirectional)
+ */
+void
+do_bridge(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
+{   
+    /* do we apply a bpf filter? */
+    if (options->bpf.filter != NULL) {
+        /* compile filter */
+        dbgx(2, "Try to compile pcap bpf filter: %s", options->bpf.filter);
+        if (pcap_compile(options->pcap1, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) {
+            errx(-1, "Error compiling BPF filter: %s", pcap_geterr(options->pcap1));
+        }
+        
+        /* apply filter */
+        pcap_setfilter(options->pcap1, &options->bpf.program);
+
+        /* same for other interface if applicable */
+        if (options->unidir == 0) {
+            /* compile filter */
+            dbgx(2, "Try to compile pcap bpf filter: %s", options->bpf.filter);
+            if (pcap_compile(options->pcap2, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) {
+                errx(-1, "Error compiling BPF filter: %s", pcap_geterr(options->pcap2));
+            }
+        
+            /* apply filter */
+            pcap_setfilter(options->pcap2, &options->bpf.program);
+        }
     }
     }
 
 
-} /* do_bridge() */
+    /* register signals */
+    didsig = 0;
+    (void)signal(SIGINT, catcher);
+
+
+    if (options->unidir == 1) {
+        do_bridge_unidirectional(options, tcpedit);
+    } else {
+        do_bridge_bidirectional(options, tcpedit);
+    }
+            
+    packet_stats(&begin, &end, bytes_sent, pkts_sent, failed);
+}
 
 
 
 
 /**
 /**
  * This is the callback we use with pcap_dispatch to process
  * This is the callback we use with pcap_dispatch to process
  * each packet recieved by libpcap on the two interfaces.
  * each packet recieved by libpcap on the two interfaces.
+ * Need to return > 0 to denote success
  */
  */
 static int
 static int
 live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
 live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
               const u_char * nextpkt)
               const u_char * nextpkt)
 {
 {
     ipv4_hdr_t *ip_hdr = NULL;
     ipv4_hdr_t *ip_hdr = NULL;
-    sendpacket_t *sp = NULL;
+    pcap_t *send = NULL;
     static u_char *pktdata = NULL;     /* full packet buffer */
     static u_char *pktdata = NULL;     /* full packet buffer */
-    u_char **packet;
-    int cache_mode;
+    int cache_mode, retcode;
     static unsigned long packetnum = 0;
     static unsigned long packetnum = 0;
     struct macsrc_t *node, finder;  /* rb tree nodes */
     struct macsrc_t *node, finder;  /* rb tree nodes */
 #ifdef DEBUG
 #ifdef DEBUG
@@ -214,7 +373,7 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
     u_int16_t l2proto;
     u_int16_t l2proto;
 
 
     packetnum++;
     packetnum++;
-    dbgx(2, "packet %d caplen %d", packetnum, pkthdr->caplen);
+    dbgx(2, "packet %lu caplen %d", packetnum, pkthdr->caplen);
 
 
     /* only malloc the first time */
     /* only malloc the first time */
     if (pktdata == NULL) {
     if (pktdata == NULL) {
@@ -231,8 +390,8 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
 
 
 #ifdef ENABLE_VERBOSE
 #ifdef ENABLE_VERBOSE
     /* decode packet? */
     /* decode packet? */
-    if (options.verbose)
-        tcpdump_print(options.tcpdump, pkthdr, nextpkt);
+    if (livedata->options->verbose)
+        tcpdump_print(livedata->options->tcpdump, pkthdr, nextpkt);
 #endif
 #endif
 
 
 
 
@@ -245,18 +404,17 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
 #endif
 #endif
 
 
     /* first, is this a packet sent locally?  If so, ignore it */
     /* first, is this a packet sent locally?  If so, ignore it */
-    if ((memcmp(sendpacket_get_hwaddr(options.sp1), &finder.key, 
-            ETHER_ADDR_LEN)) == 0) {
-        dbgx(1, "Packet matches the MAC of %s, skipping.", options.intf1);
+    if ((memcmp(livedata->options->intf1_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
+        dbgx(1, "Packet matches the MAC of %s, skipping.", livedata->options->intf1);
         return (1);
         return (1);
     }
     }
-    else if ((memcmp(sendpacket_get_hwaddr(options.sp2), &finder.key,
-            ETHER_ADDR_LEN)) == 0) {
-        dbgx(1, "Packet matches the MAC of %s, skipping.", options.intf2);
+    else if ((memcmp(livedata->options->intf2_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
+        dbgx(1, "Packet matches the MAC of %s, skipping.", livedata->options->intf2);
         return (1);
         return (1);
     }
     }
 
 
     node = RB_FIND(macsrc_tree, &macsrc_root, &finder);
     node = RB_FIND(macsrc_tree, &macsrc_root, &finder);
+    
     /* if we can't find the node, build a new one */
     /* if we can't find the node, build a new one */
     if (node == NULL) {
     if (node == NULL) {
         dbg(1, "Unable to find MAC in the tree");
         dbg(1, "Unable to find MAC in the tree");
@@ -264,10 +422,11 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
         node->source = livedata->source;
         node->source = livedata->source;
         memcpy(&node->key, &finder.key, ETHER_ADDR_LEN);
         memcpy(&node->key, &finder.key, ETHER_ADDR_LEN);
         RB_INSERT(macsrc_tree, &macsrc_root, node);
         RB_INSERT(macsrc_tree, &macsrc_root, node);
-    }                           /* otherwise compare sources */
+    }
+    
+    /* otherwise compare sources */
     else if (node->source != livedata->source) {
     else if (node->source != livedata->source) {
-        dbg(1,
-            "Found the MAC and we had a source missmatch... skipping packet");
+        dbg(1, "Found the dest MAC in the tree and it doesn't match this source NIC... skipping packet");
         /*
         /*
          * IMPORTANT!!!
          * IMPORTANT!!!
          * Never send a packet out the same interface we sourced it on!
          * Never send a packet out the same interface we sourced it on!
@@ -275,21 +434,20 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
         return (1);
         return (1);
     }
     }
 
 
-
-
     /* what is our cache mode? */
     /* what is our cache mode? */
     cache_mode = livedata->source == PCAP_INT1 ? TCPR_DIR_C2S : TCPR_DIR_S2C;
     cache_mode = livedata->source == PCAP_INT1 ? TCPR_DIR_C2S : TCPR_DIR_S2C;
 
 
     l2proto = tcpedit_l3proto(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
     l2proto = tcpedit_l3proto(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
     dbgx(2, "Packet protocol: %04hx", l2proto);
     dbgx(2, "Packet protocol: %04hx", l2proto);
+    
     /* should we skip this packet based on CIDR match? */
     /* should we skip this packet based on CIDR match? */
     if (l2proto == ETHERTYPE_IP) {
     if (l2proto == ETHERTYPE_IP) {
         dbg(3, "Packet is IP");
         dbg(3, "Packet is IP");
         ip_hdr = (ipv4_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
         ip_hdr = (ipv4_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
 
 
         /* look for include or exclude CIDR match */
         /* look for include or exclude CIDR match */
-        if (options.xX.cidr != NULL) {
-            if (!process_xX_by_cidr(options.xX.mode, options.xX.cidr, ip_hdr)) {
+        if (livedata->options->xX.cidr != NULL) {
+            if (!process_xX_by_cidr(livedata->options->xX.mode, livedata->options->xX.cidr, ip_hdr)) {
                 dbg(2, "Skipping packet due to CIDR match");
                 dbg(2, "Skipping packet due to CIDR match");
                 return (1);
                 return (1);
             }
             }
@@ -297,35 +455,42 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
 
 
     }
     }
 
 
-    packet = &pktdata;
-    if (tcpedit_packet(livedata->tcpedit, &pkthdr, packet, cache_mode) == -1) {
-        return -1;
+    if ((retcode = tcpedit_packet(livedata->tcpedit, &pkthdr, &pktdata, cache_mode)) < 0) {
+        if (retcode == TCPEDIT_SOFT_ERROR) {
+            return 1;
+        } else { /* TCPEDIT_ERROR */
+            return -1;
+        }
     }
     }
 
 
     /* 
     /* 
      * send packets out the OTHER interface
      * send packets out the OTHER interface
      * and update the dst mac if necessary
      * and update the dst mac if necessary
      */
      */
-    if (node->source == PCAP_INT1) {
-        dbgx(2, "Packet source was %s... sending out on %s", options.intf1, 
-            options.intf2);
-        sp = options.sp2;
-    }
-    else if (node->source == PCAP_INT2) {
-        dbgx(2, "Packet source was %s... sending out on %s", options.intf2, 
-            options.intf1);
-        sp = options.sp1;
-    } else {
-        errx(1, "wtf?  our node->source != PCAP_INT1 and != PCAP_INT2: %c", 
-             node->source);
+    switch(node->source) {
+        case PCAP_INT1:
+            dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf1, 
+                livedata->options->intf2);
+            send = livedata->options->pcap2;
+            break;
+
+        case PCAP_INT2:
+            dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf2, 
+                livedata->options->intf1);
+            send = livedata->options->pcap1;
+            break;
+        
+        default:
+            errx(-1, "wtf?  our node->source != PCAP_INT1 and != PCAP_INT2: %c", 
+                 node->source);        
     }
     }
 
 
     /*
     /*
      * write packet out on the network 
      * write packet out on the network 
      */
      */
-     if (sendpacket(sp, pktdata, pkthdr->caplen) < (int)pkthdr->caplen) {
-         errx(1, "Unable to send packet out %s: %s", sp->device, sendpacket_geterr(sp));
-     }
+     if (pcap_sendpacket(send, pktdata, pkthdr->caplen) < 0)
+         errx(-1, "Unable to send packet out %s: %s", 
+            send == livedata->options->pcap1 ? livedata->options->intf1 : livedata->options->intf2, pcap_geterr(send));
 
 
     bytes_sent += pkthdr->caplen;
     bytes_sent += pkthdr->caplen;
     pkts_sent++;
     pkts_sent++;
@@ -336,11 +501,4 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
     return (1);
     return (1);
 } /* live_callback() */
 } /* live_callback() */
 
 
-/*
- Local Variables:
- mode:c
- indent-tabs-mode:nil
- c-basic-offset:4
- End:
-*/
 
 

+ 3 - 2
src/bridge.h

@@ -1,4 +1,4 @@
-/* $Id: bridge.h 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: bridge.h 2127 2009-01-10 06:06:46Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -61,10 +61,11 @@ struct live_data_t {
     char *l2data;
     char *l2data;
     pcap_t *pcap;
     pcap_t *pcap;
     tcpedit_t *tcpedit;
     tcpedit_t *tcpedit;
+    tcpbridge_opt_t *options;
 };
 };
 
 
 void rbinit(void);
 void rbinit(void);
-void do_bridge(tcpedit_t *, pcap_t *, pcap_t *);
+void do_bridge(tcpbridge_opt_t *, tcpedit_t *);
 
 
 
 
 #endif
 #endif

BIN
src/common/._cidr.c


BIN
src/common/._dlt_names.h


BIN
src/common/._fakepoll.c


BIN
src/common/._fakepoll.h


BIN
src/common/._interface.c


BIN
src/common/._interface.h


BIN
src/common/._sendpacket.c


+ 1 - 1
src/common/Makefile.am

@@ -20,7 +20,7 @@ if ENABLE_TCPDUMP
 libcommon_a_SOURCES += tcpdump.c
 libcommon_a_SOURCES += tcpdump.c
 endif
 endif
 
 
-AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS)
+AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS) @LDNETINC@
 
 
 libcommon_a_LIBADD = ../../lib/libstrl.a
 libcommon_a_LIBADD = ../../lib/libstrl.a
 
 

+ 18 - 11
src/common/Makefile.in

@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
 # @configure_input@
 # @configure_input@
 
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -39,7 +39,8 @@ subdir = src/common
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
 	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
@@ -103,20 +104,22 @@ DEFS = @DEFS@
 DEPDIR = @DEPDIR@
 DEPDIR = @DEPDIR@
 DMALLOC_LIB = @DMALLOC_LIB@
 DMALLOC_LIB = @DMALLOC_LIB@
 DSYMUTIL = @DSYMUTIL@
 DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
 ECHO = @ECHO@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
+FGREP = @FGREP@
 GREP = @GREP@
 GREP = @GREP@
+GROFF = @GROFF@
 INSTALL = @INSTALL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
 LDFLAGS = @LDFLAGS@
 LDFLAGS = @LDFLAGS@
 LDNETINC = @LDNETINC@
 LDNETINC = @LDNETINC@
 LDNETLIB = @LDNETLIB@
 LDNETLIB = @LDNETLIB@
@@ -126,10 +129,9 @@ LIBOPTS_DIR = @LIBOPTS_DIR@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBOPTS_LDADD = @LIBOPTS_LDADD@
 LIBS = @LIBS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
 LNAVLIB = @LNAVLIB@
 LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNAV_CFLAGS = @LNAV_CFLAGS@
-LNETINC = @LNETINC@
-LNETLIB = @LNETLIB@
 LN_S = @LN_S@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
 LPCAPLIB = @LPCAPLIB@
@@ -137,8 +139,12 @@ LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 MKDIR_P = @MKDIR_P@
+NM = @NM@
 NMEDIT = @NMEDIT@
 NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
 PACKAGE = @PACKAGE@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_NAME = @PACKAGE_NAME@
@@ -162,7 +168,7 @@ abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
 am__include = @am__include@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
 am__quote = @am__quote@
@@ -194,6 +200,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localedir = @localedir@
 localstatedir = @localstatedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 mkdir_p = @mkdir_p@
 nic1 = @nic1@
 nic1 = @nic1@
@@ -225,7 +232,7 @@ libcommon_a_SOURCES = cidr.c err.c list.c cache.c services.c get.c \
 	fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c timer.c \
 	fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c timer.c \
 	svn_version.c abort.c sendpacket.c dlt_names.c mac.c \
 	svn_version.c abort.c sendpacket.c dlt_names.c mac.c \
 	interface.c rdtsc.c $(am__append_1)
 	interface.c rdtsc.c $(am__append_1)
-AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS)
+AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS) @LDNETINC@
 libcommon_a_LIBADD = ../../lib/libstrl.a
 libcommon_a_LIBADD = ../../lib/libstrl.a
 noinst_HEADERS = cidr.h err.h list.h cache.h services.h get.h \
 noinst_HEADERS = cidr.h err.h list.h cache.h services.h get.h \
 		 fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \
 		 fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \
@@ -243,8 +250,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__confi
 	@for dep in $?; do \
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	      exit 1;; \
 	  esac; \
 	  esac; \
 	done; \
 	done; \
@@ -335,7 +342,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 	mkid -fID $$unique
 tags: TAGS
 tags: TAGS

+ 16 - 16
src/common/cache.c

@@ -1,4 +1,4 @@
-/* $Id: cache.c 1907 2007-10-05 23:24:38Z aturner $ */
+/* $Id: cache.c 2110 2009-01-08 00:22:22Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -87,22 +87,22 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
 
 
     /* open the file or abort */
     /* open the file or abort */
     if ((cachefd = open(cachefile, O_RDONLY)) == -1)
     if ((cachefd = open(cachefile, O_RDONLY)) == -1)
-        errx(1, "unable to open %s:%s", cachefile, strerror(errno));
+        errx(-1, "unable to open %s:%s", cachefile, strerror(errno));
 
 
     /* read the cache header and determine compatibility */
     /* read the cache header and determine compatibility */
     if ((read_size = read(cachefd, &header, sizeof(header))) < 0)
     if ((read_size = read(cachefd, &header, sizeof(header))) < 0)
-        errx(1, "unable to read from %s:%s,", cachefile, strerror(errno));
+        errx(-1, "unable to read from %s:%s,", cachefile, strerror(errno));
 
 
     if (read_size < (ssize_t)sizeof(header))
     if (read_size < (ssize_t)sizeof(header))
-        errx(1, "Cache file %s doesn't contain a full header", cachefile);
+        errx(-1, "Cache file %s doesn't contain a full header", cachefile);
 
 
     /* verify our magic: tcpprep\0 */
     /* verify our magic: tcpprep\0 */
     if (memcmp(header.magic, CACHEMAGIC, sizeof(CACHEMAGIC)) != 0)
     if (memcmp(header.magic, CACHEMAGIC, sizeof(CACHEMAGIC)) != 0)
-        errx(1, "Unable to process %s: not a tcpprep cache file", cachefile);
+        errx(-1, "Unable to process %s: not a tcpprep cache file", cachefile);
 
 
     /* verify version */
     /* verify version */
     if (atoi(header.version) != atoi(CACHEVERSION))
     if (atoi(header.version) != atoi(CACHEVERSION))
-        errx(1, "Unable to process %s: cache file version missmatch",
+        errx(-1, "Unable to process %s: cache file version missmatch",
              cachefile);
              cachefile);
 
 
     /* read the comment */
     /* read the comment */
@@ -113,7 +113,7 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
     
     
     if ((read_size = read(cachefd, *comment, header.comment_len)) 
     if ((read_size = read(cachefd, *comment, header.comment_len)) 
             != header.comment_len)
             != header.comment_len)
-        errx(1, "Unable to read %d bytes of data for the comment (%d) %s", 
+        errx(-1, "Unable to read %d bytes of data for the comment (%zu) %s", 
             header.comment_len, read_size, 
             header.comment_len, read_size, 
             read_size == -1 ? strerror(read_size) : "");
             read_size == -1 ? strerror(read_size) : "");
 
 
@@ -138,8 +138,8 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
     /* read in the cache */
     /* read in the cache */
     if ((COUNTER)(read_size = read(cachefd, *cachedata, cache_size)) 
     if ((COUNTER)(read_size = read(cachefd, *cachedata, cache_size)) 
             != cache_size)
             != cache_size)
-        errx(1, "Cache data length (%ld bytes) doesn't match "
-            "cache header (%ld bytes)", read_size, cache_size);
+        errx(-1, "Cache data length (%ld bytes) doesn't match "
+            "cache header (" COUNTER_SPEC " bytes)", read_size, cache_size);
 
 
     dbgx(1, "Loaded in %llu packets from cache.", header.num_packets);
     dbgx(1, "Loaded in %llu packets from cache.", header.num_packets);
 
 
@@ -182,20 +182,20 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
     }
     }
 
 
     written = write(out_file, cache_header, sizeof(tcpr_cache_file_hdr_t));
     written = write(out_file, cache_header, sizeof(tcpr_cache_file_hdr_t));
-    dbgx(1, "Wrote %d bytes of cache file header", written);
+    dbgx(1, "Wrote %zu bytes of cache file header", written);
 
 
     if (written != sizeof(tcpr_cache_file_hdr_t))
     if (written != sizeof(tcpr_cache_file_hdr_t))
-        errx(1, "Only wrote %d of %d bytes of the cache file header!\n%s",
+        errx(-1, "Only wrote %zu of %zu bytes of the cache file header!\n%s",
              written, sizeof(tcpr_cache_file_hdr_t),
              written, sizeof(tcpr_cache_file_hdr_t),
              written == -1 ? strerror(errno) : "");
              written == -1 ? strerror(errno) : "");
 
 
     /* don't write comment if there is none */
     /* don't write comment if there is none */
     if (comment != NULL) {
     if (comment != NULL) {
         written = write(out_file, comment, strlen(comment));
         written = write(out_file, comment, strlen(comment));
-        dbgx(1, "Wrote %d bytes of comment", written);
+        dbgx(1, "Wrote %zu bytes of comment", written);
         
         
         if (written != (ssize_t)strlen(comment))
         if (written != (ssize_t)strlen(comment))
-            errx(1, "Only wrote %d of %d bytes of the comment!\n%s",
+            errx(-1, "Only wrote %zu of %zu bytes of the comment!\n%s",
                  written, strlen(comment), 
                  written, strlen(comment), 
                  written == -1 ? strerror(errno) : "");
                  written == -1 ? strerror(errno) : "");
     }
     }
@@ -216,9 +216,9 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
 
 
         /* write to file, and verify it wrote properly */
         /* write to file, and verify it wrote properly */
         written = write(out_file, mycache->data, chars);
         written = write(out_file, mycache->data, chars);
-        dbgx(1, "Wrote %i bytes of cache data", written);
+        dbgx(1, "Wrote %zu bytes of cache data", written);
         if (written != (ssize_t)chars)
         if (written != (ssize_t)chars)
-            errx(1, "Only wrote %i of %i bytes to cache file!", written, chars);
+            errx(-1, "Only wrote %zu of %i bytes to cache file!", written, chars);
 
 
         /*
         /*
          * if that was the last, stop processing, otherwise wash,
          * if that was the last, stop processing, otherwise wash,
@@ -342,7 +342,7 @@ check_cache(char *cachedata, COUNTER packetid)
     assert(cachedata);
     assert(cachedata);
 
 
     if (packetid == 0)
     if (packetid == 0)
-        err(1, "packetid must be > 0");
+        err(-1, "packetid must be > 0");
 
 
     index = (packetid - 1) / (COUNTER)CACHE_PACKETS_PER_BYTE;
     index = (packetid - 1) / (COUNTER)CACHE_PACKETS_PER_BYTE;
     bit = (u_int32_t)(((packetid - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * 
     bit = (u_int32_t)(((packetid - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * 

+ 2 - 2
src/common/cidr.c

@@ -1,4 +1,4 @@
-/* $Id: cidr.c 2053 2008-05-31 02:19:17Z aturner $ */
+/* $Id: cidr.c 2074 2008-11-09 08:42:24Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -241,7 +241,7 @@ cidr2cidr(char *cidr)
     memset(ebuf, '\0', EBUF_SIZE);
     memset(ebuf, '\0', EBUF_SIZE);
     strcpy(ebuf, "Unable to parse as a vaild CIDR: ");
     strcpy(ebuf, "Unable to parse as a vaild CIDR: ");
     strlcat(ebuf, cidr, EBUF_SIZE);
     strlcat(ebuf, cidr, EBUF_SIZE);
-    errx(1, "%s", ebuf);
+    errx(-1, "%s", ebuf);
     return NULL;
     return NULL;
 }
 }
 
 

+ 3 - 74
src/common/err.c

@@ -1,4 +1,4 @@
-/* $Id: err.c 1897 2007-08-25 04:57:38Z aturner $ */
+/* $Id: err.c 2070 2008-11-09 08:32:47Z aturner $ */
 
 
 /*
 /*
  * err.c
  * err.c
@@ -77,11 +77,11 @@ notice(const char *fmt, ...)
  * 
  * 
  * You don't actually want to call this!  use dbgx() instead!
  * You don't actually want to call this!  use dbgx() instead!
  */
  */
+#ifdef DEBUG
 void
 void
 _our_verbose_dbgx(int dbg_level, const char *fmt, const char *function, 
 _our_verbose_dbgx(int dbg_level, const char *fmt, const char *function, 
         const int line, const char *file, ...)
         const int line, const char *file, ...)
 {
 {
-#ifdef DEBUG
     va_list ap;
     va_list ap;
 
 
     if (debug < dbg_level)
     if (debug < dbg_level)
@@ -97,70 +97,8 @@ _our_verbose_dbgx(int dbg_level, const char *fmt, const char *function,
     (void)fprintf(stderr, "\n");
     (void)fprintf(stderr, "\n");
     va_end(ap);
     va_end(ap);
     fflush(NULL);
     fflush(NULL);
-#else
-    return;
-#endif
 }
 }
-
-/**
- * Inner call to dbg() which prints the function, line & file along
- * with the message to stderr.  Always forces a newline.
- * 
- * You don't actually want to call this!  use dbg() instead!
- */
-void
-_our_verbose_dbg(int dbg_level, const char *string, const char *function, const int line, const char *file)
-{
-#ifdef DEBUG
-
-    if (debug < dbg_level)
-        return;
-
-    fprintf(stderr, "DEBUG%d in %s:%s() line %d: %s\n", dbg_level, file, 
-            function, line, string);
-#else
-    return;
 #endif
 #endif
-}
-
-
-/**
- * Inner call to err() which when in DEBUG mode, prints the function, line & file
- * along with the actual error message to stderr.  Alawys forces a newline
- */
-#ifdef DEBUG
-void
-_our_verbose_err(int eval, const char *string, const char *function, const int line, const char *file) {
-#else
-void
-_our_verbose_err(int eval, const char *string) {
-#endif
-
-    fprintf(stderr, "%s", "\n");
-#ifdef DEBUG
-    fprintf(stderr, "Fatal Error in %s:%s() line %d:\n", file, function, line);
-#endif
-    fprintf(stderr, "%s\n", string);
-    exit(eval);
-}
-
-/**
- * Inner call to warn() which when in DEBUG mode, prints the function, line & file
- * along with the actual warning to stderr.  Alawys forces a newline
- */
-#ifdef DEBUG
-void
-_our_verbose_warn(const char *string, const char *function, const int line, const char *file) {
-#else
-void
-_our_verbose_warn(const char *string) {
-#endif
-
-#ifdef DEBUG
-    fprintf(stderr, "Warning in %s:%s() line %d:\n", file, function, line);
-#endif
-    fprintf(stderr, "Warning: %s\n", string);
-}
 
 
 /**
 /**
  * Inner call to errx() which when in DEBUG mode, prints the function, line & file
  * Inner call to errx() which when in DEBUG mode, prints the function, line & file
@@ -216,13 +154,4 @@ _our_verbose_warnx(const char *fmt, ...) {
         (void)vfprintf(stderr, fmt, ap);
         (void)vfprintf(stderr, fmt, ap);
     (void)fprintf(stderr, "\n");
     (void)fprintf(stderr, "\n");
     va_end(ap);
     va_end(ap);
-}
-
-/*
- Local Variables:
- mode:c
- indent-tabs-mode:nil
- c-basic-offset:4
- End:
-*/
-
+}

+ 44 - 26
src/common/err.h

@@ -1,4 +1,4 @@
-/* $Id: err.h 1963 2008-01-23 18:21:40Z aturner $ */
+/* $Id: err.h 2100 2009-01-04 22:03:48Z aturner $ */
 
 
 /*
 /*
  * err.h
  * err.h
@@ -46,6 +46,9 @@
 #ifndef _ERR_H_
 #ifndef _ERR_H_
 #define _ERR_H_
 #define _ERR_H_
 
 
+#ifdef DEBUG
+extern int debug;
+#endif
 
 
 /*
 /*
  * We define five functions for reporting errors, warnings and debug messages:
  * We define five functions for reporting errors, warnings and debug messages:
@@ -63,45 +66,60 @@
 #  define __FUNCTION__ __func__
 #  define __FUNCTION__ __func__
 #endif
 #endif
 
 
-#define dbg(x, y) _our_verbose_dbg(x, y, __FUNCTION__, __LINE__, __FILE__)
-void _our_verbose_dbg(int dbg_level, const char *string, const char *, 
-        const int, const char *);
-
-#define dbgx(x, y, ...) _our_verbose_dbgx(x, y, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
-void _our_verbose_dbgx(int dbg_level, const char *fmt, const char *, 
-        const int, const char *, ...);
-
 void notice(const char *fmt, ...);
 void notice(const char *fmt, ...);
 
 
-
 #ifdef DEBUG /* then err, errx, warn, warnx print file, func, line */
 #ifdef DEBUG /* then err, errx, warn, warnx print file, func, line */
 
 
-#define err(x, y) _our_verbose_err(x, y, __FUNCTION__, __LINE__, __FILE__)
-void _our_verbose_err(int eval, const char *string, const char *, const int, const char *);
+#define dbg(x, y) do { \
+    if (debug >= x) \
+        fprintf(stderr, "DEBUG%d in %s:%s() line %d: %s\n", x, __FILE__, __FUNCTION__, __LINE__, y); \
+    } while(0)
+    
+#define dbgx(x, y, ...) do { \
+    if (debug >= x) { \
+        fprintf(stderr, "DEBUG%d in %s:%s() line %d: " y "\n", x, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
+    } \
+} while(0)
+        
+
+#define warn(x) fprintf(stderr, "Warning in %s:%s() line %d:\n%s\n", __FILE__, __FUNCTION__, __LINE__, x)
+
 
 
-#define warn(x) _our_verbose_warn(x, __FUNCTION__, __LINE__, __FILE__)
-void _our_verbose_warn(const char *fmt, const char *, const int, const char *);
+#define warnx(x, ...) fprintf(stderr, "Warning in %s:%s() line %d:\n" x "\n", __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
 
 
-#define errx(x, y, ...) _our_verbose_errx(x, y, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
-void _our_verbose_errx(int eval, const char *fmt, const char *, const int, const char *, ...);
+#define err(x, y) do { \
+        fprintf(stderr, "\nFatal Error in %s:%s() line %d:\n%s\n", __FILE__, __FUNCTION__, __LINE__, y); \
+        fflush(NULL); \
+        exit(x); \
+    } while (0)
 
 
-#define warnx(x, ...) _our_verbose_warnx(x, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
-void _our_verbose_warnx(const char *fmt, const char *, const int, const char *, ...);
+#define errx(x, y, ...) do {\
+        fprintf(stderr, "\nFatal Error in %s:%s() line %d:\n " y "\n", __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
+        fflush(NULL); \
+        exit(x); \
+    } while (0)
 
 
 #else /* no detailed DEBUG info */
 #else /* no detailed DEBUG info */
 
 
-#define err(x, y) _our_verbose_err(x, y)
-void _our_verbose_err(int eval, const char *string);
+/* dbg() and dbgx() become no-ops for non-DEBUG builds */
+#define dbg(x, y) { }
+#define dbgx(x, y, ...) { }
 
 
-#define errx(x, y, ...) _our_verbose_errx(x, y, __VA_ARGS__)
-void _our_verbose_errx(int eval, const char *fmt, ...);
+#define warn(x) fprintf(stderr, "Warning: %s\n", x)
 
 
-#define warn(x) _our_verbose_warn(x)
-void _our_verbose_warn(const char *fmt);
+#define warnx(x, ...) fprintf(stderr, "Warning: " x "\n", __VA_ARGS__)
 
 
-#define warnx(x, ...) _our_verbose_warnx(x, __VA_ARGS__)
-void _our_verbose_warnx(const char *fmt, ...);
+#define err(x, y) do {\
+        fprintf(stderr, "\nFatal Error:\n%s\n", y); \
+        fflush(NULL); \
+        exit(x); \
+    } while(0)
 
 
+#define errx(x, y, ...) do {\
+        fprintf(stderr, "\nFatal Error: " y "\n", __VA_ARGS__); \
+        fflush(NULL); \
+        exit(x); \
+    } while (0)
 #endif /* DEBUG */
 #endif /* DEBUG */
 
 
 
 

+ 3 - 3
src/common/fakepcapnav.c

@@ -1,4 +1,4 @@
-/* $Id: fakepcapnav.c 1897 2007-08-25 04:57:38Z aturner $ */
+/* $Id: fakepcapnav.c 2074 2008-11-09 08:42:24Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -64,12 +64,12 @@ pcapnav_open_offline(const char *filename)
 
 
     pcapnav = (pcapnav_t *) malloc(sizeof(pcapnav_t));
     pcapnav = (pcapnav_t *) malloc(sizeof(pcapnav_t));
     if (pcapnav == NULL) {
     if (pcapnav == NULL) {
-        err(1, "malloc() error: unable to malloc pcapnav_t");
+        err(-1, "malloc() error: unable to malloc pcapnav_t");
     }
     }
 
 
     pcapnav->pcap = pcap_open_offline(filename, errbuf);
     pcapnav->pcap = pcap_open_offline(filename, errbuf);
     if (pcapnav->pcap == NULL) {
     if (pcapnav->pcap == NULL) {
-        errx(1, "Error opening pcap file %s: %s", filename, errbuf);
+        errx(-1, "Error opening pcap file %s: %s", filename, errbuf);
     }
     }
 
 
     return (pcapnav);
     return (pcapnav);

+ 3 - 4
src/common/get.c

@@ -1,4 +1,4 @@
-/* $Id: get.c 1991 2008-04-26 22:22:05Z aturner $ */
+/* $Id: get.c 2096 2009-01-04 20:48:34Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -127,7 +127,7 @@ get_l2protocol(const u_char *pktdata, const int datalen, const int datalink)
         break;
         break;
 
 
     default:
     default:
-        errx(1, "Unable to process unsupported DLT type: %s (0x%x)", 
+        errx(-1, "Unable to process unsupported DLT type: %s (0x%x)", 
              pcap_datalink_val_to_description(datalink), datalink);
              pcap_datalink_val_to_description(datalink), datalink);
 
 
     }
     }
@@ -143,7 +143,6 @@ int
 get_l2len(const u_char *pktdata, const int datalen, const int datalink)
 get_l2len(const u_char *pktdata, const int datalen, const int datalink)
 {
 {
     eth_hdr_t *eth_hdr;
     eth_hdr_t *eth_hdr;
-    u_int16_t ether_type;
     
     
     assert(pktdata);
     assert(pktdata);
     assert(datalen);
     assert(datalen);
@@ -176,7 +175,7 @@ get_l2len(const u_char *pktdata, const int datalen, const int datalink)
         break;
         break;
 
 
     default:
     default:
-        errx(1, "Unable to process unsupported DLT type: %s (0x%x)", 
+        errx(-1, "Unable to process unsupported DLT type: %s (0x%x)", 
              pcap_datalink_val_to_description(datalink), datalink);
              pcap_datalink_val_to_description(datalink), datalink);
         break;
         break;
     }
     }

+ 8 - 3
src/common/interface.c

@@ -1,4 +1,4 @@
-/* $Id: interface.c 1927 2007-10-26 17:19:58Z aturner $ */
+/* $Id: interface.c 2104 2009-01-05 05:05:21Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2007 Aaron Turner.
  * Copyright (c) 2007 Aaron Turner.
@@ -47,11 +47,14 @@
  * which use horrifically long interface names
  * which use horrifically long interface names
  * 
  * 
  * Returns NULL on error
  * Returns NULL on error
+ * 
+ * On success, it *may* malloc() memory equal to the length of *alias.
  */
  */
 char *
 char *
 get_interface(interface_list_t *list, const char *alias)
 get_interface(interface_list_t *list, const char *alias)
 {
 {
     interface_list_t *ptr;
     interface_list_t *ptr;
+    char *name;
     
     
     assert(alias);
     assert(alias);
     
     
@@ -69,7 +72,9 @@ get_interface(interface_list_t *list, const char *alias)
             ptr = ptr->next;
             ptr = ptr->next;
         } while (ptr != NULL);
         } while (ptr != NULL);
     } else {
     } else {
-        return(alias);
+        name = (char *)safe_malloc(strlen(alias) + 1);
+        strlcpy(name, alias, sizeof(name));
+        return(name);
     }
     }
     
     
     return(NULL);
     return(NULL);
@@ -93,7 +98,7 @@ get_interface_list(void)
 #endif
 #endif
 
 
     if (pcap_findalldevs(&pcap_if, ebuf) < 0)
     if (pcap_findalldevs(&pcap_if, ebuf) < 0)
-        errx(1, "Error: %s", ebuf);
+        errx(-1, "Error: %s", ebuf);
             
             
     pcap_if_ptr = pcap_if;
     pcap_if_ptr = pcap_if;
     list_head = (interface_list_t *)safe_malloc(sizeof(interface_list_t));
     list_head = (interface_list_t *)safe_malloc(sizeof(interface_list_t));

+ 2 - 2
src/common/list.c

@@ -1,4 +1,4 @@
-/* $Id: list.c 1897 2007-08-25 04:57:38Z aturner $ */
+/* $Id: list.c 2074 2008-11-09 08:42:24Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -82,7 +82,7 @@ parse_list(tcpr_list_t ** listdata, char *ourstr)
     /* compile the regex first */
     /* compile the regex first */
     if ((rcode = regcomp(&preg, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
     if ((rcode = regcomp(&preg, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
         regerror(rcode, &preg, ebuf, sizeof(ebuf));
         regerror(rcode, &preg, ebuf, sizeof(ebuf));
-        errx(1, "Unable to compile regex (%s): %s", regex, ebuf);
+        errx(-1, "Unable to compile regex (%s): %s", regex, ebuf);
     }
     }
 
 
     /* first iteration */
     /* first iteration */

+ 93 - 47
src/common/sendpacket.c

@@ -1,4 +1,4 @@
-/* $Id: sendpacket.c 2059 2008-06-09 19:37:53Z aturner $ */
+/* $Id: sendpacket.c 2190 2009-02-01 07:30:00Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2006 Aaron Turner.
  * Copyright (c) 2006 Aaron Turner.
@@ -40,7 +40,7 @@
  */
  */
  
  
  /* sendpacket.[ch] is my attempt to write a universal packet injection
  /* sendpacket.[ch] is my attempt to write a universal packet injection
-  * API for BPF, libpcap, libnet, and Linux's PF_PACKET.  I got sick
+  * API for BPF, libpcap, libdnet, and Linux's PF_PACKET.  I got sick
   * and tired dealing with libnet bugs and its lack of active maintenence,
   * and tired dealing with libnet bugs and its lack of active maintenence,
   * but unfortunately, libpcap frame injection support is relatively new 
   * but unfortunately, libpcap frame injection support is relatively new 
   * and not everyone uses Linux, so I decided to support all four as
   * and not everyone uses Linux, so I decided to support all four as
@@ -50,7 +50,7 @@
   * Anyways, long story short, for now the order of preference is:
   * Anyways, long story short, for now the order of preference is:
   * 1. PF_PACKET
   * 1. PF_PACKET
   * 2. BPF
   * 2. BPF
-  * 3. libnet
+  * 3. libdnet
   * 4. pcap_inject()
   * 4. pcap_inject()
   * 5. pcap_sendpacket()
   * 5. pcap_sendpacket()
   *
   *
@@ -70,7 +70,7 @@
 #include "sendpacket.h"
 #include "sendpacket.h"
 
 
 
 
-#ifdef FORCE_INJECT_LIBNET
+#ifdef FORCE_INJECT_LIBDNET
 #undef HAVE_PF_PACKET
 #undef HAVE_PF_PACKET
 #undef HAVE_PCAP_INJECT
 #undef HAVE_PCAP_INJECT
 #undef HAVE_PCAP_SENDPACKET
 #undef HAVE_PCAP_SENDPACKET
@@ -78,21 +78,21 @@
 #endif
 #endif
 
 
 #ifdef FORCE_INJECT_BPF
 #ifdef FORCE_INJECT_BPF
-#undef HAVE_LIBNET
+#undef HAVE_LIBDNET
 #undef HAVE_PCAP_INJECT
 #undef HAVE_PCAP_INJECT
 #undef HAVE_PCAP_SENDPACKET
 #undef HAVE_PCAP_SENDPACKET
 #undef HAVE_PF_PACKET
 #undef HAVE_PF_PACKET
 #endif
 #endif
 
 
 #ifdef FORCE_INJECT_PCAP_INJECT
 #ifdef FORCE_INJECT_PCAP_INJECT
-#undef HAVE_LIBNET
+#undef HAVE_LIBDNET
 #undef HAVE_PCAP_SENDPACKET
 #undef HAVE_PCAP_SENDPACKET
 #undef HAVE_BPF
 #undef HAVE_BPF
 #undef HAVE_PF_PACKET
 #undef HAVE_PF_PACKET
 #endif
 #endif
 
 
 #ifdef FORCE_INJECT_PCAP_SENDPACKET
 #ifdef FORCE_INJECT_PCAP_SENDPACKET
-#undef HAVE_LIBNET
+#undef HAVE_LIBDNET
 #undef HAVE_PCAP_INJECT
 #undef HAVE_PCAP_INJECT
 #undef HAVE_BPF
 #undef HAVE_BPF
 #undef HAVE_PF_PACKET
 #undef HAVE_PF_PACKET
@@ -102,8 +102,8 @@
 #undef HAVE_PCAP_INJECT /* configure returns true for some odd reason */
 #undef HAVE_PCAP_INJECT /* configure returns true for some odd reason */
 #endif
 #endif
 
 
-#if !defined HAVE_PCAP_INJECT && !defined HAVE_PCAP_SENDPACKET && !defined HAVE_LIBNET && !defined HAVE_PF_PACKET && !defined HAVE_BPF
-#error You need pcap_inject() or pcap_sendpacket() from libpcap, libnet 1.1.3+, Linux's PF_PACKET or *BSD's BPF
+#if !defined HAVE_PCAP_INJECT && !defined HAVE_PCAP_SENDPACKET && !defined HAVE_LIBDNET && !defined HAVE_PF_PACKET && !defined HAVE_BPF
+#error You need pcap_inject() or pcap_sendpacket() from libpcap, libdnet, Linux's PF_PACKET or *BSD's BPF
 #endif
 #endif
 
 
 #include <string.h>
 #include <string.h>
@@ -149,7 +149,7 @@ static int get_iface_index(int fd, const int8_t *device, char *);
 
 
 #endif /* HAVE_PF_PACKET */
 #endif /* HAVE_PF_PACKET */
 
 
-#ifdef HAVE_BPF
+#if defined HAVE_BPF && ! defined INJECT_METHOD
 #undef INJECT_METHOD
 #undef INJECT_METHOD
 #define INJECT_METHOD "bpf send()"
 #define INJECT_METHOD "bpf send()"
 
 
@@ -164,23 +164,29 @@ static struct tcpr_ether_addr *sendpacket_get_hwaddr_bpf(sendpacket_t *) _U_;
 
 
 #endif /* HAVE_BPF */
 #endif /* HAVE_BPF */
 
 
-#ifdef HAVE_LIBNET
+#if defined HAVE_LIBDNET && ! defined INJECT_METHOD
 #undef INJECT_METHOD
 #undef INJECT_METHOD
-#define INJECT_METHOD "libnet send()"
-
-static sendpacket_t *sendpacket_open_libnet(const char *, char *) _U_;
-static struct tcpr_ether_addr *sendpacket_get_hwaddr_libnet(sendpacket_t *) _U_;
-#endif /* HAVE_LIBNET */
-
-#if (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
+#define INJECT_METHOD "libdnet eth_send()"
+/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */
+#undef icmp_id
+#undef icmp_seq
+#undef icmp_data
+#undef icmp_mask
+#include <dnet.h>
+
+static sendpacket_t *sendpacket_open_libdnet(const char *, char *) _U_;
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_libdnet(sendpacket_t *) _U_;
+#endif /* HAVE_LIBDNET */
+
+#if (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET) && ! defined INJECT_METHOD
 static sendpacket_t *sendpacket_open_pcap(const char *, char *) _U_;
 static sendpacket_t *sendpacket_open_pcap(const char *, char *) _U_;
 static struct tcpr_ether_addr *sendpacket_get_hwaddr_pcap(sendpacket_t *) _U_;
 static struct tcpr_ether_addr *sendpacket_get_hwaddr_pcap(sendpacket_t *) _U_;
 #endif /* HAVE_PCAP_INJECT || HAVE_PACKET_SENDPACKET */
 #endif /* HAVE_PCAP_INJECT || HAVE_PACKET_SENDPACKET */
 
 
-#ifdef HAVE_PCAP_INJECT
+#if defined HAVE_PCAP_INJECT && ! defined INJECT_METHOD
 #undef INJECT_METHOD
 #undef INJECT_METHOD
 #define INJECT_METHOD "pcap_inject()"
 #define INJECT_METHOD "pcap_inject()"
-#elif defined HAVE_PCAP_SENDPACKET
+#elif defined HAVE_PCAP_SENDPACKET && ! defined INJECT_METHOD
 #undef INJECT_METHOD
 #undef INJECT_METHOD
 #define INJECT_METHOD "pcap_sendpacket()"
 #define INJECT_METHOD "pcap_sendpacket()"
 #endif
 #endif
@@ -232,7 +238,7 @@ TRY_SEND_AGAIN:
                 
                 
             default:
             default:
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
-                    INJECT_METHOD, sp->sent + 1, strerror(errno), errno);
+                    INJECT_METHOD, sp->sent + sp->failed + 1, strerror(errno), errno);
         }
         }
     } 
     } 
 
 
@@ -254,12 +260,12 @@ TRY_SEND_AGAIN:
                 
                 
             default:
             default:
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
-                    INJECT_METHOD, sp->sent + 1, strerror(errno), errno);
+                    INJECT_METHOD, sp->sent + sp->failed + 1, strerror(errno), errno);
         }
         }
     }
     }
 
 
-#elif defined HAVE_LIBNET
-    retcode = libnet_adv_write_link(sp->handle.lnet, (u_int8_t*)data, (u_int32_t)len);
+#elif defined HAVE_LIBDNET
+    retcode = eth_send(sp->handle.ldnet, (void*)data, (size_t)len);
 
 
     /* out of buffers, or hit max PHY speed, silently retry */
     /* out of buffers, or hit max PHY speed, silently retry */
     if (retcode < 0 && !didsig) {
     if (retcode < 0 && !didsig) {
@@ -276,7 +282,7 @@ TRY_SEND_AGAIN:
                 
                 
             default:
             default:
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
-                    INJECT_METHOD, sp->sent + 1, strerror(errno), errno);
+                    INJECT_METHOD, sp->sent + sp->failed + 1, strerror(errno), errno);
         }
         }
     }
     }
 
 
@@ -301,7 +307,7 @@ TRY_SEND_AGAIN:
                 
                 
             default:
             default:
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
-                    INJECT_METHOD, sp->sent + 1, pcap_geterr(sp->handle.pcap), errno);
+                    INJECT_METHOD, sp->sent + sp->failed + 1, pcap_geterr(sp->handle.pcap), errno);
         }
         }
     }
     }
 
 
@@ -322,7 +328,7 @@ TRY_SEND_AGAIN:
                 
                 
             default:
             default:
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
                 sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", 
-                    INJECT_METHOD, sp->sent + 1, pcap_geterr(sp->handle.pcap), errno);
+                    INJECT_METHOD, sp->sent + sp->failed + 1, pcap_geterr(sp->handle.pcap), errno);
          }
          }
     }
     }
     /* 
     /* 
@@ -363,8 +369,8 @@ sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction)
     sp = sendpacket_open_pf(device, errbuf);
     sp = sendpacket_open_pf(device, errbuf);
 #elif defined HAVE_BPF
 #elif defined HAVE_BPF
     sp = sendpacket_open_bpf(device, errbuf);
     sp = sendpacket_open_bpf(device, errbuf);
-#elif defined HAVE_LIBNET
-    sp = sendpacket_open_libnet(device, errbuf);
+#elif defined HAVE_LIBDNET
+    sp = sendpacket_open_libdnet(device, errbuf);
 #elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
 #elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
     sp = sendpacket_open_pcap(device, errbuf);
     sp = sendpacket_open_pcap(device, errbuf);
 #endif
 #endif
@@ -403,7 +409,35 @@ int
 sendpacket_close(sendpacket_t *sp)
 sendpacket_close(sendpacket_t *sp)
 {
 {
     assert(sp);
     assert(sp);
+    switch(sp->handle_type) {
+        case SP_TYPE_BPF:
+#if (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
+            close(sp->handle.fd);
+#endif
+            break;
+
+        case SP_TYPE_PF_PACKET:
+#ifdef HAVE_PF_PACKET
+            close(sp->handle.fd);
+#endif
+            break;
 
 
+        case SP_TYPE_LIBPCAP:
+#ifdef HAVE_LIBPCAP
+            pcap_close(sp->handle.pcap);
+#endif
+            break;
+           
+        case SP_TYPE_LIBDNET:
+#ifdef HAVE_LIBDNET            
+            eth_close(sp->handle.ldnet);
+#endif
+            break;
+
+        case SP_TYPE_LIBNET:
+            err(-1, "Libnet is no longer supported!");
+            break;
+    }
     safe_free(sp);
     safe_free(sp);
     return 0;
     return 0;
 }
 }
@@ -426,8 +460,8 @@ sendpacket_get_hwaddr(sendpacket_t *sp)
     addr = sendpacket_get_hwaddr_pf(sp);
     addr = sendpacket_get_hwaddr_pf(sp);
 #elif defined HAVE_BPF
 #elif defined HAVE_BPF
     addr = sendpacket_get_hwaddr_bpf(sp);
     addr = sendpacket_get_hwaddr_bpf(sp);
-#elif defined HAVE_LIBNET
-    addr = sendpacket_get_hwaddr_libnet(sp);
+#elif defined HAVE_LIBDNET
+    addr = sendpacket_get_hwaddr_libdnet(sp);
 #elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
 #elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
     addr = sendpacket_get_hwaddr_pcap(sp);
     addr = sendpacket_get_hwaddr_pcap(sp);
 #endif
 #endif
@@ -497,8 +531,10 @@ sendpacket_open_pcap(const char *device, char *errbuf)
      */
      */
     fd = pcap_get_selectable_fd(pcap);
     fd = pcap_get_selectable_fd(pcap);
     if (ioctl(fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1)
     if (ioctl(fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1)
-        errx(1, "Unable to enable source MAC spoof support: %s", strerror(errno));
+        errx(-1, "Unable to enable source MAC spoof support: %s", strerror(errno));
 #endif
 #endif
+    sp->handle_type = SP_TYPE_LIBPCAP;
+
     return sp;
     return sp;
 }
 }
 
 
@@ -514,50 +550,52 @@ sendpacket_get_hwaddr_pcap(sendpacket_t *sp)
 }
 }
 #endif /* HAVE_PCAP_INJECT || HAVE_PCAP_SENDPACKET */
 #endif /* HAVE_PCAP_INJECT || HAVE_PCAP_SENDPACKET */
 
 
-#if defined HAVE_LIBNET
+#if defined HAVE_LIBDNET
 /**
 /**
- * Inner sendpacket_open() method for using libnet
+ * Inner sendpacket_open() method for using libdnet
  */
  */
 static sendpacket_t * 
 static sendpacket_t * 
-sendpacket_open_libnet(const char *device, char *errbuf)
+sendpacket_open_libdnet(const char *device, char *errbuf)
 {
 {
-    libnet_t *lnet;
+    eth_t *ldnet;
     sendpacket_t *sp;
     sendpacket_t *sp;
     
     
     assert(device);
     assert(device);
     assert(errbuf);
     assert(errbuf);
     
     
-    dbg(1, "sendpacket: using Libnet");
+    dbg(1, "sendpacket: using Libdnet");
     
     
-    if ((lnet = libnet_init(LIBNET_LINK_ADV, device, errbuf)) == NULL)
+    if ((ldnet = eth_open(device)) == NULL)
         return NULL;
         return NULL;
 
 
     sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
     sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
     strlcpy(sp->device, device, sizeof(sp->device));
     strlcpy(sp->device, device, sizeof(sp->device));
-    sp->handle.lnet = lnet;
+    sp->handle.ldnet = ldnet;
+    sp->handle_type = SP_TYPE_LIBDNET;    
     return sp;    
     return sp;    
 }
 }
 
 
 /**
 /**
- * Get the hardware MAC address for the given interface using libnet
+ * Get the hardware MAC address for the given interface using libdnet
  */
  */
 static struct tcpr_ether_addr *
 static struct tcpr_ether_addr *
-sendpacket_get_hwaddr_libnet(sendpacket_t *sp)
+sendpacket_get_hwaddr_libdnet(sendpacket_t *sp)
 {
 {
     struct tcpr_ether_addr *addr;
     struct tcpr_ether_addr *addr;
+    int ret;
     assert(sp);
     assert(sp);
     
     
-    addr = (struct tcpr_ether_addr *)libnet_get_hwaddr(sp->handle.lnet);
+    ret = eth_get(sp->handle.ldnet, (eth_addr_t *)addr);
     
     
-    if (addr == NULL) {
-        sendpacket_seterr(sp, "Error getting hwaddr via libnet: %s", libnet_geterror(sp->handle.lnet));
+    if (addr == NULL || ret < 0) {
+        sendpacket_seterr(sp, "Error getting hwaddr via libdnet: %s", strerror(errno));
         return NULL;
         return NULL;
     }
     }
     
     
     memcpy(&sp->ether, addr, sizeof(struct tcpr_ether_addr));
     memcpy(&sp->ether, addr, sizeof(struct tcpr_ether_addr));
     return(&sp->ether);
     return(&sp->ether);
 }
 }
-#endif /* HAVE_LIBNET */
+#endif /* HAVE_LIBDNET */
 
 
 #if defined HAVE_PF_PACKET
 #if defined HAVE_PF_PACKET
 /**
 /**
@@ -651,7 +689,8 @@ sendpacket_open_pf(const char *device, char *errbuf)
     /* prep & return our sp handle */
     /* prep & return our sp handle */
     sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
     sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
     strlcpy(sp->device, device, sizeof(sp->device));
     strlcpy(sp->device, device, sizeof(sp->device));
-    sp->handle.fd = mysocket;   
+    sp->handle.fd = mysocket;
+    sp->handle_type = SP_TYPE_PF_PACKET;
     
     
     return sp;
     return sp;
 }
 }
@@ -827,6 +866,7 @@ sendpacket_open_bpf(const char *device, char *errbuf)
     sp->handle.fd = mysocket;
     sp->handle.fd = mysocket;
     //sp->link_type = link_type;
     //sp->link_type = link_type;
     //sp->link_offset = link_offset;
     //sp->link_offset = link_offset;
+    sp->handle_type = SP_TYPE_BPF;
     
     
     return sp; 
     return sp; 
 }
 }
@@ -897,7 +937,7 @@ sendpacket_get_dlt(sendpacket_t *sp)
         warnx("Unable to get DLT value for BPF device (%s): %s", sp->device, strerror(errno));
         warnx("Unable to get DLT value for BPF device (%s): %s", sp->device, strerror(errno));
         return(-1);
         return(-1);
     }
     }
-#elif defined HAVE_PF_PACKET || defined HAVE_LIBNET
+#elif defined HAVE_PF_PACKET || defined HAVE_LIBDNET
     /* use libpcap to get dlt */
     /* use libpcap to get dlt */
     pcap_t *pcap;
     pcap_t *pcap;
     char errbuf[PCAP_ERRBUF_SIZE];
     char errbuf[PCAP_ERRBUF_SIZE];
@@ -912,3 +952,9 @@ sendpacket_get_dlt(sendpacket_t *sp)
 #endif
 #endif
     return dlt;
     return dlt;
 }
 }
+
+const char *
+sendpacket_get_method()
+{
+    return INJECT_METHOD;
+}

+ 22 - 3
src/common/sendpacket.h

@@ -1,4 +1,4 @@
-/* $Id: sendpacket.h 2012 2008-05-03 18:54:02Z aturner $ */
+/* $Id: sendpacket.h 2114 2009-01-08 17:37:22Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2006 Aaron Turner.
  * Copyright (c) 2006 Aaron Turner.
@@ -36,14 +36,31 @@
 #include <netpacket/packet.h>
 #include <netpacket/packet.h>
 #endif
 #endif
 
 
+#ifdef HAVE_LIBDNET
+/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */
+#undef icmp_id
+#undef icmp_seq
+#undef icmp_data
+#undef icmp_mask
+#include <dnet.h>
+#endif
+
 #ifndef _SENDPACKET_H_
 #ifndef _SENDPACKET_H_
 #define _SENDPACKET_H_
 #define _SENDPACKET_H_
 
 
+enum sendpacket_type_t {
+    SP_TYPE_LIBNET,
+    SP_TYPE_LIBDNET,
+    SP_TYPE_LIBPCAP,
+    SP_TYPE_BPF,
+    SP_TYPE_PF_PACKET
+};
+
 union sendpacket_handle {
 union sendpacket_handle {
     pcap_t *pcap;
     pcap_t *pcap;
     int fd;
     int fd;
-#ifdef HAVE_LIBNET
-    libnet_t *lnet;
+#ifdef HAVE_LIBDNET
+    eth_t *ldnet;
 #endif
 #endif
 };
 };
 
 
@@ -60,6 +77,7 @@ struct sendpacket_s {
     COUNTER sent;
     COUNTER sent;
     COUNTER bytes_sent;
     COUNTER bytes_sent;
     COUNTER attempt;
     COUNTER attempt;
+    enum sendpacket_type_t handle_type;
     union sendpacket_handle handle;
     union sendpacket_handle handle;
     struct tcpr_ether_addr ether;
     struct tcpr_ether_addr ether;
 #ifdef HAVE_PF_PACKET
 #ifdef HAVE_PF_PACKET
@@ -76,6 +94,7 @@ char *sendpacket_getstat(sendpacket_t *);
 sendpacket_t *sendpacket_open(const char *, char *, tcpr_dir_t);
 sendpacket_t *sendpacket_open(const char *, char *, tcpr_dir_t);
 struct tcpr_ether_addr *sendpacket_get_hwaddr(sendpacket_t *);
 struct tcpr_ether_addr *sendpacket_get_hwaddr(sendpacket_t *);
 int sendpacket_get_dlt(sendpacket_t *);
 int sendpacket_get_dlt(sendpacket_t *);
+const char *sendpacket_get_method();
 
 
 #endif /* _SENDPACKET_H_ */
 #endif /* _SENDPACKET_H_ */
 
 

+ 4 - 4
src/common/services.c

@@ -1,4 +1,4 @@
-/* $Id: services.c 1897 2007-08-25 04:57:38Z aturner $ */
+/* $Id: services.c 2074 2008-11-09 08:42:24Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2004 Aaron Turner.
  * Copyright (c) 2004 Aaron Turner.
@@ -62,12 +62,12 @@ parse_services(const char *file, tcpr_services_t *services)
     memset(services->udp, '\0', NUM_PORTS);
     memset(services->udp, '\0', NUM_PORTS);
 
 
     if ((service = fopen(file, "r")) == NULL) {
     if ((service = fopen(file, "r")) == NULL) {
-        errx(1, "Unable to open service file: %s\n%s", file, strerror(errno));
+        errx(-1, "Unable to open service file: %s\n%s", file, strerror(errno));
     }
     }
     
     
     /* compile our regexes */
     /* compile our regexes */
     if ((regcomp(&preg, regex, REG_ICASE|REG_EXTENDED)) != 0) {
     if ((regcomp(&preg, regex, REG_ICASE|REG_EXTENDED)) != 0) {
-        errx(1, "Unable to compile regex: %s", regex);
+        errx(-1, "Unable to compile regex: %s", regex);
     }
     }
 
 
     /* parse the entire file */
     /* parse the entire file */
@@ -82,7 +82,7 @@ parse_services(const char *file, tcpr_services_t *services)
         /* look for format of 1234/tcp */
         /* look for format of 1234/tcp */
         if ((regexec(&preg, service_line, nmatch, pmatch, 0)) == 0) { /* matches */
         if ((regexec(&preg, service_line, nmatch, pmatch, 0)) == 0) { /* matches */
             if (nmatch < 2) {
             if (nmatch < 2) {
-                err(1, "WTF?  I matched the line, but I don't know where!");
+                err(-1, "WTF?  I matched the line, but I don't know where!");
             }
             }
 
 
             /* strip out the port & proto from the line */
             /* strip out the port & proto from the line */

+ 1 - 1
src/common/svn_version.c

@@ -1,4 +1,4 @@
-const char SVN_Version[] = "2065";
+const char SVN_Version[] = "2229";
 const char *svn_version(void) {
 const char *svn_version(void) {
 	return SVN_Version;
 	return SVN_Version;
 }
 }

+ 19 - 19
src/common/tcpdump.c

@@ -1,4 +1,4 @@
-/* $Id: tcpdump.c 1897 2007-08-25 04:57:38Z aturner $ */
+/* $Id: tcpdump.c 2074 2008-11-09 08:42:24Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -90,10 +90,10 @@ tcpdump_print(tcpdump_t *tcpdump, struct pcap_pkthdr *pkthdr, const u_char *data
     /* wait until we can write to the tcpdump socket */
     /* wait until we can write to the tcpdump socket */
     result = poll(poller, 1, TCPDUMP_POLL_TIMEOUT);
     result = poll(poller, 1, TCPDUMP_POLL_TIMEOUT);
     if (result < 0)
     if (result < 0)
-        errx(1, "Error during poll() to write to tcpdump\n%s", strerror(errno));
+        errx(-1, "Error during poll() to write to tcpdump\n%s", strerror(errno));
 
 
     if (result == 0)
     if (result == 0)
-        err(1, "poll() timeout... tcpdump seems to be having a problem keeping up\n"
+        err(-1, "poll() timeout... tcpdump seems to be having a problem keeping up\n"
             "Try increasing TCPDUMP_POLL_TIMEOUT");
             "Try increasing TCPDUMP_POLL_TIMEOUT");
 
 
 
 
@@ -101,23 +101,23 @@ tcpdump_print(tcpdump_t *tcpdump, struct pcap_pkthdr *pkthdr, const u_char *data
 
 
     if (write(tcpdump->infd, (char *)pkthdr, sizeof(struct pcap_pkthdr))
     if (write(tcpdump->infd, (char *)pkthdr, sizeof(struct pcap_pkthdr))
         != sizeof(struct pcap_pkthdr))
         != sizeof(struct pcap_pkthdr))
-        errx(1, "Error writing pcap file header to tcpdump\n%s", strerror(errno));
+        errx(-1, "Error writing pcap file header to tcpdump\n%s", strerror(errno));
 
 
 #ifdef DEBUG
 #ifdef DEBUG
     if (debug >= 5) {
     if (debug >= 5) {
         if (write(tcpdump->debugfd, (char *)pkthdr, sizeof(struct pcap_pkthdr))
         if (write(tcpdump->debugfd, (char *)pkthdr, sizeof(struct pcap_pkthdr))
             != sizeof(struct pcap_pkthdr))
             != sizeof(struct pcap_pkthdr))
-            errx(1, "Error writing pcap file header to tcpdump debug\n%s", strerror(errno));
+            errx(-1, "Error writing pcap file header to tcpdump debug\n%s", strerror(errno));
     }
     }
 #endif
 #endif
 
 
     if (write(tcpdump->infd, data, pkthdr->caplen) != (ssize_t)pkthdr->caplen)
     if (write(tcpdump->infd, data, pkthdr->caplen) != (ssize_t)pkthdr->caplen)
-        errx(1, "Error writing packet data to tcpdump\n%s", strerror(errno));
+        errx(-1, "Error writing packet data to tcpdump\n%s", strerror(errno));
 
 
 #ifdef DEBUG
 #ifdef DEBUG
     if (debug >= 5) {
     if (debug >= 5) {
         if (write(tcpdump->debugfd, data, pkthdr->caplen) != (ssize_t)pkthdr->caplen)
         if (write(tcpdump->debugfd, data, pkthdr->caplen) != (ssize_t)pkthdr->caplen)
-            errx(1, "Error writing packet data to tcpdump debug\n%s", strerror(errno));
+            errx(-1, "Error writing packet data to tcpdump debug\n%s", strerror(errno));
     }
     }
 #endif
 #endif
 
 
@@ -128,15 +128,15 @@ tcpdump_print(tcpdump_t *tcpdump, struct pcap_pkthdr *pkthdr, const u_char *data
 
 
     result = poll(poller, 1, TCPDUMP_POLL_TIMEOUT);
     result = poll(poller, 1, TCPDUMP_POLL_TIMEOUT);
     if (result < 0)
     if (result < 0)
-        errx(1, "Error during poll() to write to tcpdump\n%s", strerror(errno));
+        errx(-1, "Error during poll() to write to tcpdump\n%s", strerror(errno));
 
 
     if (result == 0)
     if (result == 0)
-        err(1, "poll() timeout... tcpdump seems to be having a problem keeping up\n"
+        err(-1, "poll() timeout... tcpdump seems to be having a problem keeping up\n"
             "Try increasing TCPDUMP_POLL_TIMEOUT");
             "Try increasing TCPDUMP_POLL_TIMEOUT");
 
 
     /* result > 0 if we get here */
     /* result > 0 if we get here */
     if (read(tcpdump->outfd, &decode, TCPDUMP_DECODE_LEN) < 0)
     if (read(tcpdump->outfd, &decode, TCPDUMP_DECODE_LEN) < 0)
-        errx(1, "Error reading tcpdump decode: %s", strerror(errno));
+        errx(-1, "Error reading tcpdump decode: %s", strerror(errno));
             
             
     printf("%s", decode);
     printf("%s", decode);
 
 
@@ -164,7 +164,7 @@ tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap)
 
 
     /* is tcpdump executable? */
     /* is tcpdump executable? */
     if (! can_exec(TCPDUMP_BINARY)) {
     if (! can_exec(TCPDUMP_BINARY)) {
-        errx(1, "Unable to execute tcpdump binary: %s", TCPDUMP_BINARY);
+        errx(-1, "Unable to execute tcpdump binary: %s", TCPDUMP_BINARY);
     }
     }
     
     
 #ifdef DEBUG
 #ifdef DEBUG
@@ -174,7 +174,7 @@ tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap)
 
 
          if ((tcpdump->debugfd = open(tcpdump->debugfile, O_WRONLY|O_CREAT|O_TRUNC, 
          if ((tcpdump->debugfd = open(tcpdump->debugfile, O_WRONLY|O_CREAT|O_TRUNC, 
                 S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) == -1) {
                 S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) == -1) {
-            errx(1, "Error opening tcpdump debug file: %s\n%s", tcpdump->debugfile, strerror(errno));
+            errx(-1, "Error opening tcpdump debug file: %s\n%s", tcpdump->debugfile, strerror(errno));
         }
         }
     }
     }
 #endif
 #endif
@@ -187,15 +187,15 @@ tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap)
 
 
     /* create our socket pair to send packet data to tcpdump via */
     /* create our socket pair to send packet data to tcpdump via */
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, infd) < 0)
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, infd) < 0)
-        errx(1, "Unable to create stdin socket pair: %s", strerror(errno));
+        errx(-1, "Unable to create stdin socket pair: %s", strerror(errno));
 
 
     /* create our socket pair to read packet decode from tcpdump */
     /* create our socket pair to read packet decode from tcpdump */
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, outfd) < 0)
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, outfd) < 0)
-        errx(1, "Unable to create stdout socket pair: %s", strerror(errno));
+        errx(-1, "Unable to create stdout socket pair: %s", strerror(errno));
  
  
          
          
     if ((tcpdump->pid = fork() ) < 0)
     if ((tcpdump->pid = fork() ) < 0)
-        errx(1, "Fork failed: %s", strerror(errno));
+        errx(-1, "Fork failed: %s", strerror(errno));
 
 
     dbgx(2, "tcpdump pid: %d", tcpdump->pid);
     dbgx(2, "tcpdump pid: %d", tcpdump->pid);
     
     
@@ -235,21 +235,21 @@ tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap)
         /* copy our side of the socketpair to our stdin */
         /* copy our side of the socketpair to our stdin */
         if (infd[1] != STDIN_FILENO) {
         if (infd[1] != STDIN_FILENO) {
             if (dup2(infd[1], STDIN_FILENO) != STDIN_FILENO)
             if (dup2(infd[1], STDIN_FILENO) != STDIN_FILENO)
-                errx(1, "[child] Unable to copy socket to stdin: %s", 
+                errx(-1, "[child] Unable to copy socket to stdin: %s", 
                     strerror(errno));
                     strerror(errno));
         }
         }
     
     
         /* copy our side of the socketpair to our stdout */
         /* copy our side of the socketpair to our stdout */
         if (outfd[1] != STDOUT_FILENO) {
         if (outfd[1] != STDOUT_FILENO) {
             if (dup2(outfd[1], STDOUT_FILENO) != STDOUT_FILENO)
             if (dup2(outfd[1], STDOUT_FILENO) != STDOUT_FILENO)
-                errx(1, "[child] Unable to copy socket to stdout: %s", 
+                errx(-1, "[child] Unable to copy socket to stdout: %s", 
                     strerror(errno));
                     strerror(errno));
         }
         }
 
 
         /* exec tcpdump */
         /* exec tcpdump */
         dbg(2, "[child] Exec'ing tcpdump...");
         dbg(2, "[child] Exec'ing tcpdump...");
         if (execv(TCPDUMP_BINARY, options_vec) < 0)
         if (execv(TCPDUMP_BINARY, options_vec) < 0)
-            errx(1, "Unable to exec tcpdump: %s", strerror(errno));
+            errx(-1, "Unable to exec tcpdump: %s", strerror(errno));
 
 
     }
     }
     
     
@@ -275,7 +275,7 @@ tcpdump_close(tcpdump_t *tcpdump)
     close(tcpdump->outfd);
     close(tcpdump->outfd);
 
 
     if (waitpid(tcpdump->pid, NULL, 0) != tcpdump->pid)
     if (waitpid(tcpdump->pid, NULL, 0) != tcpdump->pid)
-        errx(1, "[parent] Error in waitpid: %s", strerror(errno));
+        errx(-1, "[parent] Error in waitpid: %s", strerror(errno));
 
 
     tcpdump->pid = 0;
     tcpdump->pid = 0;
     tcpdump->infd = 0;
     tcpdump->infd = 0;

+ 2 - 2
src/common/timer.c

@@ -1,4 +1,4 @@
-/* $Id: timer.c 2061 2008-06-20 07:00:39Z aturner $ */
+/* $Id: timer.c 2068 2008-11-09 06:00:06Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -66,7 +66,7 @@ void timesdiv(struct timespec *tvs, float div)
         
         
     interval = ((double)tvs->tv_sec * 1000000000 + tvs->tv_nsec) / (double)div;
     interval = ((double)tvs->tv_sec * 1000000000 + tvs->tv_nsec) / (double)div;
     tvs->tv_sec = interval / (int)1000000000;
     tvs->tv_sec = interval / (int)1000000000;
-    tvs->tv_nsec = interval - (tvs->tv_nsec * 1000000000);
+    tvs->tv_nsec = interval - (tvs->tv_sec * 1000000000);
 }
 }
 
 
 void
 void

+ 0 - 0
src/common/timer.h


Some files were not shown because too many files changed in this diff