Use good m_ functions, because it smell like a flower, version 2.
[apps/madmutt.git] / base64.c
index df55689..9fdf037 100644 (file)
--- a/base64.c
+++ b/base64.c
  * 
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <lib-lib/lib-lib.h>
+#include <lib-mime/mime.h>
 
 #include "mutt.h"
-#include "mime.h"
 
 /* raw bytes to null-terminated base 64 string */
-void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len,
-                     size_t olen)
+void mutt_to_base64 (unsigned char *out, const unsigned char *in, ssize_t len,
+                     ssize_t olen)
 {
   while (len >= 3 && olen > 10) {
-    *out++ = B64Chars[in[0] >> 2];
-    *out++ = B64Chars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
-    *out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
-    *out++ = B64Chars[in[2] & 0x3f];
+    *out++ = __m_b64chars[in[0] >> 2];
+    *out++ = __m_b64chars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
+    *out++ = __m_b64chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
+    *out++ = __m_b64chars[in[2] & 0x3f];
     olen -= 4;
     len -= 3;
     in += 3;
@@ -64,12 +62,12 @@ void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len,
   if (len > 0 && olen > 4) {
     unsigned char fragment;
 
-    *out++ = B64Chars[in[0] >> 2];
+    *out++ = __m_b64chars[in[0] >> 2];
     fragment = (in[0] << 4) & 0x30;
     if (len > 1)
       fragment |= in[1] >> 4;
-    *out++ = B64Chars[fragment];
-    *out++ = (len < 2) ? '=' : B64Chars[(in[1] << 2) & 0x3c];
+    *out++ = __m_b64chars[fragment];
+    *out++ = (len < 2) ? '=' : __m_b64chars[(in[1] << 2) & 0x3c];
     *out++ = '=';
   }
   *out = '\0';