X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ccl%2Fcclqual.c;h=c28e98c4c14bdcd0a52449f2e4975512e8141a5f;hb=413b22aaa70d21104589618eb7c079b5a9cff4a2;hp=263b6ce25e4836fb0e766f993d472d7df0077d9a;hpb=d79d0168774190148ff0927cea715996ad82bc62;p=egate.git diff --git a/ccl/cclqual.c b/ccl/cclqual.c index 263b6ce..c28e98c 100644 --- a/ccl/cclqual.c +++ b/ccl/cclqual.c @@ -2,7 +2,15 @@ * Europagate, 1995 * * $Log: cclqual.c,v $ - * Revision 1.2 1995/02/14 10:25:56 adam + * Revision 1.4 1995/02/14 19:55:12 adam + * Header files ccl.h/cclp.h are gone! They have been merged an + * moved to ../include/ccl.h. + * Node kind(s) in ccl_rpn_node have changed names. + * + * Revision 1.3 1995/02/14 16:20:56 adam + * Qualifiers are read from a file now. + * + * Revision 1.2 1995/02/14 10:25:56 adam * The constructions 'qualifier rel term ...' implemented. * * Revision 1.1 1995/02/13 15:15:07 adam @@ -15,7 +23,7 @@ #include #include -#include "cclp.h" +#include struct ccl_qualifiers { struct ccl_qualifier *list; @@ -23,21 +31,32 @@ struct ccl_qualifiers { void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs) { - struct ccl_qualifier *new_qual; + struct ccl_qualifier *q; struct ccl_rpn_attr **attrp; - - assert (b); - new_qual = malloc (sizeof(*new_qual)); - assert (new_qual); - - new_qual->next = b->list; - b->list = new_qual; - - new_qual->name = malloc (strlen(name)+1); - assert (new_qual->name); - strcpy (new_qual->name, name); - attrp = &new_qual->attr_list; + assert (b); + for (q = b->list; q; q = q->next) + if (!strcmp (name, q->name)) + break; + if (!q) + { + struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual)); + assert (new_qual); + + new_qual->next = b->list; + b->list = new_qual; + + new_qual->name = malloc (strlen(name)+1); + assert (new_qual->name); + strcpy (new_qual->name, name); + attrp = &new_qual->attr_list; + } + else + { + attrp = &q->attr_list; + while (*attrp) + attrp = &(*attrp)->next; + } while (--no >= 0) { struct ccl_rpn_attr *attr; @@ -76,3 +95,85 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len) return q->attr_list; 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; + } + } + } +}