Zebra config renamed.
[idzebra-moved-to-github.git] / index / index.h
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: index.h,v $
7  * Revision 1.29  1995-11-28 09:09:40  adam
8  * Zebra config renamed.
9  * Use setting 'recordId' to identify record now.
10  * Bug fix in recindex.c: rec_release_blocks was invokeded even
11  * though the blocks were already released.
12  * File traversal properly deletes records when needed.
13  *
14  * Revision 1.28  1995/11/27  13:58:53  adam
15  * New option -t. storeStore data implemented in server.
16  *
17  * Revision 1.27  1995/11/25  10:24:06  adam
18  * More record fields - they are enumerated now.
19  * New options: flagStoreData flagStoreKey.
20  *
21  * Revision 1.26  1995/11/22  17:19:17  adam
22  * Record management uses the bfile system.
23  *
24  * Revision 1.25  1995/11/21  15:29:12  adam
25  * Config file 'base' read by default by both indexer and server.
26  *
27  * Revision 1.24  1995/11/21  15:01:15  adam
28  * New general match criteria implemented.
29  * New feature: document groups.
30  *
31  * Revision 1.23  1995/11/20  16:59:45  adam
32  * New update method: the 'old' keys are saved for each records.
33  *
34  * Revision 1.22  1995/11/20  11:56:26  adam
35  * Work on new traversal.
36  *
37  * Revision 1.21  1995/11/16  15:34:55  adam
38  * Uses new record management system in both indexer and server.
39  *
40  * Revision 1.20  1995/11/15  14:46:18  adam
41  * Started work on better record management system.
42  *
43  * Revision 1.19  1995/10/27  14:00:11  adam
44  * Implemented detection of database availability.
45  *
46  * Revision 1.18  1995/10/17  18:02:08  adam
47  * New feature: databases. Implemented as prefix to words in dictionary.
48  *
49  * Revision 1.17  1995/10/13  16:01:49  adam
50  * Work on relations.
51  *
52  * Revision 1.16  1995/10/10  12:24:38  adam
53  * Temporary sort files are compressed.
54  *
55  * Revision 1.15  1995/10/04  16:57:19  adam
56  * Key input and merge sort in one pass.
57  *
58  * Revision 1.14  1995/09/29  14:01:40  adam
59  * Bug fixes.
60  *
61  * Revision 1.13  1995/09/28  14:22:56  adam
62  * Sort uses smaller temporary files.
63  *
64  * Revision 1.12  1995/09/28  12:10:32  adam
65  * Bug fixes. Field prefix used in queries.
66  *
67  * Revision 1.11  1995/09/27  12:22:28  adam
68  * More work on extract in record control.
69  * Field name is not in isam keys but in prefix in dictionary words.
70  *
71  * Revision 1.10  1995/09/14  07:48:23  adam
72  * Record control management.
73  *
74  * Revision 1.9  1995/09/11  13:09:33  adam
75  * More work on relevance feedback.
76  *
77  * Revision 1.8  1995/09/08  14:52:27  adam
78  * Minor changes. Dictionary is lower case now.
79  *
80  * Revision 1.7  1995/09/06  16:11:16  adam
81  * Option: only one word key per file.
82  *
83  * Revision 1.6  1995/09/05  15:28:39  adam
84  * More work on search engine.
85  *
86  * Revision 1.5  1995/09/04  12:33:42  adam
87  * Various cleanup. YAZ util used instead.
88  *
89  * Revision 1.4  1995/09/04  09:10:35  adam
90  * More work on index add/del/update.
91  * Merge sort implemented.
92  * Initial work on z39 server.
93  *
94  * Revision 1.3  1995/09/01  14:06:35  adam
95  * Split of work into more files.
96  *
97  * Revision 1.2  1995/09/01  10:30:24  adam
98  * More work on indexing. Not working yet.
99  *
100  * Revision 1.1  1995/08/31  14:50:24  adam
101  * New simple file index tool.
102  *
103  */
104
105 #include <alexutil.h>
106 #include <dict.h>
107 #include <isam.h>
108
109 #define IT_MAX_WORD 256
110 #define IT_KEY_HAVE_SEQNO 1
111 #define IT_KEY_HAVE_FIELD 0
112
113 struct it_key {
114     int  sysno;
115     int   seqno;
116 };
117
118 enum dirsKind { dirs_dir, dirs_file };
119
120 struct dir_entry {
121     enum dirsKind kind;
122     char *name;
123     int ctime;
124 };
125
126 struct dirs_entry {
127     enum dirsKind kind;
128     char path[256];
129     SYSNO sysno;
130     int ctime;
131 };
132
133 struct recordGroup {
134     char *groupName;
135     char *databaseName;
136     char *path;
137     char *recordId;
138     char *recordType;
139     int  flagStoreData;
140     int  flagStoreKeys;
141 };
142
143 struct dirs_info *dirs_open (Dict dict, const char *rep);
144 struct dirs_entry *dirs_read (struct dirs_info *p);
145 struct dirs_entry *dirs_last (struct dirs_info *p);
146 void dirs_mkdir (struct dirs_info *p, const char *src, int ctime);
147 void dirs_rmdir (struct dirs_info *p, const char *src);
148 void dirs_add (struct dirs_info *p, const char *src, int sysno, int ctime);
149 void dirs_del (struct dirs_info *p, const char *src);
150 void dirs_free (struct dirs_info **pp);
151
152 struct dir_entry *dir_open (const char *rep);
153 void dir_sort (struct dir_entry *e);
154 void dir_free (struct dir_entry **e_p);
155
156 void repositoryUpdate (struct recordGroup *rGroup);
157 void repositoryAdd (struct recordGroup *rGroup);
158 void repositoryDelete (struct recordGroup *rGroup);
159
160 void key_open (int mem);
161 int key_close (void);
162 void key_write (int cmd, struct it_key *k, const char *str);
163 int key_compare (const void *p1, const void *p2);
164 int key_qsort_compare (const void *p1, const void *p2);
165 void key_logdump (int mask, const void *p);
166 void key_input (const char *dict_fname, const char *isam_fname,
167                  int nkeys, int cache);
168 int merge_sort (char **buf, int from, int to);
169
170 #define TEMP_FNAME  "keys%d.tmp"
171 #define FNAME_WORD_DICT "worddict"
172 #define FNAME_WORD_ISAM "wordisam"
173 #define FNAME_CONFIG "zebra.cfg"
174
175 struct strtab *strtab_mk (void);
176 int strtab_src (struct strtab *t, const char *name, void ***infop);
177 void strtab_del (struct strtab *t,
178                  void (*func)(const char *name, void *info, void *data),
179                  void *data);
180 int index_char_cvt (int c);
181 int index_word_prefix (char *string, int attset_ordinal,
182                        int local_attribute, const char *databaseName);
183
184 int fileExtract (SYSNO *sysno, const char *fname,
185                  const struct recordGroup *rGroup, int deleteFlag);