diff options
author | Lua Team <team@lua.org> | 2004-03-24 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2004-03-24 12:00:00 +0000 |
commit | ced7bbbe7a257ce6de94069d5dbf6672aeafd4d9 (patch) | |
tree | 2a01a79e6a4f451dccd247c70310ad957204cefa /etc/bin2c.c | |
parent | e7731a8fb8a317aa5c444ef073bfad82fa5baa54 (diff) | |
download | lua-github-5.1-work0.tar.gz |
Lua 5.1-work05.1-work0
Diffstat (limited to 'etc/bin2c.c')
-rw-r--r-- | etc/bin2c.c | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/etc/bin2c.c b/etc/bin2c.c deleted file mode 100644 index 0993b16d..00000000 --- a/etc/bin2c.c +++ /dev/null @@ -1,67 +0,0 @@ -/* -* bin2c.c -* convert files to byte arrays for automatic loading with lua_dobuffer -* Luiz Henrique de Figueiredo (lhf@tecgraf.puc-rio.br) -* 02 Apr 2003 20:44:31 -*/ - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> - -static void dump(FILE* f, int n) -{ - printf("static const unsigned char B%d[]={\n",n); - for (n=1;;n++) - { - int c=getc(f); - if (c==EOF) break; - printf("%3u,",c); - if (n==20) { putchar('\n'); n=0; } - } - printf("\n};\n\n"); -} - -static void fdump(const char* fn, int n) -{ - FILE* f= fopen(fn,"rb"); /* must open in binary mode */ - if (f==NULL) - { - fprintf(stderr,"bin2c: cannot open "); - perror(fn); - exit(1); - } - else - { - printf("/* %s */\n",fn); - dump(f,n); - fclose(f); - } -} - -static void emit(const char* fn, int n) -{ - printf(" lua_dobuffer(L,(const char*)B%d,sizeof(B%d),\"%s\");\n",n,n,fn); -} - -int main(int argc, char* argv[]) -{ - printf("/* code automatically generated by bin2c -- DO NOT EDIT */\n"); - printf("{\n"); - if (argc<2) - { - dump(stdin,0); - emit("=stdin",0); - } - else - { - int i; - printf("/* #include'ing this file in a C program is equivalent to calling\n"); - for (i=1; i<argc; i++) printf(" lua_dofile(L,\"%s\");\n",argv[i]); - printf("*/\n"); - for (i=1; i<argc; i++) fdump(argv[i],i); - for (i=1; i<argc; i++) emit(argv[i],i); - } - printf("}\n"); - return 0; -} |