add DXCIDR, fix version no tracking
[spider.git] / perl / DXChannel.pm
1 #
2 # module to manage channel lists & data
3 #
4 # This is the base class for all channel operations, which is everything to do 
5 # with input and output really.
6 #
7 # The instance variable in the outside world will be generally be called $dxchan
8 #
9 # This class is 'inherited' (if that is the goobledegook for what I am doing)
10 # by various other modules. The point to understand is that the 'instance variable'
11 # is in fact what normal people would call the state vector and all useful info
12 # about a connection goes in there.
13 #
14 # Another point to note is that a vector may contain a list of other vectors. 
15 # I have simply added another variable to the vector for 'simplicity' (or laziness
16 # as it is more commonly called)
17 #
18 # PLEASE NOTE - I am a C programmer using this as a method of learning perl
19 # firstly and OO about ninthly (if you don't like the design and you can't 
20 # improve it with better OO and thus make it smaller and more efficient, then tough). 
21 #
22 # Copyright (c) 1998-2016 - Dirk Koopman G1TLH
23 #
24 #
25 #
26 package DXChannel;
27
28 use Msg;
29 use DXM;
30 use DXUtil;
31 use DXVars;
32 use DXDebug;
33 use Filter;
34 use Prefix;
35 use Route;
36
37 use strict;
38 use vars qw(%channels %valid @ISA $count $maxerrors);
39
40 %channels = ();
41 $count = 0;
42
43 %valid = (
44                   'sort' => '5,Type of Channel',
45                   ann => '0,Want Announce,yesno',
46                   ann_talk => '0,Suppress Talk Anns,yesno',
47                   annfilter => '5,Ann Filt-out',
48                   badcount => '1,Bad Word Count',
49                   badip => '9,BAD IP address',
50                   beep => '0,Want Beeps,yesno',
51                   build => '1,Node Build',
52                   call => '0,Callsign',
53                   cluster => '5,Cluster data',
54                   conf => '0,In Conference?,yesno',
55                   conn => '9,Msg Conn ref',
56                   consort => '5,Connection Type',
57                   cq => '0,CQ Zone',
58                   delayed => '5,Delayed messages,parray',
59                   disconnecting => '9,Disconnecting,yesno',
60                   do_pc9x => '9,Handles PC9x,yesno',
61                   dx => '0,DX Spots,yesno',
62                   dxcc => '0,Country Code',
63                   edit => '7,Edit Function',
64                   enhanced => '5,Enhanced Client,yesno',
65                   errors => '9,Errors',
66                   func => '5,Function',
67                   group => '0,Access Group,parray',     # used to create a group of users/nodes for some purpose or other
68                   gtk => '5,Using GTK,yesno',
69                   handle_xml => '9,Handles XML,yesno',
70                   here => '0,Here?,yesno',
71                   hostname => '0,Hostname',
72                   inannfilter => '5,Ann Filt-inp',
73                   inpc92filter => '5,PC92 Route Filt-inp',
74                   inqueue => '9,Input Queue,parray',
75                   inrbnfilter => '5,RBN Filt-inp',
76                   inroutefilter => '5,Route Filt-inp',
77                   inscript => '9,In a script,yesno',
78                   inspotsfilter => '5,Spot Filt-inp',
79                   inwcyfilter => '5,WCY Filt-inp',
80                   inwwvfilter => '5,WWV Filt-inp',
81                   isbasic => '9,Internal Connection', 
82                   isolate => '5,Isolate network,yesno',
83                   isslugged => '9,Still Slugged,yesno',
84                   itu => '0,ITU Zone',
85                   lang => '0,Language',
86                   lastmsgpoll => '0,Last Msg Poll,atime',
87                   lastping => '5,Ping last sent,atime',
88                   lastread => '5,Last Msg Read',
89                   list => '9,Dep Chan List',
90                   loc => '9,Local Vars', # used by func to store local variables in
91                   logininfo => '9,Login info req,yesno',
92                   metric => '1,Route metric',
93                   name => '0,User Name',
94                   newroute => '1,New Style Routing,yesno',
95                   next_pc92_keepalive => '9,Next PC92 KeepAlive,atime',
96                   next_pc92_update => '9,Next PC92 Update,atime',
97                   nopings => '5,Ping Obs Count',
98                   oldstate => '5,Last State',
99                   outbound => '5,outbound?,yesno',
100                   pagedata => '9,Page Data Store',
101                   pagelth => '0,Page Length',
102                   passwd => '9,Passwd List,yesno',
103                   pc50_t => '5,Last PC50 Time,atime',
104                   pc92filter => '5,PC92 Route Filt-out',
105                   pingave => '0,Ping ave time',
106                   pingint => '5,Ping Interval ',
107                   pingtime => '5,Ping totaltime,parray',
108                   priv => '9,Privilege',
109                   prompt => '0,Required Prompt',
110                   rbnfilter => '5,RBN Filt-out',
111                   redirect => '0,Redirect messages to',
112                   registered => '9,Registered?,yesno',
113                   remotecmd => '9,doing rcmd,yesno',
114                   route => '9,Route Data',
115                   routefilter => '5,Route Filt-out',
116                   senddbg => '8,Sending Debug,yesno',
117                   sluggedpcs => '9,Slugged PCxx Queue,parray',
118                   spotsfilter => '5,Spot Filt-out',
119                   startt => '0,Start Time,atime',
120                   state => '0,Current State',
121                   t => '9,Time,atime',
122                   talk => '0,Want Talk,yesno',
123                   talklist => '0,Talk List,parray',
124                   user => '9,DXUser ref',
125                   ve7cc => '0,VE7CC program special,yesno',
126                   verified => '9,Verified?,yesno',
127                   version => '1,Node Version',
128                   wcy => '0,Want WCY,yesno',
129                   wcyfilter => '5,WCY Filt-out',
130                   width => '0,Column Width',
131                   wwv => '0,Want WWV,yesno',
132                   wwvfilter => '5,WWV Filt-out',
133                   wx => '0,Want WX,yesno',
134                  );
135
136 $maxerrors = 20;                                # the maximum number of concurrent errors allowed before disconnection
137
138 # object destruction
139 sub DESTROY
140 {
141         my $self = shift;
142         for (keys %$self) {
143                 if (ref($self->{$_})) {
144                         delete $self->{$_};
145                 }
146         }
147         dbg("DXChannel $self->{call} destroyed ($count)") if isdbg('chan');
148         $count--;
149 }
150
151 # create a new channel object [$obj = DXChannel->new($call, $msg_conn_obj, $user_obj)]
152 sub alloc
153 {
154         my ($pkg, $call, $conn, $user) = @_;
155         my $self = {};
156   
157         die "trying to create a duplicate channel for $call" if $channels{$call};
158         $self->{call} = $call;
159         $self->{priv} = 0;
160         $self->{conn} = $conn if defined $conn; # if this isn't defined then it must be a list
161         if (defined $user) {
162                 $self->{user} = $user;
163                 $self->{lang} = $user->lang;
164                 $user->new_group unless $user->group;
165                 $user->new_buddies unless $user->buddies;
166                 $self->{group} = $user->group;
167                 $self->{sort} = $user->sort;
168                 $self->{width} = $user->width;
169         }
170         $self->{startt} = $self->{t} = $main::systime;
171         $self->{state} = 0;
172         $self->{oldstate} = 0;
173         $self->{lang} = $main::lang if !$self->{lang};
174         $self->{func} = "";
175         $self->{width} ||=  80;
176
177         # add in all the dxcc, itu, zone info
178         my @dxcc = Prefix::extract($call);
179         if (@dxcc > 0) {
180                 $self->{dxcc} = $dxcc[1]->dxcc;
181                 $self->{itu} = $dxcc[1]->itu;
182                 $self->{cq} = $dxcc[1]->cq;
183         }
184         $self->{inqueue} = [];
185
186         $count++;
187         dbg("DXChannel $self->{call} created ($count)") if isdbg('chan');
188         bless $self, $pkg; 
189         return $channels{$call} = $self;
190 }
191
192 # count errors and disconnect if too many
193 # this has to be here because it can come from rcmd (DXProt) as
194 # well as DXCommandmode.
195 sub _error_out
196 {
197         my $self = shift;
198         my $e = shift;
199         if (++$self->{errors} > $maxerrors) {
200                 $self->send($self->msg('e26'));
201                 $self->disconnect;
202                 return ();
203         } else {
204                 return ($self->msg($e));
205         }
206 }
207
208 # rebless this channel as something else
209 sub rebless
210 {
211         my $self = shift;
212         my $class = shift;
213         return $channels{$self->{call}} = bless $self, $class;
214 }
215
216 sub rec 
217 {
218         my ($self, $msg) = @_;
219         
220         # queue the message and the channel object for later processing
221         if (defined $msg) {
222                 push @{$self->{inqueue}}, $msg;
223         }
224         $self->process_one;
225 }
226
227 # obtain a channel object by callsign [$obj = DXChannel::get($call)]
228 sub get
229 {
230         my $call = shift;
231         return $channels{$call};
232 }
233
234 # obtain all the channel objects
235 sub get_all
236 {
237         return values(%channels);
238 }
239
240 #
241 # gimme all the ak1a nodes
242 #
243 sub get_all_nodes
244 {
245         my $ref;
246         my @out;
247         foreach $ref (values %channels) {
248                 push @out, $ref if $ref->is_node;
249         }
250         return @out;
251 }
252
253 # return a list of node calls
254 sub get_all_node_calls
255 {
256         my $ref;
257         my @out;
258         foreach $ref (values %channels) {
259                 push @out, $ref->{call} if $ref->is_node;
260         }
261         return @out;
262 }
263
264 # return a list of all users
265 sub get_all_users
266 {
267         my $ref;
268         my @out;
269         foreach $ref (values %channels) {
270                 push @out, $ref if $ref->is_user;
271         }
272         return @out;
273 }
274
275 # return a list of all user callsigns
276 sub get_all_user_calls
277 {
278         my $ref;
279         my @out;
280         foreach $ref (values %channels) {
281                 push @out, $ref->{call} if $ref->is_user;
282         }
283         return @out;
284 }
285
286 # obtain a channel object by searching for its connection reference
287 sub get_by_cnum
288 {
289         my ($pkg, $conn) = @_;
290         my $self;
291   
292         foreach $self (values(%channels)) {
293                 return $self if ($self->{conn} == $conn);
294         }
295         return undef;
296 }
297
298 # get rid of a channel object [$obj->del()]
299 sub del
300 {
301         my $self = shift;
302
303         $self->{group} = undef;         # belt and braces
304         delete $channels{$self->{call}};
305 }
306
307 # is it a bbs
308 sub is_bbs
309 {
310         return $_[0]->{sort} eq 'B';
311 }
312
313 sub is_node
314 {
315         return $_[0]->{sort} =~ /^[ACRSX]$/;
316 }
317 # is it an ak1a node ?
318 sub is_ak1a
319 {
320         return $_[0]->{sort} eq 'A';
321 }
322
323 # is it a user?
324 sub is_user
325 {
326         return $_[0]->{sort} =~ /^[UW]$/;
327 }
328
329 # is it a clx node
330 sub is_clx
331 {
332         return $_[0]->{sort} eq 'C';
333 }
334
335 # it is a Web connected user
336 sub is_web
337 {
338         return $_[0]->{sort} eq 'W';
339 }
340
341 # is it a spider node
342 sub is_spider
343 {
344         return $_[0]->{sort} eq 'S';
345 }
346
347 # is it a DXNet node
348 sub is_dxnet
349 {
350         return $_[0]->{sort} eq 'X';
351 }
352
353 # is it a ar-cluster node
354 sub is_arcluster
355 {
356         return $_[0]->{sort} eq 'R';
357 }
358
359 sub is_rbn
360 {
361         return $_[0]->{sort} eq 'N';
362 }
363
364 sub is_dslink
365 {
366         return $_[0]->{sort} eq 'L';
367 }
368
369 # for perl 5.004's benefit
370 sub sort
371 {
372         my $self = shift;
373         return @_ ? $self->{sort} = shift : $self->{sort} ;
374 }
375
376 # find out whether we are prepared to believe this callsign on this interface
377 sub is_believed
378 {
379         my $self = shift;
380         my $call = shift;
381         
382         return grep $call eq $_, $self->user->believe;
383 }
384
385 # handle out going messages, immediately without waiting for the select to drop
386 # this could, in theory, block
387 sub send_now
388 {
389         my $self = shift;
390         my $conn = $self->{conn};
391         return unless $conn;
392         my $sort = shift;
393         my $call = $self->{call};
394         
395         for (@_) {
396 #               chomp;
397         my @lines = split /\n/;
398                 for (@lines) {
399                         $conn->send_now("$sort$call|$_");
400                         # debug log it, but not if it is a log message
401                         dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
402                 }
403         }
404         $self->{t} = time;
405 }
406
407 #
408 # send later with letter (more control)
409 #
410
411 sub send_later
412 {
413         my $self = shift;
414         my $conn = $self->{conn};
415         return unless $conn;
416         my $sort = shift;
417         my $call = $self->{call};
418         
419         for (@_) {
420 #               chomp;
421         my @lines = split /\n/;
422                 for (@lines) {
423                         $conn->send_later("$sort$call|$_");
424                         # debug log it, but not if it is a log message
425                         dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
426                 }
427         }
428         $self->{t} = time;
429 }
430
431 #
432 # the normal output routine
433 #
434 sub send                                                # this is always later and always data
435 {
436         my $self = shift;
437         my $conn = $self->{conn};
438         return unless $conn;
439         my $call = $self->{call};
440
441         foreach my $l (@_) {
442                 for (ref $l ? @$l : $l) {
443                         my @lines = split /\n/;
444                         for (@lines) {
445                                 $conn->send_later("D$call|$_");
446                                 dbg("-> D $call $_") if isdbg('chan');
447                         }
448                 }
449         }
450         $self->{t} = $main::systime;
451 }
452
453 # send a file (always later)
454 sub send_file
455 {
456         my ($self, $fn) = @_;
457         my $call = $self->{call};
458         my $conn = $self->{conn};
459         my @buf;
460   
461         open(F, $fn) or die "can't open $fn for sending file ($!)";
462         @buf = <F>;
463         close(F);
464         $self->send(@buf);
465 }
466
467 # this will implement language independence (in time)
468 sub msg
469 {
470         my $self = shift;
471         return DXM::msg($self->{lang}, @_);
472 }
473
474 # stick a broadcast on the delayed queue (but only up to 20 items)
475 sub delay
476 {
477         my $self = shift;
478         my $s = shift;
479         
480         $self->{delayed} = [] unless $self->{delayed};
481         push @{$self->{delayed}}, $s;
482         if (@{$self->{delayed}} >= 20) {
483                 shift @{$self->{delayed}};   # lose oldest one
484         }
485 }
486
487 # change the state of the channel - lots of scope for debugging here :-)
488 sub state
489 {
490         my $self = shift;
491         if (@_) {
492                 $self->{oldstate} = $self->{state};
493                 $self->{state} = shift;
494                 $self->{func} = '' unless defined $self->{func};
495                 dbg("$self->{call} channel func $self->{func} state $self->{oldstate} -> $self->{state}\n") if isdbg('state');
496
497                 # if there is any queued up broadcasts then splurge them out here
498                 if ($self->{delayed} && ($self->{state} eq 'prompt' || $self->{state} eq 'talk')) {
499                         $self->send (@{$self->{delayed}});
500                         delete $self->{delayed};
501                 }
502         }
503         return $self->{state};
504 }
505
506 # disconnect this channel
507 sub disconnect
508 {
509         my $self = shift;
510         my $user = $self->{user};
511         
512         $user->close($self->{startt}, $self->{hostname}) if defined $user;
513         $self->{conn}->disconnect if $self->{conn};
514         $self->del();
515 }
516
517 #
518 # just close all the socket connections down without any fiddling about, cleaning, being
519 # nice to other processes and otherwise telling them what is going on.
520 #
521 # This is for the benefit of forked processes to prepare for starting new programs, they
522 # don't want or need all this baggage.
523 #
524
525 sub closeall
526 {
527         my $ref;
528         foreach $ref (values %channels) {
529                 $ref->{conn}->disconnect() if $ref->{conn};
530         }
531 }
532
533 #
534 # Tell all the users that we have come in or out (if they want to know)
535 #
536 sub tell_login
537 {
538         my ($self, $m, $call) = @_;
539         
540         $call ||= $self->{call};
541         
542         # send info to all logged in thingies
543         my @dxchan = get_all_users();
544         my $dxchan;
545         foreach $dxchan (@dxchan) {
546                 next if $dxchan == $self;
547                 next if $dxchan->{call} eq $main::mycall;
548                 $dxchan->send($dxchan->msg($m, $call)) if $dxchan->{logininfo};
549         }
550 }
551
552 #
553 # Tell all the users if a buddy is logged or out
554 #
555 sub tell_buddies
556 {
557         my ($self, $m, $call, $node) = @_;
558         
559         $call ||= $self->{call};
560         $call =~ s/-\d+$//;
561         $m .= 'n' if $node;
562         
563         # send info to all logged in thingies
564         my @dxchan = get_all_users();
565         my $dxchan;
566         foreach $dxchan (@dxchan) {
567                 next if $dxchan == $self;
568                 next if $dxchan->{call} eq $main::mycall;
569                 $dxchan->send($dxchan->msg($m, $call, $node)) if grep $_ eq $call, @{$dxchan->{user}->{buddies}} ;
570         }
571 }
572
573 # various access routines
574
575 #
576 # return a list of valid elements 
577
578
579 sub fields
580 {
581         return keys(%valid);
582 }
583
584 #
585 # return a prompt for a field
586 #
587
588 sub field_prompt
589
590         my ($self, $ele) = @_;
591         return $valid{$ele};
592 }
593
594 # take a standard input message and decode it into its standard parts
595 sub decode_input
596 {
597         my $dxchan = shift;
598         my $data = shift;
599         my ($sort, $call, $line) = $data =~ /^([A-Z])(#?[A-Z0-9\/\-]{3,25})\|(.*)$/;
600
601         my $chcall = (ref $dxchan) ? $dxchan->call : "UN.KNOWN";
602         
603         # the above regexp must work
604         unless (defined $sort && defined $call && defined $line) {
605 #               $data =~ s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg;
606                 dbg("DUFF Line on $chcall: $data");
607                 return ();
608         }
609
610         if(ref($dxchan) && $call ne $chcall) {
611                 dbg("DUFF Line come in for $call on wrong channel $chcall");
612                 return();
613         }
614         
615         return ($sort, $call, $line);
616 }
617
618 # broadcast a message to all clusters taking into account isolation
619 # [except those mentioned after buffer]
620 sub broadcast_nodes
621 {
622         my $s = shift;                          # the line to be rebroadcast
623         my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
624         my @dxchan = get_all_nodes();
625         my $dxchan;
626         
627         # send it if it isn't the except list and isn't isolated and still has a hop count
628         foreach $dxchan (@dxchan) {
629                 next if grep $dxchan == $_, @except;
630                 next if $dxchan == $main::me;
631                 
632                 my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s;      # adjust its hop count by node name
633
634                 $dxchan->send($routeit) unless $dxchan->{isolate} || !$routeit;
635         }
636 }
637
638 # broadcast a message to all clusters ignoring isolation
639 # [except those mentioned after buffer]
640 sub broadcast_all_nodes
641 {
642         my $s = shift;                          # the line to be rebroadcast
643         my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
644         my @dxchan = get_all_nodes();
645         my $dxchan;
646         
647         # send it if it isn't the except list and isn't isolated and still has a hop count
648         foreach $dxchan (@dxchan) {
649                 next if grep $dxchan == $_, @except;
650                 next if $dxchan == $main::me;
651
652                 my $routeit = $dxchan->can('adjust_hops') ? $dxchan->adjust_hops($s) : $s;      # adjust its hop count by node name
653                 $dxchan->send($routeit);
654         }
655 }
656
657 # broadcast to all users
658 # storing the spot or whatever until it is in a state to receive it
659 sub broadcast_users
660 {
661         my $s = shift;                          # the line to be rebroadcast
662         my $sort = shift;           # the type of transmission
663         my $fref = shift;           # a reference to an object to filter on
664         my @except = @_;                        # to all channels EXCEPT these (dxchannel refs)
665         my @dxchan = get_all_users();
666         my $dxchan;
667         my @out;
668         
669         foreach $dxchan (@dxchan) {
670                 next if grep $dxchan == $_, @except;
671                 push @out, $dxchan;
672         }
673         broadcast_list($s, $sort, $fref, @out);
674 }
675
676
677 # broadcast to a list of users
678 sub broadcast_list
679 {
680         my $s = shift;
681         my $sort = shift;
682         my $fref = shift;
683         my $dxchan;
684         
685         foreach $dxchan (@_) {
686                 my $filter = 1;
687                 next if $dxchan == $main::me;
688                 
689                 if ($sort eq 'dx') {
690                     next unless $dxchan->{dx};
691                         ($filter) = $dxchan->{spotsfilter}->it($fref) if $dxchan->{spotsfilter} && ref $fref;
692                         next unless $filter;
693                 }
694                 next if $sort eq 'ann' && !$dxchan->{ann} && $s !~ /^To\s+LOCAL\s+de\s+(?:$main::myalias|$main::mycall)/i;
695                 next if $sort eq 'wwv' && !$dxchan->{wwv};
696                 next if $sort eq 'wcy' && !$dxchan->{wcy};
697                 next if $sort eq 'wx' && !$dxchan->{wx};
698
699                 $s =~ s/\a//og unless $dxchan->{beep};
700
701                 if ($dxchan->{state} eq 'prompt' || $dxchan->{state} eq 'talk') {
702                         $dxchan->send($s);      
703                 } else {
704                         $dxchan->delay($s);
705                 }
706         }
707 }
708
709 sub process_one
710 {
711         my $self = shift;
712
713         while (my $data = shift @{$self->{inqueue}}) {
714                 my ($sort, $call, $line) = $self->decode_input($data);
715                 next unless defined $sort;
716                 
717                 # do the really sexy console interface bit! (Who is going to do the TK interface then?)
718                 dbg("<- $sort $call $line") if $sort ne 'D' && isdbg('chan');
719                 
720                 # handle A records
721                 my $user = $self->user;
722                 if ($sort eq 'I') {
723                         die "\$user not defined for $call" unless defined $user;
724                         
725                         # normal input
726                         $self->normal($line);
727                 } elsif ($sort eq 'G') {
728                         $self->enhanced($line);
729                 } elsif ($sort eq 'A' || $sort eq 'O' || $sort eq 'W') {
730                         $self->start($line, $sort);
731                 } elsif ($sort eq 'C') {
732                         $self->width($line); # change number of columns
733                 } elsif ($sort eq 'Z') {
734                         $self->disconnect;
735                 } elsif ($sort eq 'D') {
736                         ;                               # ignored (an echo)
737                 } else {
738                         dbg atime . " DXChannel::process_one: Unknown command letter ($sort) received from $call\n";
739                 }
740         }
741 }
742
743 sub process
744 {
745         foreach my $dxchan (values %channels) {
746                 next if $dxchan->{disconnecting};
747                 $dxchan->process_one;
748         }
749 }
750
751 sub handle_xml
752 {
753         my $self = shift;
754         my $r = 0;
755         
756         if (DXXml::available()) {
757                 $r = $self->{handle_xml} || 0;
758         } else {
759                 delete $self->{handle_xml} if exists $self->{handle_xml};
760         }
761         return $r;
762 }
763
764 sub error_handler
765 {
766         my $self = shift;
767         my $error = shift || '';
768         dbg("$self->{call} ERROR '$error', closing") if isdbg('chan');
769         $self->{conn}->set_error(undef) if exists $self->{conn};
770         $self->disconnect(1);
771 }
772
773
774 sub isregistered
775 {
776         my $self = shift;
777
778         # the sysop is registered!
779         return 1 if $self->{call} eq $main::myalias || $self->{call} eq $main::mycall;
780         
781         if ($main::reqreg) {
782                 return $self->{registered};
783         } else {
784                 return 1;
785         }
786 }
787
788 #no strict;
789 sub AUTOLOAD
790 {
791         no strict;
792         my $name = $AUTOLOAD;
793         return if $name =~ /::DESTROY$/;
794         $name =~ s/^.*:://o;
795   
796         confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
797
798         # this clever line of code creates a subroutine which takes over from autoload
799         # from OO Perl - Conway
800         *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}};
801         goto &$AUTOLOAD;
802 }
803
804
805 1;
806 __END__;