#include #include #include #include #if defined(_WIN32) #pragma warning(disable : 4996) // The POSIX name for this item is deprecated. #endif int main(int argc, char **argv) { FILE *f_c, *f_h, *f_i; unsigned int i, j, count, size; unsigned char buf[12]; if (argc < 3) { fprintf(stderr, "Syntax: bin2c [Input file 1] [Input file 2] ..\n"); return -1; } f_c = fopen(argv[1], "w"); if (!f_c) { fprintf(stderr, "Error opening %s\n", argv[1]); return -1; } f_h = fopen(argv[2], "w"); if (!f_h) { fprintf(stderr, "Error opening %s\n", argv[2]); return -1; } fprintf(f_c, "/* Autogenerated by bin2c */\n\n"); fprintf(f_c, "#include \n\n"); fprintf(f_h, "/* Autogenerated by bin2c */\n\n"); fprintf(f_h, "#pragma once\n"); fprintf(f_h, "#include \n\n"); for (i=3; i<(unsigned int) argc; ++i) { char *name = strdup(strrchr(argv[i], '/') ? strrchr(argv[i], '/')+1 : argv[i] ); for (j=0; j 0) { fprintf(f_c, " "); for (j=0; j