summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-12 20:14:31 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-12 20:14:31 +0200
commit8998cba6839a46f11daec411c83a1b35723c5117 (patch)
tree1153da13e98c657b98009942c407f912878190bf
parenteb40da25d666b2dce9b69ae21cd36513eb885f61 (diff)
conf: add pa_config_parse_not_bool() for parsing inverse boolean configuration options
-rw-r--r--src/pulsecore/conf-parser.c24
-rw-r--r--src/pulsecore/conf-parser.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index 2dc9a223..b4ab23cc 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -278,6 +278,30 @@ int pa_config_parse_bool(const char *filename, unsigned line, const char *sectio
return 0;
}
+int pa_config_parse_not_bool(
+ const char *filename, unsigned line,
+ const char *section,
+ const char *lvalue, const char *rvalue,
+ void *data, void *userdata) {
+
+ int k;
+ pa_bool_t *b = data;
+
+ pa_assert(filename);
+ pa_assert(lvalue);
+ pa_assert(rvalue);
+ pa_assert(data);
+
+ if ((k = pa_parse_boolean(rvalue)) < 0) {
+ pa_log("[%s:%u] Failed to parse boolean value: %s", filename, line, rvalue);
+ return -1;
+ }
+
+ *b = !k;
+
+ return 0;
+}
+
int pa_config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) {
char **s = data;
diff --git a/src/pulsecore/conf-parser.h b/src/pulsecore/conf-parser.h
index 08e17ca7..c6c8a148 100644
--- a/src/pulsecore/conf-parser.h
+++ b/src/pulsecore/conf-parser.h
@@ -47,6 +47,7 @@ int pa_config_parse_int(const char *filename, unsigned line, const char *section
int pa_config_parse_unsigned(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int pa_config_parse_size(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int pa_config_parse_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
+int pa_config_parse_not_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int pa_config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
#endif