users => '0,Users,parray',
usercount => '0,User Count',
version => '0,Version',
- np => '0,Using New Prot,yesno',
- lid => '0,Last Msgid',
+ handle_xml => '0,Using XML,yesno',
+ lastmsg => '0,Last Route Msg,atime',
+ lastid => '0,Last Route MsgID',
+ do_pc92 => '0,Uses pc92,yesno',
);
$filterdef = $Route::filterdef;
return @out;
}
+# this takes in a list of node and user calls (not references) from
+# a config type update for a node and returns
+# the differences as lists of things that have gone away
+# and things that have been added.
+sub calc_config_changes
+{
+ my $self = shift;
+ my %nodes = map {$_ => 1} @{$self->{nodes}};
+ my %users = map {$_ => 1} @{$self->{users}};
+ my $cnodes = shift;
+ my $cusers = shift;
+ my (@dnodes, @dusers, @nnodes, @nusers);
+ push @nnodes, map {my @r = $nodes{$_} ? () : $_; delete $nodes{$_}; @r} @$cnodes;
+ push @dnodes, keys %nodes;
+ push @nusers, map {my @r = $users{$_} ? () : $_; delete $users{$_}; @r} @$cusers;
+ push @dusers, keys %users;
+ return (\@dnodes, \@dusers, \@nnodes, \@nusers);
+}
sub new
{
my $self = $pkg->SUPER::new($call);
$self->{parent} = ref $pkg ? [ $pkg->{call} ] : [ ];
- $self->{version} = shift;
- $self->{flags} = shift;
+ $self->{version} = shift || 5000;
+ $self->{flags} = shift || Route::here(1);
$self->{users} = [];
$self->{nodes} = [];
- $self->{lid} = 0;
+ $self->{lastid} = {};
$list{$call} = $self;
return values %list;
}
-sub newid
-{
- my $self = shift;
- my $id = shift;
-
- return 0 if $id == $self->{lid};
- if ($id > $self->{lid}) {
- $self->{lid} = $id;
- return 1;
- } elsif ($self->{lid} - $id > 60000) {
- $self->{id} = $id;
- return 1;
- }
- return 0;
-}
-
sub _addparent
{
my $self = shift;
sub AUTOLOAD
{
no strict;
-
- my $self = shift;
- $name = $AUTOLOAD;
+ my $name = $AUTOLOAD;
return if $name =~ /::DESTROY$/;
- $name =~ s/.*:://o;
+ $name =~ s/^.*:://o;
confess "Non-existant field '$AUTOLOAD'" unless $valid{$name} || $Route::valid{$name};
# this clever line of code creates a subroutine which takes over from autoload
# from OO Perl - Conway
-# print "AUTOLOAD: $AUTOLOAD\n";
-# *{$AUTOLOAD} = sub {my $self = shift; @_ ? $self->{$name} = shift : $self->{$name}} ;
- @_ ? $self->{$name} = shift : $self->{$name} ;
+ *$AUTOLOAD = sub {$_[0]->{$name} = $_[1] if @_ > 1; return $_[0]->{$name}};
+ goto &$AUTOLOAD;
}
1;