Improve M$ Windows compatibility
[spider.git] / cmd / show / isolate.pl
1 #
2 # show/isolate
3 #
4 # show all excluded users 
5 #
6 # Copyright (c) 2000 Dirk Koopman G1TLH
7 #
8 #
9 #
10
11 use DB_File;
12
13 sub handle
14 {
15         my ($self, $line) = @_;
16         return (1, $self->msg('e5')) unless $self->priv >= 1;
17
18         my @out;
19
20         if ($self->{_nospawn} || $main::is_win == 1) {
21                 return (1, generate($self));
22         } else {
23                 return (1, $self->spawn_cmd("show/isolate $line", sub { return (generate($self)); }));
24         }
25         
26 }
27
28 sub generate
29 {
30         my $self = shift;
31         my @out;
32         my @val;
33                                                         
34         my ($action, $count, $key, $data) = (0,0,0,0);
35
36         for ($action = DXUser::R_FIRST, $count=0; !$DXUser::dbm->seq($key, $data, $action); $action = DXUser::R_NEXT) {
37                 if ($data =~ m{isolate}) {
38                         my $u = DXUser::get_current($key);
39                         if ($u && $u->isolate) {
40                                 push @val, $key;
41                                 ++$count;
42                         }
43                 }
44         } 
45
46         my @l;
47         foreach my $call (@val) {
48                 if (@l >= 5) {
49                         push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
50                         @l = ();
51                 }
52                 push @l, $call;
53         }
54         if (@l) {
55                 push @l, "" while @l < 5;
56                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
57         }
58
59         push @out, , $self->msg('rec', $count);
60         return @out;    
61 }
62
63