YAZ  5.23.1
ccl.h
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data.
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Index Data nor the names of its contributors
13  * may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
32 /*
33  * CCL - header file
34  *
35  *
36  * Old Europagate Log:
37  *
38  * Revision 1.10 1996/01/08 08:41:22 adam
39  * Minor changes.
40  *
41  * Revision 1.9 1995/07/20 08:15:16 adam
42  * Bug fix: Token value for comma and OR were the same!
43  *
44  * Revision 1.8 1995/07/11 12:28:34 adam
45  * New function: ccl_token_simple (split into simple tokens) and
46  * ccl_token_del (delete tokens).
47  *
48  * Revision 1.7 1995/05/16 09:39:38 adam
49  * LICENSE.
50  *
51  * Revision 1.6 1995/05/11 14:04:03 adam
52  * Changes in the reading of qualifier(s). New function: ccl_qual_fitem.
53  * New variable ccl_case_sensitive, which controls whether reserved
54  * words and field names are case sensitive or not.
55  *
56  * Revision 1.5 1995/02/23 08:32:11 adam
57  * Changed header.
58  *
59  * Revision 1.3 1995/02/16 13:20:10 adam
60  * Spell fix.
61  *
62  * Revision 1.2 1995/02/15 17:43:08 adam
63  * Minor changes to the ccl interface. Bug fix in iso2709 module.
64  *
65  * Revision 1.1 1995/02/14 19:55:21 adam
66  * Header files ccl.h/cclp.h are gone! They have been merged an
67  * moved to ../include/ccl.h.
68  *
69  */
70 
71 #ifndef CCL_H
72 #define CCL_H
73 
74 #include <yaz/yconfig.h>
75 #include <stdio.h>
76 #include <yaz/xmalloc.h>
77 #include <yaz/wrbuf.h>
78 
80 
81 #define CCL_ERR_OK 0
82 #define CCL_ERR_TERM_EXPECTED 1
83 #define CCL_ERR_RP_EXPECTED 2
84 #define CCL_ERR_SETNAME_EXPECTED 3
85 #define CCL_ERR_OP_EXPECTED 4
86 #define CCL_ERR_BAD_RP 5
87 #define CCL_ERR_UNKNOWN_QUAL 6
88 #define CCL_ERR_DOUBLE_QUAL 7
89 #define CCL_ERR_EQ_EXPECTED 8
90 #define CCL_ERR_BAD_RELATION 9
91 #define CCL_ERR_TRUNC_NOT_LEFT 10
92 #define CCL_ERR_TRUNC_NOT_BOTH 11
93 #define CCL_ERR_TRUNC_NOT_RIGHT 12
94 #define CCL_ERR_TRUNC_NOT_EMBED 13
95 #define CCL_ERR_TRUNC_NOT_SINGLE 14
96 
98 struct ccl_rpn_attr {
102  char *set;
104  int type;
106  int kind;
107 #define CCL_RPN_ATTR_NUMERIC 1
108 #define CCL_RPN_ATTR_STRING 2
109  union {
111  int numeric;
113  char *str;
114  } value;
115 };
116 
125 };
126 
128 struct ccl_rpn_node {
131  union {
133  struct ccl_rpn_node *p[3];
135  struct {
136  char *term;
137  char *qual;
139  } t;
141  char *setname;
142  } u;
143 };
144 
146 typedef struct ccl_qualifiers *CCL_bibset;
147 
149 typedef struct ccl_parser *CCL_parser;
150 
158 YAZ_EXPORT
159 struct ccl_rpn_node *ccl_find_str(CCL_bibset bibset,
160  const char *str, int *error, int *pos);
161 
162 
170 YAZ_EXPORT
171 struct ccl_rpn_node *ccl_parser_find_str(CCL_parser cclp, const char *str);
172 
174 YAZ_EXPORT
175 void ccl_parser_set_case(CCL_parser p, int case_sensitivity_flag);
176 
178 YAZ_EXPORT
179 const char *ccl_err_msg(int ccl_errno);
180 
182 YAZ_EXPORT
183 void ccl_rpn_delete(struct ccl_rpn_node *rpn);
184 
186 YAZ_EXPORT
187 void ccl_pr_tree(struct ccl_rpn_node *rpn, FILE *fd_out);
188 
190 YAZ_EXPORT
191 void ccl_qual_add(CCL_bibset b, const char *name, int no, int *attr);
192 
194 YAZ_EXPORT
195 void ccl_qual_add_set(CCL_bibset b, const char *name, int no,
196  int *type, int *value, char **svalue, char **attsets);
197 
199 YAZ_EXPORT
200 void ccl_qual_add_special(CCL_bibset bibset, const char *n, const char *cp);
201 
203 YAZ_EXPORT
204 void ccl_qual_add_combi(CCL_bibset b, const char *n, const char **names);
205 
207 YAZ_EXPORT
208 void ccl_qual_file(CCL_bibset bibset, FILE *inf);
209 
211 YAZ_EXPORT
212 int ccl_qual_fname(CCL_bibset bibset, const char *fname);
213 
215 YAZ_EXPORT
216 void ccl_qual_buf(CCL_bibset bibset, const char *buf);
217 
219 YAZ_EXPORT
220 void ccl_qual_line(CCL_bibset bibset, char *line);
221 
222 /* Add CCL qualifier by using qual_name + value pair */
223 YAZ_EXPORT
224 void ccl_qual_fitem(CCL_bibset bibset, const char *value,
225  const char *qual_name);
226 YAZ_EXPORT
227 int ccl_qual_fitem2(CCL_bibset bibset, const char *value,
228  const char *qual_name, const char **addinfo);
229 
231 YAZ_EXPORT
232 CCL_bibset ccl_qual_mk(void);
233 
235 YAZ_EXPORT
236 CCL_bibset ccl_qual_dup(CCL_bibset b);
237 
239 YAZ_EXPORT
240 void ccl_qual_rm(CCL_bibset *b);
241 
243 extern int(*ccl_toupper)(int c);
244 
246 YAZ_EXPORT
247 int ccl_stricmp(const char *s1, const char *s2);
248 
250 YAZ_EXPORT
251 int ccl_memicmp(const char *s1, const char *s2, size_t n);
252 
254 YAZ_EXPORT
255 CCL_parser ccl_parser_create(CCL_bibset bibset);
256 
258 YAZ_EXPORT
259 void ccl_parser_destroy(CCL_parser p);
260 
262 YAZ_EXPORT
263 const char **ccl_qual_search_special(CCL_bibset b, const char *name);
265 YAZ_EXPORT
266 void ccl_pquery(WRBUF w, struct ccl_rpn_node *p);
267 
268 YAZ_EXPORT
269 int ccl_parser_get_error(CCL_parser cclp, int *pos);
270 
271 YAZ_EXPORT
273 
274 YAZ_EXPORT
275 void ccl_add_attr_numeric(struct ccl_rpn_node *p, const char *set,
276  int type, int value);
277 
278 YAZ_EXPORT
279 void ccl_add_attr_string(struct ccl_rpn_node *p, const char *set,
280  int type, char *value);
281 
282 YAZ_EXPORT
283 int ccl_search_stop(CCL_bibset bibset, const char *qname,
284  const char *src_str, size_t src_len);
285 
286 
289 
291 YAZ_EXPORT
292 ccl_stop_words_t ccl_stop_words_create(void);
293 
295 YAZ_EXPORT
296 void ccl_stop_words_destroy(ccl_stop_words_t csw);
297 
299 YAZ_EXPORT
300 int ccl_stop_words_tree(ccl_stop_words_t csw,
301  CCL_bibset bibset, struct ccl_rpn_node **t);
302 
304 YAZ_EXPORT
305 int ccl_stop_words_info(ccl_stop_words_t csw, int idx,
306  const char **qualname, const char **term);
307 
308 YAZ_EXPORT
309 struct ccl_rpn_attr *ccl_parser_qual_search(CCL_parser cclp, const char *name,
310  size_t name_len);
311 
312 
313 #ifndef ccl_assert
314 #define ccl_assert(x) ;
315 #endif
316 
317 
348 #define CCL_BIB1_USE 1
349 #define CCL_BIB1_REL 2
350 #define CCL_BIB1_POS 3
351 #define CCL_BIB1_STR 4
352 #define CCL_BIB1_TRU 5
353 #define CCL_BIB1_COM 6
354 
355 #define CCL_BIB1_STR_WP (-1)
356 #define CCL_BIB1_STR_AND_LIST (-2)
357 #define CCL_BIB1_STR_OR_LIST (-3)
358 #define CCL_BIB1_STR_AUTO_GROUP (-4)
359 #define CCL_BIB1_STR_SPLIT_LIST (-5)
360 #define CCL_BIB1_REL_ORDER (-1)
361 #define CCL_BIB1_REL_PORDER (-2)
362 #define CCL_BIB1_REL_OMIT_EQUALS (-3)
363 
364 #define CCL_BIB1_TRU_CAN_LEFT (-1)
365 #define CCL_BIB1_TRU_CAN_RIGHT (-2)
366 #define CCL_BIB1_TRU_CAN_BOTH (-3)
367 #define CCL_BIB1_TRU_CAN_NONE (-4)
368 #define CCL_BIB1_TRU_CAN_REGEX (-5)
369 #define CCL_BIB1_TRU_CAN_Z3958 (-6)
370 
371 
373 
374 #endif
375 
376 /*
377  * Local variables:
378  * c-basic-offset: 4
379  * c-file-style: "Stroustrup"
380  * indent-tabs-mode: nil
381  * End:
382  * vim: shiftwidth=4 tabstop=8 expandtab
383  */
384 
void ccl_qual_add_special(CCL_bibset bibset, const char *n, const char *cp)
Definition: cclqual.c:81
struct ccl_rpn_node * ccl_rpn_node_create(enum ccl_rpn_kind kind)
Definition: cclfind.c:100
void ccl_parser_destroy(CCL_parser p)
Definition: ccltoken.c:265
Header for WRBUF (growing buffer)
int ccl_parser_get_error(CCL_parser cclp, int *pos)
Definition: ccltoken.c:282
int ccl_memicmp(const char *s1, const char *s2, size_t n)
Definition: cclstr.c:45
#define YAZ_END_CDECL
Definition: yconfig.h:57
struct ccl_qualifiers * CCL_bibset
CCL bibset, AKA profile.
Definition: ccl.h:146
ccl_rpn_kind
node type or RPN tree generated by the CCL parser
Definition: ccl.h:118
void ccl_add_attr_numeric(struct ccl_rpn_node *p, const char *set, int type, int value)
Definition: cclfind.c:213
char * name
Definition: initopt.c:18
int numeric
numeric attribute value
Definition: ccl.h:111
void ccl_qual_fitem(CCL_bibset bibset, const char *value, const char *qual_name)
Definition: cclqfile.c:255
CCL_parser ccl_parser_create(CCL_bibset bibset)
Definition: ccltoken.c:246
RPN tree structure node.
Definition: ccl.h:128
string buffer
Definition: wrbuf.h:42
char * term
Definition: ccl.h:136
void ccl_rpn_delete(struct ccl_rpn_node *rpn)
Definition: cclfind.c:141
int(* ccl_toupper)(int c)
Definition: cclstr.c:26
void ccl_add_attr_string(struct ccl_rpn_node *p, const char *set, int type, char *value)
Definition: cclfind.c:239
int ccl_qual_fname(CCL_bibset bibset, const char *fname)
Definition: cclqfile.c:324
void ccl_qual_add(CCL_bibset b, const char *name, int no, int *attr)
int ccl_stricmp(const char *s1, const char *s2)
Definition: cclstr.c:28
Header with fundamental macros.
void ccl_stop_words_destroy(ccl_stop_words_t csw)
destroys stop words handle
int type
attribute type, Bib-1: 1=use, 2=relation, 3=position, etc
Definition: ccl.h:104
struct ccl_rpn_node * p[3]
Boolean including proximity 0=left, 1=right, 2=prox parms.
Definition: ccl.h:133
char * qual
Definition: ccl.h:137
void ccl_qual_add_combi(CCL_bibset b, const char *n, const char **names)
adds specifies qualifier aliases
Definition: cclqual.c:127
const char ** ccl_qual_search_special(CCL_bibset b, const char *name)
Definition: cclqual.c:401
void ccl_pquery(WRBUF w, struct ccl_rpn_node *p)
Definition: cclptree.c:135
void ccl_qual_file(CCL_bibset bibset, FILE *inf)
Definition: cclqfile.c:316
struct ccl_rpn_node * ccl_parser_find_str(CCL_parser cclp, const char *str)
parse CCL find string with parser and return RPN tree
Definition: cclfind.c:1271
void ccl_qual_add_set(CCL_bibset b, const char *name, int no, int *type, int *value, char **svalue, char **attsets)
adds specifies attributes for qualifier
Definition: cclqual.c:165
ccl_stop_words_t ccl_stop_words_create(void)
creates stop words handle
attribute node (type, value) pair as used in RPN
Definition: ccl.h:98
void ccl_qual_line(CCL_bibset bibset, char *line)
Definition: cclqfile.c:286
void ccl_qual_rm(CCL_bibset *b)
destroys Bibset
Definition: cclqual.c:224
struct ccl_rpn_attr * attr_list
Definition: ccl.h:138
int ccl_stop_words_info(ccl_stop_words_t csw, int idx, const char **qualname, const char **term)
returns information about removed "stop" words
int ccl_qual_fitem2(CCL_bibset bibset, const char *value, const char *qual_name, const char **addinfo)
Definition: cclqfile.c:241
struct ccl_rpn_node * ccl_find_str(CCL_bibset bibset, const char *str, int *error, int *pos)
parse CCL find string using CCL profile return RPN tree
Definition: cclfind.c:1310
CCL_bibset ccl_qual_mk(void)
creates Bibset
Definition: cclqual.c:210
int ccl_stop_words_tree(ccl_stop_words_t csw, CCL_bibset bibset, struct ccl_rpn_node **t)
removes stop words from RPN tree
char * setname
Definition: ccl.h:141
int kind
attribute value type (numeric or string)
Definition: ccl.h:106
void ccl_pr_tree(struct ccl_rpn_node *rpn, FILE *fd_out)
Definition: cclptree.c:140
Header for memory handling functions.
char * str
string attribute value
Definition: ccl.h:113
const char * ccl_err_msg(int ccl_errno)
Definition: cclerrms.c:36
struct ccl_rpn_attr * ccl_parser_qual_search(CCL_parser cclp, const char *name, size_t name_len)
Definition: cclqual.c:387
CCL_bibset ccl_qual_dup(CCL_bibset b)
Definition: cclqual.c:267
union ccl_rpn_attr::@10 value
struct ccl_rpn_attr * next
next attribute
Definition: ccl.h:100
int ccl_search_stop(CCL_bibset bibset, const char *qname, const char *src_str, size_t src_len)
Definition: cclqual.c:413
struct ccl_parser * CCL_parser
CCL parser.
Definition: ccl.h:149
void ccl_qual_buf(CCL_bibset bibset, const char *buf)
Definition: cclqfile.c:261
struct ccl_stop_words * ccl_stop_words_t
stop words handle (pimpl)
Definition: ccl.h:288
#define YAZ_BEGIN_CDECL
Definition: yconfig.h:56
void ccl_parser_set_case(CCL_parser p, int case_sensitivity_flag)
Definition: ccltoken.c:276