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
|
#!/usr/bin/env python
import sys
import yaml
def emit_header(structs):
for name, struct in list(structs.items()):
print('void dump_%s(const unsigned char *buf);' % name)
def emit_prefix():
print('#ifndef _DUMP_H_')
print('#define _DUMP_H_')
def emit_suffix():
print('#endif')
def convert_def(filename):
f = file(filename)
structs = yaml.load(f)
f.close()
emit_header(structs)
if __name__ == '__main__':
emit_prefix()
filenames = sys.argv[1:]
for filename in filenames:
convert_def(filename)
emit_suffix()
|