forked from WL-Amigo/waifu2x-converter-cpp
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathconv.c
More file actions
33 lines (27 loc) · 692 Bytes
/
conv.c
File metadata and controls
33 lines (27 loc) · 692 Bytes
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
#include <stdio.h>
#include <string.h>
int
main(int argc, char **argv)
{
FILE *in = fopen(argv[1], "r");
FILE *out = fopen(argv[2], "w");
if (strcmp(argv[3],"str") == 0) {
fputc('{', out);
fputc('\n', out);
char line[4096];
while (fgets(line, 4096, in)) {
int len = strlen(line);
int i;
for (i=0; i<len; i++) {
fprintf(out, "0x%02x,", line[i]);
}
fputc('\n', out);
}
fputs("0x00, }", out);
fputc('\n', out);
} else {
printf("unknown mode : %s\n", argv[3]);
return 1;
}
return 0;
}