new schema diagram
[freeside.git] / fs_radlog / fs_radlogd
1 #!/usr/bin/perl -Tw
2 #
3 # ivan@sisd.com 98-mar-23
4
5 use strict;
6 use Date::Parse; #but hopefully not
7
8 $|=1;
9
10 my($file,$pos)=@_;
11 open(FILE,"<$file") or die "Can't open $file: $!";
12 seek(FILE,$pos,0) or die "Can't seek: $!";
13
14 my($datestr);
15 my(%param);
16
17 $SIG{'HUP'} = sub { print "EOF\n"; exit; };
18
19 while (1) {
20
21   while (<FILE>) {
22     next if /^$/;
23     if ( /^\S/ ) {
24       chop($datestr=$_);
25       undef %param;
26     } else {
27       warn "Unexpected line: $_";
28     }
29     while (<FILE>) {
30       if ( /^$/ ) {
31         #if ( $param{'Acct-Status-Type'} eq 'Stop' ) {
32           print join("\t",
33             tell FILE,
34             %param,
35           ),"\n";
36         #}
37         last;
38       } elsif ( /^\s+([\w\-]+)\s\=\s\"?([\w\.\-]+)\"?\s*$/ ) {
39         $param{$1}=$2;
40       } else { 
41         warn "Unexpected line: $_";
42       }
43
44     }  
45
46   }
47   sleep 1;
48   seek(FILE,0,1);
49 }
50
51