+* [Bug 663] respect ntpq -c and -p order on command line.
(4.2.5p210) 2009/09/06 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 1294] Use OPENSSL_INC and OPENSSL_LIB macros for Windows
and remove unnecessary reference to applink.c for Windows
descrip = "run a command and exit";
max = NOLIMIT;
arg-name = cmd;
- stack-arg;
+ call-proc = ntpq_custom_opt_handler;
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
value = p;
descrip = "Print a list of the peers";
flags-cant = interactive;
+ call-proc = ntpq_custom_opt_handler;
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.
#else
static int assoccmp (struct association *, struct association *);
#endif /* sgi || bsdi */
+void ntpq_custom_opt_handler (tOptions *, tOptDesc *);
/*
argv += optct;
}
+ /*
+ * Process options other than -c and -p, which are specially
+ * handled by ntpq_custom_opt_handler().
+ */
+
switch (WHICH_IDX_IPV4) {
case INDEX_OPT_IPV4:
ai_fam_templ = AF_INET;
break;
}
- if (HAVE_OPT(COMMAND)) {
- int cmdct = STACKCT_OPT( COMMAND );
- const char** cmds = STACKLST_OPT( COMMAND );
-
- while (cmdct-- > 0) {
- ADDCMD(*cmds++);
- }
- }
-
debug = DESC(DEBUG_LEVEL).optOccCt;
if (HAVE_OPT(INTERACTIVE)) {
showhostnames = 0;
}
- if (HAVE_OPT(PEERS)) {
- ADDCMD("peers");
- }
-
#if 0
while ((c = ntp_getopt(argc, argv, "46c:dinp")) != EOF)
switch (c) {
}
#endif /* not QSORT_USES_VOID_P */
+/*
+ * ntpq_custom_opt_handler - autoopts handler for -c and -p
+ *
+ * By default, autoopts loses the relative order of -c and -p options
+ * on the command line. This routine replaces the default handler for
+ * those routines and builds a list of commands to execute preserving
+ * the order.
+ */
+void
+ntpq_custom_opt_handler(
+ tOptions *pOptions,
+ tOptDesc *pOptDesc
+ )
+{
+ switch (pOptDesc->optValue) {
+
+ default:
+ fprintf(stderr,
+ "ntpq_custom_opt_handler unexpected option '%c' (%d)\n",
+ pOptDesc->optValue, pOptDesc->optValue);
+ exit(-1);
+
+ case 'c':
+ ADDCMD(pOptDesc->pzLastArg);
+ break;
+
+ case 'p':
+ ADDCMD("peers");
+ break;
+ }
+}