diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-06-25 07:40:13 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-06-25 07:40:13 +0200 |
commit | efdbd1ea13aaee8925b607d5a59a41d80f70b75b (patch) | |
tree | eca227c3ca51c121d7e7aa46028863ff99a9ba6b /src/plugins/logger/logger.c | |
parent | 52437427af75dcf002631b16f7884d5f49a15b43 (diff) | |
download | weechat-efdbd1ea13aaee8925b607d5a59a41d80f70b75b.zip |
logger: call function string_eval_path_home() to evaluate logger file path
Diffstat (limited to 'src/plugins/logger/logger.c')
-rw-r--r-- | src/plugins/logger/logger.c | 60 |
1 files changed, 15 insertions, 45 deletions
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index ec6d1e651..887d792b1 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -71,72 +71,42 @@ struct t_hook *logger_timer = NULL; /* timer to flush log files */ char * logger_get_file_path () { - char *file_path, *file_path2, *file_path3, *file_path4; - const char *weechat_dir; + char *path, *path2; int length; time_t seconds; struct tm *date_tmp; - file_path = NULL; - file_path2 = NULL; - file_path3 = NULL; - file_path4 = NULL; - - weechat_dir = weechat_info_get ("weechat_dir", ""); - if (!weechat_dir) - goto end; + path = NULL; + path2 = NULL; - /* evaluate path */ - file_path = weechat_string_eval_expression ( + /* replace %h and "~", evaluate path */ + path = weechat_string_eval_path_home ( weechat_config_string (logger_config_file_path), NULL, NULL, NULL); - if (!file_path) - goto end; - - /* replace "~" with user home */ - file_path2 = weechat_string_expand_home (file_path); - if (!file_path2) - goto end; - - /* replace "%h" with WeeChat home (at beginning of string only) */ - if (strncmp (file_path2, "%h", 2) == 0) - { - length = strlen (weechat_dir) + strlen (file_path2 + 2) + 1; - file_path3 = malloc (length); - if (file_path3) - snprintf (file_path3, length, "%s%s", weechat_dir, file_path2 + 2); - } - else - file_path3 = strdup (file_path2); - if (!file_path3) + if (!path) goto end; /* replace date/time specifiers in path */ - length = strlen (file_path3) + 256 + 1; - file_path4 = malloc (length); - if (!file_path4) + length = strlen (path) + 256 + 1; + path2 = malloc (length); + if (!path2) goto end; seconds = time (NULL); date_tmp = localtime (&seconds); - file_path4[0] = '\0'; - strftime (file_path4, length - 1, file_path3, date_tmp); + path2[0] = '\0'; + strftime (path2, length - 1, path, date_tmp); if (weechat_logger_plugin->debug) { weechat_printf_tags (NULL, "no_log", "%s: file path = \"%s\"", - LOGGER_PLUGIN_NAME, file_path4); + LOGGER_PLUGIN_NAME, path2); } end: - if (file_path) - free (file_path); - if (file_path2) - free (file_path2); - if (file_path3) - free (file_path3); - - return file_path4; + if (path) + free (path); + return path2; } /* |