diff options
author | George Kadianakis <desnacked@riseup.net> | 2013-02-11 13:43:20 +0000 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2013-02-11 18:07:26 +0000 |
commit | 266f8cddd87f8cf507e094725b3f6028bb8d803b (patch) | |
tree | 5d903eb81b90ccfe4b5356e8623d83b53ec434d0 /src/common/util.c | |
parent | b5dceab1751dfa12b27b3042a49d90e0b02c2e0c (diff) | |
download | tor-266f8cddd87f8cf507e094725b3f6028bb8d803b.tar.gz tor-266f8cddd87f8cf507e094725b3f6028bb8d803b.zip |
Refactoring to make parse_bridge_line() unittestable.
- Make parse_bridge_line() return a struct.
- Make bridge_add_from_config() accept a struct.
- Make string_is_key_value() less hysterical.
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/util.c b/src/common/util.c index 9aba7d6c5d..bcb69f2081 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -866,9 +866,10 @@ tor_digest_is_zero(const char *digest) } /** Return true if <b>string</b> is a valid '<key>=[<value>]' string. - * <value> is optional, to indicate the empty string. */ + * <value> is optional, to indicate the empty string. Log at logging + * <b>severity</b> if something ugly happens. */ int -string_is_key_value(const char *string) +string_is_key_value(int severity, const char *string) { /* position of equal sign in string */ const char *equal_sign_pos = NULL; @@ -876,19 +877,21 @@ string_is_key_value(const char *string) tor_assert(string); if (strlen(string) < 2) { /* "x=" is shortest args string */ - log_warn(LD_GENERAL, "'%s' is too short to be a k=v value.", escaped(string)); + tor_log(severity, LD_GENERAL, "'%s' is too short to be a k=v value.", + escaped(string)); return 0; } equal_sign_pos = strchr(string, '='); if (!equal_sign_pos) { - log_warn(LD_GENERAL, "'%s' is not a k=v value.", escaped(string)); + tor_log(severity, LD_GENERAL, "'%s' is not a k=v value.", escaped(string)); return 0; } /* validate that the '=' is not in the beginning of the string. */ if (equal_sign_pos == string) { - log_warn(LD_GENERAL, "'%s' is not a valid k=v value.", escaped(string)); + tor_log(severity, LD_GENERAL, "'%s' is not a valid k=v value.", + escaped(string)); return 0; } |