X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ccl%2Fcclqual.c;fp=ccl%2Fcclqual.c;h=117702d48fdf02630184e78dd2f9a0c1c0d44544;hb=db407de046272b028cf37338c9427846d97dfcf3;hp=9180f9f763ba1f3465d4dd319f141655dc86ed63;hpb=cca0f6ebd5c2e0aafab3c12b48667c317a1e5d4c;p=egate.git diff --git a/ccl/cclqual.c b/ccl/cclqual.c index 9180f9f..117702d 100644 --- a/ccl/cclqual.c +++ b/ccl/cclqual.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: cclqual.c,v $ - * Revision 1.6 1995/02/23 08:32:00 adam + * Revision 1.7 1995/04/17 09:31:46 adam + * Improved handling of qualifiers. Aliases or reserved words. + * + * Revision 1.6 1995/02/23 08:32:00 adam * Changed header. * * Revision 1.4 1995/02/14 19:55:12 adam @@ -28,10 +31,20 @@ #include +/* Definition of CCL_bibset pointer */ struct ccl_qualifiers { struct ccl_qualifier *list; }; +/* + * ccl_qual_add: Add qualifier to Bibset. If qualifier already + * exists, then attributes are appendend to old + * definition. + * name: name of qualifier + * no: No of attribute type/value pairs. + * 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) { struct ccl_qualifier *q; @@ -74,6 +87,10 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) *attrp = NULL; } +/* + * ccl_qual_mk: Make new (empty) bibset. + * return: empty bibset. + */ CCL_bibset ccl_qual_mk (void) { CCL_bibset b = malloc (sizeof(*b)); @@ -82,12 +99,39 @@ CCL_bibset ccl_qual_mk (void) return b; } +/* + * ccl_qual_rm: Delete bibset. + * b: pointer to bibset + */ void ccl_qual_rm (CCL_bibset *b) { - assert (*b); + struct ccl_qualifier *q, *q1; + + if (!*b) + return; + for (q = (*b)->list; q; q = q1) + { + struct ccl_rpn_attr *attr, *attr1; + + for (attr = q->attr_list; attr; attr = attr1) + { + attr1 = attr->next; + free (attr); + } + q1 = q->next; + free (q); + } + free (*b); *b = NULL; } +/* + * ccl_qual_search: Search for qualifier in bibset. + * b: Bibset + * name: Name of qualifier to search for (need no null-termination) + * len: Length of name. + * return: Attribute info. NULL if not found. + */ struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len) { struct ccl_qualifier *q; @@ -99,84 +143,3 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len) return NULL; } -void ccl_qual_file (CCL_bibset bibset, FILE *inf) -{ - char line[256]; - char *cp; - char qual_name[128]; - char qual_des[128]; - int no_scan; - - while (fgets (line, 255, inf)) - { - cp = line; - if (*cp == '#') - continue; - if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1) - continue; - cp += no_scan; - while (1) - { - int pair[2]; - char *qual_type; - char *qual_value; - char *split; - - if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1) - break; - - if (!(split = strchr (qual_des, '='))) - break; - cp += no_scan; - - *split++ = '\0'; - qual_type = qual_des; - qual_value = split; - while (1) - { - if ((split = strchr (qual_value, ','))) - *split++ = '\0'; - pair[1] = atoi (qual_value); - switch (qual_type[0]) - { - case 'u': - pair[0] = CCL_BIB1_USE; - break; - case 'r': - pair[0] = CCL_BIB1_REL; - if (!strcmp (qual_value, "o")) - pair[1] = CCL_BIB1_REL_ORDER; - break; - case 'p': - pair[0] = CCL_BIB1_POS; - break; - case 's': - pair[0] = CCL_BIB1_STR; - if (!strcmp (qual_value, "pw")) - pair[1] = CCL_BIB1_STR_WP; - break; - case 't': - pair[0] = CCL_BIB1_TRU; - if (!strcmp (qual_value, "l")) - pair[1] = CCL_BIB1_TRU_CAN_LEFT; - else if (!strcmp (qual_value, "r")) - pair[1] = CCL_BIB1_TRU_CAN_RIGHT; - else if (!strcmp (qual_value, "b")) - pair[1] = CCL_BIB1_TRU_CAN_BOTH; - else if (!strcmp (qual_value, "n")) - pair[1] = CCL_BIB1_TRU_CAN_NONE; - break; - case 'c': - pair[0] = CCL_BIB1_COM; - break; - default: - pair[0] = atoi (qual_type); - } - ccl_qual_add (bibset, qual_name, 1, pair); - if (!split) - break; - qual_value = split; - } - } - } -}