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