summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-15 21:33:43 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-17 00:09:15 -0400
commit799de03f51def1cb3cea376c2e3e783c721c9b89 (patch)
tree05fc39b5c7031dd8f81721289581fb8690eac703 /src/core/main.c
parenteb3491d9ab2f2a3a28d9a6749b2c4b8abff173c6 (diff)
core/main: generate 4 parsing functions from a macro
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c89
1 files changed, 21 insertions, 68 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 789976108a..f0b4152542 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -421,77 +421,30 @@ static int parse_proc_cmdline_word(const char *word) {
return 0;
}
-static int config_parse_level2(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- log_set_max_level_from_string(rvalue);
- return 0;
-}
-
-static int config_parse_target(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- log_set_target_from_string(rvalue);
- return 0;
+#define DEFINE_SETTER(name, func) \
+ static int name( \
+ const char *filename, \
+ unsigned line, \
+ const char *section, \
+ const char *lvalue, \
+ int ltype, \
+ const char *rvalue, \
+ void *data, \
+ void *userdata) { \
+ \
+ assert(filename); \
+ assert(lvalue); \
+ assert(rvalue); \
+ \
+ func(rvalue); \
+ return 0; \
}
-static int config_parse_color(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- log_show_color_from_string(rvalue);
- return 0;
-}
+DEFINE_SETTER(config_parse_level2, log_set_max_level_from_string)
+DEFINE_SETTER(config_parse_target, log_set_target_from_string)
+DEFINE_SETTER(config_parse_color, log_show_color_from_string)
+DEFINE_SETTER(config_parse_location, log_show_location_from_string)
-static int config_parse_location(
- const char *filename,
- unsigned line,
- const char *section,
- const char *lvalue,
- int ltype,
- const char *rvalue,
- void *data,
- void *userdata) {
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- log_show_location_from_string(rvalue);
- return 0;
-}
static int config_parse_cpu_affinity2(
const char *filename,