#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);
use network::nfs;
use network::smb;

"@ARGV" =~ /-h/ and die "usage: lsnetdrake [-h] [--nfs] [--smb]\n";

my $nfs = !@ARGV || "@ARGV" =~ /-(nfs)/;
my $smb = !@ARGV || "@ARGV" =~ /-(smb)/;

$| = 1;
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";

my @l;
push @l, network::nfs->new if $nfs;
push @l, network::smb->new if $smb;

foreach my $class (@l) {
    foreach my $server (sort_names($class->find_servers)) {
	foreach my $export (sort_names($class->find_exports($server))) {
	    print $class->to_fullstring($export), "\n";
	}
    }
}

sub sort_names { 
    sort { $a->{name} cmp $b->{name} } @_;
}