summaryrefslogtreecommitdiffstats
path: root/util/bin-to-hex.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:56:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:56:35 +0000
commiteba0cfa6b0bef4f2e73c8630a7efa3944df8b0f8 (patch)
tree74c37eede1f0634cc5de1c63c934edaa1630c6bc /util/bin-to-hex.c
parentInitial commit. (diff)
downloadkexec-tools-eba0cfa6b0bef4f2e73c8630a7efa3944df8b0f8.tar.xz
kexec-tools-eba0cfa6b0bef4f2e73c8630a7efa3944df8b0f8.zip
Adding upstream version 1:2.0.27.upstream/1%2.0.27upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'util/bin-to-hex.c')
-rw-r--r--util/bin-to-hex.c25
1 files changed, 25 insertions, 0 deletions
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 <stdio.h>
+
+int main(int argc, char **argv)
+{
+ int c;
+ int i;
+ const char *name = argv[1];
+ printf("#include <stddef.h>\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;
+}