YAZ  5.23.1
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ccl.h File Reference

Header with public definitions for CCL. More...

#include <yaz/yconfig.h>
#include <stdio.h>
#include <yaz/xmalloc.h>
#include <yaz/wrbuf.h>

Go to the source code of this file.

Data Structures

struct  ccl_rpn_attr
 attribute node (type, value) pair as used in RPN More...
 
struct  ccl_rpn_node
 RPN tree structure node. More...
 

Macros

#define CCL_ERR_OK   0
 
#define CCL_ERR_TERM_EXPECTED   1
 
#define CCL_ERR_RP_EXPECTED   2
 
#define CCL_ERR_SETNAME_EXPECTED   3
 
#define CCL_ERR_OP_EXPECTED   4
 
#define CCL_ERR_BAD_RP   5
 
#define CCL_ERR_UNKNOWN_QUAL   6
 
#define CCL_ERR_DOUBLE_QUAL   7
 
#define CCL_ERR_EQ_EXPECTED   8
 
#define CCL_ERR_BAD_RELATION   9
 
#define CCL_ERR_TRUNC_NOT_LEFT   10
 
#define CCL_ERR_TRUNC_NOT_BOTH   11
 
#define CCL_ERR_TRUNC_NOT_RIGHT   12
 
#define CCL_ERR_TRUNC_NOT_EMBED   13
 
#define CCL_ERR_TRUNC_NOT_SINGLE   14
 
#define CCL_RPN_ATTR_NUMERIC   1
 
#define CCL_RPN_ATTR_STRING   2
 
#define ccl_assert(x)   ;
 
#define CCL_BIB1_USE   1
 common attributes More...
 
#define CCL_BIB1_REL   2
 
#define CCL_BIB1_POS   3
 
#define CCL_BIB1_STR   4
 
#define CCL_BIB1_TRU   5
 
#define CCL_BIB1_COM   6
 
#define CCL_BIB1_STR_WP   (-1)
 
#define CCL_BIB1_STR_AND_LIST   (-2)
 
#define CCL_BIB1_STR_OR_LIST   (-3)
 
#define CCL_BIB1_STR_AUTO_GROUP   (-4)
 
#define CCL_BIB1_STR_SPLIT_LIST   (-5)
 
#define CCL_BIB1_REL_ORDER   (-1)
 
#define CCL_BIB1_REL_PORDER   (-2)
 
#define CCL_BIB1_REL_OMIT_EQUALS   (-3)
 
#define CCL_BIB1_TRU_CAN_LEFT   (-1)
 
#define CCL_BIB1_TRU_CAN_RIGHT   (-2)
 
#define CCL_BIB1_TRU_CAN_BOTH   (-3)
 
#define CCL_BIB1_TRU_CAN_NONE   (-4)
 
#define CCL_BIB1_TRU_CAN_REGEX   (-5)
 
#define CCL_BIB1_TRU_CAN_Z3958   (-6)
 

Typedefs

typedef struct ccl_qualifiersCCL_bibset
 CCL bibset, AKA profile. More...
 
typedef struct ccl_parserCCL_parser
 CCL parser. More...
 
typedef struct ccl_stop_wordsccl_stop_words_t
 stop words handle (pimpl) More...
 

Enumerations

enum  ccl_rpn_kind {
  CCL_RPN_AND, CCL_RPN_OR, CCL_RPN_NOT, CCL_RPN_TERM,
  CCL_RPN_SET, CCL_RPN_PROX
}
 node type or RPN tree generated by the CCL parser More...
 

Functions

struct ccl_rpn_nodeccl_find_str (CCL_bibset bibset, const char *str, int *error, int *pos)
 parse CCL find string using CCL profile return RPN tree More...
 
struct ccl_rpn_nodeccl_parser_find_str (CCL_parser cclp, const char *str)
 parse CCL find string with parser and return RPN tree More...
 
void ccl_parser_set_case (CCL_parser p, int case_sensitivity_flag)
 
