1 /* $Id: cql.h,v 1.3 2003-02-18 21:27:53 adam Exp $
2 Copyright (C) 2002-2003
5 This file is part of the YAZ toolkit.
10 #ifndef CQL_H_INCLUDED
11 #define CQL_H_INCLUDED
13 #include <yaz/yconfig.h>
15 typedef struct cql_parser *CQL_parser;
20 * creates a CQL parser.
22 * Returns CQL parser or NULL if parser could not be created.
25 CQL_parser cql_parser_create(void);
31 * Destroy CQL parser. This function does nothing if
32 * NULL pointer is received.
35 void cql_parser_destroy(CQL_parser cp);
40 * @str: A query string to be parsed.
42 * Parses a CQL query string.
44 * Returns 0 if parsing was succesful; non-zero (error code) if
48 int cql_parser_string(CQL_parser cp, const char *str);
53 * @getbyte: Handler to read one character (for parsing).
54 * @ungetbyte: Handler to unread one byte (for parsing).
55 * @client_data: User data associated with getbyte/ungetbyte handlers.
57 * Parses a CQL query from a user defined stream.
59 * Returns 0 if parsing was succesful; non-zero (error code) if
63 int cql_parser_stream(CQL_parser cp,
64 int (*getbyte)(void *client_data),
65 void (*ungetbyte)(int b, void *client_data),
71 * @f: FILE handler in read mode.
73 * Parses a CQL query from a file.
75 * Returns 0 if parsing was succesful; non-zero (error code) if
79 int cql_parser_stdio(CQL_parser cp, FILE *f);
82 #define CQL_NODE_BOOL 2
83 #define CQL_NODE_MOD 3
91 struct cql_node *modifiers;
92 struct cql_node *prefixes;
96 struct cql_node *left;
97 struct cql_node *right;
98 struct cql_node *modifiers;
99 struct cql_node *prefixes;
104 struct cql_node *next;
109 struct cql_properties;
111 struct cql_buf_write_info {
118 void cql_buf_write_handler (const char *b, void *client_data);
121 void cql_node_print(struct cql_node *cn);
123 struct cql_node *cql_node_mk_sc(const char *index,
124 const char *relation,
127 struct cql_node *cql_node_mk_boolean(const char *op);
129 void cql_node_destroy(struct cql_node *cn);
131 struct cql_node *cql_node_prefix(struct cql_node *n,
135 struct cql_node *cql_node_mk_mod(const char *name,
139 struct cql_node *cql_node_dup (struct cql_node *cp);
141 struct cql_node *cql_parser_result(CQL_parser cp);
144 void cql_to_xml(struct cql_node *cn,
145 void (*pr)(const char *buf, void *client_data),
148 void cql_to_xml_stdio(struct cql_node *cn, FILE *f);
150 int cql_to_xml_buf(struct cql_node *cn, char *out, int max);
153 struct cql_node *cql_node_mk_proxargs(const char *relation,
154 const char *distance,
156 const char *ordering);
160 void cql_fputs(const char *buf, void *client_data);
162 typedef struct cql_transform_t_ *cql_transform_t;
165 cql_transform_t cql_transform_open_FILE (FILE *f);
167 cql_transform_t cql_transform_open_fname(const char *fname);
169 void cql_transform_close(cql_transform_t ct);
172 void cql_transform_pr(cql_transform_t ct,
174 void (*pr)(const char *buf, void *client_data),
178 int cql_transform_FILE(cql_transform_t ct,
179 struct cql_node *cn, FILE *f);
182 int cql_transform_buf(cql_transform_t ct,
183 struct cql_node *cn, char *out, int max);
185 int cql_transform_error(cql_transform_t ct, const char **addinfo);
189 11 Unsupported query type (XCQL vs CQL)
190 12 Too many characters in query
191 13 Unbalanced or illegal use of parentheses
192 14 Unbalanced or illegal use of quotes
193 15 Illegal or unsupported index set
194 16 Illegal or unsupported index
195 17 Illegal or unsupported combination of index and index set
196 18 Illegal or unsupported combination of indexes
197 19 Illegal or unsupported relation
198 20 Illegal or unsupported relation modifier
199 21 Illegal or unsupported combination of relation modifers
200 22 Illegal or unsupported combination of relation and index
201 23 Too many characters in term
202 24 Illegal combination of relation and term
203 25 Special characters not quoted in term
204 26 Non special character escaped in term
205 27 Empty term unsupported
206 28 Masking character not supported
207 29 Masked words too short
208 30 Too many masking characters in term
209 31 Anchoring character not supported
210 32 Anchoring character in illegal or unsupported position
211 33 Combination of proximity/adjacency and masking characters not supported
212 34 Combination of proximity/adjacency and anchoring characters not supported
213 35 Terms only exclusion (stop) words
214 36 Term in invalid format for index or relation
215 37 Illegal or unsupported boolean operator
216 38 Too many boolean operators in query
217 39 Proximity not supported
218 40 Illegal or unsupported proximity relation
219 41 Illegal or unsupported proximity distance
220 42 Illegal or unsupported proximity unit
221 43 Illegal or unsupported proximity ordering
222 44 Illegal or unsupported combination of proximity modifiers
223 45 Index set name (prefix) assigned to multiple identifiers