From eba0cfa6b0bef4f2e73c8630a7efa3944df8b0f8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 04:56:35 +0200 Subject: Adding upstream version 1:2.0.27. Signed-off-by: Daniel Baumann --- util/Makefile | 12 ++++++++++++ util/bin-to-hex.c | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 util/Makefile create mode 100644 util/bin-to-hex.c (limited to 'util') diff --git a/util/Makefile b/util/Makefile new file mode 100644 index 0000000..948ee63 --- /dev/null +++ b/util/Makefile @@ -0,0 +1,12 @@ +BIN_TO_HEX:= bin/bin-to-hex + +$(BIN_TO_HEX): $(srcdir)/util/bin-to-hex.c + @$(MKDIR) -p $(@D) + $(LINK.o) $(CFLAGS) -o $@ $^ + +$(BIN_TO_HEX): CC=$(BUILD_CC) +$(BIN_TO_HEX): CFLAGS=$(BUILD_CFLAGS) +$(BIN_TO_HEX): LDFLAGS= + +dist += util/Makefile util/bin-to-hex.c +clean += util/bin-to-hex.o $(BIN_TO_HEX) diff --git a/util/bin-to-hex.c b/util/bin-to-hex.c new file mode 100644 index 0000000..48a71e7 --- /dev/null +++ b/util/bin-to-hex.c @@ -0,0 +1,25 @@ +#include + +int main(int argc, char **argv) +{ + int c; + int i; + const char *name = argv[1]; + printf("#include \n"); + printf("const 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; +} -- cgit v1.2.3