[ntpsec commit] Inline the option processing in Perl scripts...

Eric S. Raymond esr at ntpsec.org
Tue Oct 20 09:35:55 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    5a7c468f49fc15f50e207798423017524a57260d
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=5a7c468f49fc15f50e207798423017524a57260d

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Tue Oct 20 05:34:23 2015 -0400

Inline the option processing in Perl scripts...

...because autogen is gone and the *opts files aewe no longer generated.

---

 scripts/ntpsweep/ntpsweep-opts | 67 ------------------------------------------
 scripts/ntpsweep/ntpsweep.in   | 61 +++++++++++++++++++++++++++++++++++++-
 scripts/ntptrace/ntptrace-opts | 62 --------------------------------------
 scripts/ntptrace/ntptrace.in   | 57 ++++++++++++++++++++++++++++++++++-
 scripts/ntpwait/ntpwait-opts   | 62 --------------------------------------
 scripts/ntpwait/ntpwait.in     | 57 ++++++++++++++++++++++++++++++++++-
 6 files changed, 172 insertions(+), 194 deletions(-)

diff --git a/scripts/ntpsweep/ntpsweep-opts b/scripts/ntpsweep/ntpsweep-opts
deleted file mode 100644
index d51ac59..0000000
--- a/scripts/ntpsweep/ntpsweep-opts
+++ /dev/null
@@ -1,67 +0,0 @@
-# EDIT THIS FILE WITH CAUTION  (ntpsweep-opts)
-#
-# It has been AutoGen-ed  June  3, 2015 at 11:53:19 AM by AutoGen 5.18.5
-# From the definitions    ntpsweep-opts.def
-# and the template file   perlopt
-
-use Getopt::Long qw(GetOptionsFromArray);
-Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
-
-my $usage;
-
-sub usage {
-    my ($ret) = @_;
-    print STDERR $usage;
-    exit $ret;
-}
-
-sub paged_usage {
-    my ($ret) = @_;
-    my $pager = $ENV{PAGER} || '(less || more)';
-
-    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
-    print $usage;
-
-    exit $ret;
-}
-
-sub processOptions {
-    my $args = shift;
-
-    my $opts = {
-        'host-list' => [],
-        'peers' => '',
-        'maxlevel' => '',
-        'strip' => '',
-        'host' => '',
-        'help' => '', 'more-help' => ''
-    };
-    my $argument = '[hostfile]';
-    my $ret = GetOptionsFromArray($args, $opts, (
-        'host-list|l=s', 'peers|p', 'maxlevel|m=i',
-        'strip|s=s', 'host|h=s',
-        'help|?', 'more-help'));
-
-    $usage = <<'USAGE';
-ntpsweep - Print various informations about given ntp servers.
-USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile]
-
-    -l, --host-list=str          Host to execute actions on
-                                   - may appear multiple times
-    -p, --peers                  Recursively list all peers a host synchronizes to
-    -m, --maxlevel=num           Traverse peers up to this level (4 is a reasonable number)
-    -s, --strip=str              Strip this string from hostnames
-    -?, --help                   Display usage information and exit
-        --more-help              Pass the extended usage text through a pager
-
-Options are specified by doubled hyphens and their name or by a single
-hyphen and the flag character.
-USAGE
-
-    usage(0)       if $opts->{'help'};
-    paged_usage(0) if $opts->{'more-help'};
-    $_[0] = $opts;
-    return $ret;
-}
-
-END { close STDOUT };
diff --git a/scripts/ntpsweep/ntpsweep.in b/scripts/ntpsweep/ntpsweep.in
index 3e0ea93..aa58e04 100644
--- a/scripts/ntpsweep/ntpsweep.in
+++ b/scripts/ntpsweep/ntpsweep.in
@@ -21,6 +21,65 @@ use 5.006_000;
 use strict;
 use lib "@PERLLIBDIR@";
 use NTP::Util qw(do_dns ntp_read_vars ntp_peers ntp_ntpdig_line);
