9 #include "graph_config.h"
10 #include "graph_list.h"
14 #define CONFIG_FILE "/usr/lib/cgi-bin/octo/collection.conf"
16 time_t last_read_mtime = 0;
18 static int dispatch_config (const oconfig_item_t *ci) /* {{{ */
22 for (i = 0; i < ci->children_num; i++)
24 oconfig_item_t *child;
26 child = ci->children + i;
27 if (strcasecmp ("Graph", child->key) == 0)
28 graph_config_add (child);
31 DEBUG ("Unknown config option: %s", child->key);
36 } /* }}} int dispatch_config */
38 static int internal_read_config (void) /* {{{ */
42 ci = oconfig_parse_file (CONFIG_FILE);
53 } /* }}} int internal_read_config */
55 static time_t get_config_mtime (void) /* {{{ */
60 memset (&statbuf, 0, sizeof (statbuf));
61 status = stat (CONFIG_FILE, &statbuf);
65 return (statbuf.st_mtime);
66 } /* }}} time_t get_config_mtime */
68 int graph_read_config (void) /* {{{ */
72 mtime = get_config_mtime ();
74 if (mtime <= last_read_mtime)
77 internal_read_config ();
79 last_read_mtime = mtime;
82 } /* }}} int graph_read_config */
84 int graph_config_get_string (const oconfig_item_t *ci, /* {{{ */
89 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
92 tmp = strdup (ci->values[0].value.string);
100 } /* }}} int graph_config_get_string */
102 int graph_config_get_bool (const oconfig_item_t *ci, /* {{{ */
105 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
108 if (ci->values[0].value.boolean)
114 } /* }}} int graph_config_get_bool */
116 /* vim: set sw=2 sts=2 et fdm=marker : */