From 29086b1d12a2c28cffdbfbf0b3990a7bd75506b9 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 20 Apr 2017 16:49:35 +0300 Subject: work in progress --- src/utils/dec2bin.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/utils/dec2bin.c (limited to 'src/utils') diff --git a/src/utils/dec2bin.c b/src/utils/dec2bin.c deleted file mode 100644 index 97e59bb..0000000 --- a/src/utils/dec2bin.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include -#include -#include - -int -main(int argc, char *argv[]) -{ - if (argc < 3) - errx(EXIT_FAILURE, "usage: %s number\n", argv[0]); - - const struct { - const char *t; - size_t sz; - } map[] = { - { .t = "u8", .sz = sizeof(uint8_t) }, - { .t = "u16", .sz = sizeof(uint16_t) }, - { .t = "u32", .sz = sizeof(uint32_t) }, - { .t = "u64", .sz = sizeof(uint64_t) }, - }; - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) - - size_t sz = 0; - for (size_t i = 0; i < ARRAY_SIZE(map); ++i) { - if (strcmp(argv[1], map[i].t)) - continue; - - sz = map[i].sz; - break; - } - - if (!sz) - errx(EXIT_FAILURE, "unknown type: %s", argv[1]); - - const uint64_t v = strtoll(argv[2], NULL, 10); - fwrite(&v, sz, 1, stdout); - return EXIT_SUCCESS; -} -- cgit v1.2.3-70-g09d2