const char * ccl_err_msg (int ccl_errno)
 
void ccl_rpn_delete (struct ccl_rpn_node *rpn)
 
void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out)
 
void ccl_qual_add (CCL_bibset b, const char *name, int no, int *attr)
 
void ccl_qual_add_set (CCL_bibset b, const char *name, int no, int *type, int *value, char **svalue, char **attsets)
 adds specifies attributes for qualifier More...
 
void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *cp)
 
void ccl_qual_add_combi (CCL_bibset b, const char *n, const char **names)
 adds specifies qualifier aliases More...
 
void ccl_qual_file (CCL_bibset bibset, FILE *inf)
 
int ccl_qual_fname (CCL_bibset bibset, const char *fname)
 
void ccl_qual_buf (CCL_bibset bibset, const char *buf)
 
void ccl_qual_line (CCL_bibset bibset, char *line)
 
void ccl_qual_fitem (CCL_bibset bibset, const char *value, const char *qual_name)
 
int ccl_qual_fitem2 (CCL_bibset bibset, const char *value, const char *qual_name, const char **addinfo)
 
CCL_bibset ccl_qual_mk (void)
 creates Bibset More...
 
CCL_bibset ccl_qual_dup (CCL_bibset b)
 
void ccl_qual_rm (CCL_bibset *b)
 destroys Bibset More...
 
int ccl_stricmp (const char *s1, const char *s2)
 
int ccl_memicmp (const char *s1, const char *s2, size_t n)
 
CCL_parser ccl_parser_create (CCL_bibset bibset)
 
void ccl_parser_destroy (CCL_parser p)
 
const char ** ccl_qual_search_special (CCL_bibset b, const char *name)
 
void ccl_pquery (WRBUF w, struct ccl_rpn_node *p)
 
int ccl_parser_get_error (CCL_parser cclp, int *pos)
 
struct ccl_rpn_nodeccl_rpn_node_create (enum ccl_rpn_kind kind)
 
void ccl_add_attr_numeric (struct ccl_rpn_node *p, const char *set, int type, int value)
 
void ccl_add_attr_string (struct ccl_rpn_node *p, const char *set, int type, char *value)
 
int ccl_search_stop (CCL_bibset bibset, const char *qname, const char *src_str, size_t src_len)
 
ccl_stop_words_t ccl_stop_words_create (void)
 creates stop words handle More...
 
void ccl_stop_words_destroy (ccl_stop_words_t csw)
 destroys stop words handle More...
 
int ccl_stop_words_tree (ccl_stop_words_t csw, CCL_bibset bibset, struct ccl_rpn_node **t)
 removes stop words from RPN tree More...
 
int ccl_stop_words_info (ccl_stop_words_t csw, int idx, const char **qualname, const char **term)
 returns information about removed "stop" words More...
 
struct ccl_rpn_attrccl_parser_qual_search (CCL_parser cclp, const char *name, size_t name_len)
 

Variables

int(* ccl_toupper )(int c)
 

Detailed Description

Header with public definitions for CCL.

Definition in file ccl.h.

Macro Definition Documentation

#define ccl_assert (   x)    ;
#define CCL_BIB1_COM   6

Definition at line 353 of file ccl.h.

Referenced by ccl_qual_field2().

#define CCL_BIB1_POS   3

Definition at line 350 of file ccl.h.

Referenced by ccl_qual_field2().

#define CCL_BIB1_REL   2

Definition at line 349 of file ccl.h.

Referenced by ccl_qual_field2(), qualifier_relation(), and qualifiers_order().

#define CCL_BIB1_REL_OMIT_EQUALS   (-3)

Definition at line 362 of file ccl.h.

Referenced by ccl_qual_field2(), and qualifiers_order().

#define CCL_BIB1_REL_ORDER   (-1)

Definition at line 360 of file ccl.h.

Referenced by ccl_qual_field2(), and qualifier_relation().

#define CCL_BIB1_REL_PORDER   (-2)

Definition at line 361 of file ccl.h.

