5 * Revision 1.4 1995-11-01 13:54:21 quinn
8 * Revision 1.3 1995/09/29 17:12:00 quinn
11 * Revision 1.2 1995/09/27 15:02:44 quinn
12 * Modified function heads & prototypes.
14 * Revision 1.1 1995/04/10 10:28:20 quinn
17 * Revision 1.6 1995/02/23 08:32:00 adam
20 * Revision 1.4 1995/02/14 19:55:12 adam
21 * Header files ccl.h/cclp.h are gone! They have been merged an
22 * moved to ../include/ccl.h.
23 * Node kind(s) in ccl_rpn_node have changed names.
25 * Revision 1.3 1995/02/14 16:20:56 adam
26 * Qualifiers are read from a file now.
28 * Revision 1.2 1995/02/14 10:25:56 adam
29 * The constructions 'qualifier rel term ...' implemented.
31 * Revision 1.1 1995/02/13 15:15:07 adam
32 * Added handling of qualifiers. Not finished yet.
43 struct ccl_qualifiers {
44 struct ccl_qualifier *list;
47 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
49 struct ccl_qualifier *q;
50 struct ccl_rpn_attr **attrp;
53 for (q = b->list; q; q = q->next)
54 if (!strcmp (name, q->name))
58 struct ccl_qualifier *new_qual = xmalloc (sizeof(*new_qual));
61 new_qual->next = b->list;
64 new_qual->name = xmalloc (strlen(name)+1);
65 assert (new_qual->name);
66 strcpy (new_qual->name, name);
67 attrp = &new_qual->attr_list;
71 attrp = &q->attr_list;
73 attrp = &(*attrp)->next;
77 struct ccl_rpn_attr *attr;
79 attr = xmalloc (sizeof(*attr));
81 attr->type = *pairs++;
82 attr->value = *pairs++;
89 CCL_bibset ccl_qual_mk (void)
91 CCL_bibset b = xmalloc (sizeof(*b));
97 void ccl_qual_rm (CCL_bibset *b)
103 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len)
105 struct ccl_qualifier *q;
108 for (q = b->list; q; q = q->next)
109 if (strlen(q->name) == len && !memcmp (name, q->name, len))
114 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
122 while (fgets (line, 255, inf))
127 if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
137 if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
140 if (!(split = strchr (qual_des, '=')))
145 qual_type = qual_des;
149 if ((split = strchr (qual_value, ',')))
151 pair[1] = atoi (qual_value);
152 switch (qual_type[0])
155 pair[0] = CCL_BIB1_USE;
158 pair[0] = CCL_BIB1_REL;
159 if (!strcmp (qual_value, "o"))
160 pair[1] = CCL_BIB1_REL_ORDER;
163 pair[0] = CCL_BIB1_POS;
166 pair[0] = CCL_BIB1_STR;
167 if (!strcmp (qual_value, "pw"))
168 pair[1] = CCL_BIB1_STR_WP;
171 pair[0] = CCL_BIB1_TRU;
172 if (!strcmp (qual_value, "l"))
173 pair[1] = CCL_BIB1_TRU_CAN_LEFT;
174 else if (!strcmp (qual_value, "r"))
175 pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
176 else if (!strcmp (qual_value, "b"))
177 pair[1] = CCL_BIB1_TRU_CAN_BOTH;
178 else if (!strcmp (qual_value, "n"))
179 pair[1] = CCL_BIB1_TRU_CAN_NONE;
182 pair[0] = CCL_BIB1_COM;
185 pair[0] = atoi (qual_type);
187 ccl_qual_add (bibset, qual_name, 1, pair);