+use Getopt::Long qw(GetOptionsFromArray);
+Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
+
+my $usage;
+
+sub usage {
+    my ($ret) = @_;
+    print STDERR $usage;
+    exit $ret;
+}
+
+sub paged_usage {
+    my ($ret) = @_;
+    my $pager = $ENV{PAGER} || '(less || more)';
+
+    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
+    print $usage;
+
+    exit $ret;
+}
+
+sub processOptions {
+    my $args = shift;
+
+    my $opts = {
+        'host-list' => [],
+        'peers' => '',
+        'maxlevel' => '',
+        'strip' => '',
+        'host' => '',
+        'help' => '', 'more-help' => ''
+    };
+    my $argument = '[hostfile]';
+    my $ret = GetOptionsFromArray($args, $opts, (
+        'host-list|l=s', 'peers|p', 'maxlevel|m=i',
+        'strip|s=s', 'host|h=s',
+        'help|?', 'more-help'));
+
+    $usage = <<'USAGE';
+ntpsweep - Print various informations about given ntp servers.
+USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile]
+
+    -l, --host-list=str          Host to execute actions on
+                                   - may appear multiple times
+    -p, --peers                  Recursively list all peers a host synchronizes to
+    -m, --maxlevel=num           Traverse peers up to this level (4 is a reasonable number)
+    -s, --strip=str              Strip this string from hostnames
+    -?, --help                   Display usage information and exit
+        --more-help              Pass the extended usage text through a pager
+
+Options are specified by doubled hyphens and their name or by a single
+hyphen and the flag character.
+USAGE
+
+    usage(0)       if $opts->{'help'};
+    paged_usage(0) if $opts->{'more-help'};
+    $_[0] = $opts;
+    return $ret;
+}
 
 (my $program = $0) =~ s%.*/(.+?)(.pl)?$%$1%;
 my ($showpeers, $maxlevel, $strip);
@@ -196,7 +255,7 @@ sub scan_host {
     }
 }
 
- at ntpsweep_opts@
+END { close STDOUT };
 
 1;
 __END__
diff --git a/scripts/ntptrace/ntptrace-opts b/scripts/ntptrace/ntptrace-opts
deleted file mode 100644
index 25f7dc3..0000000
--- a/scripts/ntptrace/ntptrace-opts
+++ /dev/null
@@ -1,62 +0,0 @@
-# EDIT THIS FILE WITH CAUTION  (ntptrace-opts)
-#
-# It has been AutoGen-ed  June  3, 2015 at 11:53:28 AM by AutoGen 5.18.5
-# From the definitions    ntptrace-opts.def
-# and the template file   perlopt
-
-use Getopt::Long qw(GetOptionsFromArray);
-Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
-
-my $usage;
-
-sub usage {
-    my ($ret) = @_;
-    print STDERR $usage;
-    exit $ret;
-}
-
-sub paged_usage {
-    my ($ret) = @_;
-    my $pager = $ENV{PAGER} || '(less || more)';
-
-    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
-    print $usage;
-
-    exit $ret;
-}
-
-sub processOptions {
-    my $args = shift;
-
-    my $opts = {
-        'numeric' => '',
-        'max-hosts' => '99',
-        'host' => '127.0.0.1',
-        'help' => '', 'more-help' => ''
-    };
-    my $argument = '[host]';
-    my $ret = GetOptionsFromArray($args, $opts, (
-        'numeric|n', 'max-hosts|m=i', 'host|r=s',
-        'help|?', 'more-help'));
-
-    $usage = <<'USAGE';
-ntptrace - Trace peers of an NTP server.
-USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
-
-    -n, --numeric                Print IP addresses instead of hostnames
-    -m, --max-hosts=num          Maximum number of peers to trace
-    -r, --host=str               Single remote host
-    -?, --help                   Display usage information and exit
-        --more-help              Pass the extended usage text through a pager
-
-Options are specified by doubled hyphens and their name or by a single
-hyphen and the flag character.
-USAGE
-
-    usage(0)       if $opts->{'help'};
-    paged_usage(0) if $opts->{'more-help'};
-    $_[0] = $opts;
-    return $ret;
-}
-
-END { close STDOUT };
diff --git a/scripts/ntptrace/ntptrace.in b/scripts/ntptrace/ntptrace.in
index c0e2fff..29f4336 100755
--- a/scripts/ntptrace/ntptrace.in
+++ b/scripts/ntptrace/ntptrace.in
@@ -6,6 +6,60 @@ use 5.006_000;
 use strict;
 use lib "@PERLLIBDIR@";
 use NTP::Util qw(ntp_read_vars do_dns);
+use Getopt::Long qw(GetOptionsFromArray);
+Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
+
+my $usage;
+
+sub usage {
+    my ($ret) = @_;
+    print STDERR $usage;
+    exit $ret;
+}
+
+sub paged_usage {
+    my ($ret) = @_;
+    my $pager = $ENV{PAGER} || '(less || more)';
+
+    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
+    print $usage;
+
+    exit $ret;
+}
+
+sub processOptions {
+    my $args = shift;
+
+    my $opts = {
+        'numeric' => '',
+        'max-hosts' => '99',
+        'host' => '127.0.0.1',
+        'help' => '', 'more-help' => ''
+    };
+    my $argument = '[host]';
+    my $ret = GetOptionsFromArray($args, $opts, (
+        'numeric|n', 'max-hosts|m=i', 'host|r=s',
+        'help|?', 'more-help'));
+
+    $usage = <<'USAGE';
+ntptrace - Trace peers of an NTP server.
+USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
+
+    -n, --numeric                Print IP addresses instead of hostnames
+    -m, --max-hosts=num          Maximum number of peers to trace
+    -r, --host=str               Single remote host
+    -?, --help                   Display usage information and exit
+        --more-help              Pass the extended usage text through a pager
+
+Options are specified by doubled hyphens and their name or by a single
+hyphen and the flag character.
+USAGE
+
+    usage(0)       if $opts->{'help'};
+    paged_usage(0) if $opts->{'more-help'};
+    $_[0] = $opts;
+    return $ret;
+}
 
 exit run(@ARGV) unless caller;
 
