Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > e0824fcd9014cd83e936eb4556a60fd0 > files > 43

dialog-1.1-12.20100428.fc15.i686.rpm

# this is the base directory, where the req-files are stored and the
# default outbound
$flo_path = "/var/spool/ifmail";
$outbound = "/outb"; # don't be confused, it means "/var/spool/ifmail/outb"

# end of configuration #############################################

# main()
#
if ((@ARGV < 1) || @ARGV > 2 || $ARGV[0] eq "-?") {
    &usage;
} elsif ($ARGV[1] ne "") {
    $node = $ARGV[1];
}
$file = $ARGV[0];

if (! ($node =~ /\d+:\d+\/\d+/)) {
    die "Wrong address: $node!!!";
}

($zone, $netnode) = split (/:/, $node);
$reqfile = sprintf("%04x%04x", split(/\//, $netnode));

if ($reqfile eq "00000000") {
    print ("can't resolve the fido address \"$node\"\n");
    &usage;
} else {
    if ( $zone == 2 ) {
        $reqfile = $flo_path . $outbound . "/" . $reqfile . ".req";
    } elsif ( $zone < 7 ) {
        $reqfile = $flo_path . $outbound . ".00$zone/" . $reqfile . ".req";
    } else {
        $outbound = "";
        open (CONFIG, "< $config") || die "can't open $config";
        while ($_ = <CONFIG>) {
            if ( /^address.*$zone:.*\@(\w*)/ ) { $outbound = $1; }
        }
        if ( $outbound eq "" ) {
            die "No Zone $zone found in $config";
        }
        $reqfile = $flo_path . "/$outbound/" . $reqfile . ".req";
    }

    # seperate the file names of the first argument
    @files = split (/\s+/, $ARGV[0]);

    # open the flofile for appending
    open(FLOFILE, ">>" . $reqfile) || die "can't open $reqfile";
        while (@files) {
            print (FLOFILE shift(@files), "\n");
        }
    close(FLOFILE);

    print ("--- fido request $ver ---------------------------\n");
    print ("requesting \"$file\" from fido-node $node\n");
    print ("--- executing ifstat .. ------------------------\n");
    system("ifstat");
}

#
# subroutine "usage"
#
sub usage {
    printf ("--- fido request %s -------------\n", $ver);
    printf ("usage: ifreq <file> [<3-d address>]\n");
    printf ("e.g. : ifreq FILES 2:2410/305\n");
    exit 1;
}