diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/Makefile | 4 | ||||
-rw-r--r-- | util/bin-to-hex.c | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/util/Makefile b/util/Makefile new file mode 100644 index 0000000..d6e8e79 --- /dev/null +++ b/util/Makefile @@ -0,0 +1,4 @@ +BIN_TO_HEX:= $(OBJDIR)/bin/bin-to-hex +$(BIN_TO_HEX): util/bin-to-hex.c + mkdir -p $(@D) + $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@ diff --git a/util/bin-to-hex.c b/util/bin-to-hex.c new file mode 100644 index 0000000..5906f93 --- /dev/null +++ b/util/bin-to-hex.c @@ -0,0 +1,25 @@ +#include <stdio.h> + +int main(int argc, char **argv) +{ + int c; + int i; + const char *name = argv[1]; + printf("#include <stddef.h>\n"); + printf("const unsigned char %s[] = {\n", name); + i = 0; + while((c = getchar()) != EOF) { + if ((i % 16) != 0) { + putchar(' '); + } + printf("0x%02x,", c); + i++; + if ((i %16) == 0) { + putchar('\n'); + } + } + putchar('\n'); + printf("};\n"); + printf("size_t %s_size = sizeof(%s);\n", name, name); + return 0; +} |