1 /* $Id: cql.h,v 1.7 2004-03-15 21:39:06 adam Exp $
2 Copyright (C) 2002-2004
5 This file is part of the YAZ toolkit.
10 #ifndef CQL_H_INCLUDED
11 #define CQL_H_INCLUDED
13 #include <yaz/yconfig.h>
17 typedef struct cql_parser *CQL_parser;
22 * creates a CQL parser.
24 * Returns CQL parser or NULL if parser could not be created.
27 CQL_parser cql_parser_create(void);
33 * Destroy CQL parser. This function does nothing if
34 * NULL pointer is received.
37 void cql_parser_destroy(CQL_parser cp);
42 * @str: A query string to be parsed.
44 * Parses a CQL query string.
46 * Returns 0 if parsing was succesful; non-zero (error code) if
50 int cql_parser_string(CQL_parser cp, const char *str);
55 * @getbyte: Handler to read one character (for parsing).
56 * @ungetbyte: Handler to unread one byte (for parsing).
57 * @client_data: User data associated with getbyte/ungetbyte handlers.
59 * Parses a CQL query from a user defined stream.
61 * Returns 0 if parsing was succesful; non-zero (error code) if
65 int cql_parser_stream(CQL_parser cp,
66 int (*getbyte)(void *client_data),
67 void (*ungetbyte)(int b, void *client_data),
73 * @f: FILE handler in read mode.
75 * Parses a CQL query from a file.
77 * Returns 0 if parsing was succesful; non-zero (error code) if
81 int cql_parser_stdio(CQL_parser cp, FILE *f);
84 #define CQL_NODE_BOOL 2
85 #define CQL_NODE_MOD 3
95 struct cql_node *modifiers;
99 struct cql_node *left;
100 struct cql_node *right;
101 struct cql_node *modifiers;
106 struct cql_properties;
108 struct cql_buf_write_info {
115 void cql_buf_write_handler (const char *b, void *client_data);
118 void cql_node_print(struct cql_node *cn);
120 struct cql_node *cql_node_mk_sc(const char *index,
121 const char *relation,
126 struct cql_node *cql_apply_prefix(struct cql_node *cn,
127 const char *relation,
130 struct cql_node *cql_node_mk_boolean(const char *op);
132 void cql_node_destroy(struct cql_node *cn);
134 struct cql_node *cql_node_dup (struct cql_node *cp);
136 struct cql_node *cql_parser_result(CQL_parser cp);
139 void cql_to_xml(struct cql_node *cn,
140 void (*pr)(const char *buf, void *client_data),
143 void cql_to_xml_stdio(struct cql_node *cn, FILE *f);
145 int cql_to_xml_buf(struct cql_node *cn, char *out, int max);
148 struct cql_node *cql_node_mk_proxargs(const char *relation,
149 const char *distance,
151 const char *ordering);
155 void cql_fputs(const char *buf, void *client_data);
157 typedef struct cql_transform_t_ *cql_transform_t;
160 cql_transform_t cql_transform_open_FILE (FILE *f);
162 cql_transform_t cql_transform_open_fname(const char *fname);
164 void cql_transform_close(cql_transform_t ct);
167 void cql_transform_pr(cql_transform_t ct,
169 void (*pr)(const char *buf, void *client_data),
173 int cql_transform_FILE(cql_transform_t ct,
174 struct cql_node *cn, FILE *f);
177 int cql_transform_buf(cql_transform_t ct,
178 struct cql_node *cn, char *out, int max);
180 int cql_transform_error(cql_transform_t ct, const char **addinfo);
183 const char *cql_strerror(int code);
186 const char *cql_uri();