]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Convert ntpdc to autogen; some cleanup in ntpq
authorHarlan Stenn <stenn@ntp.org>
Sun, 6 Feb 2005 06:22:40 +0000 (01:22 -0500)
committerHarlan Stenn <stenn@ntp.org>
Sun, 6 Feb 2005 06:22:40 +0000 (01:22 -0500)
bk: 4205b7b03MALfySip6NR6xUwBPYhug

ntpdc/Makefile.am
ntpdc/ntpdc-opts.def [new file with mode: 0644]
ntpdc/ntpdc.c
ntpq/Makefile.am

index b80502080d81efc2801ed1a63cec1890ef168ed2..d0010af716da663eca175d31696a82f59b56a776 100644 (file)
@@ -5,18 +5,34 @@ bin_PROGRAMS= ntpdc
 EXTRA_PROGRAMS=        ntpdc-layout
 EXTRA_DATA=    check-layout
 BUILT_SOURCES= maybe-layout
-AM_CPPFLAGS=   -I$(top_srcdir)/include
+AM_CPPFLAGS=   -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
 # LDADD might need RESLIB and ADJLIB
-ntpdc_LDADD=   version.o ../libntp/libntp.a @READLINE_LIBS@
+ntpdc_LDADD=   version.o ../libntp/libntp.a @READLINE_LIBS@ $(LIBOPTS_LDADD)
 # ntpdc-layout doesn't need any additional libraries at all
 ntpdc_layout_LDADD=
 DISTCLEANFILES=        .version version.c
 CLEANFILES=    check-layout layout.here nl.c ntpdc-layout
 noinst_HEADERS=        ntpdc.h
-EXTRA_DIST=    nl_in.c nl.pl layout.std
 ETAGS_ARGS=    Makefile.am
+EXTRA_DIST=    nl_in.c nl.pl layout.std        \
+               ntpdc-opts.def ntpdc.1 ntpdc-opts.texi ntpdc-opts.menu
+BUILT_SOURCES+=        ntpdc-opts.c ntpdc-opts.h ntpdc.1 ntpdc-opts.texi       \
+               ntpdc-opts.menu
+man_MANS=      ntpdc.1
 
-ntpdc_SOURCES = ntpdc.c ntpdc_ops.c
+
+ntpdc-opts.h: ntpdc-opts.c
+ntpdc-opts.c: ntpdc-opts.def
+       cd $(srcdir) && autogen ntpdc-opts.def
+
+ntpdc.1: ntpdc-opts.def
+       cd $(srcdir) && autogen -Tagman1.tpl -bntpdc ntpdc-opts.def
+
+ntpdc-opts.texi ntpdc-opts.menu: ntpdc-opts.def
+       cd $(srcdir) && autogen -L ${prefix}/share/autogen \
+               -Taginfo.tpl -DLEVEL=section ntpdc-opts.def
+
+ntpdc_SOURCES = ntpdc.c ntpdc_ops.c ntpdc-opts.c ntpdc-opts.h
 
 maybe-layout:
        @case "${PATH_PERL}" in \
