5 * Revision 1.3 1995-09-29 17:12:00 quinn
8 * Revision 1.2 1995/09/27 15:02:44 quinn
9 * Modified function heads & prototypes.
11 * Revision 1.1 1995/04/10 10:28:20 quinn
14 * Revision 1.6 1995/02/23 08:32:00 adam
17 * Revision 1.4 1995/02/14 19:55:12 adam
18 * Header files ccl.h/cclp.h are gone! They have been merged an
19 * moved to ../include/ccl.h.
20 * Node kind(s) in ccl_rpn_node have changed names.
22 * Revision 1.3 1995/02/14 16:20:56 adam
23 * Qualifiers are read from a file now.
25 * Revision 1.2 1995/02/14 10:25:56 adam
26 * The constructions 'qualifier rel term ...' implemented.
28 * Revision 1.1 1995/02/13 15:15:07 adam
29 * Added handling of qualifiers. Not finished yet.
40 struct ccl_qualifiers {
41 struct ccl_qualifier *list;
44 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
46 struct ccl_qualifier *q;
47 struct ccl_rpn_attr **attrp;
50 for (q = b->list; q; q = q->next)
51 if (!strcmp (name, q->name))
55 struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
58 new_qual->next = b->list;
61 new_qual->name = malloc (strlen(name)+1);
62 assert (new_qual->name);
63 strcpy (new_qual->name, name);
64 attrp = &new_qual->attr_list;
68 attrp = &q->attr_list;
70 attrp = &(*attrp)->next;
74 struct ccl_rpn_attr *attr;
76 attr = malloc (sizeof(*attr));
78 attr->type = *pairs++;
79 attr->value = *pairs++;
86 CCL_bibset ccl_qual_mk (void)
88 CCL_bibset b = malloc (sizeof(*b));
94 void ccl_qual_rm (CCL_bibset *b)
100 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len)
102 struct ccl_qualifier *q;
105 for (q = b->list; q; q = q->next)
106 if (strlen(q->name) == len && !memcmp (name, q->name, len))
111 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
119 while (fgets (line, 255, inf))
124 if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
134 if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
137 if (!(split = strchr (qual_des, '=')))
142 qual_type = qual_des;
146 if ((split = strchr (qual_value, ',')))
148 pair[1] = atoi (qual_value);
149 switch (qual_type[0])
152 pair[0] = CCL_BIB1_USE;
155 pair[0] = CCL_BIB1_REL;
156 if (!strcmp (qual_value, "o"))
157 pair[1] = CCL_BIB1_REL_ORDER;
160 pair[0] = CCL_BIB1_POS;
163 pair[0] = CCL_BIB1_STR;
164 if (!strcmp (qual_value, "pw"))
165 pair[1] = CCL_BIB1_STR_WP;
168 pair[0] = CCL_BIB1_TRU;
169 if (!strcmp (qual_value, "l"))
170 pair[1] = CCL_BIB1_TRU_CAN_LEFT;
171 else if (!strcmp (qual_value, "r"))
172 pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
173 else if (!strcmp (qual_value, "b"))
174 pair[1] = CCL_BIB1_TRU_CAN_BOTH;
175 else if (!strcmp (qual_value, "n"))
176 pair[1] = CCL_BIB1_TRU_CAN_NONE;
179 pair[0] = CCL_BIB1_COM;
182 pair[0] = atoi (qual_type);
184 ccl_qual_add (bibset, qual_name, 1, pair);