blob: f946b05b3f00309236b5392952ee0fdb16dca66c (
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
|
#!/usr/bin/perl
# usage: generate-raddb radius-server/raddb/dictionary* >raddb.pm
# i.e.: generate-raddb ~/src/freeradius-0.2/raddb/dictionary* >FS/raddb.pm
print <<END;
package FS::raddb;
use vars qw(%attrib);
%attrib = (
END
while (<>) {
next if /^(#|\s*$|\$INCLUDE\s+)/;
next if /^(VALUE|VENDOR|BEGIN\-VENDOR|END\-VENDOR)\s+/;
/^(ATTRIBUTE|ATTRIB_NMC)\s+([\w\-\/]+)\s+/ or die $_;
$attrib = $2;
$dbname = lc($2);
$dbname =~ s/[\-\/]/_/g;
$dbname = substr($dbname,0,24);
while ( exists $hash{$dbname} ) {
#warn $dbname;
$dbname =~ s/(.)$//;
my $w = $1;
$w =~ tr/_a-z0-9/a-z0-9_/;
$dbname = "$dbname$w";
}
$hash{$dbname} = $attrib;
#print "$2\n";
}
foreach ( keys %hash ) {
# print "$_\n" if length($_)>24;
# print substr($_,0,24),"\n" if length($_)>24;
# $max = length($_) if length($_)>$max;
# have to fudge things since everything >24 is *not* unique
#print " '". substr($_,0,24). "' => '$hash{$_}',\n";
print " '$_' => '$hash{$_}',\n";
}
print <<END;
);
1;
END
|