Revision 16770,
1.1 KB
checked in by ghudson, 23 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r16769,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | /* |
---|
2 | Dump the hash tables from an ibex file. |
---|
3 | */ |
---|
4 | |
---|
5 | #include <stdio.h> |
---|
6 | #include <stdlib.h> |
---|
7 | |
---|
8 | #include "ibex_internal.h" |
---|
9 | |
---|
10 | extern void ibex_hash_dump(struct _IBEXIndex *index); |
---|
11 | |
---|
12 | static void |
---|
13 | index_iterate(struct _IBEXIndex *index) |
---|
14 | { |
---|
15 | struct _IBEXCursor *idc; |
---|
16 | int len; |
---|
17 | char *key; |
---|
18 | int total = 0, totallen = 0; |
---|
19 | |
---|
20 | idc = index->klass->get_cursor(index); |
---|
21 | key = idc->klass->next_key(idc, &len); |
---|
22 | while (len) { |
---|
23 | total++; |
---|
24 | totallen += len; |
---|
25 | printf("%s\n", key); |
---|
26 | g_free(key); |
---|
27 | key = idc->klass->next_key(idc, &len); |
---|
28 | } |
---|
29 | g_free(key); |
---|
30 | |
---|
31 | idc->klass->close(idc); |
---|
32 | |
---|
33 | printf("Iterate Totals: %d items, total bytes %d\n", total, totallen); |
---|
34 | } |
---|
35 | |
---|
36 | int main(int argc, char **argv) |
---|
37 | { |
---|
38 | ibex *ib; |
---|
39 | |
---|
40 | #ifdef ENABLE_THREADS |
---|
41 | g_thread_init(0); |
---|
42 | #endif |
---|
43 | |
---|
44 | if (argc != 2) { |
---|
45 | printf("Usage: %s ibexfile\n", argv[0]); |
---|
46 | return 1; |
---|
47 | } |
---|
48 | ib = ibex_open(argv[1], O_RDONLY, 0); |
---|
49 | if (ib == NULL) { |
---|
50 | perror("Opening ibex file\n"); |
---|
51 | return 1; |
---|
52 | } |
---|
53 | |
---|
54 | /* force real-open of the ibex internals */ |
---|
55 | ibex_contains_name(ib, "dummy"); |
---|
56 | |
---|
57 | ibex_hash_dump(ib->words->wordindex); |
---|
58 | ibex_hash_dump(ib->words->nameindex); |
---|
59 | |
---|
60 | index_iterate(ib->words->wordindex); |
---|
61 | index_iterate(ib->words->nameindex); |
---|
62 | |
---|
63 | ibex_close(ib); |
---|
64 | |
---|
65 | return 0; |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.