X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcclqual.c;h=8f9a4e8009e4cc01e4bd7c29516406611fba3c34;hp=f5fcb7cb71c4c83a3a034f1c030ce5fbb41096d0;hb=323805b6779bcf1befdc7cdd7f10c23b06885e0d;hpb=0c46d2e66bdeea1600e700124a81a5d0a65d349e diff --git a/src/cclqual.c b/src/cclqual.c index f5fcb7c..8f9a4e8 100644 --- a/src/cclqual.c +++ b/src/cclqual.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -104,6 +104,19 @@ void ccl_qual_add_special(CCL_bibset bibset, const char *n, const char *cp) yaz_tok_parse_destroy(tp); } +static struct ccl_qualifier *ccl_qual_new(CCL_bibset b, const char *name) +{ + struct ccl_qualifier *q; + q = (struct ccl_qualifier *)xmalloc(sizeof(*q)); + ccl_assert(q); + q->next = b->list; + b->list = q; + q->name = xstrdup(name); + q->attr_list = 0; + q->no_sub = 0; + q->sub = 0; + return q; +} /** \brief adds specifies qualifier aliases @@ -131,7 +144,11 @@ void ccl_qual_add_combi(CCL_bibset b, const char *n, const char **names) q->sub = (struct ccl_qualifier **) xmalloc(sizeof(*q->sub) * (1+q->no_sub)); for (i = 0; names[i]; i++) + { q->sub[i] = ccl_qual_lookup(b, names[i], strlen(names[i])); + if (!q->sub[i]) + q->sub[i] = ccl_qual_new(b, names[i]); + } } /** \brief adds specifies attributes for qualifier @@ -157,19 +174,7 @@ void ccl_qual_add_set(CCL_bibset b, const char *name, int no, if (!strcmp(name, q->name)) break; if (!q) - { - q = (struct ccl_qualifier *)xmalloc(sizeof(*q)); - ccl_assert(q); - - q->next = b->list; - b->list = q; - - q->name = xstrdup(name); - q->attr_list = 0; - - q->no_sub = 0; - q->sub = 0; - } + q = ccl_qual_new(b, name); attrp = &q->attr_list; while (*attrp) attrp = &(*attrp)->next; @@ -379,6 +384,15 @@ struct ccl_rpn_attr *ccl_qual_get_attr(ccl_qualifier_t q) return q->attr_list; } +struct ccl_rpn_attr *ccl_parser_qual_search(CCL_parser cclp, const char *name, + size_t name_len) +{ + ccl_qualifier_t q = ccl_qual_search(cclp, name, name_len, 0); + if (q) + return q->attr_list; + return 0; +} + const char *ccl_qual_get_name(ccl_qualifier_t q) { return q->name;