00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00032 #ifndef CQL_H_INCLUDED
00033 #define CQL_H_INCLUDED
00034 #include <stdio.h>
00035 #include <yaz/nmem.h>
00036
00037 YAZ_BEGIN_CDECL
00038
00040 typedef struct cql_parser *CQL_parser;
00041
00047 YAZ_EXPORT
00048 CQL_parser cql_parser_create(void);
00049
00055 YAZ_EXPORT
00056 void cql_parser_destroy(CQL_parser cp);
00057
00064 YAZ_EXPORT
00065 int cql_parser_string(CQL_parser cp, const char *str);
00066
00081 YAZ_EXPORT
00082 int cql_parser_stream(CQL_parser cp,
00083 int (*getbyte)(void *client_data),
00084 void (*ungetbyte)(int b, void *client_data),
00085 void *client_data);
00086
00096 YAZ_EXPORT
00097 int cql_parser_stdio(CQL_parser cp, FILE *f);
00098
00100 #define CQL_NODE_ST 1
00101
00102 #define CQL_NODE_BOOL 2
00103
00105 struct cql_node {
00107 int which;
00108 union {
00110 struct {
00112 char *index;
00114 char *index_uri;
00116 char *term;
00118 char *relation;
00120 char *relation_uri;
00122 struct cql_node *modifiers;
00124 struct cql_node *extra_terms;
00125 } st;
00127 struct {
00129 char *value;
00131 struct cql_node *left;
00133 struct cql_node *right;
00135 struct cql_node *modifiers;
00136 } boolean;
00137 } u;
00138 };
00139
00142 struct cql_properties;
00143
00146 struct cql_buf_write_info {
00147 int max;
00148 int off;
00149 char *buf;
00150 };
00151
00154 YAZ_EXPORT
00155 void cql_buf_write_handler(const char *b, void *client_data);
00156
00161 YAZ_EXPORT
00162 void cql_node_print(struct cql_node *cn);
00163
00165 YAZ_EXPORT
00166 struct cql_node *cql_node_mk_sc(NMEM nmem, const char *index,
00167 const char *relation, const char *term);
00168
00173 YAZ_EXPORT
00174 struct cql_node *cql_apply_prefix(NMEM nmem, struct cql_node *cn,
00175 const char *prefix, const char *uri);
00176
00178 YAZ_EXPORT
00179 struct cql_node *cql_node_mk_boolean(NMEM nmem, const char *op);
00180
00182 YAZ_EXPORT
00183 void cql_node_destroy(struct cql_node *cn);
00184
00186 YAZ_EXPORT
00187 struct cql_node *cql_node_dup (NMEM nmem, struct cql_node *cp);
00188
00193 YAZ_EXPORT
00194 struct cql_node *cql_parser_result(CQL_parser cp);
00195
00201 YAZ_EXPORT
00202 void cql_to_xml(struct cql_node *cn,
00203 void (*pr)(const char *buf, void *client_data),
00204 void *client_data);
00209 YAZ_EXPORT
00210 void cql_to_xml_stdio(struct cql_node *cn, FILE *f);
00211
00218 YAZ_EXPORT
00219 int cql_to_xml_buf(struct cql_node *cn, char *out, int max);
00220
00222 YAZ_EXPORT
00223 void cql_fputs(const char *buf, void *client_data);
00224
00228 typedef struct cql_transform_t_ *cql_transform_t;
00229
00233 YAZ_EXPORT
00234 cql_transform_t cql_transform_create(void);
00235
00243 YAZ_EXPORT
00244 cql_transform_t cql_transform_open_FILE (FILE *f);
00245
00250 YAZ_EXPORT
00251 cql_transform_t cql_transform_open_fname(const char *fname);
00252
00253
00260 YAZ_EXPORT
00261 int cql_transform_define_pattern(cql_transform_t ct, const char *pattern,
00262 const char *value);
00263
00264
00265
00269 YAZ_EXPORT
00270 void cql_transform_close(cql_transform_t ct);
00271
00282 YAZ_EXPORT
00283 int cql_transform(cql_transform_t ct,
00284 struct cql_node *cn,
00285 void (*pr)(const char *buf, void *client_data),
00286 void *client_data);
00287
00298 YAZ_EXPORT
00299 int cql_transform_FILE(cql_transform_t ct,
00300 struct cql_node *cn, FILE *f);
00301
00310 YAZ_EXPORT
00311 int cql_transform_buf(cql_transform_t ct,
00312 struct cql_node *cn, char *out, int max);
00313
00319 YAZ_EXPORT
00320 int cql_transform_error(cql_transform_t ct, const char **addinfo);
00321
00327 YAZ_EXPORT
00328 void cql_transform_set_error(cql_transform_t ct, int error, const char *addinfo);
00329
00334 YAZ_EXPORT
00335 const char *cql_strerror(int code);
00336
00340 YAZ_EXPORT
00341 const char *cql_uri(void);
00342
00350 YAZ_EXPORT
00351 int cql_strcmp(const char *s1, const char *s2);
00352
00361 YAZ_EXPORT
00362 int cql_strncmp(const char *s1, const char *s2, size_t n);
00363
00364 YAZ_END_CDECL
00365
00366 #endif
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376