5 * Revision 1.6 1995/02/23 08:32:00 adam
8 * Revision 1.4 1995/02/14 19:55:12 adam
9 * Header files ccl.h/cclp.h are gone! They have been merged an
10 * moved to ../include/ccl.h.
11 * Node kind(s) in ccl_rpn_node have changed names.
13 * Revision 1.3 1995/02/14 16:20:56 adam
14 * Qualifiers are read from a file now.
16 * Revision 1.2 1995/02/14 10:25:56 adam
17 * The constructions 'qualifier rel term ...' implemented.
19 * Revision 1.1 1995/02/13 15:15:07 adam
20 * Added handling of qualifiers. Not finished yet.
31 struct ccl_qualifiers {
32 struct ccl_qualifier *list;
35 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
37 struct ccl_qualifier *q;
38 struct ccl_rpn_attr **attrp;
41 for (q = b->list; q; q = q->next)
42 if (!strcmp (name, q->name))
46 struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
49 new_qual->next = b->list;
52 new_qual->name = malloc (strlen(name)+1);
53 assert (new_qual->name);
54 strcpy (new_qual->name, name);
55 attrp = &new_qual->attr_list;
59 attrp = &q->attr_list;
61 attrp = &(*attrp)->next;
65 struct ccl_rpn_attr *attr;
67 attr = malloc (sizeof(*attr));
69 attr->type = *pairs++;
70 attr->value = *pairs++;
77 CCL_bibset ccl_qual_mk (void)
79 CCL_bibset b = malloc (sizeof(*b));
85 void ccl_qual_rm (CCL_bibset *b)
91 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len)
93 struct ccl_qualifier *q;
96 for (q = b->list; q; q = q->next)
97 if (strlen(q->name) == len && !memcmp (name, q->name, len))
102 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
110 while (fgets (line, 255, inf))
115 if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
125 if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
128 if (!(split = strchr (qual_des, '=')))
133 qual_type = qual_des;
137 if ((split = strchr (qual_value, ',')))
139 pair[1] = atoi (qual_value);
140 switch (qual_type[0])
143 pair[0] = CCL_BIB1_USE;
146 pair[0] = CCL_BIB1_REL;
147 if (!strcmp (qual_value, "o"))
148 pair[1] = CCL_BIB1_REL_ORDER;
151 pair[0] = CCL_BIB1_POS;
154 pair[0] = CCL_BIB1_STR;
155 if (!strcmp (qual_value, "pw"))
156 pair[1] = CCL_BIB1_STR_WP;
159 pair[0] = CCL_BIB1_TRU;
160 if (!strcmp (qual_value, "l"))
161 pair[1] = CCL_BIB1_TRU_CAN_LEFT;
162 else if (!strcmp (qual_value, "r"))
163 pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
164 else if (!strcmp (qual_value, "b"))
165 pair[1] = CCL_BIB1_TRU_CAN_BOTH;
166 else if (!strcmp (qual_value, "n"))
167 pair[1] = CCL_BIB1_TRU_CAN_NONE;
170 pair[0] = CCL_BIB1_COM;
173 pair[0] = atoi (qual_type);
175 ccl_qual_add (bibset, qual_name, 1, pair);