File Coverage

blib/lib/FTN/SRIF.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 29 44.8


line stmt bran cond sub pod time code
1             package FTN::SRIF;
2              
3 2     2   35116 use warnings;
  2         4  
  2         104  
4 2     2   13 use strict;
  2         7  
  2         76  
5 2     2   10 use Carp qw( croak );
  2         15  
  2         598  
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             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            
58             This is the name of the remote sysop
59              
60             =item AKA
61              
62            
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            
70             This is the effective baud rate, not the fixed DTE rate
71              
72             =item Time
73              
74            
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            
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            
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            
99             Defines whether the session is protected by password or not.
100              
101             =item SystemStatus
102              
103            
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            
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            
128             The site info as given e.g. in EMSI handshake
129              
130             =item Location
131              
132            
133             The location info as given e.g. in EMSI handshake
134              
135             =item Phone
136              
137            
138             The phone number info as given e.g. in EMSI handshake
139              
140             =item CallerID
141              
142            
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            
149             On protected sessions, the session password. If
150             no protected session, this parameter must be ommited!
151              
152             =item DTE
153              
154            
155             The PC<->Modem speed (so call DTE rate)
156              
157             =item PORT
158              
159            
160             The FOSSIL Communication Port. The Mailer should
161             leave the fossil "hot" for the Request Processor
162              
163             =item Mailer
164              
165            
166             The Mailer name as defined by FTC
167              
168             =item MailerCode
169              
170            
171             The hex code of the remote mailer as defined by FTC
172              
173             =item SerialNumber
174              
175            
176             The remote mailer's serial number if transfered
177              
178             =item Version
179              
180            
181             The remote mailer's version number if transfered
182              
183             =item Revision
184              
185            
186             The remote mailer's revision number if transfered
187              
188             =item SessionType
189              
190            
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            
197             If the mailer does AKA matching, the AKA of the
198             mailer being called
199              
200             =item TRANX
201              
202            
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     0 1   my $srif_file = shift;
213              
214 0           my (%srif_info, $keyword, $value, @akas);
215            
216 0 0         open (SRFFILE, "<$srif_file") or croak ("Could not open SRIF file $srif_file.");
217            
218 0           while () {
219            
220 0           ($keyword, $value) = split(' ', $_, 2);
221              
222 0 0         if ($keyword ne "AKA") {
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<< >>
245              
246             =head1 BUGS
247              
248             Please report any bugs or feature requests to C, or through
249             the web interface at L.
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
268              
269             =item * AnnoCPAN: Annotated CPAN documentation
270              
271             L
272              
273             =item * CPAN Ratings
274              
275             L
276              
277             =item * Search CPAN
278              
279             L
280              
281             =back
282              
283             =head1 SEE ALSO
284              
285             For more information regarding SRIF, see L
286              
287             See also L, 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             1; # End of FTN::SRIF