linkd

Control plane daemon for unos
git clone git://git.finwo.net/app/linkd
Log | Files | Refs | README

config.h (1168B)


      1 #ifndef __LINKD_UTIL_CONFIG_H__
      2 #define __LINKD_UTIL_CONFIG_H__
      3 
      4 #include <stdio.h>
      5 
      6 #include "finwo/cnfparse.h"
      7 
      8 #define CFG_RET_ERROR -1
      9 #define CFG_RET_OK     0
     10 
     11 // A directive handler consumes its own sub-directives straight off `fd`, then
     12 // returns the first directive it did not recognise so the caller can
     13 // re-dispatch it. Returning NULL means end-of-input was reached.
     14 typedef struct cnf_directive * (*cfg_directive_fn)(FILE *fd, struct cnf_directive *dir, void *user);
     15 
     16 // Report a malformed directive. The handler return type has no error channel
     17 // (NULL means "consumed"), so this flag is how a handler rejects input without
     18 // exit(1) -- which would kill the daemon on an ifreload.
     19 void cfg_error(const char *fmt, ...);
     20 int  cfg_error_occurred(void);
     21 void cfg_error_reset(void);
     22 
     23 struct cfg_ns;
     24 
     25 // Create+get interned namespace (idempotent)
     26 struct cfg_ns *cfg_ns_get(const char *name);
     27 
     28 void cfg_register_directive(struct cfg_ns *ns, const char *name, cfg_directive_fn fn);
     29 
     30 // `wd` is the directory relative `source` patterns resolve against.
     31 int cfg_parse(struct cfg_ns *ns, const char *wd, FILE *fd, void *user);
     32 
     33 #endif // __LINKD_UTIL_CONFIG_H__