diff options
author | Mattias Andrée <maandree@kth.se> | 2024-08-28 16:42:05 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-08-28 16:42:05 +0200 |
commit | a24071ae913b223487df78859c8d830f9e69f580 (patch) | |
tree | e2ec712cc29461c82cfdd477e8b1ba961b50018d /format_result.c | |
parent | First commit (diff) | |
download | anysum-a24071ae913b223487df78859c8d830f9e69f580.tar.gz anysum-a24071ae913b223487df78859c8d830f9e69f580.tar.bz2 anysum-a24071ae913b223487df78859c8d830f9e69f580.tar.xz |
Second commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'format_result.c')
-rw-r--r-- | format_result.c | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/format_result.c b/format_result.c deleted file mode 100644 index bb0bd29..0000000 --- a/format_result.c +++ /dev/null @@ -1,42 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "common.h" - - -void -format_result(struct algorithm *algorithm, const char *file, enum format format) -{ - char *p; - size_t size = algorithm->hasher.hash_size + 1U; - size += (format & WITH_ALGOSTR) ? strlen(algorithm->algostr) + 1U : 0U; - size += (format & WITH_FILENAME) ? 2U + strlen(file) : 0U; - size += (format & WITH_NUL) ? 1U : 0U; - size += (format & WITH_LF) ? 1U : 0U; - size += ((format & FORMAT_MASK) != BINARY) ? algorithm->hasher.hash_size : 0U; - if (size > algorithm->result_size) { - algorithm->result = erealloc(algorithm->result, size); - algorithm->result_size = size; - } - algorithm->result_length = size - 1U; - p = algorithm->result; - if (format & WITH_ALGOSTR) - p = stpcpy(stpcpy(p, algorithm->algostr), ":"); - switch (format & FORMAT_MASK) { - case BINARY: - p = mempcpy(p, algorithm->hasher.hash_output, algorithm->hasher.hash_size); - break; - case LOWERCASE_HEX: - p = hex(p, algorithm->hasher.hash_output, algorithm->hasher.hash_size, "0123456789abcdef"); - break; - case UPPERCASE_HEX: - p = hex(p, algorithm->hasher.hash_output, algorithm->hasher.hash_size, "0123456789ABCDEF"); - break; - default: - abort(); - } - if (format & WITH_FILENAME) - p = stpcpy(stpcpy(p, " "), file); - if (format & WITH_NUL) - *p++ = '\0'; - if (format & WITH_LF) - *p++ = '\n'; -} |