X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=include%2Fccl.h;h=d6ed51dc8a2954690fc96e3a0b48e427d1ac890b;hp=816a3950842b99990ed0fffe78d48256aaadf22d;hb=18cc954000e6b33d2316faea946f0576602b60f3;hpb=85a2e7affad79fd8bd59b403ba7b5f7867d60523 diff --git a/include/ccl.h b/include/ccl.h index 816a395..d6ed51d 100644 --- a/include/ccl.h +++ b/include/ccl.h @@ -46,7 +46,19 @@ * CCL - header file * * $Log: ccl.h,v $ - * Revision 1.5 1997-04-30 08:52:08 quinn + * Revision 1.8 1997-09-29 09:01:19 adam + * Changed CCL parser to be thread safe. New type, CCL-parser, declared + * and a create/destructor ccl_parser_create/ccl_parser_destroy has been + * added. + * + * Revision 1.7 1997/09/01 08:49:47 adam + * New windows NT/95 port using MSV5.0. To export DLL functions the + * YAZ_EXPORT modifier was added. Defined in yconfig.h. + * + * Revision 1.6 1997/05/14 06:53:37 adam + * C++ support. + * + * Revision 1.5 1997/04/30 08:52:08 quinn * Null * * Revision 1.4 1996/10/11 15:02:26 adam @@ -88,6 +100,10 @@ #ifndef CCL_H #define CCL_H +#ifdef __cplusplus +extern "C" { +#endif + /* CCL error numbers */ #define CCL_ERR_OK 0 #define CCL_ERR_TERM_EXPECTED 1 @@ -102,7 +118,7 @@ #define CCL_ERR_TRUNC_NOT_LEFT 10 #define CCL_ERR_TRUNC_NOT_BOTH 11 #define CCL_ERR_TRUNC_NOT_RIGHT 12 - + /* attribute pair (type, value) */ struct ccl_rpn_attr { struct ccl_rpn_attr *next; @@ -110,14 +126,16 @@ struct ccl_rpn_attr { int value; }; +#define CCL_RPN_AND 1 +#define CCL_RPN_OR 2 +#define CCL_RPN_NOT 3 +#define CCL_RPN_TERM 4 +#define CCL_RPN_SET 5 +#define CCL_RPN_PROX 6 + /* RPN tree structure */ struct ccl_rpn_node { - enum rpn_node_kind { - CCL_RPN_AND, CCL_RPN_OR, CCL_RPN_NOT, - CCL_RPN_TERM, - CCL_RPN_SET, - CCL_RPN_PROX - } kind; + int kind; union { struct ccl_rpn_node *p[2]; struct { @@ -190,7 +208,7 @@ typedef struct ccl_qualifiers *CCL_bibset; /* CCL token */ struct ccl_token { char kind; - char len; + size_t len; const char *name; struct ccl_token *next; struct ccl_token *prev; @@ -203,9 +221,31 @@ struct ccl_qualifier { struct ccl_qualifier *next; }; +struct ccl_parser { +/* current lookahead token */ + struct ccl_token *look_token; + +/* holds error code if error occur (and approx position of error) */ + int error_code; + const char *error_pos; + +/* current bibset */ + CCL_bibset bibset; + + char *ccl_token_and; + char *ccl_token_or; + char *ccl_token_not; + char *ccl_token_set; + int ccl_case_sensitive; +}; + +typedef struct ccl_parser *CCL_parser; + /* Generate tokens from command string - obeys all CCL opererators */ +struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, + const char *command); struct ccl_token *ccl_tokenize (const char *command); - + /* Generate tokens from command string - oebeys only simple tokens and quoted strings */ struct ccl_token *ccl_token_simple (const char *command); @@ -245,15 +285,6 @@ CCL_bibset ccl_qual_mk (void); /* Delete CCL qualifier set */ void ccl_qual_rm (CCL_bibset *b); -/* Misc. reserved words */ -extern const char *ccl_token_and; -extern const char *ccl_token_or; -extern const char *ccl_token_not; -extern const char *ccl_token_set; - -/* Whether the CCL parser is command sensitive */ -extern int ccl_case_sensitive; - /* Char-to-upper function */ extern int (*ccl_toupper)(int c); @@ -262,6 +293,18 @@ int ccl_stricmp (const char *s1, const char *s2); int ccl_memicmp (const char *s1, const char *s2, size_t n); /* Search for qualifier 'name' in set 'b'. */ -struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len); +struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, const char *name, + size_t len); + +/* Create CCL parser */ +CCL_parser ccl_parser_create (void); + +/* Destroy CCL parser */ +void ccl_parser_destroy (CCL_parser p); + +#ifdef __cplusplus +} +#endif + #endif