Retry only for https protocol
[elinks.git] / src / util / fastfind.h
blobb01427828a9d1215918d41c644a71baad492f27e
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 */
22 FF_LOCALE_INDEP = 4 /**< whether the case conversion is
23 * locale independent or not */
26 struct fastfind_index {
27 /** Description useful for debugging mode. */
28 unsigned char *comment;
29 /** Start over. */
30 void (*reset)(void);
31 /** Get next struct fastfind_key_value in line. */
32 struct fastfind_key_value *(*next)(void);
33 /** Internal reference */
34 void *handle;
37 #define INIT_FASTFIND_INDEX(comment, reset, next) \
38 { (comment), (reset), (next) }
40 /** Initialize and index a list of keys.
41 * Keys are iterated using:
42 * @param index index info
43 * @param flags control case sensitivity, compression
45 * This function must be called once and only once per list.
46 * Failure is not an option, so call it at startup.
47 * @relates fastfind_index */
48 struct fastfind_index *fastfind_index(struct fastfind_index *index, enum fastfind_flags flags);
50 /* The main reason of all that stuff is here. */
51 /** Search the index for @a key with length @a key_len using the
52 * @a index' handle created with fastfind_index().
53 * @relates fastfind_index */
54 void *fastfind_search(struct fastfind_index *index,
55 const unsigned char *key, int key_len);
57 /** Fastfind cleanup. It frees the given @a index.
58 * Must be called once per list.
59 * @relates fastfind_index */
60 void fastfind_done(struct fastfind_index *index);
62 #endif
64 #endif /* EL__UTIL_FASTFIND_H */