]> granicus.if.org Git - neomutt/commitdiff
rename base64 functions
authorRichard Russon <rich@flatcap.org>
Thu, 16 Nov 2017 01:34:03 +0000 (01:34 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 16 Nov 2017 03:39:55 +0000 (03:39 +0000)
conn/sasl_plain.c
imap/auth_cram.c
imap/auth_gss.c
mutt/base64.c
mutt/base64.h
rfc2047.c
sendlib.c

index 0366e958a32902b49e2955e96ab792a7293bd1d9..a50d7bf6cdf953580929a14407adc6d2686fc603 100644 (file)
@@ -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;
 }
index 6a593ad33f815c6c112a66c5fda254d1dc001a75..3ce7676017e320e266084585a0da4a847c4b4487 100644 (file)
@@ -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);
 
index aea2d758a567963f680891b7ec0b9b82d6c9cae2..00b1e8ad7186ee7825ddd2feab810845e1453843 100644 (file)
@@ -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);
index ab01d5c122e466184d235425ecfe6263432e60f9..6efe4edd0fb0cd2e0dc9a96b3f2a7409ed62a8d6 100644 (file)
@@ -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;
index 174c6ee796a6ccf02f71c92a02927797538ff234..2f085e0a38dc5f183e583dd39ef463d295a6b3f4 100644 (file)
@@ -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 */
index 039affe8ce07e7894b04c6c0e8f141b08eedcf9c..0da5fd1b721744430ebc5f2aaa431a6f4c1f8dda 100644 (file)
--- 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];
 
index fa299755150a77f4caeb431e6a80b1da720588c4..c8acf3fbf319306b112c3b378060ee721adf0b62 100644 (file)
--- 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);