fixed problem with upcasing bull names
[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} = $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, uc $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->{count} 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] =~ s/^\///o;   # remove the leading /
214                         $f[3] = lc $f[3];       # to lower case;
215                         dbg('msg', "incoming file $f[3]\n");
216                         last SWITCH if $f[3] =~ /^(perl|cmd|local|src|lib|include|sys|msg|connect)/; # prevent access to executables
217                         
218                         # create any directories
219                         my @part = split /\//, $f[3];
220                         my $part;
221                         my $fn = "$main::root";
222                         pop @part;                      # remove last part
223                         foreach $part (@part) {
224                                 $fn .= "/$part";
225                                 next if -e $fn;
226                                 last SWITCH if !mkdir $fn, 0777;
227                                 dbg('msg', "created directory $fn\n");
228                         }
229                         my $stream = next_transno($f[2]);
230                         my $ref = DXMsg->alloc($stream, "$main::root/$f[3]", $self->call, time, !$f[4], $f[3], ' ', '0', '0');
231                         
232                         # forwarding variables
233                         $ref->{fromnode} = $f[1];
234                         $ref->{tonode} = $f[2];
235                         $ref->{linesreq} = $f[5];
236                         $ref->{stream} = $stream;
237                         $ref->{count} = 0;      # no of lines between PC31s
238                         $ref->{file} = 1;
239                         $work{"$f[2]$stream"} = $ref; # store in work
240                         $self->send(DXProt::pc30($f[2], $f[1], $stream)); # send ack 
241                         
242                         last SWITCH;
243                 }
244                 
245                 if ($pcno == 42) {              # abort transfer
246                         dbg('msg', "stream $f[3]: abort received\n");
247                         my $ref = $work{"$f[2]$f[3]"};
248                         if ($ref) {
249                                 $ref->stop_msg($self);
250                                 $ref = undef;
251                         }
252                         
253                         last SWITCH;
254                 }
255         }
256          
257          clean_old() if $main::systime - $last_clean > 3600 ; # clean the message queue
258 }
259
260
261 # store a message away on disc or whatever
262 #
263 # NOTE the second arg is a REFERENCE not a list
264 sub store
265 {
266         my $ref = shift;
267         my $lines = shift;
268         
269         # we only proceed if there are actually any lines in the file
270         if (!$lines || @{$lines} == 0) {
271                 return;
272         }
273         
274         if ($ref->{file}) {                     # a file
275                 dbg('msg', "To be stored in $ref->{to}\n");
276                 
277                 my $fh = new FileHandle "$ref->{to}", "w";
278                 if (defined $fh) {
279                         my $line;
280                         foreach $line (@{$lines}) {
281                                 print $fh "$line\n";
282                         }
283                         $fh->close;
284                         dbg('msg', "file $ref->{to} stored\n");
285                         Log('msg', "file $ref->{to} from $ref->{from} stored" );
286                 } else {
287                         confess "can't open file $ref->{to} $!";  
288                 }
289                 #       push @{$ref->{gotit}}, $ref->{fromnode} if $ref->{fromnode};
290         } else {                                        # a normal message
291                 
292                 # attempt to open the message file
293                 my $fn = filename($ref->{msgno});
294                 
295                 dbg('msg', "To be stored in $fn\n");
296                 
297                 # now save the file, overwriting what's there, YES I KNOW OK! (I will change it if it's a problem)
298                 my $fh = new FileHandle "$fn", "w";
299                 if (defined $fh) {
300                         my $rr = $ref->{rrreq} ? '1' : '0';
301                         my $priv = $ref->{private} ? '1': '0';
302                         print $fh "=== $ref->{msgno}^$ref->{to}^$ref->{from}^$ref->{t}^$priv^$ref->{subject}^$ref->{origin}^$ref->{read}^$rr\n";
303                         print $fh "=== ", join('^', @{$ref->{gotit}}), "\n";
304                         my $line;
305                         $ref->{size} = 0;
306                         foreach $line (@{$lines}) {
307                                 $ref->{size} += (length $line) + 1;
308                                 print $fh "$line\n";
309                         }
310                         $fh->close;
311                         dbg('msg', "msg $ref->{msgno} stored\n");
312                         Log('msg', "msg $ref->{msgno} from $ref->{from} to $ref->{to} stored" );
313                 } else {
314                         confess "can't open msg file $fn $!";  
315                 }
316         }
317 }
318
319 # delete a message
320 sub del_msg
321 {
322         my $self = shift;
323         
324         # remove it from the active message list
325         @msg = map { $_ != $self ? $_ : () } @msg;
326         
327         # belt and braces (one day I will ask someone if this is REALLY necessary)
328         delete $self->{gotit};
329         delete $self->{list};
330         
331         # remove the file
332         unlink filename($self->{msgno});
333         dbg('msg', "deleting $self->{msgno}\n");
334 }
335
336 # clean out old messages from the message queue
337 sub clean_old
338 {
339         my $ref;
340         
341         # mark old messages for deletion
342         foreach $ref (@msg) {
343                 if (!$ref->{keep} && $ref->{t} < $main::systime - $maxage) {
344                         $ref->{deleteme} = 1;
345                         delete $ref->{gotit};
346                         delete $ref->{list};
347                         unlink filename($ref->{msgno});
348                         dbg('msg', "deleting old $ref->{msgno}\n");
349                 }
350         }
351         
352         # remove them all from the active message list
353         @msg = map { $_->{deleteme} ? () : $_ } @msg;
354         $last_clean = $main::systime;
355 }
356
357 # read in a message header
358 sub read_msg_header
359
360         my $fn = shift;
361         my $file;
362         my $line;
363         my $ref;
364         my @f;
365         my $size;
366         
367         $file = new FileHandle;
368         if (!open($file, $fn)) {
369                 print "Error reading $fn $!\n";
370                 return undef;
371         }
372         $size = -s $fn;
373         $line = <$file>;                        # first line
374         chomp $line;
375         $size -= length $line;
376         if (! $line =~ /^===/o) {
377                 print "corrupt first line in $fn ($line)\n";
378                 return undef;
379         }
380         $line =~ s/^=== //o;
381         @f = split /\^/, $line;
382         $ref = DXMsg->alloc(@f);
383         
384         $line = <$file>;                        # second line
385         chomp $line;
386         $size -= length $line;
387         if (! $line =~ /^===/o) {
388                 print "corrupt second line in $fn ($line)\n";
389                 return undef;
390         }
391         $line =~ s/^=== //o;
392         $ref->{gotit} = [];
393         @f = split /\^/, $line;
394         push @{$ref->{gotit}}, @f;
395         $ref->{size} = $size;
396         
397         close($file);
398         
399         return $ref;
400 }
401
402 # read in a message header
403 sub read_msg_body
404 {
405         my $self = shift;
406         my $msgno = $self->{msgno};
407         my $file;
408         my $line;
409         my $fn = filename($msgno);
410         my @out;
411         
412         $file = new FileHandle;
413         if (!open($file, $fn)) {
414                 print "Error reading $fn $!\n";
415                 return undef;
416         }
417         chomp (@out = <$file>);
418         close($file);
419         
420         shift @out if $out[0] =~ /^=== /;
421         shift @out if $out[0] =~ /^=== /;
422         return @out;
423 }
424
425 # send a tranche of lines to the other end
426 sub send_tranche
427 {
428         my ($self, $dxchan) = @_;
429         my @out;
430         my $to = $self->{tonode};
431         my $from = $self->{fromnode};
432         my $stream = $self->{stream};
433         my $i;
434         
435         for ($i = 0; $i < $self->{linesreq} && $self->{count} < @{$self->{lines}}; $i++, $self->{count}++) {
436                 push @out, DXProt::pc29($to, $from, $stream, ${$self->{lines}}[$self->{count}]);
437 }
438 push @out, DXProt::pc32($to, $from, $stream) if $i < $self->{linesreq};
439 $dxchan->send(@out);
440 }
441
442         
443         # find a message to send out and start the ball rolling
444         sub queue_msg
445 {
446         my $sort = shift;
447         my @nodelist = DXProt::get_all_ak1a();
448         my $ref;
449         my $clref;
450         my $dxchan;
451         
452         # bat down the message list looking for one that needs to go off site and whose
453         # nearest node is not busy.
454         
455         dbg('msg', "queue msg ($sort)\n");
456         foreach $ref (@msg) {
457                 # firstly, is it private and unread? if so can I find the recipient
458                 # in my cluster node list offsite?
459                 if ($ref->{private}) {
460                         if ($ref->{read} == 0) {
461                                 $clref = DXCluster->get($ref->{to});
462                                 if ($clref && !grep { $clref->{dxchan} == $_ } DXCommandmode::get_all) {
463                                         $dxchan = $clref->{dxchan};
464                                         $ref->start_msg($dxchan) if $clref && !get_busy($dxchan->call);
465                                 }
466                         }
467                 } elsif ($sort == undef) {
468                         # otherwise we are dealing with a bulletin, compare the gotit list with
469                         # the nodelist up above, if there are sites that haven't got it yet
470                         # then start sending it - what happens when we get loops is anyone's
471                         # guess, use (to, from, time, subject) tuple?
472                         my $noderef;
473                         foreach $noderef (@nodelist) {
474                                 next if $noderef->call eq $main::mycall;
475                                 next if grep { $_ eq $noderef->call } @{$ref->{gotit}};
476                                 
477                                 # if we are here we have a node that doesn't have this message
478                                 $ref->start_msg($noderef) if !get_busy($noderef->call);
479                                 last;
480                         } 
481                 }
482                 
483                 # if all the available nodes are busy then stop
484                 last if @nodelist == scalar grep { get_busy($_->call) } @nodelist;
485         }
486 }
487
488 # start the message off on its travels with a PC28
489 sub start_msg
490 {
491         my ($self, $dxchan) = @_;
492         
493         dbg('msg', "start msg $self->{msgno}\n");
494         $self->{linesreq} = 5;
495         $self->{count} = 0;
496         $self->{tonode} = $dxchan->call;
497         $self->{fromnode} = $main::mycall;
498         $busy{$dxchan->call} = $self;
499         $work{"$self->{tonode}"} = $self;
500         $dxchan->send(DXProt::pc28($self->{tonode}, $self->{fromnode}, $self->{to}, $self->{from}, $self->{t}, $self->{private}, $self->{subject}, $self->{origin}, $self->{rrreq}));
501 }
502
503 # get the ref of a busy node
504 sub get_busy
505 {
506         my $call = shift;
507         return $busy{$call};
508 }
509
510 # get the busy queue
511 sub get_all_busy
512 {
513         return values %busy;
514 }
515
516 # get the forwarding queue
517 sub get_fwq
518 {
519         return values %work;
520 }
521
522 # stop a message from continuing, clean it out, unlock interlocks etc
523 sub stop_msg
524 {
525         my ($self, $dxchan) = @_;
526         my $node = $dxchan->call;
527         
528         dbg('msg', "stop msg $self->{msgno} stream $self->{stream}\n");
529         delete $work{$node};
530         delete $work{"$node$self->{stream}"};
531         $self->workclean;
532         delete $busy{$node};
533 }
534
535 # get a new transaction number from the file specified
536 sub next_transno
537 {
538         my $name = shift;
539         $name =~ s/\W//og;                      # remove non-word characters
540         my $fn = "$msgdir/$name";
541         my $msgno;
542         
543         my $fh = new FileHandle;
544         if (sysopen($fh, $fn, O_RDWR|O_CREAT, 0666)) {
545                 $fh->autoflush(1);
546                 $msgno = $fh->getline;
547                 chomp $msgno;
548                 $msgno++;
549                 seek $fh, 0, 0;
550                 $fh->print("$msgno\n");
551                 dbg('msg', "msgno $msgno allocated for $name\n");
552                 $fh->close;
553         } else {
554                 confess "can't open $fn $!";
555         }
556         return $msgno;
557 }
558
559 # initialise the message 'system', read in all the message headers
560 sub init
561 {
562         my $dir = new FileHandle;
563         my @dir;
564         my $ref;
565         
566         # read in the directory
567         opendir($dir, $msgdir) or confess "can't open $msgdir $!";
568         @dir = readdir($dir);
569         closedir($dir);
570         
571         for (sort @dir) {
572                 next if /^\./o;
573                 next if ! /^m\d+/o;
574                 
575                 $ref = read_msg_header("$msgdir/$_");
576                 next if !$ref;
577                 
578                 # add the message to the available queue
579                 add_dir($ref); 
580                 
581         }
582 }
583
584 # add the message to the directory listing
585 sub add_dir
586 {
587         my $ref = shift;
588         confess "tried to add a non-ref to the msg directory" if !ref $ref;
589         push @msg, $ref;
590 }
591
592 # return all the current messages
593 sub get_all
594 {
595         return @msg;
596 }
597
598 # get a particular message
599 sub get
600 {
601         my $msgno = shift;
602         for (@msg) {
603                 return $_ if $_->{msgno} == $msgno;
604                 last if $_->{msgno} > $msgno;
605         }
606         return undef;
607 }
608
609 # return the official filename for a message no
610 sub filename
611 {
612         return sprintf "$msgdir/m%06d", shift;
613 }
614
615 #
616 # return a list of valid elements 
617
618
619 sub fields
620 {
621         return keys(%valid);
622 }
623
624 #
625 # return a prompt for a field
626 #
627
628 sub field_prompt
629
630         my ($self, $ele) = @_;
631         return $valid{$ele};
632 }
633
634 #
635 # send a message state machine
636 sub do_send_stuff
637 {
638         my $self = shift;
639         my $line = shift;
640         my @out;
641         
642         if ($self->state eq 'send1') {
643                 #  $DB::single = 1;
644                 confess "local var gone missing" if !ref $self->{loc};
645                 my $loc = $self->{loc};
646                 $loc->{subject} = $line;
647                 $loc->{lines} = [];
648                 $self->state('sendbody');
649                 #push @out, $self->msg('sendbody');
650                 push @out, "Enter Message /EX (^Z) to send or /ABORT (^Y) to exit";
651         } elsif ($self->state eq 'sendbody') {
652                 confess "local var gone missing" if !ref $self->{loc};
653                 my $loc = $self->{loc};
654                 if ($line eq "\032" || uc $line eq "/EX") {
655                         my $to;
656                         
657                         if (@{$loc->{lines}} > 0) {
658                                 foreach $to (@{$loc->{to}}) {
659                                         my $ref;
660                                         my $systime = $main::systime;
661                                         my $mycall = $main::mycall;
662                                         $ref = DXMsg->alloc(DXMsg::next_transno('Msgno'),
663                                                                                 uc $to,
664                                                                                 $self->call, 
665                                                                                 $systime,
666                                                                                 $loc->{private}, 
667                                                                                 $loc->{subject}, 
668                                                                                 $mycall,
669                                                                                 '0',
670                                                                                 $loc->{rrreq});
671                                         $ref->store($loc->{lines});
672                                         $ref->add_dir();
673                                         #push @out, $self->msg('sendsent', $to);
674                                         push @out, "msgno $ref->{msgno} sent to $to";
675                                         my $dxchan = DXChannel->get(uc $to);
676                                         if ($dxchan) {
677                                                 if ($dxchan->is_user()) {
678                                                         $dxchan->send("New mail has arrived for you");
679                                                 }
680                                         }
681                                 }
682                         }
683                         delete $loc->{lines};
684                         delete $loc->{to};
685                         delete $self->{loc};
686                         $self->state('prompt');
687                         $self->func(undef);
688                         DXMsg::queue_msg();
689                 } elsif ($line eq "\031" || uc $line eq "/ABORT" || uc $line eq "/QUIT") {
690                         #push @out, $self->msg('sendabort');
691                         push @out, "aborted";
692                         delete $loc->{lines};
693                         delete $loc->{to};
694                         delete $self->{loc};
695                         $self->func(undef);
696                         $self->state('prompt');
697                 } else {
698                         
699                         # i.e. it ain't and end or abort, therefore store the line
700                         push @{$loc->{lines}}, $line;
701                 }
702         }
703         return (1, @out);
704 }
705
706 # return the standard directory line for this ref 
707 sub dir
708 {
709         my $ref = shift;
710         return sprintf "%6d%s%s%5d %8.8s %8.8s %-6.6s %5.5s %-30.30s", 
711                 $ref->msgno, $ref->read ? '-' : ' ', $ref->private ? 'p' : ' ', $ref->size,
712                         $ref->to, $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject;
713 }
714
715 no strict;
716 sub AUTOLOAD
717 {
718         my $self = shift;
719         my $name = $AUTOLOAD;
720         return if $name =~ /::DESTROY$/;
721         $name =~ s/.*:://o;
722         
723         confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
724         @_ ? $self->{$name} = shift : $self->{$name} ;
725 }
726
727 1;
728
729 __END__