base64.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
/*
* Copyright (C) 1998-2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: base64.c,v 1.18 2000/08/01 01:29:14 tale Exp $ */
#include <config.h>
#define RETERR(x) do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
/*
* sure where they should go. -- bwelling
*/
static isc_result_t
static isc_result_t
static isc_result_t
static const char base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
{
char buf[5];
unsigned int loops = 0;
if (wordlength < 4)
wordlength = 4;
loops++;
{
loops = 0;
}
}
}
return (ISC_R_SUCCESS);
}
int digits = 0;
int val[4];
unsigned char buf[3];
int seen_end = 0;
unsigned int i;
char *s;
int n;
if (length > 0)
ISC_FALSE));
else
ISC_TRUE));
break;
if (seen_end)
return (ISC_R_BADBASE64);
return (ISC_R_BADBASE64);
if (digits == 4) {
return (ISC_R_BADBASE64);
return (ISC_R_BADBASE64);
if (n != 3) {
seen_end = 1;
val[2] = 0;
val[3] = 0;
}
if (length >= 0) {
if (n > length)
return (ISC_R_BADBASE64);
else
length -= n;
}
digits = 0;
}
}
}
if (length > 0)
return (ISC_R_UNEXPECTEDEND);
if (digits != 0)
return (ISC_R_BADBASE64);
return (ISC_R_SUCCESS);
}
if (result == ISC_R_SUCCESS)
if (result == ISC_R_SUCCESS) {
}
if (isopen)
(void)isc_lex_close(lex);
return (result);
}
static isc_result_t
unsigned int l;
return (ISC_R_NOSPACE);
isc_buffer_add(target, l);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
static isc_result_t
{
if (expect == isc_tokentype_qstring)
else if (expect == isc_tokentype_number)
switch (result) {
case ISC_R_SUCCESS:
break;
case ISC_R_NOMEMORY:
return (ISC_R_NOMEMORY);
case ISC_R_NOSPACE:
return (ISC_R_NOSPACE);
default:
"isc_lex_gettoken() failed: %s",
return (ISC_R_UNEXPECTED);
}
return (ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_UNEXPECTEDTOKEN);
}
return (ISC_R_SUCCESS);
}