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.
46 \brief Header with public definitions for CCL.
52 * $Id: ccl.h,v 1.28 2007-04-30 19:55:39 adam Exp $
56 * Revision 1.10 1996/01/08 08:41:22 adam
59 * Revision 1.9 1995/07/20 08:15:16 adam
60 * Bug fix: Token value for comma and OR were the same!
62 * Revision 1.8 1995/07/11 12:28:34 adam
63 * New function: ccl_token_simple (split into simple tokens) and
64 * ccl_token_del (delete tokens).
66 * Revision 1.7 1995/05/16 09:39:38 adam
69 * Revision 1.6 1995/05/11 14:04:03 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.5 1995/02/23 08:32:11 adam
77 * Revision 1.3 1995/02/16 13:20:10 adam
80 * Revision 1.2 1995/02/15 17:43:08 adam
81 * Minor changes to the ccl interface. Bug fix in iso2709 module.
83 * Revision 1.1 1995/02/14 19:55:21 adam
84 * Header files ccl.h/cclp.h are gone! They have been merged an
85 * moved to ../include/ccl.h.
92 #include <yaz/yconfig.h>
94 #include <yaz/xmalloc.h>
95 #include <yaz/wrbuf.h>
100 #define CCL_ERR_TERM_EXPECTED 1
101 #define CCL_ERR_RP_EXPECTED 2
102 #define CCL_ERR_SETNAME_EXPECTED 3
103 #define CCL_ERR_OP_EXPECTED 4
104 #define CCL_ERR_BAD_RP 5
105 #define CCL_ERR_UNKNOWN_QUAL 6
106 #define CCL_ERR_DOUBLE_QUAL 7
107 #define CCL_ERR_EQ_EXPECTED 8
108 #define CCL_ERR_BAD_RELATION 9
109 #define CCL_ERR_TRUNC_NOT_LEFT 10
110 #define CCL_ERR_TRUNC_NOT_BOTH 11
111 #define CCL_ERR_TRUNC_NOT_RIGHT 12
113 /** \brief attribute node (type, value) pair as used in RPN */
114 struct ccl_rpn_attr {
115 /** \brief next attribute */
116 struct ccl_rpn_attr *next;
117 /** \brief attribute set */
119 /** \brief attribute type, Bib-1: 1=use, 2=relation, 3=position, .. */
121 /** \brief attribute value type (numeric or string) */
123 #define CCL_RPN_ATTR_NUMERIC 1
124 #define CCL_RPN_ATTR_STRING 2
126 /** \brief numeric attribute value */
128 /** \brief string attribute value */
133 /** \brief node type or RPN tree generated by the CCL parser */
143 /** \brief RPN tree structure node */
144 struct ccl_rpn_node {
145 /** \brief node type, one of CCL_RPN_AND, CCL_RPN_OR,.. */
146 enum ccl_rpn_kind kind;
148 /** \brief Boolean including proximity 0=left, 1=right, 2=prox parms */
149 struct ccl_rpn_node *p[3];
150 /** \brief Attributes + Term */
153 struct ccl_rpn_attr *attr_list;
160 /** \brief CCL bibset, AKA profile */
161 typedef struct ccl_qualifiers *CCL_bibset;
163 /** \brief CCL parser */
164 typedef struct ccl_parser *CCL_parser;
167 \brief parse CCL find string using CCL profile return RPN tree
169 Parses a CCL Find command in a simple C string. Returns CCL parse
170 tree node describing RPN if parsing is successful. If parsing is
171 unsuccesful, NULL is returned and error and pos is set accordingly.
174 struct ccl_rpn_node *ccl_find_str(CCL_bibset bibset,
175 const char *str, int *error, int *pos);
179 \brief parse CCL find string with parser and return RPN tree
181 Parses a CCL Find command in a simple C string. Returns CCL parse
182 tree node describing RPN if parsing is successful. If parsing is
183 unsuccesful, NULL is returned and error and pos is set accordingly.
186 struct ccl_rpn_node *ccl_parser_find_str(CCL_parser cclp, const char *str);
188 /** Set case sensitivity for parser */
190 void ccl_parser_set_case(CCL_parser p, int case_sensitivity_flag);
192 /** Return english-readable error message for CCL parser error number */
194 const char *ccl_err_msg(int ccl_errno);
196 /** Delete RPN tree returned by ccl_find */
198 void ccl_rpn_delete(struct ccl_rpn_node *rpn);
200 /** Dump RPN tree in readable format to fd_out */
202 void ccl_pr_tree(struct ccl_rpn_node *rpn, FILE *fd_out);
204 /** Add qualifier and supply attribute pairs for it */
206 void ccl_qual_add(CCL_bibset b, const char *name, int no, int *attr);
208 /** Add qualifier and supply attributes pairs+attribute set for it */
210 void ccl_qual_add_set(CCL_bibset b, const char *name, int no,
211 int *type, int *value, char **svalue, char **attsets);
213 /** Add special qualifier */
215 void ccl_qual_add_special(CCL_bibset bibset, const char *n, const char *cp);
217 /** Add combo qualifier */
219 void ccl_qual_add_combi(CCL_bibset b, const char *n, const char **names);
221 /** Read CCL qualifier list spec from file inf */
223 void ccl_qual_file(CCL_bibset bibset, FILE *inf);
225 /** Read CCL qualifier list spec from file inf */
227 int ccl_qual_fname(CCL_bibset bibset, const char *fname);
229 /** Add CCL qualifier as buf spec(multiple lines). */
231 void ccl_qual_buf(CCL_bibset bibset, const char *buf);
233 /** Add CCL qualifier as line spec. Note: line is _modified_ */
235 void ccl_qual_line(CCL_bibset bibset, char *line);
237 /* Add CCL qualifier by using qual_name + value pair */
239 void ccl_qual_fitem(CCL_bibset bibset, const char *value,
240 const char *qual_name);
242 /** Make CCL qualifier set */
244 CCL_bibset ccl_qual_mk(void);
246 /** Delete CCL qualifier set */
248 void ccl_qual_rm(CCL_bibset *b);
250 /** Char-to-upper function */
251 extern int(*ccl_toupper)(int c);
253 /** CCL version of ccl_stricmp */
255 int ccl_stricmp(const char *s1, const char *s2);
257 /** CCL version of ccl_memicmp */
259 int ccl_memicmp(const char *s1, const char *s2, size_t n);
261 /** Create CCL parser */
263 CCL_parser ccl_parser_create(CCL_bibset bibset);
265 /** Destroy CCL parser */
267 void ccl_parser_destroy(CCL_parser p);
269 /** Search for special qualifier */
271 const char **ccl_qual_search_special(CCL_bibset b, const char *name);
272 /** Pretty-print CCL RPN node tree to WRBUF */
274 void ccl_pquery(WRBUF w, struct ccl_rpn_node *p);
277 int ccl_parser_get_error(CCL_parser cclp, int *pos);
280 struct ccl_rpn_node *ccl_rpn_node_create(enum ccl_rpn_kind kind);
283 void ccl_add_attr_numeric(struct ccl_rpn_node *p, const char *set,
284 int type, int value);
287 void ccl_add_attr_string(struct ccl_rpn_node *p, const char *set,
288 int type, char *value);
292 #define ccl_assert(x) ;
296 /** \brief common attributes
303 1-6 relation (<, <=, =, >=, >, <>)
309 3 any position in field
312 0 word/phrase auto select
319 100 date (un-normalized)
320 101 name (normalized)
321 102 name (un-normalized)
326 #define CCL_BIB1_USE 1
327 #define CCL_BIB1_REL 2
328 #define CCL_BIB1_POS 3
329 #define CCL_BIB1_STR 4
330 #define CCL_BIB1_TRU 5
331 #define CCL_BIB1_COM 6
333 #define CCL_BIB1_STR_WP (-1)
334 #define CCL_BIB1_STR_AND_LIST (-2)
335 #define CCL_BIB1_STR_OR_LIST (-3)
336 #define CCL_BIB1_REL_ORDER (-1)
337 #define CCL_BIB1_REL_PORDER (-2)
339 #define CCL_BIB1_TRU_CAN_LEFT (-1)
340 #define CCL_BIB1_TRU_CAN_RIGHT (-2)
341 #define CCL_BIB1_TRU_CAN_BOTH (-3)
342 #define CCL_BIB1_TRU_CAN_NONE (-4)
353 * indent-tabs-mode: nil
355 * vim: shiftwidth=4 tabstop=8 expandtab