Zebra version corresponds to YAZ version 1.4.
[idzebra-moved-to-github.git] / index / zserver.h
1 /*
2  * Copyright (C) 1994-1997, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: zserver.h,v $
7  * Revision 1.24  1997-09-17 12:19:19  adam
8  * Zebra version corresponds to YAZ version 1.4.
9  * Changed Zebra server so that it doesn't depend on global common_resource.
10  *
11  * Revision 1.23  1996/12/23 15:30:46  adam
12  * Work on truncation.
13  * Bug fix: result sets weren't deleted after server shut down.
14  *
15  * Revision 1.22  1996/11/04 14:07:49  adam
16  * Moved truncation code to trunc.c.
17  *
18  * Revision 1.21  1996/10/29 14:09:58  adam
19  * Use of cisam system - enabled if setting isamc is 1.
20  *
21  * Revision 1.20  1996/06/04 10:19:02  adam
22  * Minor changes - removed include of ctype.h.
23  *
24  * Revision 1.19  1996/05/14  11:34:01  adam
25  * Scan support in multiple registers/databases.
26  *
27  * Revision 1.18  1996/05/14  06:16:50  adam
28  * Compact use/set bytes used in search service.
29  *
30  * Revision 1.17  1995/12/08 16:22:57  adam
31  * Work on update while servers are running. Three lock files introduced.
32  * The servers reload their registers when necessary, but they don't
33  * reestablish result sets yet.
34  *
35  * Revision 1.16  1995/12/07  17:38:48  adam
36  * Work locking mechanisms for concurrent updates/commit.
37  *
38  * Revision 1.15  1995/11/21  15:29:13  adam
39  * Config file 'base' read by default by both indexer and server.
40  *
41  * Revision 1.14  1995/11/16  17:00:57  adam
42  * Better logging of rpn query.
43  *
44  * Revision 1.13  1995/11/16  15:34:56  adam
45  * Uses new record management system in both indexer and server.
46  *
47  * Revision 1.12  1995/10/27  14:00:12  adam
48  * Implemented detection of database availability.
49  *
50  * Revision 1.11  1995/10/17  18:02:12  adam
51  * New feature: databases. Implemented as prefix to words in dictionary.
52  *
53  * Revision 1.10  1995/10/09  16:18:38  adam
54  * Function dict_lookup_grep got extra client data parameter.
55  *
56  * Revision 1.9  1995/10/06  14:38:01  adam
57  * New result set method: r_score.
58  * Local no (sysno) and score is transferred to retrieveCtrl.
59  *
60  * Revision 1.8  1995/10/06  13:52:06  adam
61  * Bug fixes. Handler may abort further scanning.
62  *
63  * Revision 1.7  1995/10/06  10:43:57  adam
64  * Scan added. 'occurrences' in scan entries not set yet.
65  *
66  * Revision 1.6  1995/09/28  09:19:48  adam
67  * xfree/xmalloc used everywhere.
68  * Extract/retrieve method seems to work for text records.
69  *
70  * Revision 1.5  1995/09/27  16:17:32  adam
71  * More work on retrieve.
72  *
73  * Revision 1.4  1995/09/14  11:53:28  adam
74  * First work on regular expressions/truncations.
75  *
76  * Revision 1.3  1995/09/08  08:53:23  adam
77  * Record buffer maintained in server_info.
78  *
79  * Revision 1.2  1995/09/06  16:11:19  adam
80  * Option: only one word key per file.
81  *
82  * Revision 1.1  1995/09/05  15:28:40  adam
83  * More work on search engine.
84  *
85  */
86
87 #include <backend.h>
88 #include <rset.h>
89
90 #include "index.h"
91 #include "zinfo.h"
92
93 typedef struct {
94     int sysno;
95     int score;
96 } ZServerSetSysno;
97
98 typedef struct ZServerSet_ {
99     char *name;
100     RSET rset;
101     int size;
102     struct ZServerSet_ *next;
103 } ZServerSet;
104    
105 typedef struct {
106     int registerState; /* 0 (no commit pages), 1 (use commit pages) */
107     time_t registerChange;
108     ZServerSet *sets;
109     Dict dict;
110     ISAM isam;
111     ISAMC isamc;
112     Records records;
113     int errCode;
114     char *errString;
115     ODR odr;
116     ZebTargetInfo *zti;
117     data1_handle dh;
118     data1_attset *registered_sets;
119     BFiles bfs;
120     Res res;
121 } ZServerInfo;
122
123 int rpn_search (ZServerInfo *zi, 
124                 Z_RPNQuery *rpn, int num_bases, char **basenames, 
125                 const char *setname, int *hits);
126
127 int rpn_scan (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
128               oid_value attributeset,
129               int num_bases, char **basenames,
130               int *position, int *num_entries, struct scan_entry **list,
131               int *status);
132
133 RSET rset_trunc (ZServerInfo *zi, ISAM_P *isam_p, int no);
134
135 ZServerSet *resultSetAdd (ZServerInfo *zi, const char *name,
136                           int ov, RSET rset);
137 ZServerSet *resultSetGet (ZServerInfo *zi, const char *name);
138 void resultSetDestroy (ZServerInfo *zi);
139
140 ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name,
141                                     int num, int *positions);
142 void resultSetSysnoDel (ZServerInfo *zi, ZServerSetSysno *records, int num);
143 void zlog_rpn (Z_RPNQuery *rpn);
144
145 int zebraServerLock (Res res, int lockCommit);
146 void zebraServerUnlock (int commitPhase);
147 int zebraServerLockGetState (Res res, time_t *timep);
148
149 typedef struct attent
150 {
151     int attset_ordinal;
152     data1_local_attribute *local_attributes;
153 } attent;
154
155 int att_getentbyatt(ZServerInfo *zi, attent *res, oid_value set, int att);