Added body-of-text to BIB-1 ANY and the WAIS profile
[yaz-moved-to-github.git] / include / ccl.h
1 /* CCL - header file
2  * Europagate, 1995
3  *
4  * $Log: ccl.h,v $
5  * Revision 1.3  1995-09-29 17:12:01  quinn
6  * Smallish
7  *
8  * Revision 1.2  1995/09/27  15:02:46  quinn
9  * Modified function heads & prototypes.
10  *
11  * Revision 1.1  1995/04/10  10:28:27  quinn
12  * Added copy of CCL.
13  *
14  * Revision 1.5  1995/02/23  08:32:11  adam
15  * Changed header.
16  *
17  * Revision 1.3  1995/02/16  13:20:10  adam
18  * Spell fix.
19  *
20  * Revision 1.2  1995/02/15  17:43:08  adam
21  * Minor changes to the ccl interface. Bug fix in iso2709 module.
22  *
23  * Revision 1.1  1995/02/14  19:55:21  adam
24  * Header files ccl.h/cclp.h are gone! They have been merged an
25  * moved to ../include/ccl.h.
26  *
27  */
28
29 #ifndef CCL_H
30 #define CCL_H
31
32 #include <yconfig.h>
33
34 /* CCL error numbers */
35 #define CCL_ERR_OK                0
36 #define CCL_ERR_TERM_EXPECTED     1
37 #define CCL_ERR_RP_EXPECTED       2
38 #define CCL_ERR_SETNAME_EXPECTED  3
39 #define CCL_ERR_OP_EXPECTED       4
40 #define CCL_ERR_BAD_RP            5
41 #define CCL_ERR_UNKNOWN_QUAL      6
42 #define CCL_ERR_DOUBLE_QUAL       7
43 #define CCL_ERR_EQ_EXPECTED       8
44 #define CCL_ERR_BAD_RELATION      9
45 #define CCL_ERR_TRUNC_NOT_LEFT   10
46 #define CCL_ERR_TRUNC_NOT_BOTH   11
47 #define CCL_ERR_TRUNC_NOT_RIGHT  12
48
49 /* attribute pair (type, value) */
50 struct ccl_rpn_attr {
51     struct ccl_rpn_attr *next;
52     int type;
53     int value;
54 };
55
56 /* RPN tree structure */
57 struct ccl_rpn_node {
58     enum rpn_node_kind {
59         CCL_RPN_AND, CCL_RPN_OR, CCL_RPN_NOT,
60         CCL_RPN_TERM,
61         CCL_RPN_SET,
62         CCL_RPN_PROX
63     } kind;
64     union {
65         struct ccl_rpn_node *p[2];
66         struct {
67             char *term;
68             struct ccl_rpn_attr *attr_list;
69         } t;
70         char *setname;
71     } u;
72 };
73
74 typedef struct ccl_qualifiers *CCL_bibset;
75
76 /* use (1)
77
78    relation (2)
79                             -1  none
80                              0  ordered
81                            1-6  relation (<, <=, =, >=, >, <>)
82
83    position (3)
84                             -1  none
85                              1  first in field
86                              2  first in sub field
87                              3  any position in field
88    structure (4)
89                             -1  none
90                              0  word/phrase auto select
91                              1  phrase
92                              2  word
93                              3  key
94                              4  year
95                              5  date (normalized)
96                              6  word list 
97                            100  date (un-normalized)
98                            101  name (normalized)
99                            102  name (un-normalized)
100    truncation (5)                            
101    completeness (6)
102 */
103
104 #define CCL_BIB1_USE 1
105 #define CCL_BIB1_REL 2
106 #define CCL_BIB1_POS 3
107 #define CCL_BIB1_STR 4
108 #define CCL_BIB1_TRU 5
109 #define CCL_BIB1_COM 6
110
111 #define CCL_BIB1_STR_WP (-1)
112 #define CCL_BIB1_REL_ORDER (-1)
113
114 #define CCL_BIB1_TRU_CAN_LEFT (-1)
115 #define CCL_BIB1_TRU_CAN_RIGHT (-2)
116 #define CCL_BIB1_TRU_CAN_BOTH  (-3)
117 #define CCL_BIB1_TRU_CAN_NONE  (-4)
118
119 #define CCL_TOK_EOL   0
120 #define CCL_TOK_TERM  1
121 #define CCL_TOK_REL   2
122 #define CCL_TOK_EQ    3
123 #define CCL_TOK_PROX  4
124 #define CCL_TOK_LP    5
125 #define CCL_TOK_RP    6
126 #define CCL_TOK_COMMA 7
127 #define CCL_TOK_AND   8
128 #define CCL_TOK_OR    7
129 #define CCL_TOK_NOT   9
130 #define CCL_TOK_MINUS 10
131 #define CCL_TOK_SET   11
132
133 struct ccl_token {
134     char kind;
135     char len;
136     const char *name;
137     struct ccl_token *next;
138     struct ccl_token *prev;
139 };
140
141 struct ccl_qualifier {
142     char *name;
143     struct ccl_rpn_attr *attr_list;
144     struct ccl_qualifier *next;
145 };
146
147 struct ccl_token *ccl_tokenize (const char *command);
148
149 struct ccl_rpn_node *ccl_find_str (CCL_bibset bibset,
150                                    const char *str, int *error, int *pos);
151
152 struct ccl_rpn_node *ccl_find (CCL_bibset abibset, struct ccl_token *list,
153                                int *error, const char **pos);
154 char *ccl_err_msg (int ccl_errno);
155 void ccl_rpn_delete (struct ccl_rpn_node *rpn);
156 void ccl_pr_tree (struct ccl_rpn_node *rpn, FILE *fd_out);
157
158 void ccl_qual_add (CCL_bibset b, const char *name, int no, int *attr);
159 void ccl_qual_file (CCL_bibset bibset, FILE *inf);
160 CCL_bibset ccl_qual_mk (void);
161 void ccl_qual_rm (CCL_bibset *b);
162
163 extern const char *ccl_token_and;
164 extern const char *ccl_token_or;
165 extern const char *ccl_token_not;
166 extern const char *ccl_token_set;
167
168
169 struct ccl_rpn_attr *ccl_qual_search (CCL_bibset b, const char *name, int len);
170 #endif
171