diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-02-19 17:32:15 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-02-19 17:36:17 -0500 |
commit | 1827be0bd6a400f4b5970f5b37b1d2c8e83b6a3f (patch) | |
tree | 52d404a9e3b2cfb44114e633d0913fb72563d1a4 /src/common/util.h | |
parent | 337e32f5b8f5f3b310da20bf0135f17d06efb3ab (diff) | |
download | tor-1827be0bd6a400f4b5970f5b37b1d2c8e83b6a3f.tar.gz tor-1827be0bd6a400f4b5970f5b37b1d2c8e83b6a3f.zip |
Make a parse_config_line_from_str variant that gives error messages
Without this patch, there's no way to know what went wrong when we
fail to parse a torrc line entirely (that is, we can't turn it into
a K,V pair.) This patch introduces a new function that yields an
error message on failure, so we can at least tell the user what to
look for in their nonfunctional torrc.
(Actually, it's the same function as before with a new name:
parse_config_line_from_str is now a wrapper macro that the unit
tests use.)
Fixes bug 7950; fix on 0.2.0.16-alpha (58de695f9062576f) which first
introduced the possibility of a torrc value not parsing correctly.
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/util.h b/src/common/util.h index ac88f1ca1c..0123a53663 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -375,8 +375,11 @@ char *read_file_to_str(const char *filename, int flags, struct stat *stat_out) char *read_file_to_str_until_eof(int fd, size_t max_bytes_to_read, size_t *sz_out) ATTR_MALLOC; -const char *parse_config_line_from_str(const char *line, - char **key_out, char **value_out); +const char *parse_config_line_from_str_verbose(const char *line, + char **key_out, char **value_out, + const char **err_out); +#define parse_config_line_from_str(line,key_out,value_out) \ + parse_config_line_from_str_verbose((line),(key_out),(value_out),NULL) char *expand_filename(const char *filename); struct smartlist_t *tor_listdir(const char *dirname); int path_is_relative(const char *filename); |