I remember seeing in the past a program that would take any file and generate a C array representing that file as output; it would prevent distribution of a separate file in some cases. Which Unix/Linux program does that?
Thank you Internet!
0x6adb015
2009-07-20 19:58:30
Boy do I feel stupid for having written my own...
Norman Ramsey
2009-07-21 01:20:05
Edited to fit in less than 15 characters :p
sigjuice
2009-07-22 15:26:45
Yet so simple, yet so cool!
To1ne
2010-06-23 08:55:44
+2
A:
hexdump -v -e '16/1 "0x%x," "\n"'
would generate a C like array from stdin, but there is no declaration, no braces or good formatting.
0x6adb015
2009-07-20 19:57:30
+2
A:
I know this is Unix/Linux question, but anyone viewing this that wants to do the same in Windows can use Bin2H.
CodeGoat
2009-07-20 20:01:24
+2
A:
For large files, converting to text and then making the compiler parse it all over again is inefficient and unnecessary. Use objcopy
instead:
objcopy -I binary -O elf32-i386 stuff stuff.o
(Adjust the output architecture as necessary for non-x86 platforms.) Then once you link it into your program, you can access it like so:
extern char _binary_stuff_start[], _binary_stuff_end[];
#define SIZE_OF_STUFF (_binary_stuff_end - _binary_stuff_start)
...
foo(_binary_stuff_start[i]);
David
2010-02-26 06:20:54