+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
/*
* Modified by Kurt D. Zeilenga for inclusion into OpenLDAP
*/
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/types.h>
+#include "portable.h"
+
+#include <ac/assert.h>
+#include <ac/stdlib.h>
+#include <ac/ctype.h>
+#include <ac/string.h>
-#include <lutil.h>
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
-#define Assert(Cond) if (!(Cond)) abort()
+#include "lutil.h"
static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
*/
int
-b64_ntop(
+lutil_b64_ntop(
u_char const *src,
size_t srclength,
char *target,
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
output[3] = input[2] & 0x3f;
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
- Assert(output[3] < 64);
+ assert(output[0] < 64);
+ assert(output[1] < 64);
+ assert(output[2] < 64);
+ assert(output[3] < 64);
if (datalength + 4 > targsize)
return (-1);
output[0] = input[0] >> 2;
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
+ assert(output[0] < 64);
+ assert(output[1] < 64);
+ assert(output[2] < 64);
if (datalength + 4 > targsize)
return (-1);
*/
int
-b64_pton(
+lutil_b64_pton(
char const *src,
u_char *target,
size_t targsize)
tarindex = 0;
while ((ch = *src++) != '\0') {
- if (isspace(ch)) /* Skip whitespace anywhere. */
+ if (isascii(ch) && isspace(ch)) /* Skip whitespace anywhere. */
continue;
if (ch == Pad64)
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
for ((void)NULL; ch != '\0'; ch = *src++)
- if (!isspace(ch))
+ if (! (isascii(ch) && isspace(ch)))
break;
/* Make sure there is another trailing = sign. */
if (ch != Pad64)
* whitespace after it?
*/
for ((void)NULL; ch != '\0'; ch = *src++)
- if (!isspace(ch))
+ if (! (isascii(ch) && isspace(ch)))
return (-1);
/*