chiark / gitweb /
use libinn logging where applicable
[inn-innduct.git] / history / hisv6 / hisv6-private.h
1 #ifndef HISV6_PRIVATE_H
2 #define HISV6_PRIVATE_H
3
4 #include "config.h"
5 #include <stdio.h>
6 #include <time.h>
7 #include <syslog.h>
8 #include <sys/stat.h>
9 #include "inn/history.h"
10 #include "storage.h"
11 #include "libinn.h"
12
13 /* Used by lots of stuff that parses history file entries.  Should be moved
14    into a header specifically for history parsing. */
15 #define HISV6_BADCHAR             '_'
16 #define HISV6_FIELDSEP            '\t'
17 #define HISV6_NOEXP               '-'
18 #define HISV6_SUBFIELDSEP         '~'
19
20 /* maximum length of a history line:
21    34 - hash
22     1 - \t
23    20 - arrived
24     1 - ~
25    20 - expires
26     1 - ~
27    20 - posted
28     1 - tab
29    38 - token
30     1 - \n */
31 #define HISV6_MAXLINE 137
32
33 /* minimum length of a history line:
34    34 - hash
35     1 - \t
36     1 - arrived
37     1 - \n */
38 #define HISV6_MINLINE 37
39
40 struct hisv6 {
41     char *histpath;
42     FILE *writefp;
43     off_t offset;               /* Offset into writefp. */
44     unsigned long nextcheck;
45     struct history *history;
46     time_t statinterval;
47     size_t synccount;
48     size_t dirty;
49     ssize_t npairs;
50     int readfd;
51     int flags;
52     struct stat st;
53 };
54
55 /* values in the bitmap returned from hisv6_splitline */
56 #define HISV6_HAVE_HASH (1<<0)
57 #define HISV6_HAVE_ARRIVED (1<<1)
58 #define HISV6_HAVE_POSTED (1<<2)
59 #define HISV6_HAVE_EXPIRES (1<<3)
60 #define HISV6_HAVE_TOKEN (1<<4)
61
62 /* structure used to hold the callback and cookie so we don't try
63  * passing too many parameters into the callers callback */
64 struct hisv6_walkstate {
65     union {
66         bool (*expire)(void *, time_t, time_t, time_t, TOKEN *);
67         bool (*walk)(void *, time_t, time_t, time_t, const TOKEN *);
68     } cb;
69     void *cookie;
70     bool paused;
71     bool ignore;
72     /* the next two fields are only used during expire... they should
73      * probably be linked off of cookie, but I've been lazy */
74     struct hisv6 *new;
75     time_t threshold;
76 };
77
78 /* maximum length of the string from hisv6_errloc */
79 #define HISV6_MAX_LOCATION 22
80
81 #endif