From 0eb3b65158ae26ed570908b11785856262d5c061 Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Sat, 11 Mar 2017 15:34:23 -0800 Subject: [PATCH] encoding: use simple int's instead of accessor functions Why are those values exposed to the outer world? They seem not be in use anyway. Signed-off-by: Ralf Ramsauer --- src/base128.c | 18 ++++-------------- src/base32.c | 18 ++++-------------- src/base64.c | 18 ++++-------------- src/encoding.h | 4 ++-- 4 files changed, 14 insertions(+), 44 deletions(-) diff --git a/src/base128.c b/src/base128.c index 7c3520e..fbf83d4 100644 --- a/src/base128.c +++ b/src/base128.c @@ -34,8 +34,8 @@ #include "encoding.h" -#define BLKSIZE_RAW 7 -#define BLKSIZE_ENC 8 +#define BASE128_BLKSIZE_RAW 7 +#define BASE128_BLKSIZE_ENC 8 /* Don't use '-' (restricted to middle of labels), prefer iso_8859-1 * accent chars since they might readily be entered in normal use, @@ -56,16 +56,6 @@ static int base128_handles_dots(void) return 0; } -static int base128_blksize_raw(void) -{ - return BLKSIZE_RAW; -} - -static int base128_blksize_enc(void) -{ - return BLKSIZE_ENC; -} - inline static void base128_reverse_init(void) { int i; @@ -271,6 +261,6 @@ const struct encoder base128_ops = { .places_dots = base128_handles_dots, .eats_dots = base128_handles_dots, - .blocksize_raw = base128_blksize_raw, - .blocksize_encoded = base128_blksize_enc + .blocksize_raw = BASE128_BLKSIZE_RAW, + .blocksize_encoded = BASE128_BLKSIZE_ENC, }; diff --git a/src/base32.c b/src/base32.c index e35867f..2662729 100644 --- a/src/base32.c +++ b/src/base32.c @@ -22,8 +22,8 @@ #include "encoding.h" -#define BLKSIZE_RAW 5 -#define BLKSIZE_ENC 8 +#define BASE32_BLKSIZE_RAW 5 +#define BASE32_BLKSIZE_ENC 8 static const char cb32[] = "abcdefghijklmnopqrstuvwxyz012345"; @@ -37,16 +37,6 @@ static int base32_handles_dots(void) return 0; } -static int base32_blksize_raw(void) -{ - return BLKSIZE_RAW; -} - -static int base32_blksize_enc(void) -{ - return BLKSIZE_ENC; -} - inline static void base32_reverse_init(void) { int i; @@ -248,6 +238,6 @@ const struct encoder base32_ops = { .places_dots = base32_handles_dots, .eats_dots = base32_handles_dots, - .blocksize_raw = base32_blksize_raw, - .blocksize_encoded = base32_blksize_enc, + .blocksize_raw = BASE32_BLKSIZE_RAW, + .blocksize_encoded = BASE32_BLKSIZE_ENC, }; diff --git a/src/base64.c b/src/base64.c index 525e4dc..abad891 100644 --- a/src/base64.c +++ b/src/base64.c @@ -22,8 +22,8 @@ #include "encoding.h" -#define BLKSIZE_RAW 3 -#define BLKSIZE_ENC 4 +#define BASE64_BLKSIZE_RAW 3 +#define BASE64_BLKSIZE_ENC 4 /* Note: the "unofficial" char is last here, which means that the \377 pattern in DOWNCODECCHECK1 ('Y' request) will properly test it. */ @@ -37,16 +37,6 @@ static int base64_handles_dots(void) return 0; } -static int base64_blksize_raw(void) -{ - return BLKSIZE_RAW; -} - -static int base64_blksize_enc(void) -{ - return BLKSIZE_ENC; -} - inline static void base64_reverse_init(void) { int i; @@ -186,6 +176,6 @@ const struct encoder base64_ops = { .places_dots = base64_handles_dots, .eats_dots = base64_handles_dots, - .blocksize_raw = base64_blksize_raw, - .blocksize_encoded = base64_blksize_enc, + .blocksize_raw = BASE64_BLKSIZE_RAW, + .blocksize_encoded = BASE64_BLKSIZE_ENC, }; diff --git a/src/encoding.h b/src/encoding.h index 49c7424..5d4c65c 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -39,8 +39,8 @@ struct encoder { int (*places_dots)(void); int (*eats_dots)(void); - int (*blocksize_raw)(void); - int (*blocksize_encoded)(void); + const int blocksize_raw; + const int blocksize_encoded; }; int build_hostname(char *, size_t, const char *, const size_t, const char *, const struct encoder *, int);