From fa8b4660e962fae6968e3d11286c0b922453e7bb Mon Sep 17 00:00:00 2001 From: Rob Riggs Date: Fri, 1 Jan 2021 22:53:29 -0600 Subject: [PATCH] Remove unused base64 encoding code. --- Src/main.c | 1 - TNC/base64.cpp | 57 -------------------------------------------------- TNC/base64.h | 38 --------------------------------- 3 files changed, 96 deletions(-) delete mode 100644 TNC/base64.cpp delete mode 100644 TNC/base64.h diff --git a/Src/main.c b/Src/main.c index d35ff85..0493c63 100644 --- a/Src/main.c +++ b/Src/main.c @@ -58,7 +58,6 @@ #include "PortInterface.h" #include "LEDIndicator.h" #include "bm78.h" -#include "base64.h" #include "KissHardware.h" #include "Log.h" diff --git a/TNC/base64.cpp b/TNC/base64.cpp deleted file mode 100644 index 09f1e74..0000000 --- a/TNC/base64.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2018 Rob Riggs -// All rights reserved. - -#include "base64.h" -#include "assert.h" - -namespace { -const char alphabet[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -} - -uint32_t base64encode(const uint8_t* src, uint32_t src_len, char* dest, - uint32_t* dest_len) -{ - uint32_t expected = ((src_len * 4) + 2) / 3; - uint32_t dpos = 0; - uint8_t b1, b2, b3, b4; - for (uint32_t i = 0; i < src_len; i += 3) - { - if (dpos == *dest_len) return expected; - b1 = src[i] >> 2; - b2 = ((src[i] & 0x3) << 4); - dest[dpos++] = alphabet[b1]; - - if (dpos == *dest_len) return expected; - if (i + 1 == src_len) - { - dest[dpos++] = alphabet[b2]; - break; - } - else - { - b2 |= (src[i + 1] >> 4); - dest[dpos++] = alphabet[b2]; - b3 = (src[i + 1] & 0x0F) << 2; - } - - if (dpos == *dest_len) return expected; - if (i + 2 == src_len) - { - dest[dpos++] = alphabet[b3]; - break; - } - else - { - b3 |= src[i + 2] >> 6; - dest[dpos++] = alphabet[b3]; - b4 = src[i + 2] & 0x3F; - } - - if (dpos == *dest_len) return expected; - dest[dpos++] = alphabet[b4]; - } - *dest_len = dpos; - assert(*dest_len == expected); - return expected; -} diff --git a/TNC/base64.h b/TNC/base64.h deleted file mode 100644 index 9e6649e..0000000 --- a/TNC/base64.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2018 Rob Riggs -// All rights reserved. - -#ifndef MOBILINKD__TNC__BASE64_H_ -#define MOBILINKD__TNC__BASE64_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Base64 encode binary data from src, storing the result in dest. The - * input value of dest_len limits the length of the string which will be - * written to dest. If this value is not >= 4/3 * src_len, the output - * string will be truncated. The amount written will be returned in - * dest_len (in this case in==out) and the amount that would have been - * written is returned. - * - * If the return value and the value returned in dest_len are different, - * dest did not contain enough space to fully encode the result. - * - * @param src is the binary data to be base64 encoded. - * @param src_len is the length of the binary data to encode. - * @param dest is the destination buffer to contain the encoded string. - * @param[in,out] dest_len on input is the size of the dest buffer and on - * output is the number of characters written to dest. - * @return the length of src fully base64 encoded. - */ -uint32_t base64encode(const uint8_t* src, uint32_t src_len, char* dest, - uint32_t* dest_len); - -#ifdef __cplusplus -} -#endif - -#endif // MOBILINKD__TNC__BASE64_H_