Referenced by ccl_qual_field2(), qualifier_relation(), and qualifiers_order().

#define CCL_BIB1_STR   4

Definition at line 351 of file ccl.h.

Referenced by ccl_qual_field2(), ccl_term_one_use(), and search_term_x().

#define CCL_BIB1_STR_AND_LIST   (-2)

Definition at line 356 of file ccl.h.

Referenced by ccl_qual_field2(), and search_term_x().

#define CCL_BIB1_STR_AUTO_GROUP   (-4)

Definition at line 358 of file ccl.h.

Referenced by ccl_qual_field2(), and search_term_x().

#define CCL_BIB1_STR_OR_LIST   (-3)

Definition at line 357 of file ccl.h.

Referenced by ccl_qual_field2(), and search_term_x().

#define CCL_BIB1_STR_SPLIT_LIST   (-5)

Definition at line 359 of file ccl.h.

Referenced by ccl_qual_field2(), and search_term_x().

#define CCL_BIB1_STR_WP   (-1)

Definition at line 355 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU   5

Definition at line 352 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU_CAN_BOTH   (-3)

Definition at line 366 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU_CAN_LEFT   (-1)

Definition at line 364 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU_CAN_NONE   (-4)

Definition at line 367 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU_CAN_REGEX   (-5)

Definition at line 368 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU_CAN_RIGHT   (-2)

Definition at line 365 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_TRU_CAN_Z3958   (-6)

Definition at line 369 of file ccl.h.

Referenced by ccl_qual_field2(), and ccl_term_one_use().

#define CCL_BIB1_USE   1

common attributes

use (1)

relation (2) -1 none 0 ordered 1-6 relation (<, <=, =, >=, >, <>)

position (3) -1 none 1 first in field 2 first in sub field 3 any position in field structure (4) -1 none 0 word/phrase auto select 1 phrase 2 word 3 key 4 year 5 date (normalized) 6 word list 100 date (un-normalized) 101 name (normalized) 102 name (un-normalized) truncation (5) completeness (6)

Definition at line 348 of file ccl.h.

Referenced by ccl_qual_field2().

#define CCL_ERR_BAD_RELATION   9

Definition at line 90 of file ccl.h.

Referenced by qualifiers_order().

#define CCL_ERR_BAD_RP   5

Definition at line 86 of file ccl.h.

Referenced by ccl_parser_find_token().

#define CCL_ERR_DOUBLE_QUAL   7

Definition at line 88 of file ccl.h.

Referenced by qualifier_list().

#define CCL_ERR_EQ_EXPECTED   8

Definition at line 89 of file ccl.h.

Referenced by qualifier_relation().

#define CCL_ERR_OK   0

Definition at line 81 of file ccl.h.

Referenced by ccl_parser_find_token().

#define CCL_ERR_OP_EXPECTED   4

Definition at line 85 of file ccl.h.

Referenced by ccl_parser_find_token().

#define CCL_ERR_RP_EXPECTED   2

Definition at line 83 of file ccl.h.

Referenced by search_terms2().

#define CCL_ERR_SETNAME_EXPECTED   3

Definition at line 84 of file ccl.h.

Referenced by search_elements().

#define CCL_ERR_TERM_EXPECTED   1

Definition at line 82 of file ccl.h.

Referenced by search_term_split_list(), and search_term_x().

#define CCL_ERR_TRUNC_NOT_BOTH   11

Definition at line 92 of file ccl.h.

Referenced by ccl_term_one_use().

#define CCL_ERR_TRUNC_NOT_EMBED   13

Definition at line 94 of file ccl.h.

Referenced by append_term().

#define CCL_ERR_TRUNC_NOT_LEFT   10

Definition at line 91 of file ccl.h.

Referenced by ccl_term_one_use().

#define CCL_ERR_TRUNC_NOT_RIGHT   12

Definition at line 93 of file ccl.h.

Referenced by ccl_term_one_use().

#define CCL_ERR_TRUNC_NOT_SINGLE   14

