#include #include #include CODE_BEGINS virtual int startup() throw (GeneralException) { int i; if (argc != 4) { printm(M_BARE, "Usage: %s \n", argv[0]); exit(-1); } printm(M_BARE, "Starting converting %s to %s:\n", argv[1], argv[2]); Input binfile(argv[1]); Output cfile(argv[2]); unsigned char * map = (unsigned char *) binfile.mmap(); cfile << "int " << argv[3] << "_size = " << binfile.GetSize() << ";\n"; cfile << "unsigned char " << argv[3] << "[] = {"; for (i = 0; i < binfile.GetSize(); i++) { String s; s.set("0x%02x, ", map[i]); if (!(i % 16)) { cfile << "\n\t"; printm(M_BARE, "%5.2f%%\r", i * 100.0 / binfile.GetSize()); } cfile << s; } cfile << "\n};\n"; printm(M_BARE, "Done! \n"); return 0; } CODE_ENDS