| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OurNet::BBSApp; |
|
2
|
|
|
|
|
|
|
$VERSION = '0.03'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require 5.006; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
OurNet::BBSApp - BBS Application Interface |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use OurNet::BBSApp; |
|
13
|
|
|
|
|
|
|
OurNet::BBSApp->new('autrijus.xml')->run(); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
The file "autrijus.xml" would look like: |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Templator |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
file="archive[% dir %]-[% recno %].html" /> |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
article.w |
|
27
|
|
|
|
|
|
|
reply.w |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
list="index-[% page %].html"> |
|
31
|
|
|
|
|
|
|
article[% recno %].html |
|
32
|
|
|
|
|
|
|
reply[% recno %].html |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
10 |
|
36
|
|
|
|
|
|
|
CVIC |
|
37
|
|
|
|
|
|
|
/srv/bbs/cvic |
|
38
|
|
|
|
|
|
|
1003 |
|
39
|
|
|
|
|
|
|
2500 |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The XML tree could also be passed as a hash reference instead. Consult |
|
43
|
|
|
|
|
|
|
L for how the attributes will look like. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Note that C attribute is set to C<{}> (null), so there are no |
|
46
|
|
|
|
|
|
|
"default" attribute keys in incoming XML structure. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
OurNet::BBSApp provides a XML-based, unified access interface to |
|
51
|
|
|
|
|
|
|
applications operating on L. The factory class for |
|
52
|
|
|
|
|
|
|
these services are usually L, which supports |
|
53
|
|
|
|
|
|
|
various tweakings on ArticleGroup classes. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The specific API remains to be documented. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 BUGS |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Too numerous to describe. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
|
6070
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
32
|
|
|
64
|
1
|
|
|
1
|
|
730
|
use OurNet::BBSApp::Monitor; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
65
|
1
|
|
|
1
|
|
1872
|
use OurNet::BBS; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use XML::Simple; |
|
67
|
|
|
|
|
|
|
use fields qw/BBS loaded config/; |
|
68
|
|
|
|
|
|
|
use vars qw/$Interval/; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$Interval = 10; # default: 10 sec sleeps |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub new { |
|
73
|
|
|
|
|
|
|
my $class = shift; |
|
74
|
|
|
|
|
|
|
my $self = fields::new($class); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$self->{config} = UNIVERSAL::isa($_[0], 'HASH') |
|
77
|
|
|
|
|
|
|
? $_[0] |
|
78
|
|
|
|
|
|
|
: XMLin( |
|
79
|
|
|
|
|
|
|
@_, |
|
80
|
|
|
|
|
|
|
keyattr => {}, |
|
81
|
|
|
|
|
|
|
searchpath => ['.'] |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->{config}{handler} = "OurNet::BBSApp::$self->{config}{handler}" |
|
85
|
|
|
|
|
|
|
unless $self->{config}{handler} =~ /::/; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $handler = $self->{config}{handler}; |
|
88
|
|
|
|
|
|
|
$handler =~ s|::|/|g; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
require "$handler.pm"; |
|
91
|
|
|
|
|
|
|
$self->{BBS} = OurNet::BBS->new(@{$self->{config}{bbsarg}}); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return $self; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub load { |
|
97
|
|
|
|
|
|
|
my $self = shift; |
|
98
|
|
|
|
|
|
|
return if $self->{loaded}++; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
foreach my $item (@{$self->{config}{'monitor'}}) { |
|
101
|
|
|
|
|
|
|
OurNet::BBSApp::Monitor::add($self->{config}{handler}->new( |
|
102
|
|
|
|
|
|
|
$self->{BBS}, $item |
|
103
|
|
|
|
|
|
|
)); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub run { |
|
108
|
|
|
|
|
|
|
my $self = shift; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$self->load() if $self; # could be called without an object |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
while (1) { |
|
113
|
|
|
|
|
|
|
OurNet::BBSApp::Monitor::process; |
|
114
|
|
|
|
|
|
|
sleep ($self ? $self->{config}{interval} : $Interval); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHORS |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Chia-Liang Kao Eclkao@clkao.org> |
|
127
|
|
|
|
|
|
|
Autrijus Tang Eautrijus@autrijus.org> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2001 by Autrijus Tang Eautrijus@autrijus.org>, |
|
132
|
|
|
|
|
|
|
Chia-Liang Kao Eclkao@clkao.org>. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
All rights reserved. You can redistribute and/or modify |
|
135
|
|
|
|
|
|
|
this module under the same terms as Perl itself. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |