various DXCluster->get alterations
[spider.git] / perl / DXMsg.pm
1 #!/usr/bin/perl
2 #
3 # This module impliments the message handling for a dx cluster
4 #
5 # Copyright (c) 1998 Dirk Koopman G1TLH
6 #
7 # $Id$
8
9
10 package DXMsg;
11
12 @ISA = qw(DXProt DXChannel);
13
14 use DXUtil;
15 use DXChannel;
16 use DXUser;
17 use DXM;
18 use DXCluster;
19 use DXProtVars;
20 use DXProtout;
21 use DXDebug;
22 use DXLog;
23 use FileHandle;
24 use Carp;
25
26 use strict;
27 use vars qw(%work @msg $msgdir %valid %busy $maxage $last_clean);
28
29 %work = ();                                             # outstanding jobs
30 @msg = ();                                              # messages we have
31 %busy = ();                                             # station interlocks
32 $msgdir = "$main::root/msg";    # directory contain the msgs
33 $maxage = 30 * 86400;                   # the maximum age that a message shall live for if not marked 
34 $last_clean = 0;                                # last time we did a clean
35
36 %valid = (
37                   fromnode => '9,From Node',
38                   tonode => '9,To Node',
39                   to => '0,To',
40                   from => '0,From',
41                   t => '0,Msg Time,cldatetime',
42                   private => '9,Private',
43                   subject => '0,Subject',
44                   linesreq => '0,Lines per Gob',
45                   rrreq => '9,Read Confirm',
46                   origin => '0,Origin',
47                   lines => '5,Data',
48                   stream => '9,Stream No',
49                   count => '9,Gob Linecnt',
50                   file => '9,File?,yesno',
51                   gotit => '9,Got it Nodes,parray',
52                   lines => '9,Lines,parray',
53                   read => '9,Times read',
54                   size => '0,Size',
55                   msgno => '0,Msgno',
56                   keep => '0,Keep this?,yesno',
57                  );
58
59 # allocate a new object
60 # called fromnode, tonode, from, to, datetime, private?, subject, nolinesper  
61 sub alloc                  
62 {
63         my $pkg = shift;
64         my $self = bless {}, $pkg;
65         $self->{msgno} = shift;
66         my $to = shift;
67         #  $to =~ s/-\d+$//o;
68         $self->{to} = uc $to;
69         my $from = shift;
70         $from =~ s/-\d+$//o;
71         $self->{from} = uc $from;
72         $self->{t} = shift;
73         $self->{private} = shift;
74         $self->{subject} = shift;
75         $self->{origin} = shift;
76         $self->{read} = shift;
77         $self->{rrreq} = shift;
78         $self->{gotit} = [];
79     
80         return $self;
81 }
82
83 sub workclean
84 {
85         my $ref = shift;
86         delete $ref->{lines};
87         delete $ref->{linesreq};
88         delete $ref->{tonode};
89         delete $ref->{fromnode};
90         delete $ref->{stream};
91         delete $ref->{lines};
92         delete $ref->{file};
93         delete $ref->{count};
94 }
95
96 sub process
97 {
98         my ($self, $line) = @_;
99         my @f = split /[\^\~]/, $line;
100         my ($pcno) = $f[0] =~ /^PC(\d\d)/; # just get the number
101         
102  SWITCH: {
103                 if ($pcno == 28) {              # incoming message
104                         my $t = cltounix($f[5], $f[6]);
105                         my $stream = next_transno($f[2]);
106                         my $ref = DXMsg->alloc($stream, $f[3], $f[4], $t, $f[7], $f[8], $f[13], '0', $f[11]);
107                         
108                         # fill in various forwarding state variables
109                         $ref->{fromnode} = $f[2];
110                         $ref->{tonode} = $f[1];
111                         $ref->{rrreq} = $f[11];
112                         $ref->{linesreq} = $f[10];
113                         $ref->{stream} = $stream;
114                         $ref->{count} = 0;      # no of lines between PC31s
115                         dbg('msg', "new message from $f[4] to $f[3] '$f[8]' stream $stream\n");
116                         $work{"$f[2]$stream"} = $ref; # store in work
117                         $busy{$f[2]} = $ref; # set interlock
118                         $self->send(DXProt::pc30($f[2], $f[1], $stream)); # send ack
119                         last SWITCH;
120                 }
121                 
122                 if ($pcno == 29) {              # incoming text
123                         my $ref = $work{"$f[2]$f[3]"};
124                         if ($ref) {
125                                 push @{$ref->{lines}}, $f[4];
126                                 $ref->{count}++;
127                                 if ($ref->{count} >= $ref->{linesreq}) {
128                                         $self->send(DXProt::pc31($f[2], $f[1], $f[3]));
129                                         dbg('msg', "stream $f[3]: $ref->{linereq} lines received\n");
130                                         $ref->{count} = 0;
131                                 }
132                         }
133                         last SWITCH;
134                 }
135                 
136                 if ($pcno == 30) {              # this is a incoming subject ack
137                         my $ref = $work{$f[2]}; # note no stream at this stage
138                         delete $work{$f[2]};
139                         $ref->{stream} = $f[3];
140                         $ref->{count} = 0;
141                         $ref->{linesreq} = 5;
142                         $work{"$f[2]$f[3]"} = $ref;     # new ref
143                         dbg('msg', "incoming subject ack stream $f[3]\n");
144                         $busy{$f[2]} = $ref; # interlock
145                         $ref->{lines} = [];
146                         push @{$ref->{lines}}, ($ref->read_msg_body);
147                         $ref->send_tranche($self);
148                         last SWITCH;
149                 }
150                 
151                 if ($pcno == 31) {              # acknowledge a tranche of lines
152                         my $ref = $work{"$f[2]$f[3]"};
153                         if ($ref) {
154                                 dbg('msg', "tranche ack stream $f[3]\n");
155                                 $ref->send_tranche($self);
156                         } else {
157                                 $self->send(DXProt::pc42($f[2], $f[1], $f[3])); # unknown stream
158                         } 
159                         last SWITCH;
160                 }
161                 
162                 if ($pcno == 32) {              # incoming EOM
163                         dbg('msg', "stream $f[3]: EOM received\n");
164                         my $ref = $work{"$f[2]$f[3]"};
165                         if ($ref) {
166                                 $self->send(DXProt::pc33($f[2], $f[1], $f[3])); # acknowledge it
167                                 
168                                 # get the next msg no - note that this has NOTHING to do with the stream number in PC protocol
169                                 # store the file or message
170                                 # remove extraneous rubbish from the hash
171                                 # remove it from the work in progress vector
172                                 # stuff it on the msg queue
173                                 if ($ref->{lines} && @{$ref->{lines}} > 0) { # ignore messages with 0 lines
174                                         $ref->{msgno} = next_transno("Msgno") if !$ref->{file};
175                                         push @{$ref->{gotit}}, $f[2]; # mark this up as being received
176                                         $ref->store($ref->{lines});
177                                         add_dir($ref);
178                                         my $dxchan = DXChannel->get($ref->{to});
179                                         $dxchan->send("New mail has arrived for you") if $dxchan;
180                                         Log('msg', "Message $ref->{msgno} from $ref->{from} received from $f[2] for $ref->{to}");
181                                 }
182                                 $ref->stop_msg($self);
183                                 queue_msg();
184                         } else {
185                                 $self->send(DXProt::pc42($f[2], $f[1], $f[3])); # unknown stream
186                         }
187                         queue_msg();
188                         last SWITCH;
189                 }
190                 
191                 if ($pcno == 33) {              # acknowledge the end of message
192                         my $ref = $work{"$f[2]$f[3]"};
193                         if ($ref) {
194                                 if ($ref->{private}) { # remove it if it private and gone off site#
195                                         Log('msg', "Message $ref->{msgno} from $ref->{from} sent to $f[2] and deleted");
196                                         $ref->del_msg;
197                                 } else {
198                                         Log('msg', "Message $ref->{msgno} from $ref->{from} sent to $f[2]");
199                                         push @{$ref->{gotit}}, $f[2]; # mark this up as being received
200                                         $ref->store($ref->{lines});     # re- store the file
201                                 }
202                                 $ref->stop_msg($self);
203                         } else {
204                                 $self->send(DXProt::pc42($f[2], $f[1], $f[3])); # unknown stream
205                         } 
206                         queue_msg();
207                         last SWITCH;
208                 }
209                 
210                 if ($pcno == 40) {              # this is a file request
211                         $f[3] =~ s/\\/\//og; # change the slashes
212                         $f[3] =~ s/\.//og;      # remove dots
213                         $f[3] = lc $f[3];       # to lower case;
214                         dbg('msg', "incoming file $f[3]\n");
215                         last SWITCH if $f[3] =~ /^\/(perl|cmd|local_cmd|src|lib|include|sys|msg)\//; # prevent access to executables
216                         
217                         # create any directories
218                         my @part = split /\//, $f[3];
219                         my $part;
220                         my $fn = "$main::root";
221                         pop @part;                      # remove last part
222                         foreach $part (@part) {
223                                 $fn .= "/$part";
224                                 next if -e $fn;
225                                 last SWITCH if !mkdir $fn, 0777;
226                                 dbg('msg', "created directory $fn\n");
227                         }
228                         my $stream = next_transno($f[2]);
229                         my $ref = DXMsg->alloc($stream, "$main::root/$f[3]", $self->call, time, !$f[4], $f[3], ' ', '0', '0');
230                         
231                         # forwarding variables
232                         $ref->{fromnode} = $f[1];
233                         $ref->{tonode} = $f[2];
234                         $ref->{linesreq} = $f[5];
235                         $ref->{stream} = $stream;
236                         $ref->{count} = 0;      # no of lines between PC31s
237                         $ref->{file} = 1;
238                         $work{"$f[2]$stream"} = $ref; # store in work
239                         $self->send(DXProt::pc30($f[2], $f[1], $stream)); # send ack 
240                         
241                         last SWITCH;
242                 }
243                 
244                 if ($pcno == 42) {              # abort transfer
245                         dbg('msg', "stream $f[3]: abort received\n");
246                         my $ref = $work{"$f[2]$f[3]"};
247                         if ($ref) {
248                                 $ref->stop_msg($self);
249                                 $ref = undef;
250                         }
251                         
252                         last SWITCH;
253                 }
254         }
255          
256          clean_old() if $main::systime - $last_clean > 3600 ; # clean the message queue
257 }
258
259
260 # store a message away on disc or whatever
261 #
262 # NOTE the second arg is a REFERENCE not a list
263 sub store
264 {
265         my $ref = shift;
266         my $lines = shift;
267         
268         # we only proceed if there are actually any lines in the file
269         if (!$lines || @{$lines} == 0) {
270                 return;
271         }
272         
273         if ($ref->{file}) {                     # a file
274                 dbg('msg', "To be stored in $ref->{to}\n");
275                 
276                 my $fh = new FileHandle "$ref->{to}", "w";
277                 if (defined $fh) {
278                         my $line;
279                         foreach $line (@{$lines}) {
280                                 print $fh "$line\n";
281                         }
282                         $fh->close;
283                         dbg('msg', "file $ref->{to} stored\n");
284                         Log('msg', "file $ref->{to} from $ref->{from} stored" );
285                 } else {
286                         confess "can't open file $ref->{to} $!";  
287                 }
288                 #       push @{$ref->{gotit}}, $ref->{fromnode} if $ref->{fromnode};
289         } else {                                        # a normal message
290                 
291                 # attempt to open the message file
292                 my $fn = filename($ref->{msgno});
293                 
294                 dbg('msg', "To be stored in $fn\n");
295                 
296                 # now save the file, overwriting what's there, YES I KNOW OK! (I will change it if it's a problem)
297                 my $fh = new FileHandle "$fn", "w";
298                 if (defined $fh) {
299                         my $rr = $ref->{rrreq} ? '1' : '0';
300                         my $priv = $ref->{private} ? '1': '0';
301                         print $fh "=== $ref->{msgno}^$ref->{to}^$ref->{from}^$ref->{t}^$priv^$ref->{subject}^$ref->{origin}^$ref->{read}^$rr\n";
302                         print $fh "=== ", join('^', @{$ref->{gotit}}), "\n";
303                         my $line;
304                         $ref->{size} = 0;
305                         foreach $line (@{$lines}) {
306                                 $ref->{size} += (length $line) + 1;
307                                 print $fh "$line\n";
308                         }
309                         $fh->close;
310                         dbg('msg', "msg $ref->{msgno} stored\n");
311                         Log('msg', "msg $ref->{msgno} from $ref->{from} to $ref->{to} stored" );
312                 } else {
313                         confess "can't open msg file $fn $!";  
314                 }
315         }
316 }
317
318 # delete a message
319 sub del_msg
320 {
321         my $self = shift;
322         
323         # remove it from the active message list
324         @msg = map { $_ != $self ? $_ : () } @msg;
325         
326         # belt and braces (one day I will ask someone if this is REALLY necessary)
327         delete $self->{gotit};
328         delete $self->{list};
329         
330         # remove the file
331         unlink filename($self->{msgno});
332         dbg('msg', "deleting $self->{msgno}\n");
333 }
334
335 # clean out old messages from the message queue
336 sub clean_old
337 {
338         my $ref;
339         
340         # mark old messages for deletion
341         foreach $ref (@msg) {
342                 if (!$ref->{keep} && $ref->{t} < $main::systime - $maxage) {
343                         $ref->{deleteme} = 1;
344                         delete $ref->{gotit};
345                         delete $ref->{list};
346                         unlink filename($ref->{msgno});
347                         dbg('msg', "deleting old $ref->{msgno}\n");
348                 }
349         }
350         
351         # remove them all from the active message list
352         @msg = map { $_->{deleteme} ? () : $_ } @msg;
353         $last_clean = $main::systime;
354 }
355
356 # read in a message header
357 sub read_msg_header
358
359         my $fn = shift;
360         my $file;
361         my $line;
362         my $ref;
363         my @f;
364         my $size;
365         
366         $file = new FileHandle;
367         if (!open($file, $fn)) {
368                 print "Error reading $fn $!\n";
369                 return undef;
370         }
371         $size = -s $fn;
372         $line = <$file>;                        # first line
373         chomp $line;
374         $size -= length $line;
375         if (! $line =~ /^===/o) {
376                 print "corrupt first line in $fn ($line)\n";
377                 return undef;
378         }
379         $line =~ s/^=== //o;
380         @f = split /\^/, $line;
381         $ref = DXMsg->alloc(@f);
382         
383         $line = <$file>;                        # second line
384         chomp $line;
385         $size -= length $line;
386         if (! $line =~ /^===/o) {
387                 print "corrupt second line in $fn ($line)\n";
388                 return undef;
389         }
390         $line =~ s/^=== //o;
391         $ref->{gotit} = [];
392         @f = split /\^/, $line;
393         push @{$ref->{gotit}}, @f;
394         $ref->{size} = $size;
395         
396         close($file);
397         
398         return $ref;
399 }
400
401 # read in a message header
402 sub read_msg_body
403 {
404         my $self = shift;
405         my $msgno = $self->{msgno};
406         my $file;
407         my $line;
408         my $fn = filename($msgno);
409         my @out;
410         
411         $file = new FileHandle;
412         if (!open($file, $fn)) {
413                 print "Error reading $fn $!\n";
414                 return undef;
415         }
416         chomp (@out = <$file>);
417         close($file);
418         
419         shift @out if $out[0] =~ /^=== /;
420         shift @out if $out[0] =~ /^=== /;
421         return @out;
422 }
423
424 # send a tranche of lines to the other end
425 sub send_tranche
426 {
427         my ($self, $dxchan) = @_;
428         my @out;
429         my $to = $self->{tonode};
430         my $from = $self->{fromnode};
431         my $stream = $self->{stream};
432         my $i;
433         
434         for ($i = 0; $i < $self->{linesreq} && $self->{count} < @{$self->{lines}}; $i++, $self->{count}++) {
435                 push @out, DXProt::pc29($to, $from, $stream, ${$self->{lines}}[$self->{count}]);
436 }
437 push @out, DXProt::pc32($to, $from, $stream) if $i < $self->{linesreq};
438 $dxchan->send(@out);
439 }
440
441         
442         # find a message to send out and start the ball rolling
443         sub queue_msg
444 {
445         my $sort = shift;
446         my @nodelist = DXProt::get_all_ak1a();
447         my $ref;
448         my $clref;
449         my $dxchan;
450         
451         # bat down the message list looking for one that needs to go off site and whose
452         # nearest node is not busy.
453         
454         dbg('msg', "queue msg ($sort)\n");
455         foreach $ref (@msg) {
456                 # firstly, is it private and unread? if so can I find the recipient
457                 # in my cluster node list offsite?
458                 if ($ref->{private}) {
459                         if ($ref->{read} == 0) {
460                                 $clref = DXCluster->get($ref->{to});
461                                 if ($clref && !grep { $clref->{dxchan} == $_ } DXCommandmode::get_all) {
462                                         $dxchan = $clref->{dxchan};
463                                         $ref->start_msg($dxchan) if $clref && !get_busy($dxchan->call);
464                                 }
465                         }
466                 } elsif ($sort == undef) {
467                         # otherwise we are dealing with a bulletin, compare the gotit list with
468                         # the nodelist up above, if there are sites that haven't got it yet
469                         # then start sending it - what happens when we get loops is anyone's
470                         # guess, use (to, from, time, subject) tuple?
471                         my $noderef;
472                         foreach $noderef (@nodelist) {
473                                 next if $noderef->call eq $main::mycall;
474                                 next if grep { $_ eq $noderef->call } @{$ref->{gotit}};
475                                 
476                                 # if we are here we have a node that doesn't have this message
477                                 $ref->start_msg($noderef) if !get_busy($noderef->call);
478                                 last;
479                         } 
480                 }
481                 
482                 # if all the available nodes are busy then stop
483                 last if @nodelist == scalar grep { get_busy($_->call) } @nodelist;
484         }
485 }
486
487 # start the message off on its travels with a PC28
488 sub start_msg
489 {
490         my ($self, $dxchan) = @_;
491         
492         dbg('msg', "start msg $self->{msgno}\n");
493         $self->{linesreq} = 5;
494         $self->{count} = 0;
495         $self->{tonode} = $dxchan->call;
496         $self->{fromnode} = $main::mycall;
497         $busy{$dxchan->call} = $self;
498         $work{"$self->{tonode}"} = $self;
499         $dxchan->send(DXProt::pc28($self->{tonode}, $self->{fromnode}, $self->{to}, $self->{from}, $self->{t}, $self->{private}, $self->{subject}, $self->{origin}, $self->{rrreq}));
500 }
501
502 # get the ref of a busy node
503 sub get_busy
504 {
505         my $call = shift;
506         return $busy{$call};
507 }
508
509 # get the busy queue
510 sub get_all_busy
511 {
512         return values %busy;
513 }
514
515 # get the forwarding queue
516 sub get_fwq
517 {
518         return values %work;
519 }
520
521 # stop a message from continuing, clean it out, unlock interlocks etc
522 sub stop_msg
523 {
524         my ($self, $dxchan) = @_;
525         my $node = $dxchan->call;
526         
527         dbg('msg', "stop msg $self->{msgno} stream $self->{stream}\n");
528         delete $work{$node};
529         delete $work{"$node$self->{stream}"};
530         $self->workclean;
531         delete $busy{$node};
532 }
533
534 # get a new transaction number from the file specified
535 sub next_transno
536 {
537         my $name = shift;
538         $name =~ s/\W//og;                      # remove non-word characters
539         my $fn = "$msgdir/$name";
540         my $msgno;
541         
542         my $fh = new FileHandle;
543         if (sysopen($fh, $fn, O_RDWR|O_CREAT, 0666)) {
544                 $fh->autoflush(1);
545                 $msgno = $fh->getline;
546                 chomp $msgno;
547                 $msgno++;
548                 seek $fh, 0, 0;
549                 $fh->print("$msgno\n");
550                 dbg('msg', "msgno $msgno allocated for $name\n");
551                 $fh->close;
552         } else {
553                 confess "can't open $fn $!";
554         }
555         return $msgno;
556 }
557
558 # initialise the message 'system', read in all the message headers
559 sub init
560 {
561         my $dir = new FileHandle;
562         my @dir;
563         my $ref;
564         
565         # read in the directory
566         opendir($dir, $msgdir) or confess "can't open $msgdir $!";
567         @dir = readdir($dir);
568         closedir($dir);
569         
570         for (sort @dir) {
571                 next if /^\./o;
572                 next if ! /^m\d+/o;
573                 
574                 $ref = read_msg_header("$msgdir/$_");
575                 next if !$ref;
576                 
577                 # add the message to the available queue
578                 add_dir($ref); 
579                 
580         }
581 }
582
583 # add the message to the directory listing
584 sub add_dir
585 {
586         my $ref = shift;
587         confess "tried to add a non-ref to the msg directory" if !ref $ref;
588         push @msg, $ref;
589 }
590
591 # return all the current messages
592 sub get_all
593 {
594         return @msg;
595 }
596
597 # get a particular message
598 sub get
599 {
600         my $msgno = shift;
601         for (@msg) {
602                 return $_ if $_->{msgno} == $msgno;
603                 last if $_->{msgno} > $msgno;
604         }
605         return undef;
606 }
607
608 # return the official filename for a message no
609 sub filename
610 {
611         return sprintf "$msgdir/m%06d", shift;
612 }
613
614 #
615 # return a list of valid elements 
616
617
618 sub fields
619 {
620         return keys(%valid);
621 }
622
623 #
624 # return a prompt for a field
625 #
626
627 sub field_prompt
628
629         my ($self, $ele) = @_;
630         return $valid{$ele};
631 }
632
633 #
634 # send a message state machine
635 sub do_send_stuff
636 {
637         my $self = shift;
638         my $line = shift;
639         my @out;
640         
641         if ($self->state eq 'send1') {
642                 #  $DB::single = 1;
643                 confess "local var gone missing" if !ref $self->{loc};
644                 my $loc = $self->{loc};
645                 $loc->{subject} = $line;
646                 $loc->{lines} = [];
647                 $self->state('sendbody');
648                 #push @out, $self->msg('sendbody');
649                 push @out, "Enter Message /EX (^Z) to send or /ABORT (^Y) to exit";
650         } elsif ($self->state eq 'sendbody') {
651                 confess "local var gone missing" if !ref $self->{loc};
652                 my $loc = $self->{loc};
653                 if ($line eq "\032" || uc $line eq "/EX") {
654                         my $to;
655                         
656                         if (@{$loc->{lines}} > 0) {
657                                 foreach $to (@{$loc->{to}}) {
658                                         my $ref;
659                                         my $systime = $main::systime;
660                                         my $mycall = $main::mycall;
661                                         $ref = DXMsg->alloc(DXMsg::next_transno('Msgno'),
662                                                                                 uc $to,
663                                                                                 $self->call, 
664                                                                                 $systime,
665                                                                                 $loc->{private}, 
666                                                                                 $loc->{subject}, 
667                                                                                 $mycall,
668                                                                                 '0',
669                                                                                 $loc->{rrreq});
670                                         $ref->store($loc->{lines});
671                                         $ref->add_dir();
672                                         #push @out, $self->msg('sendsent', $to);
673                                         push @out, "msgno $ref->{msgno} sent to $to";
674                                         my $dxchan = DXChannel->get(uc $to);
675                                         if ($dxchan) {
676                                                 if ($dxchan->is_user()) {
677                                                         $dxchan->send("New mail has arrived for you");
678                                                 }
679                                         }
680                                 }
681                         }
682                         delete $loc->{lines};
683                         delete $loc->{to};
684                         delete $self->{loc};
685                         $self->state('prompt');
686                         $self->func(undef);
687                         DXMsg::queue_msg();
688                 } elsif ($line eq "\031" || uc $line eq "/ABORT" || uc $line eq "/QUIT") {
689                         #push @out, $self->msg('sendabort');
690                         push @out, "aborted";
691                         delete $loc->{lines};
692                         delete $loc->{to};
693                         delete $self->{loc};
694                         $self->func(undef);
695                         $self->state('prompt');
696                 } else {
697                         
698                         # i.e. it ain't and end or abort, therefore store the line
699                         push @{$loc->{lines}}, $line;
700                 }
701         }
702         return (1, @out);
703 }
704
705 # return the standard directory line for this ref 
706 sub dir
707 {
708         my $ref = shift;
709         return sprintf "%6d%s%s%5d %8.8s %8.8s %-6.6s %5.5s %-30.30s", 
710                 $ref->msgno, $ref->read ? '-' : ' ', $ref->private ? 'p' : ' ', $ref->size,
711                         $ref->to, $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject;
712 }
713
714 no strict;
715 sub AUTOLOAD
716 {
717         my $self = shift;
718         my $name = $AUTOLOAD;
719         return if $name =~ /::DESTROY$/;
720         $name =~ s/.*:://o;
721         
722         confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
723         @_ ? $self->{$name} = shift : $self->{$name} ;
724 }
725
726 1;
727
728 __END__