~ubuntu-branches/ubuntu/vivid/mutt/vivid-updates

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
29
30
31
32
33
34
35
36
37
#include <stdio.h>

#define per_line 12

void
txt2c(char *sym, FILE *fp)
{
	unsigned char buf[per_line];
	int i;
	int sz = 0;

	printf("unsigned char %s[] = {\n", sym);
	while (1) {
		sz = fread(buf, sizeof(unsigned char), per_line, fp);
		if (sz == 0)
			break;
		printf("\t");
		for (i = 0; i < sz; i++)
			printf("0x%02x, ", buf[i]);
		printf("\n");
	}

	printf("\t0x00\n};\n");
}


int
main(int argc, char *argv[])
{
	if (argc != 2) {
		fprintf(stderr, "usage: %s symbol <textfile >textfile.c\n", argv[0]);
		return 2;
	}

	txt2c(argv[1], stdin);
	return 0;
}