X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcqlutil.c;h=7dba5a766b733ffbd29f395d33d1d2ee92d9d603;hb=b756b711841bac38e5b69baa51939ca9e1c01adb;hp=75505351fa550ba8a13987be131180a418f418c0;hpb=8d691989077a0addcbd840d769dce6700f3d9622;p=yaz-moved-to-github.git diff --git a/src/cqlutil.c b/src/cqlutil.c index 7550535..7dba5a7 100644 --- a/src/cqlutil.c +++ b/src/cqlutil.c @@ -1,16 +1,14 @@ -/* $Id: cqlutil.c,v 1.11 2007-01-03 08:42:15 adam Exp $ - Copyright (C) 1995-2007, 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-2011 Index Data + * See the file LICENSE for details. + */ /** * \file cqlutil.c * \brief Implements CQL tree node utilities. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -68,6 +66,7 @@ struct cql_node *cql_node_mk_sc(NMEM nmem, 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; } @@ -84,9 +83,22 @@ struct cql_node *cql_node_mk_boolean(NMEM nmem, const char *op) return p; } +struct cql_node *cql_node_mk_sort(NMEM nmem, const char *index, + struct cql_node *modifiers) +{ + struct cql_node *p = (struct cql_node *) nmem_malloc(nmem, sizeof(*p)); + p->which = CQL_NODE_SORT; + p->u.sort.index = 0; + if (index) + p->u.sort.index = nmem_strdup(nmem, index); + p->u.sort.modifiers = modifiers; + p->u.sort.next = 0; + return p; +} + 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, @@ -145,6 +157,11 @@ void cql_node_destroy(struct cql_node *cn) cql_node_destroy(cn->u.boolean.left); cql_node_destroy(cn->u.boolean.right); cql_node_destroy(cn->u.boolean.modifiers); + break; + case CQL_NODE_SORT: + cql_node_destroy(cn->u.sort.search); + cql_node_destroy(cn->u.sort.next); + cql_node_destroy(cn->u.sort.modifiers); } } @@ -186,6 +203,7 @@ int cql_strncmp(const char *s1, const char *s2, size_t n) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab