Hi Alfred, hello mailing list,
regarding http://lists.gnu.org/archive/html/bug-coreutils/2007-12/msg00125.html
Attached is a patch which shows how genparse could be used for command line
parsing of the ping command of the inetutils. If you want to know more about
genparse, you are invited to visit
http://genparse.sourceforge.net/
The ping tool was of special interest for me because it is presently being
converted to use argp, another command line parsing tool, which I presently
don't know very much. The main difference between argp and genparse is that
genparse generates command line parsing code at compile time while argp is
not a real tool but a set of library functions which perform the command
line parsing at run time. Both genparse and argp are wrappers around getopt
or getopt_long, so the core parsing code is the same for both solutions.
I added ping to the list of genparse examples at
http://genparse.sourceforge.net/examples/
>From there you can view the genparse input
http://genparse.sourceforge.net/examples/ping.gp
and the generated parser code
http://genparse.sourceforge.net/examples/ping_clp.c and
http://genparse.sourceforge.net/examples/ping_clp.h
The argp solution for the ping command is available from
http://cvs.savannah.gnu.org/viewvc/*checkout*/inetutils/ping/ping.c?root=inetutils&revision=1.34&content-type=text%2Fplain
The attached patch is targeted to inetutils version 1.5. If you want to
compile it on your own, you will need genparse version 0.7.4 in your path
which you can download from
http://sourceforge.net/project/showfiles.php?group_id=4341
Any comments welcome!
Michael
diff -u -N -r inetutils-1.5.orig/ping/Makefile.am inetutils-1.5/ping/Makefile.am
--- inetutils-1.5.orig/ping/Makefile.am 2007-06-29 00:58:24.000000000 +0200
+++ inetutils-1.5/ping/Makefile.am 2007-12-23 20:53:20.000000000 +0100
@@ -28,10 +28,19 @@
INCLUDES = -I$(top_srcdir)/lib -I../lib -I$(top_srcdir)/libicmp
ping_SOURCES = ping.c ping_common.c ping_echo.c ping_address.c \
- ping_router.c ping_timestamp.c ping_common.h ping_impl.h
+ ping_router.c ping_timestamp.c ping_common.h ping_impl.h ping-clp.c ping-clp.h
ping6_SOURCES = ping6.c ping_common.c ping_common.h ping6.h
+BUILT_SOURCES = ping-clp.c ping-clp.h
+
+ping.o: ping-clp.c ping-clp.h
+
+%-clp.c %-clp.h: %.gp
+ genparse --longmembers --static-headers --gnulib -o $(*F)-clp $<
+
+CLEANFILES = $(BUILT_SOURCES)
+
SUIDMODE = -o root -m 4775
install-ping-hook:
diff -u -N -r inetutils-1.5.orig/ping/Makefile.in inetutils-1.5/ping/Makefile.in
--- inetutils-1.5.orig/ping/Makefile.in 2007-06-29 01:04:45.000000000 +0200
+++ inetutils-1.5/ping/Makefile.in 2007-12-23 20:53:51.000000000 +0100
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.10a from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005 Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -32,15 +32,12 @@
# to the Free Software Foundation, Inc., 51 Franklin Street,
# Fifth Floor, Boston, MA 02110-1301 USA.
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = ..
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
@@ -55,47 +52,45 @@
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-bin_PROGRAMS = @ping_BUILD@ @ping6_BUILD@
EXTRA_PROGRAMS = ping$(EXEEXT) ping6$(EXEEXT)
subdir = ping
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/absolute-header.m4 \
- $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/allocsa.m4 \
- $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/d-ino.m4 \
- $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/eoverflow.m4 \
- $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exitfail.m4 \
- $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/free.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/m4/alloca.m4 \
+ $(top_srcdir)/m4/c-strtod.m4 \
+ $(top_srcdir)/m4/canonicalize-lgpl.m4 \
+ $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \
+ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/dirfd.m4 \
+ $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \
+ $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
+ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/error.m4 \
+ $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \
+ $(top_srcdir)/m4/fchdir.m4 $(top_srcdir)/m4/fcntl-safer.m4 \
+ $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/free.m4 \
$(top_srcdir)/m4/getcwd-abort-bug.m4 \
$(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \
- $(top_srcdir)/m4/getdelim.m4 $(top_srcdir)/m4/getline.m4 \
- $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/getpass.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/getusershell.m4 \
- $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/intmax_t.m4 \
- $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lib-ld.m4 \
- $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
- $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longdouble.m4 \
- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/mbchar.m4 \
- $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrtowc.m4 \
- $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \
- $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \
- $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memset.m4 \
- $(top_srcdir)/m4/minmax.m4 $(top_srcdir)/m4/onceonly_2_57.m4 \
- $(top_srcdir)/m4/poll.m4 $(top_srcdir)/m4/readutmp.m4 \
- $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/setenv.m4 \
- $(top_srcdir)/m4/signed.m4 $(top_srcdir)/m4/size_max.m4 \
- $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/ssize_t.m4 \
- $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint.m4 \
- $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \
- $(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strchrnul.m4 \
+ $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gnulib-common.m4 \
+ $(top_srcdir)/m4/gnulib-comp.m4 \
+ $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inline.m4 \
+ $(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
+ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/longlong.m4 \
+ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \
+ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/mempcpy.m4 \
+ $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/onceonly_2_57.m4 \
+ $(top_srcdir)/m4/openat.m4 $(top_srcdir)/m4/pathmax.m4 \
+ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readutmp.m4 \
+ $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/stdbool.m4 \
+ $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdlib_h.m4 \
$(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
- $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
- $(top_srcdir)/m4/sysexits.m4 $(top_srcdir)/m4/unistd-safer.m4 \
- $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlocked-io.m4 \
- $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vsnprintf.m4 \
- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wcwidth.m4 \
- $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \
- $(top_srcdir)/m4/xgetcwd.m4 $(top_srcdir)/m4/xsize.m4 \
+ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \
+ $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strtoimax.m4 \
+ $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoll.m4 \
+ $(top_srcdir)/m4/strtoul.m4 $(top_srcdir)/m4/strtoull.m4 \
+ $(top_srcdir)/m4/strtoumax.m4 $(top_srcdir)/m4/sys_stat_h.m4 \
+ $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \
+ $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/xalloc.m4 \
+ $(top_srcdir)/m4/xgetcwd.m4 $(top_srcdir)/m4/xstrndup.m4 \
+ $(top_srcdir)/m4/xstrtod.m4 $(top_srcdir)/m4/xstrtol.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -107,13 +102,14 @@
PROGRAMS = $(bin_PROGRAMS)
am_ping_OBJECTS = ping.$(OBJEXT) ping_common.$(OBJEXT) \
ping_echo.$(OBJEXT) ping_address.$(OBJEXT) \
- ping_router.$(OBJEXT) ping_timestamp.$(OBJEXT)
+ ping_router.$(OBJEXT) ping_timestamp.$(OBJEXT) \
+ ping-clp.$(OBJEXT)
ping_OBJECTS = $(am_ping_OBJECTS)
ping_DEPENDENCIES =
am_ping6_OBJECTS = ping6.$(OBJEXT) ping_common.$(OBJEXT)
ping6_OBJECTS = $(am_ping6_OBJECTS)
ping6_DEPENDENCIES =
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+DEFAULT_INCLUDES = [EMAIL PROTECTED]@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -128,12 +124,9 @@
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ABSOLUTE_STDINT_H = @ABSOLUTE_STDINT_H@
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
ALLOCA_H = @ALLOCA_H@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
@@ -153,31 +146,126 @@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DIRENT_H = @DIRENT_H@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
-EOVERFLOW = @EOVERFLOW@
EXEEXT = @EXEEXT@
+FCNTL_H = @FCNTL_H@
GETOPT_H = @GETOPT_H@
-GL_COND_LIBTOOL_FALSE = @GL_COND_LIBTOOL_FALSE@
-GL_COND_LIBTOOL_TRUE = @GL_COND_LIBTOOL_TRUE@
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
+GNULIB_CHOWN = @GNULIB_CHOWN@
+GNULIB_DUP2 = @GNULIB_DUP2@
+GNULIB_FCHDIR = @GNULIB_FCHDIR@
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@
+GNULIB_GETCWD = @GNULIB_GETCWD@
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
+GNULIB_IMAXABS = @GNULIB_IMAXABS@
+GNULIB_IMAXDIV = @GNULIB_IMAXDIV@
+GNULIB_LCHOWN = @GNULIB_LCHOWN@
+GNULIB_LSEEK = @GNULIB_LSEEK@
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@
+GNULIB_MBSCHR = @GNULIB_MBSCHR@
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@
+GNULIB_MBSLEN = @GNULIB_MBSLEN@
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@
+GNULIB_MBSSEP = @GNULIB_MBSSEP@
+GNULIB_MBSSPN = @GNULIB_MBSSPN@
+GNULIB_MBSSTR = @GNULIB_MBSSTR@
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@
+GNULIB_MEMMEM = @GNULIB_MEMMEM@
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
+GNULIB_OPEN = @GNULIB_OPEN@
+GNULIB_PUTENV = @GNULIB_PUTENV@
+GNULIB_READLINK = @GNULIB_READLINK@
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@
+GNULIB_SLEEP = @GNULIB_SLEEP@
+GNULIB_STPCPY = @GNULIB_STPCPY@
+GNULIB_STPNCPY = @GNULIB_STPNCPY@
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
+GNULIB_STRDUP = @GNULIB_STRDUP@
+GNULIB_STRERROR = @GNULIB_STRERROR@
+GNULIB_STRNDUP = @GNULIB_STRNDUP@
+GNULIB_STRNLEN = @GNULIB_STRNLEN@
+GNULIB_STRPBRK = @GNULIB_STRPBRK@
+GNULIB_STRSEP = @GNULIB_STRSEP@
+GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
+GREP = @GREP@
+HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@
+HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@
+HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@
+HAVE_DECL_MKDIR = @HAVE_DECL_MKDIR@
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
+HAVE_DECL_STRERROR = @HAVE_DECL_STRERROR@
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
+HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@
+HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@
+HAVE_DUP2 = @HAVE_DUP2@
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
+HAVE_IO_H = @HAVE_IO_H@
HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
+HAVE_LSTAT = @HAVE_LSTAT@
+HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@
+HAVE_MEMPCPY = @HAVE_MEMPCPY@
+HAVE_MKDTEMP = @HAVE_MKDTEMP@
+HAVE_OS_H = @HAVE_OS_H@
+HAVE_READLINK = @HAVE_READLINK@
+HAVE_REALLOC_POSIX = @HAVE_REALLOC_POSIX@
HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
+HAVE_SLEEP = @HAVE_SLEEP@
HAVE_STDINT_H = @HAVE_STDINT_H@
+HAVE_STPCPY = @HAVE_STPCPY@
+HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASESTR = @HAVE_STRCASESTR@
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
+HAVE_STRNDUP = @HAVE_STRNDUP@
+HAVE_STRPBRK = @HAVE_STRPBRK@
+HAVE_STRSEP = @HAVE_STRSEP@
HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@
HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
+HAVE_UNISTD_H = @HAVE_UNISTD_H@
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
HAVE_WCHAR_H = @HAVE_WCHAR_H@
HAVE__BOOL = @HAVE__BOOL@
INCAUTH = @INCAUTH@
+INCLUDE_NEXT = @INCLUDE_NEXT@
+INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@
+INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@
+INTTYPES_H = @INTTYPES_H@
KRB5CFGPATH = @KRB5CFGPATH@
LDFLAGS = @LDFLAGS@
LIBAUTH = @LIBAUTH@
@@ -186,24 +274,30 @@
LIBGLOB = @LIBGLOB@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
+LIBINTL = @LIBINTL@
LIBLS = @LIBLS@
-LIBMULTITHREAD = @LIBMULTITHREAD@
LIBNCURSES = @LIBNCURSES@
LIBOBJS = @LIBOBJS@
LIBPAM = @LIBPAM@
-LIBPTH = @LIBPTH@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
LIBTERMCAP = @LIBTERMCAP@
-LIBTHREAD = @LIBTHREAD@
LIBUTIL = @LIBUTIL@
LIBWRAP = @LIBWRAP@
-LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
+LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
-LTLIBPTH = @LTLIBPTH@
-LTLIBTHREAD = @LTLIBTHREAD@
MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
NCURSES_INCLUDE = @NCURSES_INCLUDE@
+NEXT_DIRENT_H = @NEXT_DIRENT_H@
+NEXT_FCNTL_H = @NEXT_FCNTL_H@
+NEXT_INTTYPES_H = @NEXT_INTTYPES_H@
+NEXT_STDINT_H = @NEXT_STDINT_H@
+NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRING_H = @NEXT_STRING_H@
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
+NEXT_UNISTD_H = @NEXT_UNISTD_H@
+NEXT_WCHAR_H = @NEXT_WCHAR_H@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -212,9 +306,20 @@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
-POLL_H = @POLL_H@
+PRIPTR_PREFIX = @PRIPTR_PREFIX@
+PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@
PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
RANLIB = @RANLIB@
+REPLACE_CHOWN = @REPLACE_CHOWN@
+REPLACE_FCHDIR = @REPLACE_FCHDIR@
+REPLACE_GETCWD = @REPLACE_GETCWD@
+REPLACE_LCHOWN = @REPLACE_LCHOWN@
+REPLACE_LSEEK = @REPLACE_LSEEK@
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
+REPLACE_OPEN = @REPLACE_OPEN@
+REPLACE_PUTENV = @REPLACE_PUTENV@
+REPLACE_STRERROR = @REPLACE_STRERROR@
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@
RM = @RM@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
@@ -223,19 +328,21 @@
STDBOOL_H = @STDBOOL_H@
STDINT_H = @STDINT_H@
STRIP = @STRIP@
-SYSEXITS_H = @SYSEXITS_H@
+SYS_STAT_H = @SYS_STAT_H@
U = @U@
-UNISTD_H = @UNISTD_H@
+UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@
+UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@
VERSION = @VERSION@
+WCHAR_H = @WCHAR_H@
WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
WINT_T_SUFFIX = @WINT_T_SUFFIX@
YACC = @YACC@
-ac_ct_AR = @ac_ct_AR@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -247,17 +354,26 @@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
+builddir = @builddir@
datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
exec_prefix = @exec_prefix@
ftp_BUILD = @ftp_BUILD@
ftp_INSTALL_HOOK = @ftp_INSTALL_HOOK@
ftpd_BUILD = @ftpd_BUILD@
ftpd_INSTALL_HOOK = @ftpd_INSTALL_HOOK@
+gl_LIBOBJS = @gl_LIBOBJS@
+gl_LTLIBOBJS = @gl_LTLIBOBJS@
+gltests_LIBOBJS = @gltests_LIBOBJS@
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
+htmldir = @htmldir@
ifconfig_BUILD = @ifconfig_BUILD@
ifconfig_INSTALL_HOOK = @ifconfig_INSTALL_HOOK@
includedir = @includedir@
@@ -270,18 +386,21 @@
libexecdir = @libexecdir@
libglob_BUILD = @libglob_BUILD@
libls_BUILD = @libls_BUILD@
+localedir = @localedir@
localstatedir = @localstatedir@
logger_BUILD = @logger_BUILD@
logger_INSTALL_HOOK = @logger_INSTALL_HOOK@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
ping6_BUILD = @ping6_BUILD@
ping6_INSTALL_HOOK = @ping6_INSTALL_HOOK@
ping_BUILD = @ping_BUILD@
ping_INSTALL_HOOK = @ping_INSTALL_HOOK@
prefix = @prefix@
program_transform_name = @program_transform_name@
+psdir = @psdir@
rcp_BUILD = @rcp_BUILD@
rcp_INSTALL_HOOK = @rcp_INSTALL_HOOK@
rexecd_BUILD = @rexecd_BUILD@
@@ -296,6 +415,7 @@
rshd_INSTALL_HOOK = @rshd_INSTALL_HOOK@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
sysconfdir = @sysconfdir@
syslogd_BUILD = @syslogd_BUILD@
syslogd_INSTALL_HOOK = @syslogd_INSTALL_HOOK@
@@ -316,21 +436,28 @@
tftp_INSTALL_HOOK = @tftp_INSTALL_HOOK@
tftpd_BUILD = @tftpd_BUILD@
tftpd_INSTALL_HOOK = @tftpd_INSTALL_HOOK@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
uucpd_BUILD = @uucpd_BUILD@
uucpd_INSTALL_HOOK = @uucpd_INSTALL_HOOK@
whois_BUILD = @whois_BUILD@
whois_INSTALL_HOOK = @whois_INSTALL_HOOK@
+bin_PROGRAMS = @ping_BUILD@ @ping6_BUILD@
man_MANS = ping.8
EXTRA_DIST = $(man_MANS)
ping_LDADD = -L../libinetutils -linetutils -L../libicmp -licmp -L../lib -lgnu
ping6_LDADD = -L../lib -lgnu -L../libinetutils -linetutils
INCLUDES = -I$(top_srcdir)/lib -I../lib -I$(top_srcdir)/libicmp
ping_SOURCES = ping.c ping_common.c ping_echo.c ping_address.c \
- ping_router.c ping_timestamp.c ping_common.h ping_impl.h
+ ping_router.c ping_timestamp.c ping_common.h ping_impl.h ping-clp.c ping-clp.h
ping6_SOURCES = ping6.c ping_common.c ping_common.h ping6.h
+BUILT_SOURCES = ping-clp.c ping-clp.h
+CLEANFILES = $(BUILT_SOURCES)
SUIDMODE = -o root -m 4775
-all: all-am
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
@@ -363,9 +490,10 @@
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
- test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
@@ -388,10 +516,10 @@
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
ping$(EXEEXT): $(ping_OBJECTS) $(ping_DEPENDENCIES)
@rm -f ping$(EXEEXT)
- $(LINK) $(ping_LDFLAGS) $(ping_OBJECTS) $(ping_LDADD) $(LIBS)
+ $(LINK) $(ping_OBJECTS) $(ping_LDADD) $(LIBS)
ping6$(EXEEXT): $(ping6_OBJECTS) $(ping6_DEPENDENCIES)
@rm -f ping6$(EXEEXT)
- $(LINK) $(ping6_LDFLAGS) $(ping6_OBJECTS) $(ping6_LDADD) $(LIBS)
+ $(LINK) $(ping6_OBJECTS) $(ping6_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -399,6 +527,7 @@
distclean-compile:
-rm -f *.tab.c
[EMAIL PROTECTED]@@am__include@ @[EMAIL PROTECTED]/$(DEPDIR)/[EMAIL PROTECTED]@
@AMDEP_TRUE@@am__include@ @[EMAIL PROTECTED]/$(DEPDIR)/[EMAIL PROTECTED]@
@AMDEP_TRUE@@am__include@ @[EMAIL PROTECTED]/$(DEPDIR)/[EMAIL PROTECTED]@
@AMDEP_TRUE@@am__include@ @[EMAIL PROTECTED]/$(DEPDIR)/[EMAIL PROTECTED]@
@@ -408,22 +537,21 @@
@AMDEP_TRUE@@am__include@ @[EMAIL PROTECTED]/$(DEPDIR)/[EMAIL PROTECTED]@
.c.o:
[EMAIL PROTECTED]@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
[EMAIL PROTECTED]@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
[EMAIL PROTECTED]@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
[EMAIL PROTECTED]@ 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:
[EMAIL PROTECTED]@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
[EMAIL PROTECTED]@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
[EMAIL PROTECTED]@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
[EMAIL PROTECTED]@ 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) '$<'`
-uninstall-info-am:
install-man8: $(man8_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
- test -z "$(man8dir)" || $(mkdir_p) "$(DESTDIR)$(man8dir)"
+ test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
@@ -472,84 +600,89 @@
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- tags=; \
+ set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- 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; } \
- END { for (i in files) print i; }'`; \
- test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$tags $$unique
+ $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
+ && gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
- list='$(DISTFILES)'; for file in $$list; do \
- case $$file in \
- $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
- $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
- esac; \
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test "$$dir" != "$$file" && test "$$dir" != "."; then \
- dir="/$$dir"; \
- $(mkdir_p) "$(distdir)$$dir"; \
- else \
- dir=''; \
- fi; \
if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ cp -pR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ cp -pR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
-check: check-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile $(PROGRAMS) $(MANS)
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man8dir)"; do \
- test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
-install: install-am
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
@@ -566,6 +699,7 @@
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
@@ -573,6 +707,7 @@
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
@@ -595,14 +730,21 @@
install-data-am: install-man
+install-dvi: install-dvi-am
+
install-exec-am: install-binPROGRAMS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-am
install-info: install-info-am
install-man: install-man8
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
installcheck-am:
maintainer-clean: maintainer-clean-am
@@ -622,22 +764,31 @@
ps-am:
-uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man
+uninstall-am: uninstall-binPROGRAMS uninstall-man
uninstall-man: uninstall-man8
+.MAKE: install-am install-exec-am install-strip
+
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
clean-generic ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
- install-data install-data-am install-exec install-exec-am \
- install-exec-hook install-info install-info-am install-man \
- install-man8 install-strip installcheck installcheck-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-exec-hook install-html \
+ install-html-am install-info install-info-am install-man \
+ install-man8 install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
- uninstall-info-am uninstall-man uninstall-man8
+ uninstall-man uninstall-man8
+
+ping.o: ping-clp.c ping-clp.h
+
+%-clp.c %-clp.h: %.gp
+ genparse --longmembers --static-headers --gnulib -o $(*F)-clp $<
install-ping-hook:
[EMAIL PROTECTED] program in $(bin_PROGRAMS); do \
@@ -653,6 +804,7 @@
install-exec-hook: @ping_INSTALL_HOOK@
# EOF
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff -u -N -r inetutils-1.5.orig/ping/ping.c inetutils-1.5/ping/ping.c
--- inetutils-1.5.orig/ping/ping.c 2007-06-29 00:58:24.000000000 +0200
+++ inetutils-1.5/ping/ping.c 2007-12-23 20:53:34.000000000 +0100
@@ -49,39 +49,10 @@
#include <getopt.h>
#include <icmp.h>
#include <ping.h>
+#include "ping-clp.h"
#include "ping_common.h"
#include "ping_impl.h"
-static char short_options[] = "VLhc:dfi:l:np:qRrs:t:v";
-static struct option long_options[] =
-{
- /* Help options */
- {"version", no_argument, NULL, 'V'},
- {"license", no_argument, NULL, 'L'},
- {"help", no_argument, NULL, 'h'},
- /* Common options */
- {"count", required_argument, NULL, 'c'},
- {"debug", no_argument, NULL, 'd'},
- {"ignore-routing", no_argument, NULL, 'r'},
- {"size", required_argument, NULL, 's'},
- {"interval",required_argument, NULL, 'i'},
- {"numeric", no_argument, NULL, 'n'},
- {"verbose", no_argument, NULL, 'v'},
- /* Packet types */
- {"type", required_argument, NULL, 't'},
- {"echo", no_argument, NULL, ICMP_ECHO},
- {"timestamp",no_argument, NULL, ICMP_TIMESTAMP},
- {"address", no_argument, NULL, ICMP_ADDRESS},
- {"router", no_argument, NULL, ICMP_ROUTERDISCOVERY},
- /* echo-specific options */
- {"flood", no_argument, NULL, 'f'},
- {"preload", required_argument, NULL, 'l'},
- {"pattern", required_argument, NULL, 'p'},
- {"quiet", no_argument, NULL, 'q'},
- {"route", no_argument, NULL, 'R'},
- {NULL, no_argument, NULL, 0}
-};
-
extern int ping_echo (int argc, char **argv);
extern int ping_timestamp (int argc, char **argv);
extern int ping_address (int argc, char **argv);
@@ -113,6 +84,7 @@
int pattern_len = 16;
u_char *patptr = NULL;
bool is_root = false;
+ struct arg_t cmdline;
size_t count = 0;
int socket_type = 0;
@@ -123,157 +95,122 @@
if (getuid () == 0)
is_root = true;
- /* Parse command line */
- while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
- != EOF)
+ Cmdline(&cmdline, argc, argv);
+
+ if (cmdline.version)
+ {
+ printf ("ping - %s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+ printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
+ printf ("%s comes with ABSOLUTELY NO WARRANTY.\n", PACKAGE_NAME);
+ printf ("You may redistribute copies of %s\n", PACKAGE_NAME);
+ printf ("under the terms of the GNU General Public License.\n");
+ printf ("For more information about these matters, ");
+ printf ("see the files named COPYING.\n");
+ exit (0);
+ }
+
+ if (cmdline.license)
+ {
+ show_license ();
+ exit (0);
+ }
+
+ if (cmdline.count != NULL)
+ count = ping_cvt_number (cmdline.count, 0, 0);
+
+ if (cmdline.debug)
+ socket_type = SO_DEBUG;
+
+ if (cmdline.ignore_routing)
+ socket_type = SO_DONTROUTE;
+
+ if (cmdline.interval_flag)
{
- switch (c)
+ options |= OPT_INTERVAL;
+ interval = cmdline.interval * PING_PRECISION;
+ if (!is_root && interval < MIN_USER_INTERVAL)
{
- case 'V':
- printf ("ping - %s %s\n", PACKAGE_NAME, PACKAGE_VERSION);
- printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
- printf ("%s comes with ABSOLUTELY NO WARRANTY.\n", PACKAGE_NAME);
- printf ("You may redistribute copies of %s\n", PACKAGE_NAME);
- printf ("under the terms of the GNU General Public License.\n");
- printf ("For more information about these matters, ");
- printf ("see the files named COPYING.\n");
- exit (0);
- break;
-
- case 'L':
- show_license ();
- exit (0);
-
- case 'h':
- show_usage ();
- exit (0);
- break;
-
- case 'c':
- count = ping_cvt_number (optarg, 0, 0);
- break;
-
- case 'd':
- socket_type = SO_DEBUG;
- break;
-
- case 'r':
- socket_type = SO_DONTROUTE;
- break;
-
- case 'i':
- {
- double v;
-
- v = strtod (optarg, &p);
- if (*p)
- {
- fprintf (stderr, "Invalid value (`%s' near `%s')\n",
- optarg, p);
- exit (1);
- }
-
- options |= OPT_INTERVAL;
- interval = v * PING_PRECISION;
- if (!is_root && interval < MIN_USER_INTERVAL)
- {
- fprintf (stderr, "Option value too small: %s\n", optarg);
- exit (1);
- }
- }
- break;
-
- case 'p':
- decode_pattern (optarg, &pattern_len, pattern);
- patptr = pattern;
- break;
-
- case 's':
- data_length = ping_cvt_number (optarg, PING_MAX_DATALEN, 1);
- break;
-
- case 'n':
- options |= OPT_NUMERIC;
- break;
-
- case 'q':
- options |= OPT_QUIET;
- break;
-
- case 'R':
- options |= OPT_RROUTE;
- break;
-
- case 'v':
- options |= OPT_VERBOSE;
- break;
-
- case 'l':
- if (!is_root)
- {
- fprintf (stderr, "ping: option not allowed: --preload\n");
- exit (1);
- }
- preload = strtoul (optarg, &p, 0);
- if (*p || preload > INT_MAX)
- {
- fprintf (stderr, "ping: invalid preload value (%s)\n", optarg);
- exit (1);
- }
- break;
+ fprintf (stderr, "Option value too small: %s\n", optarg);
+ exit (1);
+ }
+ }
- case 'f':
- if (is_root == false)
- {
- fprintf (stderr, "ping: option not allowed: --flood\n");
- exit (1);
- }
- options |= OPT_FLOOD;
- setbuf (stdout, (char *)NULL);
- break;
-
- case 't':
- decode_type (optarg);
- break;
-
- case ICMP_ECHO:
- decode_type ("echo");
- break;
-
- case ICMP_TIMESTAMP:
- decode_type ("timestamp");
- break;
-
- case ICMP_ADDRESS:
- if (!is_root)
- {
- fprintf (stderr, "ping: option not allowed: --address\n");
- exit (1);
- }
- decode_type ("address");
- break;
-
- case ICMP_ROUTERDISCOVERY:
- if (!is_root)
- {
- fprintf (stderr, "ping: option not allowed: --router\n");
- exit (1);
- }
- decode_type ("router");
- break;
-
- default:
- fprintf (stderr, "%c: not implemented\n", c);
+ if (cmdline.pattern != NULL)
+ {
+ decode_pattern (cmdline.pattern, &pattern_len, pattern);
+ patptr = pattern;
+ }
+
+ if (cmdline.size != NULL)
+ data_length = ping_cvt_number (cmdline.size, PING_MAX_DATALEN, 1);
+
+ if (cmdline.numeric)
+ options |= OPT_NUMERIC;
+
+ if (cmdline.quiet)
+ options |= OPT_QUIET;
+
+ if (cmdline.route)
+ options |= OPT_RROUTE;
+
+ if (cmdline.verbose)
+ options |= OPT_VERBOSE;
+
+ if (cmdline.preload)
+ {
+ if (!is_root)
+ {
+ fprintf (stderr, "ping: option not allowed: --preload\n");
+ exit (1);
+ }
+ preload = cmdline.preload;
+ }
+
+ if (cmdline.flood)
+ {
+ if (is_root == false)
+ {
+ fprintf (stderr, "ping: option not allowed: --flood\n");
+ exit (1);
+ }
+ options |= OPT_FLOOD;
+ setbuf (stdout, (char *)NULL);
+ }
+
+ if (cmdline.type != NULL)
+ decode_type (cmdline.type);
+
+ if (cmdline.echo)
+ decode_type ("echo");
+
+ if (cmdline.timestamp)
+ decode_type ("timestamp");
+
+ if (cmdline.address)
+ {
+ if (!is_root)
+ {
+ fprintf (stderr, "ping: option not allowed: --address\n");
exit (1);
}
+ decode_type ("address");
+ }
+
+ if (cmdline.router)
+ {
+ if (!is_root)
+ {
+ fprintf (stderr, "ping: option not allowed: --router\n");
+ exit (1);
+ }
+ decode_type ("router");
}
argc -= optind;
argv += optind;
if (argc == 0)
{
- show_usage ();
- exit (0);
+ usage (EXIT_SUCCESS, argv[0]);
}
ping = ping_init (ICMP_ECHO, getpid ());
@@ -468,40 +405,3 @@
printf ("\n");
return 0;
}
-
-void
-show_usage (void)
-{
- printf ("\
-Usage: ping [OPTION]... [ADDRESS]...\n\
-\n\
-Informational options:\n\
- -h, --help display this help and exit\n\
- -L, --license display license and exit\n\
- -V, --version output version information and exit\n\
-Options controlling ICMP request types:\n\
- --echo Send ICMP_ECHO requests (default)\n\
-* --address Send ICMP_ADDRESS packets\n\
- --timestamp Send ICMP_TIMESTAMP packets\n\
-* --router Send ICMP_ROUTERDISCOVERY packets\n\
-Options valid for all request types:\n\
- -c, --count N stop after sending N packets\n\
- -d, --debug set the SO_DEBUG option\n\
- -i, --interval N wait N seconds between sending each packet\n\
- -n, --numeric do not resolve host addresses\n\
- -r, --ignore-routing send directly to a host on an attached network\n\
- -v, --verbose verbose output\n\
-Options valid for --echo requests:\n\
-* -f, --flood flood ping \n\
-* -l, --preload N send N packets as fast as possible before falling into\n\
- normal mode of behavior\n\
- -p, --pattern PAT fill ICMP packet with given pattern (hex)\n\
- -q, --quiet quiet output\n\
- -R, --route record route\n\
- -s, --size N set number of data octets to send\n\
-\n\
-Options marked with an * are available only to super-user\n\
-\n\
-Report bugs to <" PACKAGE_BUGREPORT ">.\n\
-");
-}
diff -u -N -r inetutils-1.5.orig/ping/ping.gp inetutils-1.5/ping/ping.gp
--- inetutils-1.5.orig/ping/ping.gp 1970-01-01 01:00:00.000000000 +0100
+++ inetutils-1.5/ping/ping.gp 2007-12-23 20:53:24.000000000 +0100
@@ -0,0 +1,41 @@
+#include <config.h>
+
+h / help flag " display this help and exit"
+L / license flag " display license and exit"
+V / version flag " output version information and exit"
+"Options controlling ICMP request types:"
+NONE / echo flag " Send ICMP_ECHO requests (default)"
+NONE / address flag "* Send ICMP_ADDRESS packets"
+NONE / timestamp flag " Send ICMP_TIMESTAMP packets"
+t / type string " Send TYPE packets"
+NONE / router flag "* Send ICMP_ROUTERDISCOVERY packets"
+"Options valid for all request types:"
+c / count=N string " stop after sending N packets"
+d / debug flag " set the SO_DEBUG option"
+i / interval=N double " wait N seconds between sending each packet"
+ __ERR_MSG__("Invalid value (`%s')")
+ __ADD_FLAG__
+n / numeric flag " do not resolve host addresses"
+r / ignore-routing flag " send directly to a host on an attached network"
+v / verbose flag " verbose output"
+"Options valid for --echo requests:"
+f / flood flag "* flood ping"
+l / preload=N ulong [1..INT_MAX] 0
+ "* send N packets as fast as possible before falling into"
+ " normal mode of behavior"
+ __ERR_MSG__("ping: invalid preload value (%s)")
+p / pattern=PAT string " fill ICMP packet with given pattern (hex)"
+q / quiet flag " quiet output"
+R / route flag " record route"
+s / size=N string " set number of data octets to send"
+
+#usage_begin
+Usage: ping [OPTION]... [ADDRESS]...
+
+Informational options:
+__GLOSSARY_GNU__(19)
+
+Options marked with an * are available only to super-user
+
+Report bugs to <__STRING__(PACKAGE_BUGREPORT)>.
+#usage_end
_______________________________________________
bug-inetutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-inetutils