File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / curl / tests / tftpserver.pl
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Jun 3 10:01:16 2020 UTC (5 years ago) by misho
Branches: curl, MAIN
CVS tags: v7_70_0p4, HEAD
curl

    1: #!/usr/bin/env perl
    2: #***************************************************************************
    3: #                                  _   _ ____  _
    4: #  Project                     ___| | | |  _ \| |
    5: #                             / __| | | | |_) | |
    6: #                            | (__| |_| |  _ <| |___
    7: #                             \___|\___/|_| \_\_____|
    8: #
    9: # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
   10: #
   11: # This software is licensed as described in the file COPYING, which
   12: # you should have received as part of this distribution. The terms
   13: # are also available at https://curl.haxx.se/docs/copyright.html.
   14: #
   15: # You may opt to use, copy, modify, merge, publish, distribute and/or sell
   16: # copies of the Software, and permit persons to whom the Software is
   17: # furnished to do so, under the terms of the COPYING file.
   18: #
   19: # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
   20: # KIND, either express or implied.
   21: #
   22: #***************************************************************************
   23: 
   24: BEGIN {
   25:     push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
   26:     push(@INC, ".");
   27: }
   28: 
   29: use strict;
   30: use warnings;
   31: 
   32: use serverhelp qw(
   33:     server_pidfilename
   34:     server_logfilename
   35:     );
   36: 
   37: use sshhelp qw(
   38:     exe_ext
   39:     );
   40: 
   41: my $verbose = 0;     # set to 1 for debugging
   42: my $port = 8997;     # just a default
   43: my $ipvnum = 4;      # default IP version of tftp server
   44: my $idnum = 1;       # default tftp server instance number
   45: my $proto = 'tftp';  # protocol the tftp server speaks
   46: my $pidfile;
   47: my $portfile;
   48: my $logfile;
   49: my $srcdir;
   50: my $fork;
   51: 
   52: my $flags  = "";
   53: my $path   = '.';
   54: my $logdir = $path .'/log';
   55: 
   56: while(@ARGV) {
   57:     if($ARGV[0] eq '--pidfile') {
   58:         if($ARGV[1]) {
   59:             $pidfile = $ARGV[1];
   60:             shift @ARGV;
   61:         }
   62:     }
   63:     elsif($ARGV[0] eq '--portfile') {
   64:         if($ARGV[1]) {
   65:             $portfile = $ARGV[1];
   66:             shift @ARGV;
   67:         }
   68:     }
   69:     elsif($ARGV[0] eq '--logfile') {
   70:         if($ARGV[1]) {
   71:             $logfile = $ARGV[1];
   72:             shift @ARGV;
   73:         }
   74:     }
   75:     elsif($ARGV[0] eq '--srcdir') {
   76:         if($ARGV[1]) {
   77:             $srcdir = $ARGV[1];
   78:             shift @ARGV;
   79:         }
   80:     }
   81:     elsif($ARGV[0] eq '--ipv4') {
   82:         $ipvnum = 4;
   83:     }
   84:     elsif($ARGV[0] eq '--ipv6') {
   85:         $ipvnum = 6;
   86:     }
   87:     elsif($ARGV[0] eq '--port') {
   88:         if($ARGV[1] =~ /^(\d+)$/) {
   89:             $port = $1;
   90:             shift @ARGV;
   91:         }
   92:     }
   93:     elsif($ARGV[0] eq '--id') {
   94:         if($ARGV[1] =~ /^(\d+)$/) {
   95:             $idnum = $1 if($1 > 0);
   96:             shift @ARGV;
   97:         }
   98:     }
   99:     elsif($ARGV[0] eq '--verbose') {
  100:         $verbose = 1;
  101:     }
  102:     else {
  103:         print STDERR "\nWarning: tftpserver.pl unknown parameter: $ARGV[0]\n";
  104:     }
  105:     shift @ARGV;
  106: }
  107: 
  108: if(!$srcdir) {
  109:     $srcdir = $ENV{'srcdir'} || '.';
  110: }
  111: if(!$pidfile) {
  112:     $pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
  113: }
  114: if(!$logfile) {
  115:     $logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
  116: }
  117: 
  118: $flags .= "--pidfile \"$pidfile\" ".
  119:     "--portfile \"$portfile\" ".
  120:     "--logfile \"$logfile\" ";
  121: $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
  122: 
  123: exec("server/tftpd".exe_ext('SRV')." $flags");

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>