1 |
adcroft |
1.1 |
/* |
2 |
|
|
** |
3 |
|
|
** This program and library is free software; you can redistribute it and/or |
4 |
|
|
** modify it under the terms of the GNU (Library) General Public License |
5 |
|
|
** as published by the Free Software Foundation; either version 2 |
6 |
|
|
** of the License, or any later version. |
7 |
|
|
** |
8 |
|
|
** This program is distributed in the hope that it will be useful, |
9 |
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 |
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 |
|
|
** GNU (Library) General Public License for more details. |
12 |
|
|
** |
13 |
|
|
** You should have received a copy of the GNU (Library) General Public License |
14 |
|
|
** along with this program; if not, write to the Free Software |
15 |
|
|
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 |
|
|
** |
17 |
|
|
** |
18 |
|
|
** |
19 |
|
|
** 2001-07 jose ruiz initial coding |
20 |
|
|
** |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#ifndef __HasSeenModule_DB_db |
26 |
|
|
#define __HasSeenModule_DB_db 1 |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
//#include <db.h> |
30 |
|
|
#include "/usr/local/BerkeleyDB.3.2/include/db.h" |
31 |
|
|
|
32 |
|
|
struct Handle_DB_db |
33 |
|
|
{ |
34 |
|
|
|
35 |
|
|
int wordcounter; /* word counter - Used to asign WordID's */ |
36 |
|
|
|
37 |
|
|
/* How about an array of *DB ? */ |
38 |
|
|
DB *dbf_header; /* db file to store header */ |
39 |
|
|
DB *dbf_words; /* db file to store words */ |
40 |
|
|
DB *dbf_worddata; /* db file to store word's data */ |
41 |
|
|
DB *dbf_invertedindex; /* db file to store word's inverted index */ |
42 |
|
|
DB *dbf_docs; /* db file to store docs's data */ |
43 |
|
|
DB *dbf_sorted_indexes; /* db file to store sorted indexes */ |
44 |
|
|
DB *dbf_properties; /* db file to store properties */ |
45 |
|
|
|
46 |
|
|
DBC *cursor_header; /* cursor to read header data */ |
47 |
|
|
DBC *cursor_inverted; /* cursor to read the inverted word data */ |
48 |
|
|
}; |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
void initModule_DB_db (SWISH *); |
52 |
|
|
void freeModule_DB_db (SWISH *); |
53 |
|
|
int configModule_DB_db (SWISH *sw, StringList *sl); |
54 |
|
|
|
55 |
|
|
void *DB_Create_db (SWISH *sw, char *dbname); |
56 |
|
|
void *DB_Open_db (SWISH *sw, char *dbname); |
57 |
|
|
void DB_Close_db(void *db); |
58 |
|
|
void DB_Remove_db(void *db); |
59 |
|
|
|
60 |
|
|
int DB_InitWriteHeader_db(void *db); |
61 |
|
|
int DB_EndWriteHeader_db(void *db); |
62 |
|
|
int DB_WriteHeaderData_db(int id, unsigned char *s, int len, void *db); |
63 |
|
|
|
64 |
|
|
int DB_InitReadHeader_db(void *db); |
65 |
|
|
int DB_ReadHeaderData_db(int *id, unsigned char **s, int *len, void *db); |
66 |
|
|
int DB_EndReadHeader_db(void *db); |
67 |
|
|
|
68 |
|
|
int DB_InitWriteWords_db(void *db); |
69 |
|
|
long DB_GetWordID_db(void *db); |
70 |
|
|
int DB_WriteWord_db(char *word, long wordID, void *db); |
71 |
|
|
int DB_WriteWordHash_db(char *word, long wordID, void *db); |
72 |
|
|
long DB_WriteWordData_db(long wordID, unsigned char *worddata, int lendata, void *db); |
73 |
|
|
int DB_EndWriteWords_db(void *db); |
74 |
|
|
|
75 |
|
|
int DB_InitReadWords_db(void *db); |
76 |
|
|
int DB_ReadWordHash_db(char *word, long *wordID, void *db); |
77 |
|
|
int DB_ReadFirstWordInvertedIndex_db(char *word, char **resultword, long *wordID, void *db); |
78 |
|
|
int DB_ReadNextWordInvertedIndex_db(char *word, char **resultword, long *wordID, void *db); |
79 |
|
|
long DB_ReadWordData_db(long wordID, unsigned char **worddata, int *lendata, void *db); |
80 |
|
|
int DB_EndReadWords_db(void *db); |
81 |
|
|
|
82 |
|
|
|
83 |
|
|
int DB_InitWriteFiles_db(void *db); |
84 |
|
|
int DB_EndWriteFiles_db(void *db); |
85 |
|
|
int DB_WriteFile_db(int filenum, unsigned char *filedata,int sz_filedata, void *db); |
86 |
|
|
int DB_InitReadFiles_db(void *db); |
87 |
|
|
int DB_ReadFile_db(int filenum, unsigned char **filedata,int *sz_filedata, void *db); |
88 |
|
|
int DB_EndReadFiles_db(void *db); |
89 |
|
|
|
90 |
|
|
int DB_InitWriteSortedIndex_db(void *db); |
91 |
|
|
int DB_WriteSortedIndex_db(int propID, unsigned char *data, int sz_data,void *db); |
92 |
|
|
int DB_EndWriteSortedIndex_db(void *db); |
93 |
|
|
|
94 |
|
|
int DB_InitReadSortedIndex_db(void *db); |
95 |
|
|
int DB_ReadSortedIndex_db(int propID, unsigned char **data, int *sz_data,void *db); |
96 |
|
|
int DB_EndReadSortedIndex_db(void *db); |
97 |
|
|
|
98 |
|
|
|
99 |
|
|
#ifdef PROPFILE |
100 |
|
|
void DB_WriteProperty_db( FileRec *fi, int propID, char *buffer, int datalen, void *db ); |
101 |
|
|
char * DB_ReadProperty_db( FileRec *fi, int propID, void *db ); |
102 |
|
|
void DB_Reopen_PropertiesForRead_db(void *db); |
103 |
|
|
#endif |
104 |
|
|
|
105 |
|
|
|
106 |
|
|
#endif |