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