5 * Revision 1.3 1995/02/14 16:20:56 adam
6 * Qualifiers are read from a file now.
8 * Revision 1.2 1995/02/14 10:25:56 adam
9 * The constructions 'qualifier rel term ...' implemented.
11 * Revision 1.1 1995/02/13 15:15:07 adam
12 * Added handling of qualifiers. Not finished yet.
23 struct ccl_qualifiers {
24 struct ccl_qualifier *list;
27 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
29 struct ccl_qualifier *q;
30 struct ccl_rpn_attr **attrp;
33 for (q = b->list; q; q = q->next)
34 if (!strcmp (name, q->name))
38 struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
41 new_qual->next = b->list;
44 new_qual->name = malloc (strlen(name)+1);
45 assert (new_qual->name);
46 strcpy (new_qual->name, name);
47 attrp = &new_qual->attr_list;
51 attrp = &q->attr_list;
53 attrp = &(*attrp)->next;
57 struct ccl_rpn_attr *attr;
59 attr = malloc (sizeof(*attr));
61 attr->type = *pairs++;
62 attr->value = *pairs++;
69 CCL_bibset ccl_qual_mk (void)
71 CCL_bibset b = malloc (sizeof(*b));
77 void ccl_qual_rm (CCL_bibset *b)
83 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len)
85 struct ccl_qualifier *q;
88 for (q = b->list; q; q = q->next)
89 if (strlen(q->name) == len && !memcmp (name, q->name, len))
94 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
102 while (fgets (line, 255, inf))
107 if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
117 if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
120 if (!(split = strchr (qual_des, '=')))
125 qual_type = qual_des;
129 if ((split = strchr (qual_value, ',')))
131 pair[1] = atoi (qual_value);
132 switch (qual_type[0])
135 pair[0] = CCL_BIB1_USE;
138 pair[0] = CCL_BIB1_REL;
139 if (!strcmp (qual_value, "o"))
140 pair[1] = CCL_BIB1_REL_ORDER;
143 pair[0] = CCL_BIB1_POS;
146 pair[0] = CCL_BIB1_STR;
147 if (!strcmp (qual_value, "pw"))
148 pair[1] = CCL_BIB1_STR_WP;
151 pair[0] = CCL_BIB1_TRU;
152 if (!strcmp (qual_value, "l"))
153 pair[1] = CCL_BIB1_TRU_CAN_LEFT;
154 else if (!strcmp (qual_value, "r"))
155 pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
156 else if (!strcmp (qual_value, "b"))
157 pair[1] = CCL_BIB1_TRU_CAN_BOTH;
158 else if (!strcmp (qual_value, "n"))
159 pair[1] = CCL_BIB1_TRU_CAN_NONE;
162 pair[0] = CCL_BIB1_COM;
165 pair[0] = atoi (qual_type);
167 printf ("adding %s t=%d, v=%d\n", qual_name, pair[0], pair[1]);
168 ccl_qual_add (bibset, qual_name, 1, pair);