Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (44 sloc) 1.28 kb
620e13f @armon Adding configuration module
authored
1 #ifndef CONFIG_H
2 #define CONFIG_H
3 #include <stdint.h>
4 #include <syslog.h>
5
6 /**
7 * Stores our configuration
8 */
9 typedef struct {
10 int tcp_port;
11 int udp_port;
12 char *log_level;
13 int syslog_log_level;
14 double timer_eps;
15 char *stream_cmd;
16 int flush_interval;
17 } statsite_config;
18
19 /**
20 * Initializes the configuration from a filename.
21 * Reads the file as an INI configuration, and sets up the
22 * config object.
23 * @arg filename The name of the file to read. NULL for defaults.
24 * @arg config Output. The config object to initialize.
25 * @return 0 on success, negative on error.
26 */
27 int config_from_filename(char *filename, statsite_config *config);
28
29 /**
30 * Validates the configuration
31 * @arg config The config object to validate.
32 * @return 0 on success, negative on error.
33 */
34 int validate_config(statsite_config *config);
35
36 // Configuration validation methods
37 int sane_log_level(char *log_level, int *syslog_level);
38 int sane_timer_eps(double eps);
39 int sane_flush_interval(int intv);
40
41 /**
42 * Joins two strings as part of a path,
43 * and adds a separating slash if needed.
44 * @param path Part one of the path
45 * @param part2 The second part of the path
46 * @return A new string, that uses a malloc()'d buffer.
47 */
48 char* join_path(char *path, char *part2);
49
50 #endif
Something went wrong with that request. Please try again.