-/* $Id: cqlutil.c,v 1.8 2005-06-25 15:46:04 adam Exp $
- Copyright (C) 1995-2005, Index Data ApS
- Index Data Aps
-
-This file is part of the YAZ toolkit.
-
-See the file LICENSE for details.
-*/
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2008 Index Data
+ * See the file LICENSE for details.
+ */
/**
* \file cqlutil.c
p->u.st.relation = nmem_strdup(nmem, relation);
p->u.st.relation_uri = 0;
p->u.st.modifiers = 0;
+ p->u.st.extra_terms = 0;
return p;
}
return p;
}
-const char *cql_uri()
+const char *cql_uri(void)
{
- return "info:srw/cql-context-set/1/cql-v1.1";
+ return "info:srw/cql-context-set/1/cql-v1.2";
}
struct cql_node *cql_apply_prefix(NMEM nmem,
const char *cp = strchr(n->u.st.index, '.');
if (prefix && cp &&
strlen(prefix) == (size_t) (cp - n->u.st.index) &&
- !memcmp(n->u.st.index, prefix, strlen(prefix)))
+ !cql_strncmp(n->u.st.index, prefix, strlen(prefix)))
{
char *nval = nmem_strdup(nmem, cp+1);
n->u.st.index_uri = nmem_strdup(nmem, uri);
const char *cp = strchr(n->u.st.relation, '.');
if (prefix && cp &&
strlen(prefix) == (size_t)(cp - n->u.st.relation) &&
- !memcmp(n->u.st.relation, prefix, strlen(prefix)))
+ !cql_strncmp(n->u.st.relation, prefix, strlen(prefix)))
{
char *nval = nmem_strdup(nmem, cp+1);
n->u.st.relation_uri = nmem_strdup(nmem, uri);
cql_node_destroy(cn->u.boolean.modifiers);
}
}
+
+int cql_strcmp(const char *s1, const char *s2)
+{
+ while (*s1 && *s2)
+ {
+ int c1 = *s1++;
+ int c2 = *s2++;
+ if (c1 >= 'A' && c1 <= 'Z')
+ c1 = c1 + ('a' - 'A');
+ if (c2 >= 'A' && c2 <= 'Z')
+ c2 = c2 + ('a' - 'A');
+ if (c1 != c2)
+ return c1 - c2;
+ }
+ return *s1 - *s2;
+}
+
+int cql_strncmp(const char *s1, const char *s2, size_t n)
+{
+ while (*s1 && *s2 && n)
+ {
+ int c1 = *s1++;
+ int c2 = *s2++;
+ if (c1 >= 'A' && c1 <= 'Z')
+ c1 = c1 + ('a' - 'A');
+ if (c2 >= 'A' && c2 <= 'Z')
+ c2 = c2 + ('a' - 'A');
+ if (c1 != c2)
+ return c1 - c2;
+ --n;
+ }
+ if (!n)
+ return 0;
+ return *s1 - *s2;
+}
+
/*
* Local variables:
* c-basic-offset: 4