use Config;
use Cwd;
# List explicitly here the variables you want Configure to
# generate. Metaconfig only looks for shell variables, so you
# have to mention them as if they were shell variables, not
# %Config entries. Thus you write
# $startperl
# to ensure Configure will look for $Config{startperl}.
# This forces PL files to create target in same directory as PL file.
# This is so that make depend always knows where to find PL derivatives.
chdir dirname($0);
print "Extracting $file (with variable substitutions)\n";
# In this section, perl variables will be expanded during extraction.
# You can use $Config{...} to use Configure variables.
print OUT <<"!GROK!THIS!";
eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
if \$running_under_some_shell;
# In the following, perl variables are not expanded during extraction.
print OUT <<'!NO!SUBS!';
=head1 NAME
libnetcfg - configure libnet
=head1 DESCRIPTION
The libnetcfg utility can be used to configure the libnet.
Starting from perl 5.8 libnet is part of the standard Perl
distribution, but the libnetcfg can be used for any libnet
installation.
=head1 USAGE
Without arguments libnetcfg displays the current configuration.
$ libnetcfg
# old config ./libnet.cfg
daytime_hosts ntp1.none.such
ftp_int_passive 0
ftp_testhost ftp.funet.fi
inet_domain none.such
nntp_hosts nntp.none.such
ph_hosts
pop3_hosts pop.none.such
smtp_hosts smtp.none.such
snpp_hosts
test_exist 1
test_hosts 1
time_hosts ntp.none.such
# libnetcfg -h for help
$
It tells where the old configuration file was found (if found).
The C<-h> option will show a usage message.
To change the configuration you will need to use either the C<-c> or
the C<-d> options.
The default name of the old configuration file is by default
"libnet.cfg", unless otherwise specified using the -i option,
C<-i oldfile>, and it is searched first from the current directory,
and then from your module path.
The default name of the new configuration file is "libnet.cfg", and by
default it is written to the current directory, unless otherwise
specified using the -o option, C<-o newfile>.
=head1 SEE ALSO
L<Net::Config>, L<Net::libnetFAQ>
=head1 AUTHORS
Graham Barr, the original Configure script of libnet.
Jarkko Hietaniemi, conversion into libnetcfg for inclusion into Perl 5.8.
=cut
# $Id: Configure,v 1.8 1997/03/04 09:22:32 gbarr Exp $
use strict;
##
##
##
my %cfg = ();
my @cfg = ();
##
##
##
sub valid_host
{
my $h = shift;
}
##
##
##
sub test_hostnames (\@)
{
my $hlist = shift;
my @h = ();
my $host;
my $err = 0;
{
if(valid_host($host))
{
push(@h, $host);
next;
}
warn "Bad hostname: '$host'\n";
$err++;
}
@$hlist = @h;
$err ? join(" ",@h) : undef;
}
##
##
##
sub Prompt
{
chomp($prompt);
if($opt_d)
{
return $def;
}
}
##
##
##
sub get_host_list
{
my @hosts;
do
{
$ans =~ s/(\A\s+|\s+\Z)//g;
}
\@hosts;
}
##
##
##
sub get_hostname
{
my $host;
while(1)
{
last
$def =""
print <<"EDQ";
*** ERROR:
}
length $host
? $host
: undef;
}
##
##
##
sub get_bool ($$)
{
chomp($prompt);
}
##
##
##
sub get_netmask ($$)
{
chomp($prompt);
my %list;
MASK:
while(1) {
my $bad = 0;
if($ans eq '*') {
%list = ();
next;
}
if($ans eq '=') {
next;
}
warn "Bad netmask '$ans'\n";
next;
}
warn "Bad netmask '$ans'\n";
next MASK;
}
if ( $byte > 255 ) {
warn "Bad netmask '$ans'\n";
next MASK;
}
}
if ($remove) {
}
else {
}
}
[ keys %list ];
}
##
##
##
sub default_hostname
{
my $host;
my @host;
foreach $host (@_)
{
{
return $host
unless wantarray;
}
}
return wantarray ? @host : undef;
}
##
##
##
getopts('dcho:i:');
$libnet_cfg_in = "libnet.cfg"
unless(defined($libnet_cfg_in = $opt_i));
$libnet_cfg_out = "libnet.cfg"
unless(defined($libnet_cfg_out = $opt_o));
my %oldcfg = ();
if( -f $libnet_cfg_in )
{
%oldcfg = ( %{ do $libnet_cfg_in } );
}
{
$have_old = 1;
}
#---------------------------------------------------------------------------
if ($opt_h) {
print <<EOU;
exit(0);
}
#---------------------------------------------------------------------------
{
my $oldcfgfile;
my @inc;
for (@inc) {
if (-f $trycfgfile && -r $trycfgfile) {
$oldcfgfile = $trycfgfile;
last;
}
}
print "# old config $oldcfgfile\n" if defined $oldcfgfile;
for (sort keys %oldcfg) {
printf "%-20s %s\n", $_,
}
print "# $0 -h for help\n";
exit(0);
}
}
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
{
$opt_d = 1
}
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
print <<EDQ;
$msg = 'Enter a list of available NNTP hosts :';
#---------------------------------------------------------------------------
$msg = 'Enter a list of available SMTP hosts :';
#---------------------------------------------------------------------------
$msg = 'Enter a list of available POP3 hosts :';
#---------------------------------------------------------------------------
$msg = 'Enter a list of available SNPP hosts :';
#---------------------------------------------------------------------------
$msg = 'Enter a list of available PH Hosts :' ;
[ default_hostname('dirserv') ];
#---------------------------------------------------------------------------
$msg = 'Enter a list of available TIME Hosts :' ;
#---------------------------------------------------------------------------
$msg = 'Enter a list of available DAYTIME Hosts :' ;
#---------------------------------------------------------------------------
(y|n) ?
$msg = <<'EDQ';
0) None
1) -----------------------
2) -----------------------
3) -----------------------
4) -----------------------
5) -----------------------
6) -----------------------
7) -----------------------
}
else {
delete $cfg{'ftp_firewall'};
}
#---------------------------------------------------------------------------
if (defined $cfg{'ftp_firewall'})
{
print <<EDQ;
$def = [];
if(ref($oldcfg{'local_netmask'}))
{
print "Your current netmasks are :\n\n\t",
}
print "
";
}
#---------------------------------------------------------------------------
###$msg =<<EDQ;
###
###SOCKS is a commonly used firewall protocol. If you use SOCKS firewalls
###then enter a list of hostames
###
###Enter a list of available SOCKS hosts :
###EDQ
###
###$def = $cfg{'socks_hosts'} ||
### [ default_hostname($ENV{SOCKS5_SERVER},
### $ENV{SOCKS_SERVER},
### $ENV{SOCKS4_SERVER}) ];
###
###$cfg{'socks_hosts'} = get_host_list($msg,$def);
#---------------------------------------------------------------------------
print <<EDQ;
if (defined $cfg{'ftp_firewall'}) {
$msg = "\nShould all other FTP connections be passive (y|n) ?";
}
else {
$msg = "\nShould all FTP connections be passive (y|n) ?";
}
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
if $cfg{'test_hosts'};
print "\n";
#---------------------------------------------------------------------------
die "Cannot create `$libnet_cfg_out': $!";
print "Writing $libnet_cfg_out\n";
print $fh "{\n";
my $key;
if(!defined($val)) {
$val = "undef";
}
elsif(ref($val)) {
map {
my $v = "undef";
if(defined $_) {
($v = $_) =~ s/'/\'/sog;
$v = "'" . $v . "'";
}
$v;
} @$val ) . ']';
}
else {
$val =~ s/'/\'/sog;
}
}
print $fh "}\n";
$fh->close;
############################################################################
############################################################################
exit 0;
close OUT or die "Can't close $file: $!";
chdir $origdir;