X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcclqual.c;h=24ea31ca4cb0c058b01ddd41c2bbd83900097bb0;hp=b68f70d62233e0e6a47205d2f5203e82482c198a;hb=62fd62f25a6893d042c4c87f8c770929fd8cf95d;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9 diff --git a/src/cclqual.c b/src/cclqual.c index b68f70d..24ea31c 100644 --- a/src/cclqual.c +++ b/src/cclqual.c @@ -41,10 +41,14 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * */ +/** + * \file cclqual.c + * \brief Implements CCL qualifier utilities + */ /* CCL qualifiers * Europagate, 1995 * - * $Id: cclqual.c,v 1.1 2003-10-27 12:21:30 adam Exp $ + * $Id: cclqual.c,v 1.3 2005-06-25 15:46:03 adam Exp $ * * Old Europagate Log: * @@ -84,14 +88,14 @@ #include -/* Definition of CCL_bibset pointer */ +/** Definition of CCL_bibset pointer */ struct ccl_qualifiers { struct ccl_qualifier *list; struct ccl_qualifier_special *special; }; -/* CCL Qualifier special */ +/** CCL Qualifier special */ struct ccl_qualifier_special { char *name; char *value; @@ -116,25 +120,25 @@ void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v) const char *pe; for (p = bibset->special; p && strcmp(p->name, n); p = p->next) - ; + ; if (p) - xfree (p->value); + xfree (p->value); else { - p = (struct ccl_qualifier_special *) xmalloc (sizeof(*p)); - p->name = ccl_strdup (n); - p->value = 0; - p->next = bibset->special; - bibset->special = p; + p = (struct ccl_qualifier_special *) xmalloc (sizeof(*p)); + p->name = ccl_strdup (n); + p->value = 0; + p->next = bibset->special; + bibset->special = p; } while (strchr(" \t", *v)) - ++v; + ++v; for (pe = v + strlen(v); pe != v; --pe) - if (!strchr(" \n\r\t", pe[-1])) - break; + if (!strchr(" \n\r\t", pe[-1])) + break; p->value = (char*) xmalloc (pe - v + 1); if (pe - v) - memcpy (p->value, v, pe - v); + memcpy (p->value, v, pe - v); p->value[pe - v] = '\0'; } @@ -162,7 +166,7 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names) int i, len; struct ccl_qualifier *q; for (q = b->list; q && strcmp(q->name, n); q = q->next) - ; + ; if (q) return ; q = (struct ccl_qualifier *) xmalloc (sizeof(*q)); @@ -184,7 +188,7 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names) } } -/* +/** * ccl_qual_add: Add qualifier to Bibset. If qualifier already * exists, then attributes are appendend to old * definition. @@ -195,8 +199,8 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names) */ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, - int *type_ar, int *value_ar, char **svalue_ar, - char **attsets) + int *type_ar, int *value_ar, char **svalue_ar, + char **attsets) { struct ccl_qualifier *q; struct ccl_rpn_attr **attrp; @@ -208,7 +212,7 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, if (!q) { struct ccl_qualifier *new_qual = - (struct ccl_qualifier *)xmalloc (sizeof(*new_qual)); + (struct ccl_qualifier *)xmalloc (sizeof(*new_qual)); ccl_assert (new_qual); new_qual->next = b->list; @@ -234,27 +238,27 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, attr = (struct ccl_rpn_attr *)xmalloc (sizeof(*attr)); ccl_assert (attr); - attr->set = *attsets++; + attr->set = *attsets++; attr->type = *type_ar++; - if (*svalue_ar) - { - attr->kind = CCL_RPN_ATTR_STRING; - attr->value.str = *svalue_ar; - } - else - { - attr->kind = CCL_RPN_ATTR_NUMERIC; - attr->value.numeric = *value_ar; - } - svalue_ar++; - value_ar++; + if (*svalue_ar) + { + attr->kind = CCL_RPN_ATTR_STRING; + attr->value.str = *svalue_ar; + } + else + { + attr->kind = CCL_RPN_ATTR_NUMERIC; + attr->value.numeric = *value_ar; + } + svalue_ar++; + value_ar++; *attrp = attr; attrp = &attr->next; } *attrp = NULL; } -/* +/** * ccl_qual_mk: Make new (empty) bibset. * return: empty bibset. */ @@ -267,7 +271,7 @@ CCL_bibset ccl_qual_mk (void) return b; } -/* +/** * ccl_qual_rm: Delete bibset. * b: pointer to bibset */ @@ -283,32 +287,32 @@ void ccl_qual_rm (CCL_bibset *b) struct ccl_rpn_attr *attr, *attr1; for (attr = q->attr_list; attr; attr = attr1) - { - attr1 = attr->next; - if (attr->set) - xfree(attr->set); - if (attr->kind == CCL_RPN_ATTR_STRING) - xfree(attr->value.str); - xfree (attr); - } + { + attr1 = attr->next; + if (attr->set) + xfree(attr->set); + if (attr->kind == CCL_RPN_ATTR_STRING) + xfree(attr->value.str); + xfree (attr); + } q1 = q->next; - xfree (q->name); + xfree (q->name); if (q->sub) xfree (q->sub); - xfree (q); + xfree (q); } for (sp = (*b)->special; sp; sp = sp1) { - sp1 = sp->next; - xfree (sp->name); - xfree (sp->value); - xfree (sp); + sp1 = sp->next; + xfree (sp->name); + xfree (sp->value); + xfree (sp); } xfree (*b); *b = NULL; } -/* +/** * ccl_qual_search: Search for qualifier in bibset. * b: Bibset * name: Name of qualifier to search for (need no null-termination) @@ -316,7 +320,7 @@ void ccl_qual_rm (CCL_bibset *b) * return: Attribute info. NULL if not found. */ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, - const char *name, size_t len, + const char *name, size_t len, int seq) { struct ccl_qualifier *q; @@ -325,11 +329,11 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, ccl_assert (cclp); if (!cclp->bibset) - return NULL; + return NULL; aliases = ccl_qual_search_special(cclp->bibset, "case"); if (aliases) - case_sensitive = atoi(aliases); + case_sensitive = atoi(aliases); for (q = cclp->bibset->list; q; q = q->next) if (strlen(q->name) == len) @@ -358,14 +362,22 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, } const char *ccl_qual_search_special (CCL_bibset b, - const char *name) + const char *name) { struct ccl_qualifier_special *q; if (!b) - return 0; + return 0; for (q = b->special; q && strcmp(q->name, name); q = q->next) - ; + ; if (q) - return q->value; + return q->value; return 0; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +