summaryrefslogtreecommitdiff
path: root/fs_radlog/fs_radlogd
blob: 74c2af3611d6e39d20fedad6fb92177f62593015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl -Tw
#
# ivan@sisd.com 98-mar-23

use strict;
use Date::Parse; #but hopefully not

$|=1;

my($file,$pos)=@_;
open(FILE,"<$file") or die "Can't open $file: $!";
seek(FILE,$pos,0) or die "Can't seek: $!";

my($datestr);
my(%param);

$SIG{'HUP'} = sub { print "EOF\n"; exit; };

while (1) {

  while (<FILE>) {
    next if /^$/;
    if ( /^\S/ ) {
      chop($datestr=$_);
      undef %param;
    } else {
      warn "Unexpected line: $_";
    }
    while (<FILE>) {
      if ( /^$/ ) {
        #if ( $param{'Acct-Status-Type'} eq 'Stop' ) {
          print join("\t",
            tell FILE,
            %param,
          ),"\n";
        #}
        last;
      } elsif ( /^\s+([\w\-]+)\s\=\s\"?([\w\.\-]+)\"?\s*$/ ) {
        $param{$1}=$2;
      } else { 
        warn "Unexpected line: $_";
      }

    }  

  }
  sleep 1;
  seek(FILE,0,1);
}