Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
[egate.git] / ccl / cclstr.c
diff --git a/ccl/cclstr.c b/ccl/cclstr.c
new file mode 100644 (file)
index 0000000..434182a
--- /dev/null
@@ -0,0 +1,57 @@
+/* CCL string compare utilities
+ * Europagate, 1995
+ *
+ * $Log: cclstr.c,v $
+ * Revision 1.1  1995/05/11 14:03:57  adam
+ * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
+ * New variable ccl_case_sensitive, which controls whether reserved
+ * words and field names are case sensitive or not.
+ *
+ */
+#include <ctype.h>
+#include <stdio.h>
+
+#include <ccl.h>
+
+static int ccli_toupper (int c)
+{
+    return toupper (c);
+}
+
+int (*ccl_toupper)(int c) = NULL;
+
+int ccl_stricmp (const char *s1, const char *s2)
+{
+    if (!ccl_toupper)
+        ccl_toupper = ccli_toupper;
+    while (*s1 && *s2)
+    {
+        int c1, c2;
+        c1 = (*ccl_toupper)(*s1);
+        c2 = (*ccl_toupper)(*s2);
+        if (c1 != c2)
+            return c1 - c2;
+        s1++;
+        s2++;
+    }
+    return (*ccl_toupper)(*s1) - (*ccl_toupper)(*s2);
+}
+
+int ccl_memicmp (const char *s1, const char *s2, size_t n)
+{
+    if (!ccl_toupper)
+        ccl_toupper = ccli_toupper;
+    while (1)
+    {
+        int c1, c2;
+
+        c1 = (*ccl_toupper)(*s1);
+        c2 = (*ccl_toupper)(*s2);
+        if (n <= 1 || c1 != c2)
+            return c1 - c2;
+        s1++;
+        s2++;
+        --n;
+    }
+}
+