X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=base64.c;h=69ae3a73cc7d768ace1d36ea0030e16f4c940b5d;hp=0bcc865d6ba336bff69d58fdb77476d826c3f7e2;hb=9a1efcc01ddeca4106847f8eb28a704aca2dcf0b;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1 diff --git a/base64.c b/base64.c index 0bcc865..69ae3a7 100644 --- 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 - * Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111, USA. + * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * */ @@ -39,6 +39,10 @@ * */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mime.h" @@ -46,22 +50,20 @@ /* 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) + size_t olen) { - while (len >= 3 && olen > 10) - { + 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]; - olen -= 4; - len -= 3; - in += 3; + olen -= 4; + len -= 3; + in += 3; } /* clean up remainder */ - if (len > 0 && olen > 4) - { + if (len > 0 && olen > 4) { unsigned char fragment; *out++ = B64Chars[in[0] >> 2]; @@ -82,8 +84,7 @@ int mutt_from_base64 (char *out, const char *in) int len = 0; register unsigned char digit1, digit2, digit3, digit4; - do - { + do { digit1 = in[0]; if (digit1 > 127 || base64val (digit1) == BAD) return -1; @@ -99,16 +100,14 @@ int mutt_from_base64 (char *out, const char *in) in += 4; /* digits are already sanity-checked */ - *out++ = (base64val(digit1) << 2) | (base64val(digit2) >> 4); + *out++ = (base64val (digit1) << 2) | (base64val (digit2) >> 4); len++; - if (digit3 != '=') - { - *out++ = ((base64val(digit2) << 4) & 0xf0) | (base64val(digit3) >> 2); + if (digit3 != '=') { + *out++ = ((base64val (digit2) << 4) & 0xf0) | (base64val (digit3) >> 2); len++; - if (digit4 != '=') - { - *out++ = ((base64val(digit3) << 6) & 0xc0) | base64val(digit4); - len++; + if (digit4 != '=') { + *out++ = ((base64val (digit3) << 6) & 0xc0) | base64val (digit4); + len++; } } }