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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 #ifndef CCL_H
00072 #define CCL_H
00073
00074 #include <yaz/yconfig.h>
00075 #include <stdio.h>
00076 #include <yaz/xmalloc.h>
00077 #include <yaz/wrbuf.h>
00078
00079 YAZ_BEGIN_CDECL
00080
00081 #define CCL_ERR_OK 0
00082 #define CCL_ERR_TERM_EXPECTED 1
00083 #define CCL_ERR_RP_EXPECTED 2
00084 #define CCL_ERR_SETNAME_EXPECTED 3
00085 #define CCL_ERR_OP_EXPECTED 4
00086 #define CCL_ERR_BAD_RP 5
00087 #define CCL_ERR_UNKNOWN_QUAL 6
00088 #define CCL_ERR_DOUBLE_QUAL 7
00089 #define CCL_ERR_EQ_EXPECTED 8
00090 #define CCL_ERR_BAD_RELATION 9
00091 #define CCL_ERR_TRUNC_NOT_LEFT 10
00092 #define CCL_ERR_TRUNC_NOT_BOTH 11
00093 #define CCL_ERR_TRUNC_NOT_RIGHT 12
00094
00096 struct ccl_rpn_attr {
00098 struct ccl_rpn_attr *next;
00100 char *set;
00102 int type;
00104 int kind;
00105 #define CCL_RPN_ATTR_NUMERIC 1
00106 #define CCL_RPN_ATTR_STRING 2
00107 union {
00109 int numeric;
00111 char *str;
00112 } value;
00113 };
00114
00116 enum ccl_rpn_kind {
00117 CCL_RPN_AND,
00118 CCL_RPN_OR,
00119 CCL_RPN_NOT,
00120 CCL_RPN_TERM,
00121 CCL_RPN_SET,
00122 CCL_RPN_PROX
00123 };
00124
00126 struct ccl_rpn_node {
00128 enum ccl_rpn_kind kind;
00129 union {
00131 struct ccl_rpn_node *p[3];
00133 struct {
00134 char *term;
00135 char *qual;
00136 struct ccl_rpn_attr *attr_list;
00137 } t;
00139 char *setname;
00140 } u;
00141 };
00142
00144 typedef struct ccl_qualifiers *CCL_bibset;
00145
00147 typedef struct ccl_parser *CCL_parser;
00148
00156 YAZ_EXPORT
00157 struct ccl_rpn_node *ccl_find_str(CCL_bibset bibset,
00158 const char *str, int *error, int *pos);
00159
00160
00168 YAZ_EXPORT
00169 struct ccl_rpn_node *ccl_parser_find_str(CCL_parser cclp, const char *str);
00170
00172 YAZ_EXPORT
00173 void ccl_parser_set_case(CCL_parser p, int case_sensitivity_flag);
00174
00176 YAZ_EXPORT
00177 const char *ccl_err_msg(int ccl_errno);
00178
00180 YAZ_EXPORT
00181 void ccl_rpn_delete(struct ccl_rpn_node *rpn);
00182
00184 YAZ_EXPORT
00185 void ccl_pr_tree(struct ccl_rpn_node *rpn, FILE *fd_out);
00186
00188 YAZ_EXPORT
00189 void ccl_qual_add(CCL_bibset b, const char *name, int no, int *attr);
00190
00192 YAZ_EXPORT
00193 void ccl_qual_add_set(CCL_bibset b, const char *name, int no,
00194 int *type, int *value, char **svalue, char **attsets);
00195
00197 YAZ_EXPORT
00198 void ccl_qual_add_special(CCL_bibset bibset, const char *n, const char *cp);
00199
00201 YAZ_EXPORT
00202 void ccl_qual_add_combi(CCL_bibset b, const char *n, const char **names);
00203
00205 YAZ_EXPORT
00206 void ccl_qual_file(CCL_bibset bibset, FILE *inf);
00207
00209 YAZ_EXPORT
00210 int ccl_qual_fname(CCL_bibset bibset, const char *fname);
00211
00213 YAZ_EXPORT
00214 void ccl_qual_buf(CCL_bibset bibset, const char *buf);
00215
00217 YAZ_EXPORT
00218 void ccl_qual_line(CCL_bibset bibset, char *line);
00219
00220
00221 YAZ_EXPORT
00222 void ccl_qual_fitem(CCL_bibset bibset, const char *value,
00223 const char *qual_name);
00224
00226 YAZ_EXPORT
00227 CCL_bibset ccl_qual_mk(void);
00228
00230 YAZ_EXPORT
00231 void ccl_qual_rm(CCL_bibset *b);
00232
00234 extern int(*ccl_toupper)(int c);
00235
00237 YAZ_EXPORT
00238 int ccl_stricmp(const char *s1, const char *s2);
00239
00241 YAZ_EXPORT
00242 int ccl_memicmp(const char *s1, const char *s2, size_t n);
00243
00245 YAZ_EXPORT
00246 CCL_parser ccl_parser_create(CCL_bibset bibset);
00247
00249 YAZ_EXPORT
00250 void ccl_parser_destroy(CCL_parser p);
00251
00253 YAZ_EXPORT
00254 const char **ccl_qual_search_special(CCL_bibset b, const char *name);
00256 YAZ_EXPORT
00257 void ccl_pquery(WRBUF w, struct ccl_rpn_node *p);
00258
00259 YAZ_EXPORT
00260 int ccl_parser_get_error(CCL_parser cclp, int *pos);
00261
00262 YAZ_EXPORT
00263 struct ccl_rpn_node *ccl_rpn_node_create(enum ccl_rpn_kind kind);
00264
00265 YAZ_EXPORT
00266 void ccl_add_attr_numeric(struct ccl_rpn_node *p, const char *set,
00267 int type, int value);
00268
00269 YAZ_EXPORT
00270 void ccl_add_attr_string(struct ccl_rpn_node *p, const char *set,
00271 int type, char *value);
00272
00273 YAZ_EXPORT
00274 int ccl_search_stop(CCL_bibset bibset, const char *qname,
00275 const char *src_str, size_t src_len);
00276
00277
00279 typedef struct ccl_stop_words *ccl_stop_words_t;
00280
00282 YAZ_EXPORT
00283 ccl_stop_words_t ccl_stop_words_create(void);
00284
00286 YAZ_EXPORT
00287 void ccl_stop_words_destroy(ccl_stop_words_t csw);
00288
00290 YAZ_EXPORT
00291 int ccl_stop_words_tree(ccl_stop_words_t csw,
00292 CCL_bibset bibset, struct ccl_rpn_node **t);
00293
00295 YAZ_EXPORT
00296 int ccl_stop_words_info(ccl_stop_words_t csw, int idx,
00297 const char **qualname, const char **term);
00298
00299 #ifndef ccl_assert
00300 #define ccl_assert(x) ;
00301 #endif
00302
00303
00334 #define CCL_BIB1_USE 1
00335 #define CCL_BIB1_REL 2
00336 #define CCL_BIB1_POS 3
00337 #define CCL_BIB1_STR 4
00338 #define CCL_BIB1_TRU 5
00339 #define CCL_BIB1_COM 6
00340
00341 #define CCL_BIB1_STR_WP (-1)
00342 #define CCL_BIB1_STR_AND_LIST (-2)
00343 #define CCL_BIB1_STR_OR_LIST (-3)
00344 #define CCL_BIB1_REL_ORDER (-1)
00345 #define CCL_BIB1_REL_PORDER (-2)
00346
00347 #define CCL_BIB1_TRU_CAN_LEFT (-1)
00348 #define CCL_BIB1_TRU_CAN_RIGHT (-2)
00349 #define CCL_BIB1_TRU_CAN_BOTH (-3)
00350 #define CCL_BIB1_TRU_CAN_NONE (-4)
00351
00352
00353
00354 YAZ_END_CDECL
00355
00356 #endif
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366