aboutsummaryrefslogtreecommitdiff
path: root/contrib/tools/data2header.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tools/data2header.c')
-rw-r--r--contrib/tools/data2header.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/contrib/tools/data2header.c b/contrib/tools/data2header.c
new file mode 100644
index 00000000..885a5a7b
--- /dev/null
+++ b/contrib/tools/data2header.c
@@ -0,0 +1,41 @@
1/*
2 * by Luis Figueiredo (stdio@netc.pt)
3 */
4#include <stdio.h>
5#include <fcntl.h>
6#include <stdlib.h>
7#include <string.h>
8#ifdef WIN32
9#include <io.h>
10#endif
11
12
13
14int main(int argc, char *argv[]) { // Johannes E. Schindelin
15 unsigned char ch;
16 char *vn;
17 unsigned int i=0;
18 if(argc<2) {
19 fprintf(stderr,"Need a name for VAR\n");
20 exit(1); // Johannes E. Schindelin
21 };
22 vn=malloc(strlen(argv[1])+1);
23 for(i=0;i<strlen(argv[1]);i++)vn[i]=toupper(argv[1][i]);
24 vn[i]='\0';
25 printf("/*\n * by data2header by Luis Figueiredo (stdio@netc.pt)\n */\n");
26 printf("#ifndef _%s_H_\n",vn);
27 printf("#define _%s_H_\n\n",vn);
28 free(vn);
29 i=0;
30 printf("char %s[]=\"",argv[1]);
31 while(read(0,&ch,1)) {
32 i++;if(i>25){i=0;printf("\"\n\"");};
33 printf("\\x%X",ch);
34 };
35 printf("\";\n\n");
36 printf("#endif\n");
37 return 0; // Johannes E. Schindelin
38};
39
40
41