diff options
Diffstat (limited to 'bin2h.c')
| -rw-r--r-- | bin2h.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +/* bin2h -- embed a binary file as the C array clectio compiles in. + * usage: bin2h <file> > text.lz.h (public domain) */ +#include <stdio.h> + +int main(int argc, char **argv) { + FILE *f; + int c, n = 0; + if (argc != 2 || !(f = fopen(argv[1], "rb"))) { + fprintf(stderr, "usage: bin2h <file> > out.h\n"); + return 1; + } + printf("static const unsigned char text_lz[] = {"); + while ((c = fgetc(f)) != EOF) { + if (n % 20 == 0) + printf("\n\t"); + printf("%d,", c); + n++; + } + printf("\n};\nstatic const unsigned text_lz_len = %d;\n", n); + fclose(f); + return 0; +} |
