| 1 | package FTN::SRIF; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | 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.09 | ||||||||||
| 14 | |||||||||||
| 15 | =cut | ||||||||||
| 16 | |||||||||||
| 17 | 5 | our $VERSION = '0.09'; | |||||||||
| 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 | 2 | ▶ | sub parse_srif { | ||||||||
|
Subroutine
parse_srif: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 211 | |||||||||||
| 212 | 2 | my $srif_file = shift; | |||||||||
| 213 | |||||||||||
| 214 | 2 | my (%srif_info, $keyword, $value, @akas); | |||||||||
| 215 | |||||||||||
| 216 | 2 | ▶ | open my $srif_handle, q{<}, "$srif_file" or croak ("Could not open SRIF file $srif_file."); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 217 | |||||||||||
| 218 | 2 | ▶ | while (<$srif_handle>) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 219 | |||||||||||
| 220 | 26 | ($keyword, $value) = split(' ', $_, 2); | |||||||||
| 221 | |||||||||||
| 222 | 26 | ▶ | if ($keyword ne "AKA") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 223 | |||||||||||
| 224 | 20 | $srif_info{$keyword} = $value; # add to SRIF hash | |||||||||
| 225 | |||||||||||
| 226 | } else { | ||||||||||
| 227 | |||||||||||
| 228 | 6 | push @akas, $value; # add to akas array | |||||||||
| 229 | |||||||||||
| 230 | } | ||||||||||
| 231 | |||||||||||
| 232 | } | ||||||||||
| 233 | |||||||||||
| 234 | 2 | close ($srif_handle); | |||||||||
| 235 | |||||||||||
| 236 | # Add a reference to the Akas array to the srif_info hash. | ||||||||||
| 237 | 2 | $srif_info{Akas} = \@akas; | |||||||||
| 238 | |||||||||||
| 239 | 2 | return \%srif_info; | |||||||||
| 240 | } | ||||||||||
| 241 | |||||||||||
| 242 | =head2 get_request_list | ||||||||||
| 243 | |||||||||||
| 244 | Syntax: @request_list = get_request_list($request_file); | ||||||||||
| 245 | |||||||||||
| 246 | Reads the request file passed to it and returns a reference to an array of lines | ||||||||||
| 247 | containing the list of requests in that request file. | ||||||||||
| 248 | |||||||||||
| 249 | =cut | ||||||||||
| 250 | |||||||||||
| 251 | 1 | ▶ | sub get_request_list { | ||||||||
|
Subroutine
get_request_list: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 252 | |||||||||||
| 253 | 1 | my $request_file = shift; | |||||||||
| 254 | |||||||||||
| 255 | 1 | ▶ | open my $req_handle, q{<}, "$request_file" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 256 | or croak ("Could not open Request File $request_file"); | ||||||||||
| 257 | |||||||||||
| 258 | 1 | my @request_list = <$req_handle>; | |||||||||
| 259 | |||||||||||
| 260 | 1 | close($req_handle); | |||||||||
| 261 | |||||||||||
| 262 | 1 | return \@request_list; | |||||||||
| 263 | } | ||||||||||
| 264 | |||||||||||
| 265 | |||||||||||
| 266 | |||||||||||
| 267 | =head1 AUTHOR | ||||||||||
| 268 | |||||||||||
| 269 | Robert James Clay, C<< <jame at rocasa.us> >> | ||||||||||
| 270 | |||||||||||
| 271 | =head1 BUGS | ||||||||||
| 272 | |||||||||||
| 273 | Please report any bugs or feature requests to C<bug-ftn-srif at rt.cpan.org>, or through | ||||||||||
| 274 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FTN-SRIF>. | ||||||||||
| 275 | I will be notified, and then you'll automatically be notified of progress on your bug as | ||||||||||
| 276 | I make changes. | ||||||||||
| 277 | |||||||||||
| 278 | |||||||||||
| 279 | =head1 SUPPORT | ||||||||||
| 280 | |||||||||||
| 281 | You can find documentation for this module with the perldoc command. | ||||||||||
| 282 | |||||||||||
| 283 | perldoc FTN::SRIF | ||||||||||
| 284 | |||||||||||
| 285 | |||||||||||
| 286 | You can also look for information at: | ||||||||||
| 287 | |||||||||||
| 288 | =over 4 | ||||||||||
| 289 | |||||||||||
| 290 | =item * RT: CPAN's request tracker | ||||||||||
| 291 | |||||||||||
| 292 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=FTN-SRIF> | ||||||||||
| 293 | |||||||||||
| 294 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 295 | |||||||||||
| 296 | L<http://annocpan.org/dist/FTN-SRIF> | ||||||||||
| 297 | |||||||||||
| 298 | =item * CPAN Ratings | ||||||||||
| 299 | |||||||||||
| 300 | L<http://cpanratings.perl.org/d/FTN-SRIF> | ||||||||||
| 301 | |||||||||||
| 302 | =item * Search CPAN | ||||||||||
| 303 | |||||||||||
| 304 | L<http://search.cpan.org/dist/FTN-SRIF> | ||||||||||
| 305 | |||||||||||
| 306 | =back | ||||||||||
| 307 | |||||||||||
| 308 | =head1 SEE ALSO | ||||||||||
| 309 | |||||||||||
| 310 | For more information regarding SRIF, see L<http://www.ftsc.org/docs/fsc-0086.001> | ||||||||||
| 311 | |||||||||||
| 312 | See also L<ftn-srif>, for an example of usage of this module. | ||||||||||
| 313 | |||||||||||
| 314 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 315 | |||||||||||
| 316 | Copyright 2001-2003,2010-2012 Robert James Clay, all rights reserved. | ||||||||||
| 317 | |||||||||||
| 318 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 319 | under the same terms as Perl itself. | ||||||||||
| 320 | |||||||||||
| 321 | =cut | ||||||||||
| 322 | |||||||||||
| 323 | 5 | 1; # End of FTN::SRIF | |||||||||