diff --git a/ntpdc/ntpdc-opts.def b/ntpdc/ntpdc-opts.def
new file mode 100644 (file)
index 0000000..3fefa7f
--- /dev/null
@@ -0,0 +1,178 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+/*
+ *   $Id: opts.def,v 3.34 2004/10/15 01:48:34 bkorb Exp $
+ *
+ *  NTP copyright 1970-2004 Someone
+ *
+ *  NTP is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  AutoGen 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 AutoGen.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             59 Temple Place - Suite 330,
+ *             Boston,  MA  02111-1307, USA.
+ */
+
+copyright = {
+    date  = "1970-2004";
+    owner = "ntp.org";
+    eaddr = "http://bugs.ntp.isc.org, bugs@ntp.org";
+    type  = bsd;
+};
+
+
+prog-name      = "ntpdc";
+prog-title     = "vendor-specific NTP query program";
+homerc         =  $HOME, ".";
+long-opts;
+
+#ifndef __windows__
+rcfile         = ".ntprc";
+#else
+rcfile         = "ntp.ini";
+#endif
+
+environrc;
+
+version         = `
+eval VERSION=\`sed -e 's/.*,\\[//' -e 's/\\].*//' < ../version.m4\`
+[ -z "${VERSION}" ] && echo "Cannot determine VERSION" && kill -TERM $AG_pid
+echo $VERSION`;
+
+test-main;
+
+flag = {
+    name      = ipv4;
+    value     = 4;
+    equivalence = ipv4;
+    descrip   = "Force IPv4 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv4 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = ipv6;
+    value     = 6;
+    equivalence = ipv4;
+    descrip   = "Force IPv6 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv6 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = command;
+    value     = c;
+    arg-type  = string;
+    descrip   = "run a command and exit";
+    max       = NOLIMIT;
+    arg-name  = cmd;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       The following argument is interpreted as an interactive format command
+       and is added to the list of commands to be executed on the specified
+       host(s).
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = listpeers;
+    value     = l;
+    descrip   = "Print a list of the peers";
+    flags-cant = command;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary
+       of their state. This is equivalent to the listpeers interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = peers;
+    value     = p;
+    descrip   = "Print a list of the peers";
+    flags-cant = command;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary
+       of their state. This is equivalent to the peers interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = showpeers;
+    value     = s;
+    descrip   = "Show a list of the peers";
+    flags-cant = command;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary
+       of their state. This is equivalent to the dmpeers interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = interactive;
+    value     = i;
+    flags-cant = command, listpeers, peers, showpeers;
+    descrip   = "Force ntpq to operate in interactive mode";
+    doc = <<-  _EndOfDoc_
+       Force ntpq to operate in interactive mode.  Prompts will be written
+       to the standard output and commands read from the standard input.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = debug-level;
+    value     = d;
+    max       = NOLIMIT;
+    descrip   = "Increase output debug message level";
+    doc = <<-  _EndOfDoc_
+       Increase the debugging message output level.  Can be supplied multiple times.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = set-debug-level;
+    value     = D;
+    max       = NOLIMIT;
+    descrip   = "Set the output debug message level";
+    arg-type  = string;
+    flag-code = <<- _EOS_
+       DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
+       _EOS_;
+    doc = <<-  _EndOfDoc_
+       Set the output debugging level.  Can be supplied multiple times,
+       but each overrides the previous value(s).
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = numeric;
+    value     = n;
+    descrip   = "numeric host addresses";
+    doc = <<-  _EndOfDoc_
+       Output all host addresses in dotted-quad numeric format rather than
+       converting to the canonical host names. 
+       _EndOfDoc_;
+};
+
+detail = <<-  _END_DETAIL
+       The ntpq utility program is used to monitor NTP daemon ntpd operations
+       and determine performance. It uses the standard NTP mode 6 control
+       message formats defined in Appendix B of the NTPv3 specification
+       RFC1305. The same formats are used in NTPv4, although some of the
+       variables have changed and new ones added. The description on this
+       page is for the NTPv4 variables.
+       _END_DETAIL;
index 3168596ea99b9238ffad63be994179c59e2373df..d0e179c93f23281f3ef8f31f15d5dd5eb60d1ffd 100644 (file)
@@ -17,6 +17,8 @@
 #include "isc/net.h"
 #include "isc/result.h"
 
+#include "ntpdc-opts.h"
+
 #ifdef SYS_WINNT
 #include <Mswsock.h>
 # include <io.h>
@@ -314,6 +316,57 @@ ntpdcmain(
        }
 
        progname = argv[0];
+
+       {
+               int optct = optionProcess(&ntpdcOptions, argc, argv);
+               argc -= optct;
+               argv += optct;
+       }
+
+       switch (WHICH_IDX_IPV4) {
+           case INDEX_OPT_IPV4:
+               ai_fam_templ = AF_INET;
+               break;
+           case INDEX_OPT_IPV6:
+               ai_fam_templ = AF_INET6;
+               break;
+           default:
+               ai_fam_templ = ai_fam_default;
+               break;
+       }
+
+       if (HAVE_OPT(COMMAND)) {
+               int     cmdct = STACKCT_OPT( COMMAND );
+               char**  cmds  = STACKLST_OPT( COMMAND );
+
+               while (cmdct-- > 0) {
+                       ADDCMD(*cmds++);
+               }
+       }
+
+       debug = DESC(DEBUG_LEVEL).optOccCt;
+
+       if (HAVE_OPT(INTERACTIVE)) {
+               interactive = 1;
+       }
+
+       if (HAVE_OPT(NUMERIC)) {
+               showhostnames = 0;
+       }
+
+       if (HAVE_OPT(LISTPEERS)) {
+               ADDCMD("listpeers");
+       }
+
+       if (HAVE_OPT(PEERS)) {
+               ADDCMD("peers");
+       }
+
+       if (HAVE_OPT(SHOWPEERS)) {
+               ADDCMD("dmpeers");
+       }
+
+#if 0
        ai_fam_templ = ai_fam_default;
        while ((c = ntp_getopt(argc, argv, "46c:dilnps")) != EOF)
            switch (c) {
@@ -365,6 +418,7 @@ ntpdcmain(
            && isatty(fileno(stdin)) && isatty(fileno(stderr))) {
                interactive = 1;
        }
+#endif
 
 #ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */
        if (interactive)
index 3815b5a05561650faa821b89b823e5cf17bacd1d..b8cbd0a9822fe057d360899af4f90a38ac90bf3f 100644 (file)
@@ -21,7 +21,7 @@ ntpq-opts.c: ntpq-opts.def
 ntpq.1: ntpq-opts.def
        cd $(srcdir) && autogen -Tagman1.tpl -bntpq ntpq-opts.def
 
-ntpq.texi ntpq.menu: ntpq-opts.def
+ntpq-opts.texi ntpq-opts.menu: ntpq-opts.def
        cd $(srcdir) && autogen -L ${prefix}/share/autogen \
                -Taginfo.tpl -DLEVEL=section ntpq-opts.def