]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/base64.c
All implementations of lutil_lockf (aka ldap_lockf) block until
[openldap] / libraries / liblutil / base64.c
index 01ead24322caefac0ad3bb9004a569ee4496cf02..96a6b284223b275da67b70ef75d22fdbfc1ff231 100644 (file)
  * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
  */
 
+#include "portable.h"
+
 #include <stdlib.h>
 #include <stddef.h>
-#include <string.h>
-#include <sys/types.h>
+#include <ctype.h>
+
+#include <ac/string.h>
+
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
 
-#include <lutil.h>
+#include "lutil.h"
 
 #define Assert(Cond) if (!(Cond)) abort()
 
@@ -121,7 +127,7 @@ static const char Pad64 = '=';
    */
 
 int
-b64_ntop(
+lutil_b64_ntop(
        u_char const *src,
        size_t srclength,
        char *target,
@@ -192,7 +198,7 @@ b64_ntop(
  */
 
 int
-b64_pton(
+lutil_b64_pton(
        char const *src,
        u_char *target, 
        size_t targsize)
@@ -204,7 +210,7 @@ b64_pton(
        tarindex = 0;
 
        while ((ch = *src++) != '\0') {
-               if (isspace(ch))        /* Skip whitespace anywhere. */
+               if (isascii(ch) && isspace(ch)) /* Skip whitespace anywhere. */
                        continue;
 
                if (ch == Pad64)
@@ -274,7 +280,7 @@ b64_pton(
                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)
@@ -289,7 +295,7 @@ b64_pton(
                         * whitespace after it?
                         */
                        for ((void)NULL; ch != '\0'; ch = *src++)
-                               if (!isspace(ch))
+                               if (! (isascii(ch) && isspace(ch)))
                                        return (-1);
 
                        /*