Add flag to inhibit checking for alternate certificate chains. Setting this
[openssl.git] / crypto / o_str.c
index 174db3156e0afcee93d5bf36a59879054fc4ed77..16fd4e42315022dcd5a145266d82669e5f1a6f94 100644 (file)
@@ -1,6 +1,7 @@
 /* crypto/o_str.c -*- mode:C; c-file-style: "eay" -*- */
-/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
- * project 2003.
+/*
+ * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
+ * 2003.
  */
 /* ====================================================================
  * Copyright (c) 2003 The OpenSSL Project.  All rights reserved.
@@ -10,7 +11,7 @@
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *
  */
 
-#include <o_str.h>
-#include <openssl/e_os2.h>
+#include <ctype.h>
+#include <e_os.h>
+#include "o_str.h"
+
+#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && \
+    !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_WINCE) && \
+    !defined(NETWARE_CLIB)
+# include <strings.h>
+#endif
 
 int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
-       {
-#if defined(OPENSSL_SYS_VMS)
-       while (*str1 && *str2 && n)
-               {
-               int res = toupper(*str1) - toupper(*str2);
-               if (res) return res < 0 ? -1 : 1;
-               str1++;
-               str2++;
-               n--;
-               }
-       if (n == 0)
-               return 0;
-       if (*str1)
-               return 1;
-       if (*str2)
-               return -1;
-       return 0;
-#elif defined(OPENSSL_SYS_WINDOWS)
-       return _strnicmp(str1, str2, n);
+{
+#if defined(OPENSSL_IMPLEMENTS_strncasecmp)
+    while (*str1 && *str2 && n) {
+        int res = toupper(*str1) - toupper(*str2);
+        if (res)
+            return res < 0 ? -1 : 1;
+        str1++;
+        str2++;
+        n--;
+    }
+    if (n == 0)
+        return 0;
+    if (*str1)
+        return 1;
+    if (*str2)
+        return -1;
+    return 0;
 #else
-       return strncasecmp(str1, str2, n);
+    /*
+     * Recursion hazard warning! Whenever strncasecmp is #defined as
+     * OPENSSL_strncasecmp, OPENSSL_IMPLEMENTS_strncasecmp must be defined as
+     * well.
+     */
+    return strncasecmp(str1, str2, n);
 #endif
-       }
+}
+
 int OPENSSL_strcasecmp(const char *str1, const char *str2)
-       {
-#if defined(OPENSSL_SYS_VMS)
-       return OSSL_strncasecmp(str1, str2, (size_t)-1);
-#elif defined(OPENSSL_SYS_WINDOWS)
-       return _stricmp(str1, str2);
+{
+#if defined(OPENSSL_IMPLEMENTS_strncasecmp)
+    return OPENSSL_strncasecmp(str1, str2, (size_t)-1);
 #else
-       return strcasecmp(str1, str2);
+    return strcasecmp(str1, str2);
 #endif
-       }
+}
+
+int OPENSSL_memcmp(const void *v1, const void *v2, size_t n)
+{
+    const unsigned char *c1 = v1, *c2 = v2;
+    int ret = 0;
+
+    while (n && (ret = *c1 - *c2) == 0)
+        n--, c1++, c2++;
 
+    return ret;
+}