mutt stable branch with some hacks
1#include <stdio.h>
2
3#define per_line 12
4
5void
6txt2c(char *sym, FILE *fp)
7{
8 unsigned char buf[per_line];
9 int i;
10 int sz = 0;
11
12 printf("unsigned char %s[] = {\n", sym);
13 while (1) {
14 sz = fread(buf, sizeof(unsigned char), per_line, fp);
15 if (sz == 0)
16 break;
17 printf("\t");
18 for (i = 0; i < sz; i++)
19 printf("0x%02x, ", buf[i]);
20 printf("\n");
21 }
22
23 printf("\t0x00\n};\n");
24}
25
26
27int
28main(int argc, char *argv[])
29{
30 if (argc != 2) {
31 fprintf(stderr, "usage: %s symbol <textfile >textfile.c\n", argv[0]);
32 return 2;
33 }
34
35 txt2c(argv[1], stdin);
36 return 0;
37}