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