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