projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
oopsie, small fixes.
[apps/madmutt.git]
/
base64.c
diff --git
a/base64.c
b/base64.c
index
ad6c6c4
..
a5e6cf3
100644
(file)
--- a/
base64.c
+++ b/
base64.c
@@
-13,8
+13,8
@@
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
- * Software Foundation, Inc., 5
9 Temple Place - Suite 330,
- * Boston, MA
0211
1, USA.
+ * Software Foundation, Inc., 5
1 Franklin Street, Fifth Floor,
+ * Boston, MA
02110-130
1, USA.
*
*/
*
*/
@@
-43,20
+43,19
@@
# include "config.h"
#endif
# include "config.h"
#endif
-#include "mutt.h"
-#include "mime.h"
+#include <lib-mime/mime.h>
-#
define BAD -1
+#
include "mutt.h"
/* raw bytes to null-terminated base 64 string */
/* 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, s
s
ize_t len,
+ s
s
ize_t olen)
{
while (len >= 3 && olen > 10) {
{
while (len >= 3 && olen > 10) {
- *out++ =
B64C
hars[in[0] >> 2];
- *out++ =
B64C
hars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
- *out++ =
B64C
hars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
- *out++ =
B64C
hars[in[2] & 0x3f];
+ *out++ =
__m_b64c
hars[in[0] >> 2];
+ *out++ =
__m_b64c
hars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
+ *out++ =
__m_b64c
hars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
+ *out++ =
__m_b64c
hars[in[2] & 0x3f];
olen -= 4;
len -= 3;
in += 3;
olen -= 4;
len -= 3;
in += 3;
@@
-66,12
+65,12
@@
void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len,
if (len > 0 && olen > 4) {
unsigned char fragment;
if (len > 0 && olen > 4) {
unsigned char fragment;
- *out++ =
B64C
hars[in[0] >> 2];
+ *out++ =
__m_b64c
hars[in[0] >> 2];
fragment = (in[0] << 4) & 0x30;
if (len > 1)
fragment |= in[1] >> 4;
fragment = (in[0] << 4) & 0x30;
if (len > 1)
fragment |= in[1] >> 4;
- *out++ =
B64C
hars[fragment];
- *out++ = (len < 2) ? '=' :
B64C
hars[(in[1] << 2) & 0x3c];
+ *out++ =
__m_b64c
hars[fragment];
+ *out++ = (len < 2) ? '=' :
__m_b64c
hars[(in[1] << 2) & 0x3c];
*out++ = '=';
}
*out = '\0';
*out++ = '=';
}
*out = '\0';
@@
-86,32
+85,31
@@
int mutt_from_base64 (char *out, const char *in)
do {
digit1 = in[0];
do {
digit1 = in[0];
- if (
digit1 > 127 || base64val (digit1) == BAD
)
+ if (
base64val(digit1) < 0
)
return -1;
digit2 = in[1];
return -1;
digit2 = in[1];
- if (
digit2 > 127 || base64val (digit2) == BAD
)
+ if (
base64val(digit2) < 0
)
return -1;
digit3 = in[2];
return -1;
digit3 = in[2];
- if (digit3
> 127 || ((digit3 != '=') && (base64val (digit3) == BAD))
)
+ if (digit3
!= '=' && base64val(digit3) < 0
)
return -1;
digit4 = in[3];
return -1;
digit4 = in[3];
- if (digit4
> 127 || ((digit4 != '=') && (base64val (digit4) == BAD))
)
+ if (digit4
!= '=' && base64val(digit4) < 0
)
return -1;
in += 4;
/* digits are already sanity-checked */
return -1;
in += 4;
/* digits are already sanity-checked */
- *out++ = (base64val
(digit1) << 2) | (base64val
(digit2) >> 4);
+ *out++ = (base64val
(digit1) << 2) | (base64val
(digit2) >> 4);
len++;
if (digit3 != '=') {
len++;
if (digit3 != '=') {
- *out++ = ((base64val
(digit2) << 4) & 0xf0) | (base64val
(digit3) >> 2);
+ *out++ = ((base64val
(digit2) << 4) & 0xf0) | (base64val
(digit3) >> 2);
len++;
if (digit4 != '=') {
len++;
if (digit4 != '=') {
- *out++ = ((base64val
(digit3) << 6) & 0xc0) | base64val
(digit4);
+ *out++ = ((base64val
(digit3) << 6) & 0xc0) | base64val
(digit4);
len++;
}
}
len++;
}
}
- }
- while (*in && digit4 != '=');
+ } while (*in && digit4 != '=');
return len;
}
return len;
}