X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ccl%2Fcclqual.c;h=8ccc6434eed36b1670c6396ce9e3267867847128;hb=db9768c3988f9536c898250880c13923a2dde32d;hp=c8be663601bd2d28ad6a789b4a872e03808d9843;hpb=c126b2a625462f95475f00efdfdf9ce41a0e9c79;p=yaz-moved-to-github.git diff --git a/ccl/cclqual.c b/ccl/cclqual.c index c8be663..8ccc643 100644 --- a/ccl/cclqual.c +++ b/ccl/cclqual.c @@ -45,7 +45,14 @@ * Europagate, 1995 * * $Log: cclqual.c,v $ - * Revision 1.13 2000-01-31 13:15:21 adam + * Revision 1.15 2001-03-07 13:24:40 adam + * Member and_not in Z_Operator is kept for backwards compatibility. + * Added support for definition of CCL operators in field spec file. + * + * Revision 1.14 2000/11/16 09:58:02 adam + * Implemented local AttributeSet setting for CCL field maps. + * + * Revision 1.13 2000/01/31 13:15:21 adam * Removed uses of assert(3). Cleanup of ODR. CCL parser update so * that some characters are not surrounded by spaces in resulting term. * ILL-code updates. @@ -116,8 +123,46 @@ /* Definition of CCL_bibset pointer */ struct ccl_qualifiers { struct ccl_qualifier *list; + struct ccl_qualifier_special *special; +}; + + +/* CCL Qualifier special */ +struct ccl_qualifier_special { + char *name; + char *value; + struct ccl_qualifier_special *next; }; +void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v) +{ + struct ccl_qualifier_special *p; + const char *pe; + + for (p = bibset->special; p && strcmp(p->name, n); p = p->next) + ; + if (p) + free (p->value); + else + { + p = (struct ccl_qualifier_special *) malloc (sizeof(*p)); + p->name = ccl_strdup (n); + p->value = 0; + p->next = bibset->special; + bibset->special = p; + } + while (strchr(" \t", *v)) + ++v; + for (pe = v + strlen(v); pe != v; --pe) + if (!strchr(" \n\r\t", pe[-1])) + break; + p->value = (char*) malloc (pe - v + 1); + if (pe - v) + memcpy (p->value, v, pe - v); + p->value[pe - v] = '\0'; +} + + /* * ccl_qual_add: Add qualifier to Bibset. If qualifier already * exists, then attributes are appendend to old @@ -127,7 +172,8 @@ struct ccl_qualifiers { * pairs: Attributes. pairs[0] first type, pair[1] first value, * ... pair[2*no-2] last type, pair[2*no-1] last value. */ -void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) +void ccl_qual_add_set (CCL_bibset b, const char *name, int no, int *pairs, + char **attsets) { struct ccl_qualifier *q; struct ccl_rpn_attr **attrp; @@ -162,6 +208,7 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) attr = (struct ccl_rpn_attr *)malloc (sizeof(*attr)); ccl_assert (attr); + attr->set = *attsets++; attr->type = *pairs++; attr->value = *pairs++; *attrp = attr; @@ -179,6 +226,7 @@ CCL_bibset ccl_qual_mk (void) CCL_bibset b = (CCL_bibset)malloc (sizeof(*b)); ccl_assert (b); b->list = NULL; + b->special = NULL; return b; } @@ -189,6 +237,7 @@ CCL_bibset ccl_qual_mk (void) void ccl_qual_rm (CCL_bibset *b) { struct ccl_qualifier *q, *q1; + struct ccl_qualifier_special *sp, *sp1; if (!*b) return; @@ -199,12 +248,21 @@ void ccl_qual_rm (CCL_bibset *b) for (attr = q->attr_list; attr; attr = attr1) { attr1 = attr->next; + if (attr->set) + free (attr->set); free (attr); } q1 = q->next; free (q->name); free (q); } + for (sp = (*b)->special; sp; sp = sp1) + { + sp1 = sp->next; + free (sp->name); + free (sp->value); + free (sp); + } free (*b); *b = NULL; } @@ -241,3 +299,15 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, return NULL; } +const char *ccl_qual_search_special (CCL_bibset b, + const char *name) +{ + struct ccl_qualifier_special *q; + if (!b) + return 0; + for (q = b->special; q && strcmp(q->name, name); q = q->next) + ; + if (q) + return q->value; + return 0; +}