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