81 const char *value_str = 0;
178 (*pp)->attr_list.num_attributes = ae_num;
180 (*pp)->attr_list.attributes = 0;
186 memcpy((*pp)->attr_list.attributes, ae,
222 while (fgets(line,
sizeof(line)-1, f))
279 FILE *f = fopen(fname,
"r");
295 #define Z_AttributeValue_numeric 1
296 #define Z_AttributeValue_complex 2
323 const char *category,
327 size_t clen = strlen(category);
330 if (!strncmp(e->
pattern, category, clen))
364 const char *pat1,
const char *pat2,
370 if (pat1 && pat2 && pat3)
371 sprintf(
pattern,
"%.39s.%.39s.%.39s", pat1, pat2, pat3);
372 else if (pat1 && pat2)
373 sprintf(
pattern,
"%.39s.%.39s", pat1, pat2);
374 else if (pat1 && pat3)
375 sprintf(
pattern,
"%.39s.%.39s", pat1, pat3);
377 sprintf(
pattern,
"%.39s", pat1);
390 const char *uri,
const char *val,
const char *default_val,
391 void (*pr)(
const char *buf,
void *client_data),
396 const char *eval = val ? val : default_val;
397 const char *prefix = 0;
405 !strcmp(e->
value, uri))
418 if (!res && !prefix && !strcmp(category,
"relation"))
420 if (!strcmp(val,
"=="))
422 if (!strcmp(val,
"="))
424 if (!strcmp(val,
"<="))
426 if (!strcmp(val,
">="))
436 const char *cp0 = res, *cp1;
437 while ((cp1 = strchr(cp0,
'=')))
440 while (*cp1 && *cp1 !=
' ')
442 if (cp1 - cp0 >= (ptrdiff_t)
sizeof(buf))
444 memcpy(buf, cp0, cp1 - cp0);
446 (*pr)(
"@attr ", client_data);
448 for (i = 0; buf[i]; i++)
451 (*pr)(eval, client_data);
457 (*pr)(tmp, client_data);
460 (*pr)(
" ", client_data);
476 const char *val,
const char *default_val,
477 void (*pr)(
const char *buf,
void *client_data),
482 val, default_val, pr, client_data, errcode);
487 void (*pr)(
const char *buf,
void *client_data),
491 sprintf(buf,
"%d", val);
492 (*pr)(buf, client_data);
493 (*pr)(
" ", client_data);
499 void (*pr)(
const char *buf,
void *client_data),
510 const char *
name = mods->
u.
st.index;
511 const char *term = mods->
u.
st.term;
512 const char *relation = mods->
u.
st.relation;
514 if (!strcmp(
name,
"distance")) {
515 distance = strtol(term, (
char**) 0, 0);
516 if (!strcmp(relation,
"="))
518 else if (!strcmp(relation,
">"))
520 else if (!strcmp(relation,
"<"))
522 else if (!strcmp(relation,
">="))
524 else if (!strcmp(relation,
"<="))
526 else if (!strcmp(relation,
"<>"))
534 else if (!strcmp(
name,
"ordered"))
536 else if (!strcmp(
name,
"unordered"))
538 else if (!strcmp(
name,
"unit"))
552 mods = mods->
u.
st.modifiers;
556 distance = (unit == 2) ? 1 : 0;
562 (*pr)(
"k ", client_data);
571 for (mod = cn->
u.
st.modifiers; mod != 0; mod = mod->
u.
st.modifiers) {
572 if (!mod->
u.
st.term && !strcmp(mod->
u.
st.index,
name))
581 const char *
term,
int length,
582 void (*pr)(
const char *buf,
void *client_data),
586 const char *ns = cn->
u.
st.index_uri;
588 int process_term = 1;
598 r =
cql_pr_attr(ct, addinfo,
"truncation",
"cql", 0,
609 for (i = 0; i < length; i++)
611 if (
term[i] ==
'\\' && i < length - 1)
620 else if (i == length - 1)
626 else if (i == length - 1)
639 r =
cql_pr_attr(ct, addinfo,
"position",
"firstAndLast", 0,
647 else if (anchor == 1)
649 r =
cql_pr_attr(ct, addinfo,
"position",
"first", 0,
657 else if (anchor == 2)
659 r =
cql_pr_attr(ct, addinfo,
"position",
"last", 0,
676 if (trunc == 3 && !
cql_pr_attr(ct, addinfo,
"truncation",
677 "both", 0, pr, client_data, 0))
682 else if (trunc == 1 && !
cql_pr_attr(ct, addinfo,
"truncation",
683 "left", 0, pr, client_data, 0))
688 else if (trunc == 2 && !
cql_pr_attr(ct, addinfo,
"truncation",
689 "right", 0, pr, client_data, 0))
701 r =
cql_pr_attr(ct, addinfo,
"truncation",
"z3958", 0,
710 cn->
u.
st.index,
"serverChoice",
715 if (cn->
u.
st.modifiers)
718 for (; mod; mod = mod->
u.
st.modifiers)
723 "relationModifier", mod->
u.
st.index, 0,
731 (*pr)(
"\"", client_data);
733 for (i = 0; i < length; i++)
736 if (
term[i] ==
'\\' && i < length - 1)
739 if (strchr(
"\"\\",
term[i]))
740 pr(
"\\", client_data);
741 if (z3958_mode && strchr(
"#?",
term[i]))
742 pr(
"\\\\", client_data);
747 else if (z3958_mode &&
term[i] ==
'*')
749 pr(
"?", client_data);
751 pr(
"\\\\", client_data);
753 else if (z3958_mode &&
term[i] ==
'?')
755 pr(
"#", client_data);
760 pr(
"\\", client_data);
761 if (z3958_mode && strchr(
"#?",
term[i]))
762 pr(
"\\\\", client_data);
770 for (i = 0; i < length; i++)
778 (*pr)(
"\" ", client_data);
784 void (*pr)(
const char *buf,
void *client_data),
792 (*pr)(
"@", client_data);
793 (*pr)(op, client_data);
794 (*pr)(
" ", client_data);
798 for (; !r && ne; ne = ne->
u.
st.extra_terms)
800 if (ne->
u.
st.extra_terms)
802 (*pr)(
"@", client_data);
803 (*pr)(op, client_data);
804 (*pr)(
" ", client_data);
814 void (*pr)(
const char *buf,
void *client_data),
819 const char *cp0 = cn->
u.
st.term;
821 const char *last_term = 0;
827 cp1 = strchr(cp0,
' ');
830 (*pr)(
"@", client_data);
831 (*pr)(op, client_data);
832 (*pr)(
" ", client_data);
833 r =
emit_term(ct, cn, addinfo, last_term, last_length,
838 last_length = cp1 - cp0;
840 last_length = strlen(cp0);
844 r =
emit_term(ct, cn, addinfo, last_term, last_length, pr, client_data);
850 void (*pr)(
const char *buf,
void *client_data),
862 ns = cn->
u.
st.index_uri;
868 (*pr)(
"@set \"", client_data);
869 (*pr)(cn->
u.
st.term, client_data);
870 (*pr)(
"\" ", client_data);
878 if (cn->
u.
st.modifiers)
881 for (; mod; mod = mod->
u.
st.modifiers)
886 if (mod->
u.
st.relation && strcmp(mod->
u.
st.relation,
"="))
891 pr(
"@prox 0 0 0 0 k 8 ", client_data);
895 cql_pr_attr(ct, addinfo,
"always", 0, 0, pr, client_data, 0);
910 r =
emit_terms(ct, cn, addinfo, pr, client_data,
"and");
912 if (cn->
u.
st.modifiers)
915 for (; mod; mod = mod->
u.
st.modifiers)
921 mod->
u.
st.index,
"serverChoice",
925 pr(mod->
u.
st.term, client_data);
926 pr(
" ", client_data);
932 (*pr)(
"@", client_data);
933 (*pr)(cn->
u.
boolean.value, client_data);
934 (*pr)(
" ", client_data);
936 if (!strcmp(cn->
u.
boolean.value,
"prox"))
938 r =
cql_pr_prox(ct, mods, addinfo, pr, client_data);
960 fprintf(stderr,
"Fatal: impossible CQL node-type %d\n", cn->
which);
968 void (*pr)(
const char *buf,
void *client_data),
982 r =
emit_node(ct, cn, addinfo, pr, client_data);
988 void (*pr)(
const char *buf,
void *client_data),
1018 sprintf(numbuf,
"%ld", (
long) info.
max);
1023 info.
buf[info.
off] =
'\0';
#define CQL_NODE_SORT
Node type: sortby single spec.
struct cql_transform_t_ * cql_transform_t
CQL transform handle. The transform describes how to convert from CQL to PQF (Type-1 AKA RPN).
#define CQL_NODE_ST
Node type: search term.
#define CQL_NODE_BOOL
Node type: boolean.
int cql_strcmp(const char *s1, const char *s2)
compares two CQL strings (ala strcmp)
int cql_strncmp(const char *s1, const char *s2, size_t n)
compares two CQL strings (ala strncmp)
void cql_fputs(const char *buf, void *client_data)
stream handle for file (used by cql_to_xml_stdio)
struct cql_node * cql_apply_prefix(NMEM nmem, struct cql_node *n, const char *prefix, const char *uri)
applies a prefix+uri to "unresolved" index and relation URIs. "unresolved" URIs are those nodes where...
const char * cql_uri(void)
returns the standard CQL context set URI.
Diagnostics: Generated by csvtodiag.tcl from ./srw.csv.
#define YAZ_SRW_UNSUPP_PROX_RELATION
#define YAZ_SRW_UNSUPP_CONTEXT_SET
#define YAZ_SRW_UNSUPP_INDEX
#define YAZ_SRW_MASKING_CHAR_UNSUPP
#define YAZ_SRW_UNSUPP_PROX_UNIT
#define YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER
#define YAZ_SRW_UNSUPP_RELATION
#define YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION
#define YAZ_SRW_TOO_MANY_CHARS_IN_QUERY
#define YAZ_SRW_UNSUPP_RELATION_MODIFIER
#define YAZ_SRW_UNSUPP_COMBI_OF_RELATION_AND_TERM
FILE * yaz_log_file(void)
returns FILE handle for log or NULL if no file is in use
void yaz_log(int level, const char *fmt,...)
Writes log message.
#define YLOG_WARN
log level: warning
int yaz_memcmp(const void *a, const void *b, size_t len_a, size_t len_b)
compares two buffers of different size
Header for YAZ iconv interface.
NMEM nmem_create(void)
returns new NMEM handle
void * nmem_malloc(NMEM n, size_t size)
allocates memory block on NMEM handle
void nmem_destroy(NMEM n)
destroys NMEM handle and memory associated with it
nmem_int_t * nmem_intdup(NMEM mem, nmem_int_t v)
allocates and sets integer for NMEM
char * nmem_strdup(NMEM mem, const char *src)
allocates string on NMEM handle (similar strdup)
void odr_setprint_noclose(ODR o, FILE *file)
ODR odr_createmem(int direction)
char * odr_getbuf(ODR o, int *len, int *size)
yaz_oid_db_t yaz_oid_std(void)
returns standard OID database
Odr_oid * yaz_string_to_oid_nmem(yaz_oid_db_t oid_list, oid_class oclass, const char *name, NMEM nmem)
creates NMEM malloc'ed OID from string
const Odr_oid yaz_oid_attset_bib_1[]
int oid_oidcmp(const Odr_oid *o1, const Odr_oid *o2)
compares OIDs
int z_str_to_ProxUnit(const char *str)
converts unit name string to unit integer
Header for JSON functions.
Header for RPN to CQL tranform.
union Z_AttributeElement::@50 value
Z_ComplexAttribute * complex
Z_AttributeSetId * attributeSet
Z_AttributeElement ** attributes
Z_StringOrNumeric ** list
Odr_int ** semanticAction
union Z_StringOrNumeric::@72 u
Z_InternationalString * string
Structure used by cql_buf_write_handler.
struct cql_node::@10::@12 boolean
struct cql_node::@10::@13 sort
struct cql_node::@10::@11 st
Z_AttributeList attr_list
struct cql_prop_entry * next
yaz_tok_parse_t yaz_tok_parse_buf(yaz_tok_cfg_t t, const char *buf)
yaz_tok_cfg_t yaz_tok_cfg_create(void)
const char * yaz_tok_parse_string(yaz_tok_parse_t tp)
void yaz_tok_parse_destroy(yaz_tok_parse_t tp)
void yaz_tok_cfg_single_tokens(yaz_tok_cfg_t t, const char *simple)
void yaz_tok_cfg_destroy(yaz_tok_cfg_t t)
int yaz_tok_move(yaz_tok_parse_t tp)
Header with public definitions about YAZ' tokenizer.
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
void wrbuf_rewind(WRBUF b)
empty WRBUF content (length of buffer set to 0)
WRBUF wrbuf_alloc(void)
construct WRBUF
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
void wrbuf_puts(WRBUF b, const char *buf)
appends C-string to WRBUF
Header for WRBUF (growing buffer)
void cql_buf_write_handler(const char *b, void *client_data)
Handler for cql_buf_write_info.
Header for memory handling functions.
#define xstrdup(s)
utility macro which calls xstrdup_f
#define xfree(x)
utility macro which calls xfree_f
#define xmalloc(x)
utility macro which calls malloc_f
ASN.1 Module Z39-50-APDU-1995.
#define Z_AttributeValue_numeric
int z_AttributeList(ODR o, Z_AttributeList **p, int opt, const char *name)
#define Z_AttributeValue_complex
#define Z_StringOrNumeric_string
int z_AttributeElement(ODR o, Z_AttributeElement **p, int opt, const char *name)