Definition at line 95 of file ccl.h.

Referenced by append_term().

#define CCL_ERR_UNKNOWN_QUAL   6

Definition at line 87 of file ccl.h.

Referenced by qualifier_list().

#define CCL_RPN_ATTR_NUMERIC   1
#define CCL_RPN_ATTR_STRING   2

Typedef Documentation

typedef struct ccl_qualifiers* CCL_bibset

CCL bibset, AKA profile.

Definition at line 146 of file ccl.h.

typedef struct ccl_parser* CCL_parser

CCL parser.

Definition at line 149 of file ccl.h.

stop words handle (pimpl)

Definition at line 288 of file ccl.h.

Enumeration Type Documentation

node type or RPN tree generated by the CCL parser

Enumerator
CCL_RPN_AND 
CCL_RPN_OR 
CCL_RPN_NOT 
CCL_RPN_TERM 
CCL_RPN_SET 
CCL_RPN_PROX 

Definition at line 118 of file ccl.h.

Function Documentation

void ccl_add_attr_numeric ( struct ccl_rpn_node p,
const char *  set,
int  type,
int  value 
)

add_attr_numeric: Add attribute (type/value) to RPN term node. p: RPN node of type term. type: Type of attribute value: Value of attribute set: Attribute set name

Definition at line 213 of file cclfind.c.

References add_attr_node(), CCL_RPN_ATTR_NUMERIC, ccl_rpn_attr::kind, ccl_rpn_attr::numeric, and ccl_rpn_attr::value.

Referenced by ccl_set_attr_numeric(), and ccl_term_one_use().

void ccl_add_attr_string ( struct ccl_rpn_node p,
const char *  set,
int  type,
char *  value 
)
const char* ccl_err_msg ( int  ccl_errno)

Return english-readable error message for CCL parser error number

Definition at line 36 of file cclerrms.c.

References err_msg_array.

Referenced by ccl2pqf(), and ZOOM_query_ccl2rpn().

struct ccl_rpn_node* ccl_find_str ( CCL_bibset  bibset,
const char *  str,
int *  error,
int *  pos 
)

parse CCL find string using CCL profile return RPN tree

Parses a CCL Find command in a simple C string. Returns CCL parse tree node describing RPN if parsing is successful. If parsing is unsuccesful, NULL is returned and error and pos is set accordingly.

ccl_find_str: Parse CCL find - string representation bibset: Bibset to be used for the parsing str: String to be parsed error: Pointer to integer. Holds error no. on completion. pos: Pointer to char position. Holds approximate error position. return: RPN tree on successful completion; NULL otherwise.

Definition at line 1310 of file cclfind.c.

References ccl_parser_create(), ccl_parser_destroy(), ccl_parser_find_token(), ccl_parser_tokenize(), ccl_token_del(), ccl_parser::error_code, ccl_parser::error_pos, and ccl_rpn_node::p.

Referenced by ccl2pqf(), and ZOOM_query_ccl2rpn().

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

CCL version of ccl_memicmp

Definition at line 45 of file cclstr.c.

References ccl_toupper, and ccli_toupper().

Referenced by ccl_qual_search(), ccl_search_stop(), and token_cmp().

CCL_parser ccl_parser_create ( CCL_bibset  bibset)
void ccl_parser_destroy ( CCL_parser  p)
struct ccl_rpn_node* ccl_parser_find_str ( CCL_parser  cclp,
const char *  str 
)

parse CCL find string with parser and return RPN tree

Parses a CCL Find command in a simple C string. Returns CCL parse tree node describing RPN if parsing is successful. If parsing is unsuccesful, NULL is returned and error and pos is set accordingly.

Definition at line 1271 of file cclfind.c.

References ccl_parser_find_token(), ccl_parser_tokenize(), ccl_token_del(), and ccl_rpn_node::p.

int ccl_parser_get_error ( CCL_parser  cclp,
int *  pos 
)

Definition at line 282 of file ccltoken.c.

