#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <yaz/rpn2cql.h>
#include <yaz/xmalloc.h>
#include <yaz/diagsrw.h>
#include <yaz/tokenizer.h>
#include <yaz/wrbuf.h>
#include <yaz/z-core.h>
#include <yaz/matchstr.h>
#include <yaz/oid_db.h>
#include <yaz/log.h>
Go to the source code of this file.
Data Structures | |
| struct | cql_prop_entry |
| struct | cql_transform_t_ |
Functions | |
| cql_transform_t | cql_transform_create (void) |
| creates a CQL transform handle | |
| static int | cql_transform_parse_tok_line (cql_transform_t ct, const char *pattern, yaz_tok_parse_t tp) |
| int | cql_transform_define_pattern (cql_transform_t ct, const char *pattern, const char *value) |
| defines CQL transform pattern | |
| cql_transform_t | cql_transform_open_FILE (FILE *f) |
| creates a CQL transform handle from am opened file handle | |
| void | cql_transform_close (cql_transform_t ct) |
| destroys a CQL transform handle | |
| cql_transform_t | cql_transform_open_fname (const char *fname) |
| creates a CQL transform handle from a file | |
| static int | compare_attr (Z_AttributeElement *a, Z_AttributeElement *b) |
| const char * | cql_lookup_reverse (cql_transform_t ct, const char *category, Z_AttributeList *attributes) |
| find a pattern that has a subset of attributes | |
| static const char * | cql_lookup_property (cql_transform_t ct, const char *pat1, const char *pat2, const char *pat3) |
| int | cql_pr_attr_uri (cql_transform_t ct, const char *category, const char *uri, const char *val, const char *default_val, void(*pr)(const char *buf, void *client_data), void *client_data, int errcode) |
| int | cql_pr_attr (cql_transform_t ct, const char *category, const char *val, const char *default_val, void(*pr)(const char *buf, void *client_data), void *client_data, int errcode) |
| static void | cql_pr_int (int val, void(*pr)(const char *buf, void *client_data), void *client_data) |
| static int | cql_pr_prox (cql_transform_t ct, struct cql_node *mods, void(*pr)(const char *buf, void *client_data), void *client_data) |
| static const char * | wcchar (int start, const char *term, int length) |
| static int | has_modifier (struct cql_node *cn, const char *name) |
| void | emit_term (cql_transform_t ct, struct cql_node *cn, const char *term, int length, void(*pr)(const char *buf, void *client_data), void *client_data) |
| void | emit_terms (cql_transform_t ct, struct cql_node *cn, void(*pr)(const char *buf, void *client_data), void *client_data, const char *op) |
| void | emit_wordlist (cql_transform_t ct, struct cql_node *cn, void(*pr)(const char *buf, void *client_data), void *client_data, const char *op) |
| void | cql_transform_r (cql_transform_t ct, struct cql_node *cn, void(*pr)(const char *buf, void *client_data), void *client_data) |
| int | cql_transform (cql_transform_t ct, struct cql_node *cn, void(*pr)(const char *buf, void *client_data), void *client_data) |
| tranforms PQF given a CQL tree | |
| int | cql_transform_FILE (cql_transform_t ct, struct cql_node *cn, FILE *f) |
| transforms PQF given a CQL tree (from FILE) | |
| int | cql_transform_buf (cql_transform_t ct, struct cql_node *cn, char *out, int max) |
| transforms PQF given a CQL tree (from FILE) | |
| int | cql_transform_error (cql_transform_t ct, const char **addinfo) |
| returns additional information for last transform | |
| void | cql_transform_set_error (cql_transform_t ct, int error, const char *addinfo) |
| sets error and addinfo for transform | |
Evaluation order of rules:
always relation structure position truncation index relationModifier
Definition in file cqltransform.c.
| static int compare_attr | ( | Z_AttributeElement * | a, | |
| Z_AttributeElement * | b | |||
| ) | [static] |
Definition at line 301 of file cqltransform.c.
References odr_createmem(), odr_destroy(), ODR_ENCODE, odr_getbuf(), yaz_memcmp(), and z_AttributeElement().
Referenced by cql_lookup_reverse().
| static const char* cql_lookup_property | ( | cql_transform_t | ct, | |
| const char * | pat1, | |||
| const char * | pat2, | |||
| const char * | pat3 | |||
| ) | [static] |
Definition at line 359 of file cqltransform.c.
References cql_strcmp(), cql_transform_t_::entry, cql_prop_entry::next, cql_prop_entry::pattern, and cql_prop_entry::value.
Referenced by cql_pr_attr_uri().
| const char* cql_lookup_reverse | ( | cql_transform_t | ct, | |
| const char * | category, | |||
| Z_AttributeList * | attributes | |||
| ) |
find a pattern that has a subset of attributes
| ct | CQL transform handle | |
| category | pattern category | |
| attributes | RPN attributes |
Definition at line 322 of file cqltransform.c.
References cql_prop_entry::attr_list, Z_AttributeList::attributes, compare_attr(), cql_transform_t_::entry, cql_prop_entry::next, Z_AttributeList::num_attributes, and cql_prop_entry::pattern.
Referenced by rpn2cql_attr().
| int cql_pr_attr | ( | cql_transform_t | ct, | |
| const char * | category, | |||
| const char * | val, | |||
| const char * | default_val, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data, | |||
| int | errcode | |||
| ) |
Definition at line 475 of file cqltransform.c.
References cql_pr_attr_uri().
Referenced by cql_transform_r(), and emit_term().
| int cql_pr_attr_uri | ( | cql_transform_t | ct, | |
| const char * | category, | |||
| const char * | uri, | |||
| const char * | val, | |||
| const char * | default_val, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data, | |||
| int | errcode | |||
| ) |
Definition at line 385 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_lookup_property(), cql_transform_t_::entry, cql_transform_t_::error, cql_prop_entry::next, cql_prop_entry::pattern, cql_prop_entry::value, and xstrdup.
Referenced by cql_pr_attr(), and emit_term().
| static void cql_pr_int | ( | int | val, | |
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data | |||
| ) | [static] |
| static int cql_pr_prox | ( | cql_transform_t | ct, | |
| struct cql_node * | mods, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data | |||
| ) | [static] |
Definition at line 497 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_pr_int(), cql_transform_t_::error, name, cql_node::st, cql_node::u, xstrdup, YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER, YAZ_SRW_UNSUPP_PROX_RELATION, and YAZ_SRW_UNSUPP_PROX_UNIT.
Referenced by cql_transform_r().
| int cql_transform | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data | |||
| ) |
tranforms PQF given a CQL tree
| ct | CQL transform handle | |
| cn | CQL node tree | |
| pr | print function | |
| client_data | data to be passed to pr |
| 0 | success | |
| != | 0 error |
Definition at line 885 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_apply_prefix(), cql_strcmp(), cql_strncmp(), cql_transform_r(), cql_transform_t_::entry, cql_transform_t_::error, cql_prop_entry::next, nmem_create(), nmem_destroy(), cql_prop_entry::pattern, cql_prop_entry::value, and xfree.
Referenced by cql2pqf(), cql_transform_buf(), and cql_transform_FILE().
| int cql_transform_buf | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| char * | out, | |||
| int | max | |||
| ) |
transforms PQF given a CQL tree (from FILE)
| ct | CQL transform handle | |
| cn | CQL tree | |
| out | buffer for output | |
| max | maximum bytes for output (size of buffer) |
| 0 | success | |
| !=0 | failure (error code) |
Definition at line 914 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_buf_write_info::buf, cql_buf_write_handler(), cql_transform(), cql_transform_t_::error, cql_buf_write_info::max, cql_buf_write_info::off, xstrdup, and YAZ_SRW_TOO_MANY_CHARS_IN_QUERY.
Referenced by cql2pqf().
| void cql_transform_close | ( | cql_transform_t | ct | ) |
destroys a CQL transform handle
| ct | CQL transform handle |
Definition at line 255 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_transform_t_::entry, cql_prop_entry::next, cql_transform_t_::nmem, nmem_destroy(), cql_prop_entry::pattern, cql_transform_t_::tok_cfg, cql_prop_entry::value, cql_transform_t_::w, wrbuf_destroy(), xfree, and yaz_tok_cfg_destroy().
Referenced by cql2pqf(), and cql_transform_open_FILE().
| cql_transform_t cql_transform_create | ( | void | ) |
creates a CQL transform handle
Definition at line 52 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_transform_t_::entry, cql_transform_t_::error, cql_transform_t_::nmem, nmem_create(), cql_transform_t_::tok_cfg, cql_transform_t_::w, wrbuf_alloc(), xmalloc, and yaz_tok_cfg_create().
Referenced by cql_transform_open_FILE().
| int cql_transform_define_pattern | ( | cql_transform_t | ct, | |
| const char * | pattern, | |||
| const char * | value | |||
| ) |
defines CQL transform pattern
| ct | CQL transform handle | |
| pattern | pattern string | |
| value | pattern value |
Definition at line 202 of file cqltransform.c.
References cql_transform_parse_tok_line(), cql_transform_t_::tok_cfg, yaz_tok_cfg_single_tokens(), yaz_tok_parse_buf(), and yaz_tok_parse_destroy().
| int cql_transform_error | ( | cql_transform_t | ct, | |
| const char ** | addinfo | |||
| ) |
returns additional information for last transform
| ct | CQL transform handle | |
| addinfo | additional info (result) |
Definition at line 938 of file cqltransform.c.
References cql_transform_t_::addinfo, and cql_transform_t_::error.
Referenced by cql2pqf().
| int cql_transform_FILE | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| FILE * | f | |||
| ) |
transforms PQF given a CQL tree (from FILE)
| ct | CQL transform handle | |
| cn | CQL tree | |
| f | FILE where output is written |
| 0 | success | |
| !=0 | failure (error code) |
Definition at line 909 of file cqltransform.c.
References cql_fputs(), and cql_transform().
| cql_transform_t cql_transform_open_FILE | ( | FILE * | f | ) |
creates a CQL transform handle from am opened file handle
| f | file where transformation spec is read |
Definition at line 213 of file cqltransform.c.
References cql_transform_close(), cql_transform_create(), cql_transform_parse_tok_line(), cql_prop_entry::pattern, cql_transform_t_::tok_cfg, cql_transform_t_::w, wrbuf_rewind(), xfree, xstrdup, yaz_tok_cfg_single_tokens(), YAZ_TOK_EOF, yaz_tok_move(), yaz_tok_parse_buf(), yaz_tok_parse_destroy(), yaz_tok_parse_string(), and YAZ_TOK_STRING.
Referenced by cql_transform_open_fname().
| cql_transform_t cql_transform_open_fname | ( | const char * | fname | ) |
creates a CQL transform handle from a file
| fname | name of where transformation spec is read |
Definition at line 276 of file cqltransform.c.
References cql_transform_open_FILE().
Referenced by cql2pqf(), and xml_config_read().
| static int cql_transform_parse_tok_line | ( | cql_transform_t | ct, | |
| const char * | pattern, | |||
| yaz_tok_parse_t | tp | |||
| ) | [static] |
Definition at line 64 of file cqltransform.c.
References Z_AttributeElement::attributeSet, Z_AttributeElement::attributeType, CLASS_ATTSET, Z_AttributeElement::complex, cql_transform_t_::entry, Z_ComplexAttribute::list, cql_prop_entry::next, cql_transform_t_::nmem, nmem_intdup(), nmem_malloc(), nmem_strdup(), Z_ComplexAttribute::num_list, Z_ComplexAttribute::num_semanticAction, Z_AttributeElement::numeric, odr_createmem(), odr_destroy(), ODR_PRINT, odr_setprint(), Z_ComplexAttribute::semanticAction, Z_StringOrNumeric::string, Z_StringOrNumeric::u, Z_AttributeElement::value, cql_transform_t_::w, Z_StringOrNumeric::which, Z_AttributeElement::which, wrbuf_alloc(), wrbuf_cstr(), wrbuf_destroy(), wrbuf_puts(), xmalloc, xstrdup, yaz_log(), yaz_log_file(), yaz_oid_std(), yaz_string_to_oid_nmem(), YAZ_TOK_EOF, yaz_tok_move(), yaz_tok_parse_string(), YAZ_TOK_STRING, YLOG_WARN, z_AttributeList(), Z_AttributeValue_complex, Z_AttributeValue_numeric, and Z_StringOrNumeric_string.
Referenced by cql_transform_define_pattern(), and cql_transform_open_FILE().
| void cql_transform_r | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data | |||
| ) |
Definition at line 812 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_node::boolean, CQL_NODE_BOOL, CQL_NODE_ST, cql_pr_attr(), cql_pr_prox(), cql_strcmp(), cql_uri(), emit_terms(), emit_wordlist(), cql_transform_t_::error, cql_node::st, cql_node::u, cql_node::which, xstrdup, YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER, YAZ_SRW_UNSUPP_COMBI_OF_RELATION_AND_TERM, YAZ_SRW_UNSUPP_CONTEXT_SET, and YAZ_SRW_UNSUPP_RELATION.
Referenced by cql_transform().
| void cql_transform_set_error | ( | cql_transform_t | ct, | |
| int | error, | |||
| const char * | addinfo | |||
| ) |
sets error and addinfo for transform
| ct | CQL transform handle | |
| error | error code | |
| addinfo | additional info |
Definition at line 944 of file cqltransform.c.
References cql_transform_t_::addinfo, cql_transform_t_::error, xfree, and xstrdup.
Referenced by cql_transform_rpn2cql_stream(), rpn2cql_simple(), and rpn2cql_structure().
| void emit_term | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| const char * | term, | |||
| int | length, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data | |||
| ) |
Definition at line 610 of file cqltransform.c.
References CQL_NODE_ST, cql_pr_attr(), cql_pr_attr_uri(), has_modifier(), cql_node::st, cql_node::u, wcchar(), cql_node::which, xfree, xmalloc, YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION, YAZ_SRW_MASKING_CHAR_UNSUPP, YAZ_SRW_UNSUPP_INDEX, and YAZ_SRW_UNSUPP_RELATION_MODIFIER.
Referenced by emit_terms(), and emit_wordlist().
| void emit_terms | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data, | |||
| const char * | op | |||
| ) |
Definition at line 751 of file cqltransform.c.
References emit_term(), cql_node::st, and cql_node::u.
Referenced by cql_transform_r().
| void emit_wordlist | ( | cql_transform_t | ct, | |
| struct cql_node * | cn, | |||
| void(*)(const char *buf, void *client_data) | pr, | |||
| void * | client_data, | |||
| const char * | op | |||
| ) |
Definition at line 779 of file cqltransform.c.
References emit_term(), cql_node::st, and cql_node::u.
Referenced by cql_transform_r().
| static int has_modifier | ( | struct cql_node * | cn, | |
| const char * | name | |||
| ) | [static] |
Definition at line 599 of file cqltransform.c.
References cql_node::st, and cql_node::u.
Referenced by emit_term().
| static const char* wcchar | ( | int | start, | |
| const char * | term, | |||
| int | length | |||
| ) | [static] |
1.5.6