summaryrefslogtreecommitdiffstats
path: root/doc/html/bits.html
blob: d889727dd201f571bb4fa7cc4f584bbacd0fa5bd (plain)
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
38
39
40
41
42
43
44
<pre>
#include &#60;stdio.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/stat.h&#62;
#include &#60;unistd.h&#62;
		     
int main(int argc, char **argv)
{
    int i;
    for(i = 1;i &#60; argc;i++)
    {
	FILE *f = fopen(argv[i], "rb");
	char c;
	struct stat buf;

	if(!f)
	{
	    fprintf(stderr, "Can't open file.\n");
	    return 255;
	}

	int s = 0, sz;
	stat(argv[i], &buf);
	
	sz = buf.st_size;

	printf("%s\nstd::string fmt_codec::fmt_pixmap()\n{\n\treturn std::string(\"", argv[i]);

	while(s++ &#60; sz-1)
	{
	    fread(&c, 1, 1, f);
	    printf("%u,", (unsigned char)c);
	}

	fread(&c, 1, 1, f);
	printf("%u", (unsigned char)c);

	printf("\");\n}\n\n");
	fclose(f);
    }

    return 0;
}
</pre>