-<!-- $Id: introduction.xml,v 1.18 2004-02-05 11:55:56 adam Exp $ -->
+<!-- $Id: introduction.xml,v 1.19 2005-06-27 22:03:59 adam Exp $ -->
<chapter id="introduction"><title>Introduction</title>
<para>
&yaz; is a C/C++ library for information retrieval applications
using the Z39.50/SRW/SRU protocols for information retrieval.
</para>
-
+
<para>
Properties of &yaz;:
<itemizedlist>
-/* $Id: cql.h,v 1.12 2005-06-25 15:46:02 adam Exp $
+/* $Id: cql.h,v 1.13 2005-06-27 22:03:59 adam Exp $
Copyright (C) 1995-2005, Index Data ApS
Index Data Aps
YAZ_EXPORT
const char *cql_uri();
+/**
+ * Compares two CQL strings (for relations, operators, etc)
+ * (unfortunately defined as case-insensitive unlike XML etc)
+ */
+YAZ_EXPORT
+int cql_strcmp(const char *s1, const char *s2);
+
+/**
+ * Compares two CQL strings at most n bytes
+ * (unfortunately defined as case-insensitive unlike XML etc)
+ */
+YAZ_EXPORT
+int cql_strncmp(const char *s1, const char *s2, size_t n);
+
YAZ_END_CDECL
#endif
-/* $Id: cql.y,v 1.8 2004-11-01 20:13:02 adam Exp $
+/* $Id: cql.y,v 1.9 2005-06-27 22:03:59 adam Exp $
Copyright (C) 2002-2004
Index Data Aps
#endif
if (c != 0)
cp->ungetbyte(c, cp->client_data);
- if (!strcmp(lval->buf, "and"))
+ if (!cql_strcmp(lval->buf, "and"))
return AND;
- if (!strcmp(lval->buf, "or"))
+ if (!cql_strcmp(lval->buf, "or"))
return OR;
- if (!strcmp(lval->buf, "not"))
+ if (!cql_strcmp(lval->buf, "not"))
return NOT;
- if (!strncmp(lval->buf, "prox", 4))
+ if (!cql_strcmp(lval->buf, "prox"))
return PROX;
}
return TERM;
-/* $Id: cqltransform.c,v 1.15 2005-06-25 15:46:03 adam Exp $
+/* $Id: cqltransform.c,v 1.16 2005-06-27 22:03:59 adam Exp $
Copyright (C) 1995-2005, Index Data ApS
Index Data Aps
for (e = ct->entry; e; e = e->next)
{
- if (!strcmp(e->pattern, pattern))
+ if (!cql_strcmp(e->pattern, pattern))
return e->value;
}
return 0;
if (ns)
{
if (!strcmp(ns, cql_uri())
- && cn->u.st.index && !strcmp(cn->u.st.index, "resultSet"))
+ && cn->u.st.index && !cql_strcmp(cn->u.st.index, "resultSet"))
{
(*pr)("@set \"", client_data);
(*pr)(cn->u.st.term, client_data);
ct->addinfo = 0;
}
}
- if (cn->u.st.relation && !strcmp(cn->u.st.relation, "="))
+ if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "="))
cql_pr_attr(ct, "relation", "eq", "scr",
pr, client_data, 19);
- else if (cn->u.st.relation && !strcmp(cn->u.st.relation, "<="))
+ else if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "<="))
cql_pr_attr(ct, "relation", "le", "scr",
pr, client_data, 19);
- else if (cn->u.st.relation && !strcmp(cn->u.st.relation, ">="))
+ else if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, ">="))
cql_pr_attr(ct, "relation", "ge", "scr",
pr, client_data, 19);
else
}
cql_pr_attr(ct, "structure", cn->u.st.relation, 0,
pr, client_data, 24);
- if (cn->u.st.relation && !strcmp(cn->u.st.relation, "all"))
+ if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "all"))
{
emit_wordlist(ct, cn, pr, client_data, "and");
}
- else if (cn->u.st.relation && !strcmp(cn->u.st.relation, "any"))
+ else if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "any"))
{
emit_wordlist(ct, cn, pr, client_data, "or");
}
for (e = ct->entry; e ; e = e->next)
{
- if (!memcmp(e->pattern, "set.", 4))
+ if (!cql_strncmp(e->pattern, "set.", 4))
cql_apply_prefix(nmem, cn, e->pattern+4, e->value);
- else if (!strcmp(e->pattern, "set"))
+ else if (!cql_strcmp(e->pattern, "set"))
cql_apply_prefix(nmem, cn, 0, e->value);
}
cql_transform_r (ct, cn, pr, client_data);
-/* $Id: cqlutil.c,v 1.8 2005-06-25 15:46:04 adam Exp $
+/* $Id: cqlutil.c,v 1.9 2005-06-27 22:03:59 adam Exp $
Copyright (C) 1995-2005, Index Data ApS
Index Data Aps
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