diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-02-04 10:07:19 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-02-04 10:07:19 +0100 |
commit | 763bb073b4710777c3083833c931290bdc5df066 (patch) | |
tree | bf211a68230f031912efd308eec5400d40118b96 /src | |
parent | 9f0b72279307337632f4c8af23b624971adf10c5 (diff) | |
download | weechat-763bb073b4710777c3083833c931290bdc5df066.zip |
Added string_tolower/upper in plugins API, added "name_lower_case" option in logger plugin (bug #19522)
The new option "name_lower_case" is "on" by default and will convert category/name to lower case for log filename.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/logger/logger.c | 27 | ||||
-rw-r--r-- | src/plugins/plugin.c | 2 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 6 |
3 files changed, 31 insertions, 4 deletions
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index fd92047da..bc30a7d9e 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -47,12 +47,14 @@ WEECHAT_PLUGIN_LICENSE("GPL"); struct t_weechat_plugin *weechat_logger_plugin = NULL; -#define LOGGER_OPTION_PATH "path" -#define LOGGER_OPTION_TIME_FORMAT "time_format" -#define LOGGER_OPTION_INFO_LINES "info_lines" -#define LOGGER_OPTION_BACKLOG "backlog" +#define LOGGER_OPTION_PATH "path" +#define LOGGER_OPTION_NAME_LOWER_CASE "name_lower_case" +#define LOGGER_OPTION_TIME_FORMAT "time_format" +#define LOGGER_OPTION_INFO_LINES "info_lines" +#define LOGGER_OPTION_BACKLOG "backlog" char *logger_option_path = NULL; +int logger_option_name_lower_case; char *logger_option_time_format = NULL; int logger_option_info_lines; int logger_option_backlog; @@ -77,6 +79,17 @@ logger_config_read () logger_option_path = weechat_config_get_plugin ("path"); } + string = weechat_config_get_plugin (LOGGER_OPTION_NAME_LOWER_CASE); + if (!string) + { + weechat_config_set_plugin (LOGGER_OPTION_NAME_LOWER_CASE, "on"); + string = weechat_config_get_plugin (LOGGER_OPTION_NAME_LOWER_CASE); + } + if (string && (weechat_config_string_to_boolean (string) > 0)) + logger_option_name_lower_case = 1; + else + logger_option_name_lower_case = 0; + logger_option_time_format = weechat_config_get_plugin (LOGGER_OPTION_TIME_FORMAT); if (!logger_option_time_format) { @@ -209,11 +222,15 @@ logger_get_filename (struct t_gui_buffer *buffer) strcpy (res, log_path2); if (category2) { + if (logger_option_name_lower_case) + weechat_string_tolower (category2); strcat (res, category2); strcat (res, "."); } if (name2) { + if (logger_option_name_lower_case) + weechat_string_tolower (name2); strcat (res, name2); strcat (res, "."); } @@ -644,6 +661,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) weechat_hook_config ("plugin", "logger." LOGGER_OPTION_PATH, &logger_config_cb, NULL); + weechat_hook_config ("plugin", "logger." LOGGER_OPTION_NAME_LOWER_CASE, + &logger_config_cb, NULL); weechat_hook_config ("plugin", "logger." LOGGER_OPTION_TIME_FORMAT, &logger_config_cb, NULL); weechat_hook_config ("plugin", "logger." LOGGER_OPTION_INFO_LINES, diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index d841d1c18..9e2e5b357 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -234,6 +234,8 @@ plugin_load (char *filename) new_plugin->gettext = &plugin_api_gettext; new_plugin->ngettext = &plugin_api_ngettext; new_plugin->strndup = &string_strndup; + new_plugin->string_tolower = &string_tolower; + new_plugin->string_toupper = &string_toupper; new_plugin->strcasecmp = &string_strcasecmp; new_plugin->strncasecmp = &string_strncasecmp; new_plugin->strcmp_ignore_chars = &string_strcmp_ignore_chars; diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 34bda39d9..91112eb0c 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -95,6 +95,8 @@ struct t_weechat_plugin char *(*gettext) (char *string); char *(*ngettext) (char *single, char *plural, int count); char *(*strndup) (char *string, int length); + void (*string_tolower) (char *string); + void (*string_toupper) (char *string); int (*strcasecmp) (char *string1, char *string2); int (*strncasecmp) (char *string1, char *string2, int max); int (*strcmp_ignore_chars) (char *string1, char *string2, @@ -360,6 +362,10 @@ struct t_weechat_plugin weechat_plugin->ngettext(single, plural, number) #define weechat_strndup(__string, __length) \ weechat_plugin->strndup(__string, __length) +#define weechat_string_tolower(__string) \ + weechat_plugin->string_tolower(__string) +#define weechat_string_toupper(__string) \ + weechat_plugin->string_toupper(__string) #define weechat_strcasecmp(__string1, __string2) \ weechat_plugin->strcasecmp(__string1, __string2) #define weechat_strncasecmp(__string1, __string2, __max) \ |