5 * Revision 1.1 1995-04-10 10:28:20 quinn
8 * Revision 1.6 1995/02/23 08:32:00 adam
11 * Revision 1.4 1995/02/14 19:55:12 adam
12 * Header files ccl.h/cclp.h are gone! They have been merged an
13 * moved to ../include/ccl.h.
14 * Node kind(s) in ccl_rpn_node have changed names.
16 * Revision 1.3 1995/02/14 16:20:56 adam
17 * Qualifiers are read from a file now.
19 * Revision 1.2 1995/02/14 10:25:56 adam
20 * The constructions 'qualifier rel term ...' implemented.
22 * Revision 1.1 1995/02/13 15:15:07 adam
23 * Added handling of qualifiers. Not finished yet.
34 struct ccl_qualifiers {
35 struct ccl_qualifier *list;
38 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
40 struct ccl_qualifier *q;
41 struct ccl_rpn_attr **attrp;
44 for (q = b->list; q; q = q->next)
45 if (!strcmp (name, q->name))
49 struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
52 new_qual->next = b->list;
55 new_qual->name = malloc (strlen(name)+1);
56 assert (new_qual->name);
57 strcpy (new_qual->name, name);
58 attrp = &new_qual->attr_list;
62 attrp = &q->attr_list;
64 attrp = &(*attrp)->next;
68 struct ccl_rpn_attr *attr;
70 attr = malloc (sizeof(*attr));
72 attr->type = *pairs++;
73 attr->value = *pairs++;
80 CCL_bibset ccl_qual_mk (void)
82 CCL_bibset b = malloc (sizeof(*b));
88 void ccl_qual_rm (CCL_bibset *b)
94 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len)
96 struct ccl_qualifier *q;
99 for (q = b->list; q; q = q->next)
100 if (strlen(q->name) == len && !memcmp (name, q->name, len))
105 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
113 while (fgets (line, 255, inf))
118 if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
128 if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
131 if (!(split = strchr (qual_des, '=')))
136 qual_type = qual_des;
140 if ((split = strchr (qual_value, ',')))
142 pair[1] = atoi (qual_value);
143 switch (qual_type[0])
146 pair[0] = CCL_BIB1_USE;
149 pair[0] = CCL_BIB1_REL;
150 if (!strcmp (qual_value, "o"))
151 pair[1] = CCL_BIB1_REL_ORDER;
154 pair[0] = CCL_BIB1_POS;
157 pair[0] = CCL_BIB1_STR;
158 if (!strcmp (qual_value, "pw"))
159 pair[1] = CCL_BIB1_STR_WP;
162 pair[0] = CCL_BIB1_TRU;
163 if (!strcmp (qual_value, "l"))
164 pair[1] = CCL_BIB1_TRU_CAN_LEFT;
165 else if (!strcmp (qual_value, "r"))
166 pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
167 else if (!strcmp (qual_value, "b"))
168 pair[1] = CCL_BIB1_TRU_CAN_BOTH;
169 else if (!strcmp (qual_value, "n"))
170 pair[1] = CCL_BIB1_TRU_CAN_NONE;
173 pair[0] = CCL_BIB1_COM;
176 pair[0] = atoi (qual_type);
178 ccl_qual_add (bibset, qual_name, 1, pair);