Makefile: Add target to run sql-dependant tests
[nagios-reports-module.git] / cfgfile.h
blob707ce98e8e3c78f5a54942949d04c961602d866c
1 #ifndef _CFGFILE_H_
2 #define _CFGFILE_H_
4 /* have a care with this one. It can't be used when (c) has side-effects */
5 #undef ISSPACE
6 #define ISSPACE(c) ((c) == ' ' || (c) == '\t')
8 /* types */
9 struct cfg_var {
10 unsigned line; /* starting line */
11 char *key;
12 char *value;
13 size_t key_len;
14 size_t value_len;
17 #define next_var(c) (c->cur_var >= c->vars ? NULL : c->vlist[c->cur_var++])
19 struct cfg_comp {
20 const char *name; /* filename, or everything leading up to '{' */
21 char *buf; /* file contents, if this is a file */
22 char *template_name; /* 'name' entry from compound */
23 char *use; /* the value of any "use" variables */
24 unsigned int vars; /* number of variables */
25 unsigned int cur_var; /* current variable (for next_var) */
26 unsigned int vlist_len; /* size of vlist */
27 unsigned start, end; /* starting and ending line */
28 unsigned nested; /* number of compounds nested below this */
29 struct cfg_var **vlist; /* array of variables */
30 struct cfg_comp *parent; /* nested from */
31 struct cfg_comp **nest; /* compounds nested inside this one */
34 /* prototypes */
35 struct cfg_comp *cfg_parse_file(const char *path);
36 void cfg_destroy_compound(struct cfg_comp *comp);
37 void cfg_warn(struct cfg_comp *comp, struct cfg_var *v, const char *fmt, ...)
38 __attribute__((__format__(__printf__, 3, 4)));
39 void cfg_error(struct cfg_comp *comp, struct cfg_var *v, const char *fmt, ...)
40 __attribute__((__format__(__printf__, 3, 4), __noreturn__));
41 char *cfg_copy_value(struct cfg_var *v);
43 #endif /* _CONFIG_H */