summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-22 15:48:46 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-22 15:48:46 +0000
commite935d73b34094a88dbd997769be1c52b633fc3d3 (patch)
treeb4ce641936e6998987b887e94374b761bd9f6d2b /src/or/config.c
parent4ec5e139c8442b321ef9b58684da547ea0388261 (diff)
downloadtor-e935d73b34094a88dbd997769be1c52b633fc3d3.tar.gz
tor-e935d73b34094a88dbd997769be1c52b633fc3d3.zip
r12852@catbus: nickm | 2007-05-22 11:00:27 -0400
Use svn revisions consistently throughout all log messages. svn:r10291
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 51610e777d..69de3a51bd 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -697,6 +697,25 @@ set_options(or_options_t *new_val, char **msg)
return 0;
}
+extern const char tor_svn_revision[]; /* from main.c */
+
+/** Return the current Tor version, possibly */
+const char *
+get_version(void)
+{
+ static char *version = NULL;
+ if (version == NULL) {
+ if (strlen(tor_svn_revision)) {
+ size_t len = strlen(VERSION)+strlen(tor_svn_revision)+8;
+ version = tor_malloc(len);
+ tor_snprintf(version, len, "%s (r%s)", VERSION, tor_svn_revision);
+ } else {
+ version = tor_strdup(VERSION);
+ }
+ }
+ return version;
+}
+
/** Release all memory and resources held by global configuration structures.
*/
void
@@ -3080,8 +3099,6 @@ check_nickname_list(const char *lst, const char *name, char **msg)
return r;
}
-extern const char tor_svn_revision[]; /* from main.c */
-
/** Read a configuration file into <b>options</b>, finding the configuration
* file location based on the command line. After loading the options,
* validate them for consistency, then take actions based on them.
@@ -3118,13 +3135,7 @@ options_init_from_torrc(int argc, char **argv)
}
if (argc > 1 && (!strcmp(argv[1],"--version"))) {
- char vbuf[128];
- if (strlen(tor_svn_revision)) {
- tor_snprintf(vbuf, sizeof(vbuf), " (r%s)", tor_svn_revision);
- } else {
- vbuf[0] = 0;
- }
- printf("Tor version %s%s.\n",VERSION,vbuf);
+ printf("Tor version %s.\n",get_version());
if (argc > 2 && (!strcmp(argv[2],"--version"))) {
print_svn_version();
}
@@ -4311,7 +4322,10 @@ or_state_save(time_t now)
global_state->LastWritten = time(NULL);
tor_free(global_state->TorVersion);
- global_state->TorVersion = tor_strdup("Tor " VERSION);
+ len = strlen(get_version())+8;
+ global_state->TorVersion = tor_malloc(len);
+ tor_snprintf(global_state->TorVersion, len, "Tor %s", get_version());
+
state = config_dump(&state_format, global_state, 1, 0);
len = strlen(state)+256;
contents = tor_malloc(len);