diff options
Diffstat (limited to 'bin2c.cpp')
-rw-r--r-- | bin2c.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
@@ -1,40 +1,40 @@ -#include <Input.h> -#include <Output.h> -#include <Main.h> - -CODE_BEGINS -virtual int startup() throw (GeneralException) { - int i; - - if (argc != 4) { - printm(M_BARE, "Usage: %s <bin file> <c file> <symbol>\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 +#include <Input.h>
+#include <Output.h>
+#include <Main.h>
+
+CODE_BEGINS
+virtual int startup() throw (GeneralException) {
+ int i;
+
+ if (argc != 4) {
+ printm(M_BARE, "Usage: %s <bin file> <c file> <symbol>\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
|