YAZ  4.2.57
cql.h
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2013 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 #ifndef CQL_H_INCLUDED
33 #define CQL_H_INCLUDED
34 #include <stdio.h>
35 #include <yaz/nmem.h>
36 
38 
40 typedef struct cql_parser *CQL_parser;
41 
47 YAZ_EXPORT
48 CQL_parser cql_parser_create(void);
49 
55 YAZ_EXPORT
56 void cql_parser_destroy(CQL_parser cp);
57 
64 YAZ_EXPORT
65 int cql_parser_string(CQL_parser cp, const char *str);
66 
81 YAZ_EXPORT
82 int cql_parser_stream(CQL_parser cp,
83  int (*getbyte)(void *client_data),
84  void (*ungetbyte)(int b, void *client_data),
85  void *client_data);
86 
96 YAZ_EXPORT
97 int cql_parser_stdio(CQL_parser cp, FILE *f);
98 
106 YAZ_EXPORT
107 void cql_parser_strict(CQL_parser cp, int mode);
108 
110 #define CQL_NODE_ST 1
111 
112 #define CQL_NODE_BOOL 2
113 
114 #define CQL_NODE_SORT 3
115 
118 struct cql_node {
120  int which;
121  union {
123  struct {
125  char *index;
127  char *index_uri;
129  char *term;
131  char *relation;
138  } st;
140  struct {
142  char *value;
144  struct cql_node *left;
146  struct cql_node *right;
148  struct cql_node *modifiers;
149  } boolean;
151  struct {
152  char *index;
154  struct cql_node *next;
156  struct cql_node *modifiers;
158  struct cql_node *search;
159  } sort;
160  } u;
161 };
162 
165 struct cql_properties;
166 
170  int max;
171  int off;
172  char *buf;
173 };
174 
177 YAZ_EXPORT
178 void cql_buf_write_handler(const char *b, void *client_data);
179 
184 YAZ_EXPORT
185 void cql_node_print(struct cql_node *cn);
186 
188 YAZ_EXPORT
189 struct cql_node *cql_node_mk_sc(NMEM nmem, const char *index,
190  const char *relation, const char *term);
191 
196 YAZ_EXPORT
197 struct cql_node *cql_apply_prefix(NMEM nmem, struct cql_node *cn,
198  const char *prefix, const char *uri);
199 
201 YAZ_EXPORT
202 struct cql_node *cql_node_mk_boolean(NMEM nmem, const char *op);
203 
205 YAZ_EXPORT
206 struct cql_node *cql_node_mk_sort(NMEM nmem, const char *index,
207  struct cql_node *modifiers);
208 
210 YAZ_EXPORT
211 void cql_node_destroy(struct cql_node *cn);
212 
214 YAZ_EXPORT
215 struct cql_node *cql_node_dup (NMEM nmem, struct cql_node *cp);
216 
221 YAZ_EXPORT
222 struct cql_node *cql_parser_result(CQL_parser cp);
223 
228 YAZ_EXPORT
229 struct cql_node *cql_parser_sort_result(CQL_parser cp);
230 
236 YAZ_EXPORT
237 void cql_to_xml(struct cql_node *cn,
238  void (*pr)(const char *buf, void *client_data),
239  void *client_data);
244 YAZ_EXPORT
245 void cql_to_xml_stdio(struct cql_node *cn, FILE *f);
246 
253 YAZ_EXPORT
254 int cql_to_xml_buf(struct cql_node *cn, char *out, int max);
255 
261 YAZ_EXPORT
262 int cql_to_ccl(struct cql_node *cn,
263  void (*pr)(const char *buf, void *client_data),
264  void *client_data);
265 
270 YAZ_EXPORT
271 void cql_to_ccl_stdio(struct cql_node *cn, FILE *f);
272 
281 YAZ_EXPORT
282 int cql_to_ccl_buf(struct cql_node *cn, char *out, int max);
283 
285 YAZ_EXPORT
286 void cql_fputs(const char *buf, void *client_data);
287 
292 
296 YAZ_EXPORT
297 cql_transform_t cql_transform_create(void);
298 
306 YAZ_EXPORT
307 cql_transform_t cql_transform_open_FILE (FILE *f);
308 
313 YAZ_EXPORT
314 cql_transform_t cql_transform_open_fname(const char *fname);
315 
316 
323 YAZ_EXPORT
324 int cql_transform_define_pattern(cql_transform_t ct, const char *pattern,
325  const char *value);
326 
327 
328 
332 YAZ_EXPORT
333 void cql_transform_close(cql_transform_t ct);
334 
345 YAZ_EXPORT
346 int cql_transform(cql_transform_t ct,
347  struct cql_node *cn,
348  void (*pr)(const char *buf, void *client_data),
349  void *client_data);
350 
361 YAZ_EXPORT
362 int cql_transform_FILE(cql_transform_t ct,
363  struct cql_node *cn, FILE *f);
364 
373 YAZ_EXPORT
374 int cql_transform_buf(cql_transform_t ct,
375  struct cql_node *cn, char *out, int max);
376 
382 YAZ_EXPORT
383 int cql_transform_error(cql_transform_t ct, const char **addinfo);
384 
390 YAZ_EXPORT
391 void cql_transform_set_error(cql_transform_t ct, int error, const char *addinfo);
392 
397 YAZ_EXPORT
398 const char *cql_strerror(int code);
399 
403 YAZ_EXPORT
404 const char *cql_uri(void);
405 
413 YAZ_EXPORT
414 int cql_strcmp(const char *s1, const char *s2);
415 
424 YAZ_EXPORT
425 int cql_strncmp(const char *s1, const char *s2, size_t n);
426 
453 YAZ_EXPORT
454 int cql_sortby_to_sortkeys(struct cql_node *cn,
455  void (*pr)(const char *buf, void *client_data),
456  void *client_data);
457 
465 YAZ_EXPORT
466 int cql_sortby_to_sortkeys_buf(struct cql_node *cn, char *out, int max);
467 
469 
470 #endif
471 /* CQL_H_INCLUDED */
472 /*
473  * Local variables:
474  * c-basic-offset: 4
475  * c-file-style: "Stroustrup"
476  * indent-tabs-mode: nil
477  * End:
478  * vim: shiftwidth=4 tabstop=8 expandtab
479  */
480