-/* $OpenBSD: base64.c,v 1.3 1997/11/08 20:46:55 deraadt Exp $ */
+/* $OpenBSD: base64.c,v 1.4 2002/01/02 23:00:10 deraadt Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-#include "config.h"
+/* OPENBSD ORIGINAL: lib/libc/net/base64.c */
-#if !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP)
+#include "includes.h"
+
+#if (!defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP)) || (!defined(HAVE_B64_PTON) && !defined(HAVE___B64_PTON))
#include <sys/types.h>
#include <sys/param.h>
#include "base64.h"
+/* XXX abort illegal in library */
#define Assert(Cond) if (!(Cond)) abort()
static const char Base64[] =
characters followed by one "=" padding character.
*/
+#if !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP)
int
b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize)
{
size_t datalength = 0;
u_char input[3];
u_char output[4];
- int i;
+ u_int i;
while (2 < srclength) {
input[0] = *src++;
target[datalength] = '\0'; /* Returned value doesn't count \0. */
return (datalength);
}
+#endif /* !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP) */
+
+#if !defined(HAVE_B64_PTON) && !defined(HAVE___B64_PTON)
/* skips all whitespace anywhere.
converts characters, four at a time, starting at (or after)
int
b64_pton(char const *src, u_char *target, size_t targsize)
{
- int tarindex, state, ch;
+ u_int tarindex, state;
+ int ch;
char *pos;
state = 0;
return (tarindex);
}
-#endif /* !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP) */
+#endif /* !defined(HAVE_B64_PTON) && !defined(HAVE___B64_PTON) */
+#endif