1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef H_DBINDEX
#define H_DBINDEX
#ifdef HAVE_DB1_DB_H
#include <db1/db.h>
#else
#ifdef HAVE_DB_185_H
#include <db_185.h>
#else
#include <db.h>
#endif
#endif
/* this will break if sizeof(int) != 4 */
typedef /*@abstract@*/ struct {
unsigned int recOffset;
unsigned int fileNumber;
} dbiIndexRecord;
typedef /*@abstract@*/ struct {
/*@only@*/ dbiIndexRecord * recs;
int count;
} dbiIndexSet;
typedef /*@abstract@*/ struct {
DB * db;
const char * indexname;
} dbiIndex;
#ifdef __cplusplus
extern "C" {
#endif
/*@only@*/ dbiIndex * dbiOpenIndex(const char * filename, int flags, int perms, DBTYPE type);
void dbiCloseIndex( /*@only@*/ dbiIndex * dbi);
void dbiSyncIndex(dbiIndex * dbi);
int dbiSearchIndex(dbiIndex * dbi, const char * str, /*@out@*/ dbiIndexSet * set);
/* -1 error, 0 success, 1 not found */
int dbiUpdateIndex(dbiIndex * dbi, const char * str, dbiIndexSet * set);
/* 0 on success */
int dbiAppendIndexRecord( /*@out@*/ dbiIndexSet * set, dbiIndexRecord rec);
/* 0 on success - should never fail */
int dbiRemoveIndexRecord(dbiIndexSet * set, dbiIndexRecord rec);
/* 0 on success - fails if rec is not found */
dbiIndexSet dbiCreateIndexRecord(void);
void dbiFreeIndexRecord(dbiIndexSet set);
int dbiGetFirstKey(dbiIndex * dbi, /*@out@*/ const char ** key);
extern unsigned int dbiIndexSetCount(dbiIndexSet set);
/* structure return */
extern dbiIndexRecord dbiReturnIndexRecordInstance(unsigned int recOffset, unsigned int fileNumber);
extern unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno);
extern unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno);
#ifdef __cplusplus
}
#endif
#endif /* H_DBINDEX */
|