mirror of
https://github.com/dimoniche/solarium.vlad.git
synced 2026-01-30 21:13:31 +03:00
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
files = ['index.html', 'logo.png', 'favicon.ico', 'network.html', 'status.csv', 'param.csv', 'reboot.html']
|
|
|
|
output = open('html_files.c', 'wb')
|
|
|
|
for filename in files:
|
|
fd = open(filename, 'rb')
|
|
fdata=fd.read()
|
|
fd.close()
|
|
converted = '/' + filename + chr(0x00)
|
|
offset = len(converted)
|
|
|
|
dataname = 'data_%s_template' % filename.replace('.', '_')
|
|
fsname = 'file_%s' % filename.replace('.', '_')
|
|
|
|
output.write('static const unsigned char data_%s_template[] =\r\n' % filename.replace('.', '_'))
|
|
output.write('/* /%s */\r\n' % filename)
|
|
|
|
output.write('{')
|
|
for ch in converted:
|
|
output.write('0x%02x, ' % ord(ch))
|
|
output.write('\r\n')
|
|
|
|
for ch in fdata:
|
|
if ch == '\r' or ch == '\n':
|
|
try:
|
|
if filename.split('.')[1] == 'html':
|
|
continue
|
|
except:
|
|
continue
|
|
output.write('0x%02x, ' % ord(ch))
|
|
|
|
output.write('0x00')
|
|
output.write('};')
|
|
output.write('\r\n')
|
|
|
|
output.write('const struct httpd_fsdata_file ')
|
|
output.write('%s[] = ' % fsname)
|
|
output.write('{{NULL, %s, %s + %d, sizeof(%s) - %d}}; ' % (dataname, dataname, offset, dataname, offset))
|
|
output.write('\r\n')
|
|
output.write('\r\n')
|
|
|
|
output.close()
|