YAZ  5.23.1
Functions
cqlutil.c File Reference

Implements CQL tree node utilities. More...

#include <stdlib.h>
#include <string.h>
#include <yaz/cql.h>

Go to the source code of this file.

Functions

void cql_fputs (const char *buf, void *client_data)
 stream handle for file (used by cql_to_xml_stdio) More...
 
struct cql_nodecql_node_dup (NMEM nmem, struct cql_node *cp)
 
struct cql_nodecql_node_mk_sc (NMEM nmem, const char *index, const char *relation, const char *term)
 creates a search clause node (st). More...
 
struct cql_nodecql_node_mk_boolean (NMEM nmem, const char *op)
 creates a boolean node. More...
 
struct cql_nodecql_node_mk_sort (NMEM nmem, const char *index, struct cql_node *modifiers)
 creates a sort single spec node. More...
 
const char * cql_uri (void)
 returns the standard CQL context set URI. More...
 
struct cql_nodecql_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 member index_uri / relation_uri is NULL. More...
 
void cql_node_destroy (struct cql_node *cn)
 destroys a node and its children. More...
 
int cql_strcmp (const char *s1, const char *s2)
 compares two CQL strings (ala strcmp) More...
 
int cql_strncmp (const char *s1, const char *s2, size_t n)
 compares two CQL strings (ala strncmp) More...
 

Detailed Description

Implements CQL tree node utilities.

Definition in file cqlutil.c.

Function Documentation

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 member index_uri / relation_uri is NULL.

Definition at line 110 of file cqlutil.c.

References cql_node::boolean, cql_apply_prefix(), CQL_NODE_BOOL, CQL_NODE_SORT, CQL_NODE_ST, cql_strncmp(), nmem_strdup(), cql_node::sort, cql_node::st, cql_node::u, and cql_node::which.

Referenced by cql_apply_prefix(), cql_transform_r(), and yyparse().

void cql_fputs ( const char *  buf,
void *  client_data 
)

stream handle for file (used by cql_to_xml_stdio)

Definition at line 18 of file cqlutil.c.

Referenced by cql_to_ccl_stdio(), cql_to_xml_stdio(), and cql_transform_FILE().

void cql_node_destroy ( struct cql_node cn)
struct cql_node* cql_node_dup ( NMEM  nmem,
struct cql_node cp 
)

duplicates a node (returns a copy of supplied node) .

Definition at line 24 of file cqlutil.c.

References cql_node::boolean, CQL_NODE_BOOL, cql_node_dup(), cql_node_mk_boolean(), cql_node_mk_sc(), cql_node_mk_sort(), CQL_NODE_SORT, CQL_NODE_ST, nmem_strdup(), cql_node::sort, cql_node::st, cql_node::u, and cql_node::which.

Referenced by cql_node_dup(), and yyparse().

struct cql_node* cql_node_mk_boolean ( NMEM  nmem,
const char *  op 
)

creates a boolean node.

Definition at line 78 of file cqlutil.c.

References cql_node::boolean, CQL_NODE_BOOL, nmem_malloc(), nmem_strdup(), cql_node::u, and cql_node::which.

Referenced by cql_node_dup(), and yyparse().

struct cql_node* cql_node_mk_sc ( NMEM  nmem,
const char *  index,
const char *  relation,
const char *  term 
)

creates a search clause node (st).

Definition at line 55 of file cqlutil.c.

References CQL_NODE_ST, nmem_malloc(), nmem_strdup(), cql_node::st, cql_node::u, and cql_node::which.

Referenced by cql_node_dup(), and yyparse().

struct cql_node* cql_node_mk_sort ( NMEM  nmem,
const char *  index,
struct cql_node modifiers 
)

creates a sort single spec node.

Definition at line 91 of file cqlutil.c.

References CQL_NODE_SORT, cql_node::modifiers, nmem_malloc(), nmem_strdup(), cql_node::sort, cql_node::u, and cql_node::which.

Referenced by cql_node_dup(), and yyparse().

int cql_strcmp ( const char *  s1,
const char *  s2 
)

compares two CQL strings (ala strcmp)

Parameters
s1string 1
s2string 2
Returns
comparison value Compares two CQL strings (for relations, operators, etc) (unfortunately defined as case-insensitive unlike XML etc)

Definition at line 194 of file cqlutil.c.

Referenced by cql_lookup_property(), cql_transform_r(), emit_node(), and yylex().

int cql_strncmp ( const char *  s1,
const char *  s2,
size_t  n 
)

compares two CQL strings (ala strncmp)

Parameters
s1string 1
s2string 2
nsize
Returns
comparison value Compares two CQL strings at most n bytes (unfortunately defined as case-insensitive unlike XML etc)

Definition at line 210 of file cqlutil.c.

Referenced by cql_apply_prefix(), and cql_transform_r().

const char* cql_uri ( void  )

returns the standard CQL context set URI.

Returns
CQL URI string

Definition at line 105 of file cqlutil.c.

Referenced by emit_node().