chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Put a frame around user management window (and the other popups) and
[disorder]
/
lib
/
base64.c
diff --git
a/lib/base64.c
b/lib/base64.c
index 7ba47300d9c5c13b20431cedfc750623564fe16b..7909b4f6240e447c5371a6e383da38f265a869d4 100644
(file)
--- a/
lib/base64.c
+++ b/
lib/base64.c
@@
-1,6
+1,6
@@
/*
* This file is part of DisOrder
/*
* This file is part of DisOrder
- * Copyright (C) 2005, 2007 Richard Kettlewell
+ * Copyright (C) 2005, 2007
, 2008
Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-38,7
+38,6
@@
static const char mime_base64_table[] =
/** @brief Convert MIME base64
* @param s base64 data
* @param nsp Where to store length of converted data
/** @brief Convert MIME base64
* @param s base64 data
* @param nsp Where to store length of converted data
- * @param table Table of characters to use
* @return Decoded data
*
* See <a href="http://tools.ietf.org/html/rfc2045#section-6.8">RFC
* @return Decoded data
*
* See <a href="http://tools.ietf.org/html/rfc2045#section-6.8">RFC
@@
-51,6
+50,7
@@
char *mime_base64(const char *s, size_t *nsp) {
/** @brief Convert base64
* @param s base64 data
* @param nsp Where to store length of converted data
/** @brief Convert base64
* @param s base64 data
* @param nsp Where to store length of converted data
+ * @param table Table of characters to use
* @return Decoded data
*
* @p table should consist of 65 characters. The first 64 will be used to
* @return Decoded data
*
* @p table should consist of 65 characters. The first 64 will be used to
@@
-65,7
+65,14
@@
char *generic_base64(const char *s, size_t *nsp, const char *table) {
dynstr_init(&d);
n = 0;
while((c = (unsigned char)*s++)) {
dynstr_init(&d);
n = 0;
while((c = (unsigned char)*s++)) {
- if((t = strchr(table, c))) {
+ if(c == table[64]) {
+ if(n >= 2) {
+ dynstr_append(&d, (b[0] << 2) + (b[1] >> 4));
+ if(n == 3)
+ dynstr_append(&d, (b[1] << 4) + (b[2] >> 2));
+ }
+ break;
+ } else if((t = strchr(table, c))) {
b[n++] = t - table;
if(n == 4) {
dynstr_append(&d, (b[0] << 2) + (b[1] >> 4));
b[n++] = t - table;
if(n == 4) {
dynstr_append(&d, (b[0] << 2) + (b[1] >> 4));
@@
-73,13
+80,6
@@
char *generic_base64(const char *s, size_t *nsp, const char *table) {
dynstr_append(&d, (b[2] << 6) + b[3]);
n = 0;
}
dynstr_append(&d, (b[2] << 6) + b[3]);
n = 0;
}
- } else if(c == table[64]) {
- if(n >= 2) {
- dynstr_append(&d, (b[0] << 2) + (b[1] >> 4));
- if(n == 3)
- dynstr_append(&d, (b[1] << 4) + (b[2] >> 2));
- }
- break;
}
}
if(nsp)
}
}
if(nsp)