Remember fragment of the splitted char and decode it next time. Idea by Jonas.
[elinks.git] / src / util / fastfind.h
blob4f50ea3d6c6a419b1258c60a7bf129a76e1ca9c4
1 #ifndef EL__UTIL_FASTFIND_H
2 #define EL__UTIL_FASTFIND_H
4 /* Whether to use these routines or not. */
5 #ifndef CONFIG_SMALL
6 #define USE_FASTFIND 1
7 #else
8 #undef USE_FASTFIND
9 #endif
11 #ifdef USE_FASTFIND
13 struct fastfind_key_value {
14 unsigned char *key;
15 void *data;
18 enum fastfind_flags {
19 FF_NONE = 0,
20 FF_CASE_AWARE = 1, /* honour case when comparing */
21 FF_COMPRESS = 2, /* compress nodes if possible */
24 struct fastfind_index {
25 /* Description useful for debugging mode. */
26 unsigned char *comment;
27 /* Start over. */
28 void (*reset)(void);
29 /* Get next struct fastfind_key_value in line. */
30 struct fastfind_key_value *(*next)(void);
31 /* Internal reference */
32 void *handle;
35 #define INIT_FASTFIND_INDEX(comment, reset, next) \
36 { (comment), (reset), (next) }
38 /* Initialize and index a list of keys. */
39 /* Keys are iterated using:
40 * @index index info
41 * @flags control case sensitivity, compression */
42 /* This function must be called once and only once per list. */
43 /* Failure is not an option, so call it at startup. */
44 struct fastfind_index *fastfind_index(struct fastfind_index *index, enum fastfind_flags flags);
46 /* The main reason of all that stuff is here. */
47 /* Search the index for @key with length @key_len using the
48 * @index' handle created with fastfind_index(). */
49 void *fastfind_search(struct fastfind_index *index, unsigned char *key, int key_len);
51 /* Fastfind cleanup. It frees the index given by the @fastfind_handle. */
52 /* Must be called once per list. */
53 void fastfind_done(struct fastfind_index *index);
55 #endif
57 #endif /* EL__UTIL_FASTFIND_H */