References ccl_parser::error_code, ccl_parser::error_pos, and ccl_parser::start_pos.

struct ccl_rpn_attr* ccl_parser_qual_search ( CCL_parser  cclp,
const char *  name,
size_t  name_len 
)

Definition at line 387 of file cclqual.c.

References ccl_qualifier::attr_list, and ccl_qual_search().

void ccl_parser_set_case ( CCL_parser  p,
int  case_sensitivity_flag 
)

Set case sensitivity for parser

Definition at line 276 of file ccltoken.c.

References ccl_parser::ccl_case_sensitive.

void ccl_pquery ( WRBUF  w,
struct ccl_rpn_node p 
)

Pretty-print CCL RPN node tree to WRBUF

Definition at line 135 of file cclptree.c.

References ccl_pquery_indent().

Referenced by ccl_rpn_query(), ccl_scan_query(), and ZOOM_query_ccl2rpn().

void ccl_pr_tree ( struct ccl_rpn_node rpn,
FILE *  fd_out 
)

Dump RPN tree in readable format to fd_out

Definition at line 140 of file cclptree.c.

References ccl_pquery_indent(), wrbuf_alloc(), wrbuf_cstr(), and wrbuf_destroy().

void ccl_qual_add ( CCL_bibset  b,
const char *  name,
int  no,
int *  attr 
)

Add qualifier and supply attribute pairs for it

void ccl_qual_add_combi ( CCL_bibset  b,
const char *  n,
const char **  names 
)

adds specifies qualifier aliases

Add combo qualifier

Parameters
bbibset
nqualifier name
nameslist of qualifier aliases

Definition at line 127 of file cclqual.c.

References ccl_qualifier::attr_list, ccl_qual_lookup(), ccl_qual_new(), ccl_qualifiers::list, ccl_qualifier::name, ccl_qualifier::next, ccl_qualifier::no_sub, ccl_qualifier::sub, xmalloc, and xstrdup.

Referenced by ccl_qual_field2().

void ccl_qual_add_set ( CCL_bibset  b,
const char *  name,
int  no,
int *  type_ar,
int *  value_ar,
char **  svalue_ar,
char **  attsets 
)

adds specifies attributes for qualifier

Add qualifier and supply attributes pairs+attribute set for it

Parameters
bbibset
namequalifier name
nonumber of attribute type+value pairs
type_arattributes type of size no
value_arattribute value of size no
svalue_arattribute string values ([i] only used if != NULL)
attsetsattribute sets of size no

Definition at line 165 of file cclqual.c.

References ccl_qualifier::attr_list, ccl_assert, ccl_qual_new(), CCL_RPN_ATTR_NUMERIC, CCL_RPN_ATTR_STRING, ccl_rpn_attr::kind, ccl_qualifiers::list, ccl_qualifier::name, ccl_qualifier::next, ccl_rpn_attr::next, ccl_rpn_attr::numeric, ccl_rpn_attr::set, ccl_rpn_attr::str, ccl_rpn_attr::type, ccl_rpn_attr::value, and xmalloc.

Referenced by ccl_qual_field2().

void ccl_qual_add_special ( CCL_bibset  bibset,
const char *  n,
const char *  cp 
)
void ccl_qual_buf ( CCL_bibset  bibset,
const char *  buf 
)

Add CCL qualifier as buf spec(multiple lines).

Definition at line 261 of file cclqfile.c.

References ccl_qual_line().

Referenced by ZOOM_query_ccl2rpn().

CCL_bibset ccl_qual_dup ( CCL_bibset  b)
void ccl_qual_file ( CCL_bibset  bibset,
FILE *  inf 
)

Read CCL qualifier list spec from file inf

Definition at line 316 of file cclqfile.c.

References ccl_qual_line().

Referenced by ccl_qual_fname(), and xml_config_read().

void ccl_qual_fitem ( CCL_bibset  bibset,
const char *  value,
const char *  qual_name 
)

Definition at line 255 of file cclqfile.c.

References ccl_qual_fitem2().

