blob: cf4f02cc8a028ec5b26ade7fed7c9312b1f2f6d9 (
plain) (
blame)
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
|
/*
Dump the hash tables from an ibex file.
*/
#include <stdio.h>
#include <stdlib.h>
#include "ibex_internal.h"
extern void ibex_hash_dump(struct _IBEXIndex *index);
static void
index_iterate(struct _IBEXIndex *index)
{
struct _IBEXCursor *idc;
int len;
char *key;
int total = 0, totallen = 0;
idc = index->klass->get_cursor(index);
key = idc->klass->next_key(idc, &len);
while (len) {
total++;
totallen += len;
printf("%s\n", key);
g_free(key);
key = idc->klass->next_key(idc, &len);
}
g_free(key);
idc->klass->close(idc);
printf("Iterate Totals: %d items, total bytes %d\n", total, totallen);
}
int main(int argc, char **argv)
{
ibex *ib;
if (argc != 2) {
printf("Usage: %s ibexfile\n", argv[0]);
return 1;
}
ib = ibex_open(argv[1], O_RDONLY, 0);
if (ib == NULL) {
perror("Opening ibex file\n");
return 1;
}
ibex_hash_dump(ib->words->wordindex);
ibex_hash_dump(ib->words->nameindex);
index_iterate(ib->words->wordindex);
index_iterate(ib->words->nameindex);
ibex_close(ib);
return 0;
}
|