diff options
| author | fukachan <fukachan> | 2001-01-24 07:32:58 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-24 07:32:58 +0000 |
| commit | 86ba38b7ca78ffeba37f194c5fb506688bcbe512 (patch) | |
| tree | ceebb5dec797a7c767118602c60e1386bff0d1a5 /fml/lib | |
| parent | e00836b542f2df20d8fa34669d9edd79333fa298 (diff) | |
| download | fml8-86ba38b7ca78ffeba37f194c5fb506688bcbe512.tar.gz fml8-86ba38b7ca78ffeba37f194c5fb506688bcbe512.tar.bz2 fml8-86ba38b7ca78ffeba37f194c5fb506688bcbe512.zip | |
prepare PCB manipulation
Diffstat (limited to 'fml/lib')
| -rw-r--r-- | fml/lib/FML/PCB.pm | 168 | ||||
| -rw-r--r-- | fml/lib/FML/Process/Kernel.pm | 4 |
2 files changed, 172 insertions, 0 deletions
diff --git a/fml/lib/FML/PCB.pm b/fml/lib/FML/PCB.pm new file mode 100644 index 00000000..c98ba603 --- /dev/null +++ b/fml/lib/FML/PCB.pm @@ -0,0 +1,168 @@ +#-*- perl -*- +# Copyright (C) 2000 Ken'ichi Fukamachi +# +# $Id$ +# $FML$ # 注意: cvs のタグを $FML$ にする +# + +package FML::PCB; + +use strict; +use Carp; + +# PCB: Process Control Block +use vars qw(%_fml_PCB); + + +sub new +{ + my ($self, $args) = @_; + + unless (defined %_fml_PCB) { %_fml_PCB = ();} + my $me = \%_fml_PCB; + + # import variables + if (defined $args) { + my ($k, $v); + while (($k, $v) = each %$args) { set($me, $k, $v);} + } + + return bless $me, $self; +} + + +sub dump_variables +{ + my ($k, $v); + while (($k, $v) = each %_fml_PCB) { + print "${k}: $v\n"; + } +} + + +sub get +{ + my ($self, $category, $key) = @_; + $self->{ $category }->{ $key }; +} + + +sub set +{ + my ($self, $category, $key, $value) = @_; + $self->{ $category }->{ $key } = $value; +} + + +sub FETCH +{ + my ($self, $key) = @_; + return $_fml_PCB{$key}; +} + + +sub STORE +{ + my ($self, $key, $value) = @_; + $_fml_PCB{$key} = $value; +} + + +sub DELETE +{ + my ($self, $key) = @_; + delete $_fml_PCB{$key}; +} + + +sub CLEAR +{ + my ($self) = @_; + undef %_fml_PCB; +} + + +=head1 NAME + +FML::PCB -- fml5 PCBuration holding object + +=head1 SYNOPSIS + + $PCB = new FML::PCB; + + # get the current value + $PCB->{recipient_maps}; + + # set the new value + $PCB->{recipient_maps} = 'mysql:toymodel'; + + # function style to get/set the value for the key "recipient_maps" + $PCB->get('recipient_maps'); + $PCB->set('recipient_maps', 'mysql:toymodel'); + + +=head1 DESCRIPTION + + +=head1 METHOD + +=item Init( ref_to_curproc ) + +special method only used in the initialization phase. +This method binds $curproc and the %_fml_PCB memory area. + +=item load_file( filename ) + +read the PCBuration file, split key and value and set them to +%_fml_PCB. + +=item get( key ) + +=item set( key, value ) + +=item dump_variables() + +show all {key => value} for debug. + +=head1 DATA STRUCTURE + +C<%CurProc> holds the CURrent PROCess information. +The hash holds several references to other data structures, +which are mainly hashes. + + $CurProc = { + # PCBurations + PCB => { + key => value, + }, + + # emulator mode though fml mode in fact + emulator => $emulator, + + # struct incoming_mail holds the mail input from STDIN. + incoming_mail => $r_msg, + article => $r_msg, + }; + +We use r_variable_name syntax where "r_" implies "reference to" here. +C<$r_msg> is the reference to "struct message". + + $r_msg = { + r_header => \$header, + r_body => \$body, + info => { + mime-version => 1.0, + content-type => { + charset => ISO-2022-JP, + }, + size => $size, + }, + }; + +where $header is the object returned by Mail::Header class (CPAN +module) and the $body is the reference to the mail body region on +memory which locates within FML::Parse name space. + +=cut + +1; diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm index 8a17fd16..be525d4e 100644 --- a/fml/lib/FML/Process/Kernel.pm +++ b/fml/lib/FML/Process/Kernel.pm @@ -44,6 +44,10 @@ sub new use FML::Config; $curproc->{ config } = new FML::Config $cfargs; + # initialize PCB + use FML::PCB; + $curproc->{ pcb } = new FML::PCB; + bless $curproc, $self; # load config.cf files, which is passed from fmlwrapper. |
