2 * Copyright (c) 1995, the EUROPAGATE consortium (see below).
4 * The EUROPAGATE consortium members are:
6 * University College Dublin
7 * Danmarks Teknologiske Videnscenter
8 * An Chomhairle Leabharlanna
9 * Consejo Superior de Investigaciones Cientificas
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation, in whole or in part, for any purpose, is hereby granted,
15 * 1. This copyright and permission notice appear in all copies of the
16 * software and its documentation. Notices of copyright or attribution
17 * which appear at the beginning of any file must remain unchanged.
19 * 2. The names of EUROPAGATE or the project partners may not be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * 3. Users of this software (implementors and gateway operators) agree to
24 * inform the EUROPAGATE consortium of their use of the software. This
25 * information will be used to evaluate the EUROPAGATE project and the
26 * software, and to plan further developments. The consortium may use
27 * the information in later publications.
29 * 4. Users of this software agree to make their best efforts, when
30 * documenting their use of the software, to acknowledge the EUROPAGATE
31 * consortium, and the role played by the software in their work.
33 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
35 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
36 * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE
37 * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF
38 * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
39 * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND
40 * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
41 * USE OR PERFORMANCE OF THIS SOFTWARE.
48 * Revision 1.9 1998-02-11 11:53:33 adam
49 * Changed code so that it compiles as C++.
51 * Revision 1.8 1997/09/29 08:56:38 adam
52 * Changed CCL parser to be thread safe. New type, CCL_parser, declared
53 * and a create/destructers ccl_parser_create/ccl_parser/destory has
56 * Revision 1.7 1997/09/01 08:48:12 adam
57 * New windows NT/95 port using MSV5.0. Only a few changes made
60 * Revision 1.6 1997/04/30 08:52:07 quinn
63 * Revision 1.5 1996/10/11 15:00:25 adam
64 * CCL parser from Europagate Email gateway 1.0.
66 * Revision 1.9 1995/05/16 09:39:27 adam
69 * Revision 1.8 1995/05/11 14:03:57 adam
70 * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
71 * New variable ccl_case_sensitive, which controls whether reserved
72 * words and field names are case sensitive or not.
74 * Revision 1.7 1995/04/17 09:31:46 adam
75 * Improved handling of qualifiers. Aliases or reserved words.
77 * Revision 1.6 1995/02/23 08:32:00 adam
80 * Revision 1.4 1995/02/14 19:55:12 adam
81 * Header files ccl.h/cclp.h are gone! They have been merged an
82 * moved to ../include/ccl.h.
83 * Node kind(s) in ccl_rpn_node have changed names.
85 * Revision 1.3 1995/02/14 16:20:56 adam
86 * Qualifiers are read from a file now.
88 * Revision 1.2 1995/02/14 10:25:56 adam
89 * The constructions 'qualifier rel term ...' implemented.
91 * Revision 1.1 1995/02/13 15:15:07 adam
92 * Added handling of qualifiers. Not finished yet.
103 /* Definition of CCL_bibset pointer */
104 struct ccl_qualifiers {
105 struct ccl_qualifier *list;
109 * ccl_qual_add: Add qualifier to Bibset. If qualifier already
110 * exists, then attributes are appendend to old
112 * name: name of qualifier
113 * no: No of attribute type/value pairs.
114 * pairs: Attributes. pairs[0] first type, pair[1] first value,
115 * ... pair[2*no-2] last type, pair[2*no-1] last value.
117 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *pairs)
119 struct ccl_qualifier *q;
120 struct ccl_rpn_attr **attrp;
123 for (q = b->list; q; q = q->next)
124 if (!strcmp (name, q->name))
128 struct ccl_qualifier *new_qual = (struct ccl_qualifier *)malloc (sizeof(*new_qual));
131 new_qual->next = b->list;
134 new_qual->name = (char *)malloc (strlen(name)+1);
135 assert (new_qual->name);
136 strcpy (new_qual->name, name);
137 attrp = &new_qual->attr_list;
141 attrp = &q->attr_list;
143 attrp = &(*attrp)->next;
147 struct ccl_rpn_attr *attr;
149 attr = (struct ccl_rpn_attr *)malloc (sizeof(*attr));
151 attr->type = *pairs++;
152 attr->value = *pairs++;
160 * ccl_qual_mk: Make new (empty) bibset.
161 * return: empty bibset.
163 CCL_bibset ccl_qual_mk (void)
165 CCL_bibset b = (CCL_bibset)malloc (sizeof(*b));
172 * ccl_qual_rm: Delete bibset.
173 * b: pointer to bibset
175 void ccl_qual_rm (CCL_bibset *b)
177 struct ccl_qualifier *q, *q1;
181 for (q = (*b)->list; q; q = q1)
183 struct ccl_rpn_attr *attr, *attr1;
185 for (attr = q->attr_list; attr; attr = attr1)
198 * ccl_qual_search: Search for qualifier in bibset.
200 * name: Name of qualifier to search for (need no null-termination)
201 * len: Length of name.
202 * return: Attribute info. NULL if not found.
204 struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp,
205 const char *name, size_t len)
207 struct ccl_qualifier *q;
212 for (q = cclp->bibset->list; q; q = q->next)
213 if (strlen(q->name) == len)
214 if (cclp->ccl_case_sensitive)
216 if (!memcmp (name, q->name, len))
221 if (!ccl_memicmp (name, q->name, len))