blib/lib/FTN/SRIF.pm

filter: Statementstmt 50.0% 11 / 22 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 45.4% 15 / 33 SCAR 20.3
CC
4
Cov
39%
parse_srif
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.6
↑ Summary
1 package FTN::SRIF;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 FTN::SRIF - Perl extension to parse an Fidonet/FTN Standard Request Information File.
10  
11 =head1 VERSION
12  
13 Version 0.05
14  
15 =cut
16  
17 2 our $VERSION = '0.05';
18  
19 =head1 DESCRIPTION
20  
21 Parsing an FTN SRIF (Standard Request Information File) received by an FTN mailer for what
22 is being requested by another mailer. A common use of such files is for use by an external
23 request processor (ERP) for an Fidonet/FTN mailer.
24  
25 To give an example of it being used:
26  
27 use FTN::SRIF qw(&parse_srif);
28 ...
29 $srif_info = FTN::SRIF::parse_srif($SRIF);
30 ...
31 $request_file = ${$srif_info}{'RequestList'};
32 $response_file = ${$srif_info}{'ResponseList'};
33 ...
34  
35 =head1 EXPORT
36  
37 The following is a list of functions that can be exported: parse_srif().
38  
39 =head1 FUNCTIONS
40  
41 =head2 parse_srif
42  
43 Syntax: $srif_info = parse_srif($srif_file);
44  
45 Parses the SRIF $srif_file and returns the information therein as a refererence
46 to a hash containing the SRIF information. Note that the only keyword that is
47 allowed to have multiple values is the one for Akas, which is returned as a
48 refererence to an array containing the Akas list.
49  
50 The base set of keys to the hash, and also that required in the SRIF,
51 are as follows:
52  
53 =over 4
54  
55 =item Sysop
56  
57 <Sysop_Name>
58 This is the name of the remote sysop
59  
60 =item AKA
61  
62 <Zone:Net/Node[.Point][@Domain]>
63 This is the main aka of the remote system in 4D or 5D notation. A zero
64 as point number may be ommited, the domain with "@" is optional. This
65 is included in a key, Akas, which is a reference to an array containing it.
66  
67 =item Baud
68  
69 <Current LINE rate>
70 This is the effective baud rate, not the fixed DTE rate
71  
72 =item Time
73  
74 <Time in minutes>
75 This is the time till next event which does not allow file requests.
76 Use -1 if there is no limit.
77  
78 =item RequestList
79  
80 <File of request list>
81 This is the filename of the file containing the request list. If
82 the request(s) is for files, it will be a listing of files being
83 requested.
84  
85 =item ResponseList
86  
87 <File of response list>
88 This is the filename of the response list. It must not be equal
89 to RequestList. One file per line, including drives/pathes to the
90 file. The first character defines the way the mailer should act after
91 sending that file:
92 = erase file if sent successfully
93 + do not erase the file after sent
94 - erase the file in any case after session
95  
96 =item RemoteStatus
97  
98 <PROTECTED or UNPROTECTED>
99 Defines whether the session is protected by password or not.
100  
101 =item SystemStatus
102  
103 <LISTED or UNLISTED>
104 Defines whether the remote system is listed in any current nodelist
105 of a system.
106  
107 =back
108  
109 The following are optional statements: these parameters are already known and defined,
110 but an ERP should run also without them:
111  
112 =over 4
113  
114 =item SessionProtocol
115  
116 e.g. ZAP,ZMO,XMA.
117  
118 =item AKA
119  
120 <Zone:Net/Node[.Point][@Domain]>
121 Additional AKAs. One AKA is required (see REQUIRED section, above)
122 They are included in a key, Akas, which is a reference to an array
123 containing them.
124  
125 =item Site
126  
127 <Site Info>
128 The site info as given e.g. in EMSI handshake
129  
130 =item Location
131  
132 <Location and/or ZIP>
133 The location info as given e.g. in EMSI handshake
134  
135 =item Phone
136  
137 <Phone Number>
138 The phone number info as given e.g. in EMSI handshake
139  
140 =item CallerID
141  
142 <Phone Number>
143 The phone number as delivered by the PTT. This is
144 only possible in digital networks like ISDN.
145  
146 =item Password
147  
148 <Session password>
149 On protected sessions, the session password. If
150 no protected session, this parameter must be ommited!
151  
152 =item DTE
153  
154 <Current DTE rate>
155 The PC<->Modem speed (so call DTE rate)
156  
157 =item PORT
158  
159 <COM Port from 1 to 8>
160 The FOSSIL Communication Port. The Mailer should
161 leave the fossil "hot" for the Request Processor
162  
163 =item Mailer
164  
165 <Remote's mailer if EMSI>
166 The Mailer name as defined by FTC
167  
168 =item MailerCode
169  
170 <Remote's FTSC code>
171 The hex code of the remote mailer as defined by FTC
172  
173 =item SerialNumber
174  
175 <Remote's serial number if passed>
176 The remote mailer's serial number if transfered
177  
178 =item Version
179  
180 <Remote's version number if EMSI>
181 The remote mailer's version number if transfered
182  
183 =item Revision
184  
185 <remote's revision number if EMSI>
186 The remote mailer's revision number if transfered
187  
188 =item SessionType
189  
190 <may be EMSI, FTSC0001, WAZOO, JANUS, HYDRA or OTHER>
191 The session-type, this may be one of the known
192 session types or "OTHER" if not (yet) defined
193  
194 =item OurAKA
195  
196 <AKA which has been called for proper response>
197 If the mailer does AKA matching, the AKA of the
198 mailer being called
199  
200 =item TRANX
201  
202 <Tranx Line as 8 digit hex string>
203 The unix-style time stamp (hexadecimal notation
204 of seconds since 1.1.1980)
205  
206 =back
207  
208 =cut
209  
210 sub parse_srif {
211  
212 0 ▶ my $srif_file = shift;
Subroutine parse_srif: not called CC=4 SCAR=30.0
Pod documented
213  
214 0 my (%srif_info, $keyword, $value, @akas);
215
216 0 ▶ open (SRFFILE, "<$srif_file") or croak ("Could not open SRIF file $srif_file.");
Branch: 1 branch
BranchTrueFalseTotal
open SRFFILE, "<$srif_file" or croak("Could not open SRIF file $srif_file.") 0 0 0
217
218 0 ▶ while (<SRFFILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline SRFFILE)) 0 0 0
219
220 0 ($keyword, $value) = split(' ', $_, 2);
221  
222 0 ▶ if ($keyword ne "AKA") {
Branch: 1 branch
BranchTrueFalseTotal
if ($keyword ne 'AKA') { } 0 0 0
223  
224 0 $srif_info{$keyword} = $value; # add to SRIF hash
225  
226 } else {
227  
228 0 push @akas, $value; # add to akas array
229  
230 }
231  
232 }
233
234 0 close (SRFFILE);
235  
236 # Add a reference to the Akas array to the srif_info hash.
237 0 $srif_info{Akas} = \@akas;
238
239 0 return \%srif_info;
240 }
241  
242 =head1 AUTHOR
243  
244 Robert James Clay, C<< <jame at rocasa.us> >>
245  
246 =head1 BUGS
247  
248 Please report any bugs or feature requests to C<bug-ftn-srif at rt.cpan.org>, or through
249 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FTN-SRIF>.
250 I will be notified, and then you'll automatically be notified of progress on your bug as
251 I make changes.
252  
253  
254 =head1 SUPPORT
255  
256 You can find documentation for this module with the perldoc command.
257  
258 perldoc FTN::SRIF
259  
260  
261 You can also look for information at:
262  
263 =over 4
264  
265 =item * RT: CPAN's request tracker
266  
267 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=FTN-SRIF>
268  
269 =item * AnnoCPAN: Annotated CPAN documentation
270  
271 L<http://annocpan.org/dist/FTN-SRIF>
272  
273 =item * CPAN Ratings
274  
275 L<http://cpanratings.perl.org/d/FTN-SRIF>
276  
277 =item * Search CPAN
278  
279 L<http://search.cpan.org/dist/FTN-SRIF>
280  
281 =back
282  
283 =head1 SEE ALSO
284  
285 For more information regarding SRIF, see L<http://www.ftsc.org/docs/fsc-0086.001>
286  
287 See also L<ftn-srif>, for an example of usage of this module.
288  
289 =head1 COPYRIGHT & LICENSE
290  
291 Copyright 2001-2003,2010 Robert James Clay, all rights reserved.
292  
293 This program is free software; you can redistribute it and/or modify it
294 under the same terms as Perl itself.
295  
296 =cut
297  
298 2 1; # End of FTN::SRIF
↑ Summary