diff options
author | Kamran Riaz Khan <krkhan@inspirated.com> | 2011-08-08 19:19:06 +0500 |
---|---|---|
committer | Kamran Riaz Khan <krkhan@inspirated.com> | 2011-08-08 19:19:06 +0500 |
commit | 02c62b2966083ce549fc6ba6c743d5c37f357fe6 (patch) | |
tree | 44682b820c830dac91db04cbb9200df866553034 /src/or/control.c | |
parent | 5a801a8c8b71c9551a80913398135809cb10cecd (diff) | |
download | tor-02c62b2966083ce549fc6ba6c743d5c37f357fe6.tar.gz tor-02c62b2966083ce549fc6ba6c743d5c37f357fe6.zip |
Refactor to do CONF_CHANGED event formatting inside control.c
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c index 0b19a25d99..05797038de 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -4002,12 +4002,34 @@ control_event_guard(const char *nickname, const char *digest, * by SETCONF requests and RELOAD/SIGHUP signals. The <b>values</b> are the * keyword/value pairs for the configuration changes tor is using. */ int -control_event_conf_changed(const char *values) +control_event_conf_changed(smartlist_t *elements) { - if(strlen(values) > 0) { - send_control_event(EVENT_CONF_CHANGED, 0, - "650-CONF_CHANGED\r\n%s\r\n650 OK\r\n", values); + int i; + char *result; + smartlist_t *lines; + if (smartlist_len(elements) == 0) { + return 0; } + lines = smartlist_create(); + for (i = 0; i < smartlist_len(elements); i += 2) { + char *k = smartlist_get(elements, i); + char *v = smartlist_get(elements, i+1); + if (v == NULL) { + char *tmp; + tor_asprintf(&tmp, "650-%s", k); + smartlist_add(lines, tmp); + } else { + char *tmp; + tor_asprintf(&tmp, "650-%s=%s", k, v); + smartlist_add(lines, tmp); + } + } + result = smartlist_join_strings(lines, "\r\n", 0, NULL); + send_control_event(EVENT_CONF_CHANGED, 0, + "650-CONF_CHANGED\r\n%s\r\n650 OK\r\n", result); + tor_free(result); + SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp)); + smartlist_free(lines); return 0; } |