#!/usr/bin/python
from sys import argv
infile = open(argv[1], 'r')
outfile_name = argv[1].replace('.', '_')
indata = infile.readlines()
infile.close()
outfile = open(outfile_name + '.h', 'w')
h_guard = outfile_name.upper() + '_H_'
outfile.write('#ifndef ' + h_guard + '\n#define ' + h_guard + '\nstatic const char* ' + outfile_name + ' =\n')
for line in indata:
outfile.write('"' + line.replace('"', '\\"').replace('\n', '\\n') + '"\n')
outfile.write(';\n#endif\n')
outfile.close()
Egy kis Python szkript, ha C/C++ programba xml/html doksit kell beszúrni, ez kiescapeli az idézőjeleket, és beteszi egy headerbe. |