Refactor to move task code out of tr_main.c.
[trust_router.git] / include / tr_cfgwatch.h
1 #ifndef TR_CFGWATCH_H
2 #define TR_CFGWATCH_H
3
4 #include <talloc.h>
5 #include <time.h>
6 #include <sys/time.h>
7
8 #include <tr.h>
9
10
11 struct tr_fstat {
12   char *name;
13   struct timespec mtime;
14 };
15
16 struct tr_cfgwatch_data {
17   struct timeval poll_interval; /* how often should we check for updates? */
18   struct timeval settling_time; /* how long should we wait for changes to settle before updating? */
19   char *config_dir; /* what directory are we watching? */
20   struct tr_fstat *fstat_list; /* file names and mtimes */
21   int n_files; /* number of files in fstat_list */
22   int change_detected; /* have we detected a change? */
23   struct timeval last_change_detected; /* when did we last note a changed mtime? */
24   TALLOC_CTX *ctx; /* what context should own configuration talloc blocks? */
25   TR_INSTANCE *tr; /* what trust router are we updating? */
26 };
27 typedef struct tr_cfgwatch_data TR_CFGWATCH;
28
29
30 /* prototypes */
31 TR_CFGWATCH *tr_cfgwatch_create(TALLOC_CTX *mem_ctx);
32 int tr_read_and_apply_config(TR_CFGWATCH *cfgwatch);
33 int tr_cfgwatch_event_init(struct event_base *base, TR_CFGWATCH *cfg_status, struct event **cfgwatch_ev);
34
35 #endif /* TR_CFGWATCH_H */