diff options
Diffstat (limited to 'accel-pppd/radius/dict2c.py')
-rw-r--r-- | accel-pppd/radius/dict2c.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/accel-pppd/radius/dict2c.py b/accel-pppd/radius/dict2c.py new file mode 100644 index 00000000..ff0961e7 --- /dev/null +++ b/accel-pppd/radius/dict2c.py @@ -0,0 +1,20 @@ +import sys,re + +hdr = file(sys.argv[2],'w') + +def process(fname, hdr): + for line in file(fname): + if line[:-1].strip() == '': + continue + if line[0] == '#': + continue + f = re.compile('[$.a-zA-Z0-9\-]+').findall(line) + if f[0] == 'ATTRIBUTE' or f[0] == 'VENDOR': + hdr.write('#define {0} {1}\n'.format(f[1].replace('-','_').replace('.','_'), f[2])) + elif f[0] == 'VALUE': + hdr.write('#define {0}_{1} {2}\n'.format(f[1].replace('-','_').replace('.','_'), f[2].replace('-','_'),f[3])) + elif f[0] == '$INCLUDE': + process(f[1], hdr) + +if __name__ == '__main__': + process(sys.argv[1], hdr) |