Referenced by ccl_qual_line(), and ccl_xml_config_qual().

int ccl_qual_fitem2 ( CCL_bibset  bibset,
const char *  value,
const char *  qual_name,
const char **  addinfo 
)

Definition at line 241 of file cclqfile.c.

References ccl_qual_add_special(), and ccl_qual_field2().

Referenced by ccl_qual_fitem().

int ccl_qual_fname ( CCL_bibset  bibset,
const char *  fname 
)

Read CCL qualifier list spec from file inf

Definition at line 324 of file cclqfile.c.

References ccl_qual_file().

void ccl_qual_line ( CCL_bibset  bibset,
char *  line 
)

Add CCL qualifier as line spec. Note: line is modified

Definition at line 286 of file cclqfile.c.

References ccl_qual_fitem().

Referenced by ccl_qual_buf(), and ccl_qual_file().

CCL_bibset ccl_qual_mk ( void  )

creates Bibset

Make CCL qualifier set

Returns
bibset

Definition at line 210 of file cclqual.c.

References ccl_assert, ccl_qualifiers::list, ccl_qualifiers::special, and xmalloc.

Referenced by ccl_qual_dup(), xml_config_read(), and ZOOM_query_ccl2rpn().

void ccl_qual_rm ( CCL_bibset b)
const char** ccl_qual_search_special ( CCL_bibset  b,
const char *  name 
)
void ccl_rpn_delete ( struct ccl_rpn_node rpn)
struct ccl_rpn_node* ccl_rpn_node_create ( enum ccl_rpn_kind  kind)

mk_node: Create RPN node. kind: Type of node. return: pointer to allocated node.

Definition at line 100 of file cclfind.c.

References ccl_assert, CCL_RPN_TERM, ccl_rpn_node::kind, ccl_rpn_node::p, ccl_rpn_node::t, ccl_rpn_node::u, and xmalloc.

Referenced by ccl_rpn_node_mkbool(), ccl_term_one_use(), qualifiers_order(), search_elements(), and search_terms().

int ccl_search_stop ( CCL_bibset  bibset,
const char *  qname,
const char *  src_str,
size_t  src_len 
)

Definition at line 413 of file cclqual.c.

References ccl_memicmp(), ccl_qual_search_special(), and yaz_snprintf().

Referenced by ccl_remove_stop_r().

ccl_stop_words_t ccl_stop_words_create ( void  )

creates stop words handle

Definition at line 53 of file ccl_stop_words.c.

References ccl_stop_words::blank_chars, ccl_stop_words::nmem, nmem_create(), ccl_stop_words::removed_items, xmalloc, and xstrdup.

void ccl_stop_words_destroy ( ccl_stop_words_t  csw)

destroys stop words handle

Definition at line 63 of file ccl_stop_words.c.

References ccl_stop_words::blank_chars, ccl_stop_words::nmem, nmem_destroy(), and xfree.

int ccl_stop_words_info ( ccl_stop_words_t  csw,
int  idx,
const char **  qualname,
const char **  term 
)

returns information about removed "stop" words

Definition at line 178 of file ccl_stop_words.c.

References ccl_stop_info::next, ccl_stop_info::qualname, ccl_stop_words::removed_items, and ccl_stop_info::term.

int ccl_stop_words_tree ( ccl_stop_words_t  csw,
CCL_bibset  bibset,
struct ccl_rpn_node **  t 
)

removes stop words from RPN tree

Definition at line 162 of file ccl_stop_words.c.

References ccl_remove_stop_r(), ccl_stop_words::nmem, nmem_reset(), and ccl_stop_words::removed_items.

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

CCL version of ccl_stricmp

Definition at line 28 of file cclstr.c.

References ccl_toupper, and ccli_toupper().

Referenced by ccl_qual_field2().

Variable Documentation

int(* ccl_toupper) (int c)

Char-to-upper function

Definition at line 26 of file cclstr.c.

Referenced by ccl_memicmp(), and ccl_stricmp().