1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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_message holds the mail input from STDIN.
incoming_message => $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;
|