aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-09-10 09:19:10 -0400
committerNick Mathewson <nickm@torproject.org>2010-09-10 09:19:10 -0400
commit07049b3d25cbc397dd39c71d32422bfd7c39d814 (patch)
treec037b87814aac248cbbe9533a51f0bbdc599ea65 /src/common/util.c
parentc05c8dbd78f13bff79cda8fda1579aba51e30b0c (diff)
downloadtor-07049b3d25cbc397dd39c71d32422bfd7c39d814.tar.gz
tor-07049b3d25cbc397dd39c71d32422bfd7c39d814.zip
Support mutli-line torrc options via the usual backslash syntax
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 1d770458f7..6b9455ddd7 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2285,6 +2285,7 @@ const char *
parse_config_line_from_str(const char *line, char **key_out, char **value_out)
{
const char *key, *val, *cp;
+ int continuation = 0;
tor_assert(key_out);
tor_assert(value_out);
@@ -2329,8 +2330,13 @@ parse_config_line_from_str(const char *line, char **key_out, char **value_out)
if (*line && *line != '#' && *line != '\n')
return NULL;
} else {
- while (*line && *line != '\n' && *line != '#')
+ while (*line && *line != '\n' && *line != '#') {
+ if (*line == '\\' && line[1] == '\n') {
+ continuation = 1;
+ ++line;
+ }
++line;
+ }
if (*line == '\n') {
cp = line++;
} else {
@@ -2340,7 +2346,21 @@ parse_config_line_from_str(const char *line, char **key_out, char **value_out)
--cp;
tor_assert(cp >= val);
+
*value_out = tor_strndup(val, cp-val);
+ if (continuation) {
+ char *v_out, *v_in;
+ v_out = v_in = *value_out;
+ while (*v_in) {
+ if (v_in[0] == '\\' && v_in[1] == '\n') {
+ v_in += 2;
+ } else {
+ *v_out++ = *v_in++;
+ }
+ }
+ *v_out = '\0';
+ }
+
}
if (*line == '#') {