Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / bin / generate-raddb
1 #!/usr/bin/perl
2
3 # usage: generate-raddb radius-server/raddb/dictionary* >raddb.pm
4 #  i.e.: generate-raddb ~/freeradius/freeradius-1.0.5/share/dictionary* ~/wirelessoceans/dictionary.ip3networks ~/wtxs/dictionary.mot.canopy >raddb.pm.new
5 print <<END;
6 package FS::raddb;
7 use vars qw(%attrib);
8
9 %attrib = (
10 END
11
12 while (<>) {
13   next if /^\s*$/;
14   next if /^\s*(#|\$INCLUDE\s+)/;
15   next if /^(VALUE|VENDOR|BEGIN\-(VENDOR|TLV)|END\-(VENDOR|TLV))\s+/;
16   /^(ATTRIBUTE|ATTRIB_NMC)\s+([\w\-\/\.]+)\s+/ or die $_;
17   $attrib = $2;
18   $dbname = lc($2);
19   $dbname =~ s/[\-\/]/_/g;
20   $dbname = substr($dbname,0,24);
21   while ( exists $hash{$dbname} ) {
22     #warn $dbname;
23     $dbname =~ s/(.)$//;
24     my $w = $1;
25     $w =~ tr/_a-z0-9/a-z0-9_/;
26     $dbname = "$dbname$w";
27   }
28   $hash{$dbname} = $attrib;
29   #print "$2\n";
30 }
31
32 foreach ( sort keys %hash ) {
33 #  print "$_\n" if length($_)>24;
34 #  print substr($_,0,24),"\n" if length($_)>24; 
35 #  $max = length($_) if length($_)>$max;
36 # have to fudge things since everything >24 is *not* unique
37
38   #print "  '". substr($_,0,24). "' => '$hash{$_}',\n";
39   print "  '$_' ". ( " " x (24-length($_) ) ). "=> '$hash{$_}',\n";
40 }
41
42 print <<END;
43
44   #(RADIATOR?)
45   #'authentication_type'      => 'Authentication-Type',
46
47   #Canopy? (Kellin)
48   'motorola_canopy_gateway'   => 'Motorola-Canopy-Gateway',
49
50 );
51
52 1;
53 END
54