aboutsummaryrefslogtreecommitdiff
path: root/src/app/config/confparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-06-19 16:06:15 -0400
committerNick Mathewson <nickm@torproject.org>2019-06-25 12:51:25 -0400
commita114df9a040dbdedfc89f7d2ff777476e204a2cf (patch)
treed55855fd9bcfb96bf282948851fc4a594ee79f48 /src/app/config/confparse.c
parenta91ed23403ae28974639a9bdb67530c5c07a0ce6 (diff)
downloadtor-a114df9a040dbdedfc89f7d2ff777476e204a2cf.tar.gz
tor-a114df9a040dbdedfc89f7d2ff777476e204a2cf.zip
Add a function to make sure all values in a config object are ok
Diffstat (limited to 'src/app/config/confparse.c')
-rw-r--r--src/app/config/confparse.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/app/config/confparse.c b/src/app/config/confparse.c
index b9b5fddb96..2890d8c81b 100644
--- a/src/app/config/confparse.c
+++ b/src/app/config/confparse.c
@@ -673,3 +673,21 @@ config_dump(const config_format_t *fmt, const void *default_options,
}
return result;
}
+
+/**
+ * Return true if every member of <b>options</b> is in-range and well-formed.
+ * Return false otherwise. Log errors at level <b>severity</b>.
+ */
+bool
+config_check_ok(const config_format_t *fmt, const void *options, int severity)
+{
+ bool all_ok = true;
+ for (int i=0; fmt->vars[i].member.name; ++i) {
+ if (!struct_var_ok(options, &fmt->vars[i].member)) {
+ log_fn(severity, LD_BUG, "Invalid value for %s",
+ fmt->vars[i].member.name);
+ all_ok = false;
+ }
+ }
+ return all_ok;
+}