5 * Revision 1.4 1995/02/14 19:55:12 adam
6 * Header files ccl.h/cclp.h are gone! They have been merged an
7 * moved to ../include/ccl.h.
8 * Node kind(s) in ccl_rpn_node have changed names.
10 * Revision 1.3 1995/02/14 16:20:56 adam
11 * Qualifiers are read from a file now.
13 * Revision 1.2 1995/02/14 10:25:56 adam
14 * The constructions 'qualifier rel term ...' implemented.
16 * Revision 1.1 1995/02/13 15:15:07 adam
17 * Added handling of qualifiers. Not finished yet.
28 struct ccl_qualifiers {
29 struct ccl_qualifier *list;
32 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
34 struct ccl_qualifier *q;
35 struct ccl_rpn_attr **attrp;
38 for (q = b->list; q; q = q->next)
39 if (!strcmp (name, q->name))
43 struct ccl_qualifier *new_qual = malloc (sizeof(*new_qual));
46 new_qual->next = b->list;
49 new_qual->name = malloc (strlen(name)+1);
50 assert (new_qual->name);
51 strcpy (new_qual->name, name);
52 attrp = &new_qual->attr_list;
56 attrp = &q->attr_list;
58 attrp = &(*attrp)->next;
62 struct ccl_rpn_attr *attr;
64 attr = malloc (sizeof(*attr));
66 attr->type = *pairs++;
67 attr->value = *pairs++;
74 CCL_bibset ccl_qual_mk (void)
76 CCL_bibset b = malloc (sizeof(*b));
82 void ccl_qual_rm (CCL_bibset *b)
88 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len)
90 struct ccl_qualifier *q;
93 for (q = b->list; q; q = q->next)
94 if (strlen(q->name) == len && !memcmp (name, q->name, len))
99 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
107 while (fgets (line, 255, inf))
112 if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
122 if (sscanf (cp, "%s%n", qual_des, &no_scan) != 1)
125 if (!(split = strchr (qual_des, '=')))
130 qual_type = qual_des;
134 if ((split = strchr (qual_value, ',')))
136 pair[1] = atoi (qual_value);
137 switch (qual_type[0])
140 pair[0] = CCL_BIB1_USE;
143 pair[0] = CCL_BIB1_REL;
144 if (!strcmp (qual_value, "o"))
145 pair[1] = CCL_BIB1_REL_ORDER;
148 pair[0] = CCL_BIB1_POS;
151 pair[0] = CCL_BIB1_STR;
152 if (!strcmp (qual_value, "pw"))
153 pair[1] = CCL_BIB1_STR_WP;
156 pair[0] = CCL_BIB1_TRU;
157 if (!strcmp (qual_value, "l"))
158 pair[1] = CCL_BIB1_TRU_CAN_LEFT;
159 else if (!strcmp (qual_value, "r"))
160 pair[1] = CCL_BIB1_TRU_CAN_RIGHT;
161 else if (!strcmp (qual_value, "b"))
162 pair[1] = CCL_BIB1_TRU_CAN_BOTH;
163 else if (!strcmp (qual_value, "n"))
164 pair[1] = CCL_BIB1_TRU_CAN_NONE;
167 pair[0] = CCL_BIB1_COM;
170 pair[0] = atoi (qual_type);
172 ccl_qual_add (bibset, qual_name, 1, pair);