chiark / gitweb /
Commit 2.4.5-5 as unpacked
[inn-innduct.git] / include / inn / history.h
1 /*  $Id: history.h 4916 2001-07-18 12:33:01Z alexk $
2 **
3 **  Interface to history API
4 */
5
6 #ifndef INN_HISTORY_H
7 #define INN_HISTORY_H
8
9 #include <inn/defines.h>
10
11 BEGIN_DECLS
12
13 /*
14 **  ensure appropriate scoping; we don't pull inn/storage.h as we
15 **  don't need; our caller then has the option
16 */
17 struct history;
18 struct token;
19
20 /*
21 **  structure giving cache statistics returned from HISstats
22 */
23 struct histstats {
24     /* number of positive hits */
25     int hitpos;
26     /* number of negative hits */
27     int hitneg;
28     /* number of misses (positive hit, but not in cache) */
29     int misses;
30     /* number of does not exists (negative hit, but not in cache) */
31     int dne;
32 };
33
34
35 /*
36 **  flags passed to HISopen
37 */
38
39 /* open database read only */
40 #define HIS_RDONLY (0)
41
42 /* open database read/write */
43 #define HIS_RDWR (1<<0)
44
45 /* create on open */
46 #define HIS_CREAT (1<<1)
47
48 /* hint that the data should be kept on disk */
49 #define HIS_ONDISK (1<<2)
50
51 /* hint that the data should be kept in core */
52 #define HIS_INCORE (1<<3)
53
54 /* hint that the data should be kept mmap()ed */
55 #define HIS_MMAP (1<<4)
56
57 /*
58 **  values passed to HISctl
59 */
60 enum {
61     /* (char **) get history path */
62     HISCTLG_PATH,
63
64     /* (char *) set history path */
65     HISCTLS_PATH,
66
67     /* (int) how many history writes may be outstanding */
68     HISCTLS_SYNCCOUNT,
69
70     /* (size_t) number of pairs for which the database should be sized */
71     HISCTLS_NPAIRS,
72
73     /* (bool) Ignore old database during expire */
74     HISCTLS_IGNOREOLD,
75     
76     /* (time_t) interval, in s, between stats of the history database
77      * for * detecting a replacement, or 0 to disable (no checks);
78      * defaults {hisv6, taggedhash} */
79     HISCTLS_STATINTERVAL
80
81 };
82
83 struct history *        HISopen(const char *, const char *, int);
84 bool                    HISclose(struct history *);
85 bool                    HISsync(struct history *);
86 void                    HISsetcache(struct history *, size_t);
87 bool                    HISlookup(struct history *, const char *, time_t *,
88                                   time_t *, time_t *, struct token *);
89 bool                    HIScheck(struct history *, const char *);
90 bool                    HISwrite(struct history *, const char *, time_t,
91                                  time_t, time_t, const struct token *);
92 bool                    HISremember(struct history *, const char *, time_t);
93 bool                    HISreplace(struct history *, const char *, time_t,
94                                    time_t, time_t, const struct token *);
95 bool                    HISexpire(struct history *, const char *, const char *,
96                                   bool, void *, time_t,
97                                   bool (*)(void *, time_t, time_t, time_t,
98                                            struct token *));
99 bool                    HISwalk(struct history *, const char *, void *,
100                                 bool (*)(void *, time_t, time_t, time_t,
101                                          const struct token *));
102 struct histstats        HISstats(struct history *);
103 const char *            HISerror(struct history *);
104 bool                    HISctl(struct history *, int, void *);
105 void                    HISlogclose(void);
106 void                    HISlogto(const char *s);
107
108 END_DECLS
109
110 #endif