projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
move some decoding functions right into the str module, with a bit more
[apps/madmutt.git]
/
base64.c
diff --git
a/base64.c
b/base64.c
index
ad6c6c4
..
df55689
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.
*
*/
*
*/
@@
-46,8
+46,6
@@
#include "mutt.h"
#include "mime.h"
#include "mutt.h"
#include "mime.h"
-#define BAD -1
-
/* 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)
/* 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)
@@
-86,32
+84,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;
}