Remove debugging code.
[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_config.h>
9 #include <tr_event.h>
10 /* interval in seconds */
11 #define TR_CFGWATCH_DEFAULT_POLL 1
12 #define TR_CFGWATCH_DEFAULT_SETTLE 5
13 /* note: settling time is minimum - only checked on poll intervals */
14
15 struct tr_fstat {
16   char *name;
17   struct timespec mtime;
18 };
19
20 typedef struct tr_cfgwatch_data {
21   struct timeval poll_interval; /* how often should we check for updates? */
22   struct timeval settling_time; /* how long should we wait for changes to settle before updating? */
23   char *config_dir; /* what directory are we watching? */
24   struct tr_fstat *fstat_list; /* file names and mtimes */
25   int n_files; /* number of files in fstat_list */
26   int change_detected; /* have we detected a change? */
27   struct timeval last_change_detected; /* when did we last note a changed mtime? */
28   TR_CFG_MGR *cfg_mgr; /* what trust router config are we updating? */
29   void (*update_cb)(TR_CFG *new_cfg, void *cookie); /* callback after config updated */
30   void *update_cookie; /* data for the update_cb() */
31 } TR_CFGWATCH;
32
33
34 /* prototypes */
35 TR_CFGWATCH *tr_cfgwatch_create(TALLOC_CTX *mem_ctx);
36 int tr_read_and_apply_config(TR_CFGWATCH *cfgwatch);
37 int tr_cfgwatch_event_init(struct event_base *base, TR_CFGWATCH *cfg_status, struct event **cfgwatch_ev);
38
39 #endif /* TR_CFGWATCH_H */