From 26ee8370caadf6e7053c129d1ee933638b33f22a Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 16 Nov 2017 01:34:03 +0000 Subject: [PATCH] rename base64 functions --- conn/sasl_plain.c | 2 +- imap/auth_cram.c | 4 ++-- imap/auth_gss.c | 10 +++++----- mutt/base64.c | 12 ++++++------ mutt/base64.h | 4 ++-- rfc2047.c | 2 +- sendlib.c | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/conn/sasl_plain.c b/conn/sasl_plain.c index 0366e958a..a50d7bf6c 100644 --- a/conn/sasl_plain.c +++ b/conn/sasl_plain.c @@ -63,6 +63,6 @@ size_t mutt_sasl_plain_msg(char *buf, size_t buflen, const char *cmd, tmplen = snprintf(tmp, sizeof(tmp), "%s%c%s%c%s", NONULL(authz), '\0', user, '\0', pass); len = snprintf(buf, buflen, "%s ", cmd); - len += mutt_to_base64(buf + len, tmp, tmplen, buflen - len); + len += mutt_b64_encode(buf + len, tmp, tmplen, buflen - len); return len; } diff --git a/imap/auth_cram.c b/imap/auth_cram.c index 6a593ad33..3ce767601 100644 --- a/imap/auth_cram.c +++ b/imap/auth_cram.c @@ -140,7 +140,7 @@ enum ImapAuthRes imap_auth_cram_md5(struct ImapData *idata, const char *method) goto bail; } - len = mutt_from_base64(obuf, idata->buf + 2); + len = mutt_b64_decode(obuf, idata->buf + 2); if (len == -1) { mutt_debug(1, "Error decoding base64 response.\n"); @@ -175,7 +175,7 @@ enum ImapAuthRes imap_auth_cram_md5(struct ImapData *idata, const char *method) /* ibuf must be long enough to store the base64 encoding of obuf, * plus the additional debris */ - mutt_to_base64(ibuf, obuf, strlen(obuf), sizeof(ibuf) - 2); + mutt_b64_encode(ibuf, obuf, strlen(obuf), sizeof(ibuf) - 2); safe_strcat(ibuf, sizeof(ibuf), "\r\n"); mutt_socket_write(idata->conn, ibuf); diff --git a/imap/auth_gss.c b/imap/auth_gss.c index aea2d758a..00b1e8ad7 100644 --- a/imap/auth_gss.c +++ b/imap/auth_gss.c @@ -176,7 +176,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) /* now start the security context initialisation loop... */ mutt_debug(2, "Sending credentials\n"); - mutt_to_base64(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); + mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); gss_release_buffer(&min_stat, &send_token); safe_strcat(buf1, sizeof(buf1), "\r\n"); mutt_socket_write(idata->conn, buf1); @@ -195,7 +195,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) goto bail; } - request_buf.length = mutt_from_base64(buf2, idata->buf + 2); + request_buf.length = mutt_b64_decode(buf2, idata->buf + 2); request_buf.value = buf2; sec_token = &request_buf; @@ -212,7 +212,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) goto err_abort_cmd; } - mutt_to_base64(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); + mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); gss_release_buffer(&min_stat, &send_token); safe_strcat(buf1, sizeof(buf1), "\r\n"); mutt_socket_write(idata->conn, buf1); @@ -230,7 +230,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) mutt_debug(1, "Error receiving server response.\n"); goto bail; } - request_buf.length = mutt_from_base64(buf2, idata->buf + 2); + request_buf.length = mutt_b64_decode(buf2, idata->buf + 2); request_buf.value = buf2; maj_stat = gss_unwrap(&min_stat, context, &request_buf, &send_token, &cflags, &quality); @@ -280,7 +280,7 @@ enum ImapAuthRes imap_auth_gss(struct ImapData *idata, const char *method) goto err_abort_cmd; } - mutt_to_base64(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); + mutt_b64_encode(buf1, send_token.value, send_token.length, sizeof(buf1) - 2); mutt_debug(2, "Requesting authorisation as %s\n", idata->conn->account.user); safe_strcat(buf1, sizeof(buf1), "\r\n"); mutt_socket_write(idata->conn, buf1); diff --git a/mutt/base64.c b/mutt/base64.c index ab01d5c12..6efe4edd0 100644 --- a/mutt/base64.c +++ b/mutt/base64.c @@ -36,8 +36,8 @@ * * | Function | Description * | :----------------- | :------------------------------------------------- - * | mutt_from_base64() | convert null-terminated base64 string to raw bytes - * | mutt_to_base64() | convert raw bytes to null-terminated base64 string + * | mutt_b64_decode() | convert null-terminated base64 string to raw bytes + * | mutt_b64_encode() | convert raw bytes to null-terminated base64 string */ #include "config.h" @@ -79,7 +79,7 @@ const int Index_64[128] = { // clang-format on /** - * mutt_to_base64 - convert raw bytes to null-terminated base64 string + * mutt_b64_encode - convert raw bytes to null-terminated base64 string * @param out Output buffer for the base64 encoded string * @param cin Input buffer for the raw bytes * @param len Length of the input buffer @@ -91,7 +91,7 @@ const int Index_64[128] = { * null-byte is returned (equivalent to calling strlen() on the output buffer * after this function returns). */ -size_t mutt_to_base64(char *out, const char *cin, size_t len, size_t olen) +size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen) { unsigned char *begin = (unsigned char *) out; const unsigned char *in = (const unsigned char *) cin; @@ -125,7 +125,7 @@ size_t mutt_to_base64(char *out, const char *cin, size_t len, size_t olen) } /** - * mutt_from_base64 - convert null-terminated base64 string to raw bytes + * mutt_b64_decode - convert null-terminated base64 string to raw bytes * @param out Output buffer for the raw bytes * @param in Input buffer for the null-terminated base64-encoded string * @retval n Number of bytes written on success @@ -135,7 +135,7 @@ size_t mutt_to_base64(char *out, const char *cin, size_t len, size_t olen) * null-terminated. If the input buffer contains invalid base64 characters, * this function returns -1. */ -int mutt_from_base64(char *out, const char *in) +int mutt_b64_decode(char *out, const char *in) { int len = 0; unsigned char digit1, digit2, digit3, digit4; diff --git a/mutt/base64.h b/mutt/base64.h index 174c6ee79..2f085e0a3 100644 --- a/mutt/base64.h +++ b/mutt/base64.h @@ -27,7 +27,7 @@ extern const int Index_64[]; #define base64val(c) Index_64[(unsigned int) (c)] -size_t mutt_to_base64(char *out, const char *cin, size_t len, size_t olen); -int mutt_from_base64(char *out, const char *in); +size_t mutt_b64_encode(char *out, const char *cin, size_t len, size_t olen); +int mutt_b64_decode(char *out, const char *in); #endif /* _MUTT_BASE64_H */ diff --git a/rfc2047.c b/rfc2047.c index 039affe8c..0da5fd1b7 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -206,7 +206,7 @@ static size_t b_encoder(char *s, ICONV_CONST char *d, size_t dlen, const char *t size_t ret; size_t in_len = MIN(3, dlen); - ret = mutt_to_base64(encoded, d, in_len, sizeof(encoded)); + ret = mutt_b64_encode(encoded, d, in_len, sizeof(encoded)); for (size_t i = 0; i < ret; i++) *s++ = encoded[i]; diff --git a/sendlib.c b/sendlib.c index fa2997551..c8acf3fbf 100644 --- a/sendlib.c +++ b/sendlib.c @@ -239,7 +239,7 @@ static int b64_init(struct B64Context *ctx) static void b64_flush(struct B64Context *ctx, FILE *fout) { - /* for some reasons, mutt_to_base64 expects the + /* for some reasons, mutt_b64_encode expects the * output buffer to be larger than 10B */ char encoded[11]; size_t ret; @@ -256,7 +256,7 @@ static void b64_flush(struct B64Context *ctx, FILE *fout) /* ret should always be equal to 4 here, because ctx->size * is a value between 1 and 3 (included), but let's not hardcode it * and prefer the return value of the function */ - ret = mutt_to_base64(encoded, ctx->buffer, ctx->size, sizeof(encoded)); + ret = mutt_b64_encode(encoded, ctx->buffer, ctx->size, sizeof(encoded)); for (size_t i = 0; i < ret; i++) { fputc(encoded[i], fout); -- 2.40.0