@@ -74,7 +128,8 @@ sub get_next_host {
     return $info->{srcadr};
 }
 
- at ntptrace_opts@
+END { close STDOUT };
+
 
 1;
 __END__
diff --git a/scripts/ntpwait/ntpwait-opts b/scripts/ntpwait/ntpwait-opts
deleted file mode 100644
index 9e24b75..0000000
--- a/scripts/ntpwait/ntpwait-opts
+++ /dev/null
@@ -1,62 +0,0 @@
-# EDIT THIS FILE WITH CAUTION  (ntpwait-opts)
-#
-# It has been AutoGen-ed  June  3, 2015 at 11:53:09 AM by AutoGen 5.18.5
-# From the definitions    ntpwait-opts.def
-# and the template file   perlopt
-
-use Getopt::Long qw(GetOptionsFromArray);
-Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
-
-my $usage;
-
-sub usage {
-    my ($ret) = @_;
-    print STDERR $usage;
-    exit $ret;
-}
-
-sub paged_usage {
-    my ($ret) = @_;
-    my $pager = $ENV{PAGER} || '(less || more)';
-
-    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
-    print $usage;
-
-    exit $ret;
-}
-
-sub processOptions {
-    my $args = shift;
-
-    my $opts = {
-        'tries' => '100',
-        'sleep' => '6',
-        'verbose' => '',
-        'help' => '', 'more-help' => ''
-    };
-    my $argument = '';
-    my $ret = GetOptionsFromArray($args, $opts, (
-        'tries|n=i', 'sleep|s=i', 'verbose|v',
-        'help|?', 'more-help'));
-
-    $usage = <<'USAGE';
-ntpwait - Wait for ntpd to stabilize the system clock.
-USAGE: ntpwait [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
-
-    -n, --tries=num              Number of times to check ntpd
-    -s, --sleep=num              How long to sleep between tries
-    -v, --verbose                Be verbose
-    -?, --help                   Display usage information and exit
-        --more-help              Pass the extended usage text through a pager
-
-Options are specified by doubled hyphens and their name or by a single
-hyphen and the flag character.
-USAGE
-
-    usage(0)       if $opts->{'help'};
-    paged_usage(0) if $opts->{'more-help'};
-    $_[0] = $opts;
-    return $ret;
-}
-
-END { close STDOUT };
diff --git a/scripts/ntpwait/ntpwait.in b/scripts/ntpwait/ntpwait.in
index ef11c19..087312b 100644
--- a/scripts/ntpwait/ntpwait.in
+++ b/scripts/ntpwait/ntpwait.in
@@ -6,6 +6,60 @@ use strict;
 use warnings;
 use lib "@PERLLIBDIR@";
 use NTP::Util qw(ntp_read_vars);
+use Getopt::Long qw(GetOptionsFromArray);
+Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
+
+my $usage;
+
+sub usage {
+    my ($ret) = @_;
+    print STDERR $usage;
+    exit $ret;
+}
+
+sub paged_usage {
+    my ($ret) = @_;
+    my $pager = $ENV{PAGER} || '(less || more)';
+
+    open STDOUT, "| $pager" or die "Can't fork a pager: $!";
+    print $usage;
+
+    exit $ret;
+}
+
+sub processOptions {
+    my $args = shift;
+
+    my $opts = {
+        'tries' => '100',
+        'sleep' => '6',
+        'verbose' => '',
+        'help' => '', 'more-help' => ''
+    };
+    my $argument = '';
+    my $ret = GetOptionsFromArray($args, $opts, (
+        'tries|n=i', 'sleep|s=i', 'verbose|v',
+        'help|?', 'more-help'));
+
+    $usage = <<'USAGE';
+ntpwait - Wait for ntpd to stabilize the system clock.
+USAGE: ntpwait [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
+
+    -n, --tries=num              Number of times to check ntpd
+    -s, --sleep=num              How long to sleep between tries
+    -v, --verbose                Be verbose
+    -?, --help                   Display usage information and exit
+        --more-help              Pass the extended usage text through a pager
+
+Options are specified by doubled hyphens and their name or by a single
+hyphen and the flag character.
+USAGE
+
+    usage(0)       if $opts->{'help'};
+    paged_usage(0) if $opts->{'more-help'};
+    $_[0] = $opts;
+    return $ret;
+}
 
 exit run(@ARGV) unless caller;
 
@@ -60,7 +114,8 @@ sub run {
     return 1;
 }
 
- at ntp_wait_opts@
+END { close STDOUT };
+
 
 1;
 __END__



More information about the vc mailing list