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.
49 * Revision 1.7 1997-09-01 08:49:47 adam
50 * New windows NT/95 port using MSV5.0. To export DLL functions the
51 * YAZ_EXPORT modifier was added. Defined in yconfig.h.
53 * Revision 1.6 1997/05/14 06:53:37 adam
56 * Revision 1.5 1997/04/30 08:52:08 quinn
59 * Revision 1.4 1996/10/11 15:02:26 adam
60 * CCL parser from Europagate Email gateway 1.0.
62 * Revision 1.10 1996/01/08 08:41:22 adam
65 * Revision 1.9 1995/07/20 08:15:16 adam
66 * Bug fix: Token value for comma and OR were the same!
68 * Revision 1.8 1995/07/11 12:28:34 adam
69 * New function: ccl_token_simple (split into simple tokens) and
70 * ccl_token_del (delete tokens).
72 * Revision 1.7 1995/05/16 09:39:38 adam
75 * Revision 1.6 1995/05/11 14:04:03 adam
76 * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
77 * New variable ccl_case_sensitive, which controls whether reserved
78 * words and field names are case sensitive or not.
80 * Revision 1.5 1995/02/23 08:32:11 adam
83 * Revision 1.3 1995/02/16 13:20:10 adam
86 * Revision 1.2 1995/02/15 17:43:08 adam
87 * Minor changes to the ccl interface. Bug fix in iso2709 module.
89 * Revision 1.1 1995/02/14 19:55:21 adam
90 * Header files ccl.h/cclp.h are gone! They have been merged an
91 * moved to ../include/ccl.h.
102 /* CCL error numbers */
104 #define CCL_ERR_TERM_EXPECTED 1
105 #define CCL_ERR_RP_EXPECTED 2
106 #define CCL_ERR_SETNAME_EXPECTED 3
107 #define CCL_ERR_OP_EXPECTED 4
108 #define CCL_ERR_BAD_RP 5
109 #define CCL_ERR_UNKNOWN_QUAL 6
110 #define CCL_ERR_DOUBLE_QUAL 7
111 #define CCL_ERR_EQ_EXPECTED 8
112 #define CCL_ERR_BAD_RELATION 9
113 #define CCL_ERR_TRUNC_NOT_LEFT 10
114 #define CCL_ERR_TRUNC_NOT_BOTH 11
115 #define CCL_ERR_TRUNC_NOT_RIGHT 12
117 /* attribute pair (type, value) */
118 struct ccl_rpn_attr {
119 struct ccl_rpn_attr *next;
124 #define CCL_RPN_AND 1
126 #define CCL_RPN_NOT 3
127 #define CCL_RPN_TERM 4
128 #define CCL_RPN_SET 5
129 #define CCL_RPN_PROX 6
131 /* RPN tree structure */
132 struct ccl_rpn_node {
135 struct ccl_rpn_node *p[2];
138 struct ccl_rpn_attr *attr_list;
144 typedef struct ccl_qualifiers *CCL_bibset;
151 1-6 relation (<, <=, =, >=, >, <>)
157 3 any position in field
160 0 word/phrase auto select
167 100 date (un-normalized)
168 101 name (normalized)
169 102 name (un-normalized)
174 #define CCL_BIB1_USE 1
175 #define CCL_BIB1_REL 2
176 #define CCL_BIB1_POS 3
177 #define CCL_BIB1_STR 4
178 #define CCL_BIB1_TRU 5
179 #define CCL_BIB1_COM 6
181 #define CCL_BIB1_STR_WP (-1)
182 #define CCL_BIB1_REL_ORDER (-1)
184 #define CCL_BIB1_TRU_CAN_LEFT (-1)
185 #define CCL_BIB1_TRU_CAN_RIGHT (-2)
186 #define CCL_BIB1_TRU_CAN_BOTH (-3)
187 #define CCL_BIB1_TRU_CAN_NONE (-4)
189 #define CCL_TOK_EOL 0
190 #define CCL_TOK_TERM 1
191 #define CCL_TOK_REL 2
193 #define CCL_TOK_PROX 4
196 #define CCL_TOK_COMMA 7
197 #define CCL_TOK_AND 8
199 #define CCL_TOK_NOT 10
200 #define CCL_TOK_MINUS 11
201 #define CCL_TOK_SET 12
208 struct ccl_token *next;
209 struct ccl_token *prev;
213 struct ccl_qualifier {
215 struct ccl_rpn_attr *attr_list;
216 struct ccl_qualifier *next;
219 /* Generate tokens from command string - obeys all CCL opererators */
220 struct ccl_token *ccl_tokenize (const char *command);
222 /* Generate tokens from command string - oebeys only simple tokens and
224 struct ccl_token *ccl_token_simple (const char *command);
226 /* Delete token list */
227 void ccl_token_del (struct ccl_token *list);
229 /* Parse CCL Find command - NULL-terminated string */
230 struct ccl_rpn_node *ccl_find_str (CCL_bibset bibset,
231 const char *str, int *error, int *pos);
233 /* Parse CCL Find command - Tokens read by ccl_tokenize */
234 struct ccl_rpn_node *ccl_find (CCL_bibset abibset, struct ccl_token *list,
235 int *error, const char **pos);
237 /* Return english-readable error message */
238 char *ccl_err_msg (int ccl_errno);
240 /* Delete RPN tree returned by ccl_find */
241 void ccl_rpn_delete (struct ccl_rpn_node *rpn);
243 /* Dump RPN tree in readable format to fd_out */
244 void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out);
246 /* Add CCL qualifier */
247 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *attr);
249 /* Read CCL qualifier list spec from file inf */
250 void ccl_qual_file (CCL_bibset bibset, FILE *inf);
252 /* Add CCL qualifier by using single-line spec */
253 void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name);
255 /* Make CCL qualifier set */
256 CCL_bibset ccl_qual_mk (void);
258 /* Delete CCL qualifier set */
259 void ccl_qual_rm (CCL_bibset *b);
261 /* Misc. reserved words */
262 extern const char *ccl_token_and;
263 extern const char *ccl_token_or;
264 extern const char *ccl_token_not;
265 extern const char *ccl_token_set;
267 /* Whether the CCL parser is command sensitive */
268 extern int ccl_case_sensitive;
270 /* Char-to-upper function */
271 extern int (*ccl_toupper)(int c);
273 /* String utilities */
274 int ccl_stricmp (const char *s1, const char *s2);
275 int ccl_memicmp (const char *s1, const char *s2, size_t n);
277 /* Search for qualifier 'name' in set 'b'. */
278 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name,