Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Unloved program to convert a binary on stdin to a C include on stdout
0003  *
0004  * Jan 1999 Matt Mackall <mpm@selenic.com>
0005  *
0006  * This software may be used and distributed according to the terms
0007  * of the GNU General Public License, incorporated herein by reference.
0008  */
0009 
0010 #include <stdio.h>
0011 
0012 int main(int argc, char *argv[])
0013 {
0014     int ch, total = 0;
0015 
0016     if (argc > 1)
0017         printf("const char %s[] %s=\n",
0018             argv[1], argc > 2 ? argv[2] : "");
0019 
0020     do {
0021         printf("\t\"");
0022         while ((ch = getchar()) != EOF) {
0023             total++;
0024             printf("\\x%02x", ch);
0025             if (total % 16 == 0)
0026                 break;
0027         }
0028         printf("\"\n");
0029     } while (ch != EOF);
0030 
0031     if (argc > 1)
0032         printf("\t;\n\n#include <linux/types.h>\n\nconst size_t %s_size = %d;\n",
0033                argv[1], total);
0034 
0035     return 0;
0036 }