summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-05-30 20:23:01 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-05-30 20:28:01 +0200
commitf6a8c28d2dcf4d4ed6f87e7e94574b331455b40a (patch)
treed3c76b7ab7b439c54bf08050cfa63dca66ea994a /src
parentf131b9f7defeee9e48eb8ed077d491bcdfcf0e03 (diff)
downloadweechat-f6a8c28d2dcf4d4ed6f87e7e94574b331455b40a.zip
api: add function config_option_get_string in plugin API
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config-file.c25
-rw-r--r--src/core/wee-config-file.h2
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/weechat-plugin.h6
4 files changed, 32 insertions, 2 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 3a5bcd3e3..f0a7a33eb 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -1906,7 +1906,30 @@ config_file_option_value_to_string (struct t_config_option *option,
}
/*
- * Gets a pointer of an option property.
+ * Gets a string value of an option property.
+ */
+
+const char *
+config_file_option_get_string (struct t_config_option *option,
+ const char *property)
+{
+ if (!option || !property)
+ return NULL;
+
+ if (string_strcasecmp (property, "name") == 0)
+ return option->name;
+ else if (string_strcasecmp (property, "parent_name") == 0)
+ return option->parent_name;
+ else if (string_strcasecmp (property, "type") == 0)
+ return config_option_type_string[option->type];
+ else if (string_strcasecmp (property, "description") == 0)
+ return option->description;
+
+ return NULL;
+}
+
+/*
+ * Gets a pointer on an option property.
*/
void *
diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h
index d835b87e9..10b635e44 100644
--- a/src/core/wee-config-file.h
+++ b/src/core/wee-config-file.h
@@ -264,6 +264,8 @@ extern char *config_file_option_value_to_string (struct t_config_option *option,
int default_value,
int add_delimiters,
int use_colors);
+extern const char *config_file_option_get_string (struct t_config_option *option,
+ const char *property);
extern void *config_file_option_get_pointer (struct t_config_option *option,
const char *property);
extern int config_file_option_is_null (struct t_config_option *option);
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 326df8edf..bb2c25e7d 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -728,6 +728,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->config_option_set_null = &config_file_option_set_null;
new_plugin->config_option_unset = &config_file_option_unset;
new_plugin->config_option_rename = &config_file_option_rename;
+ new_plugin->config_option_get_string = &config_file_option_get_string;
new_plugin->config_option_get_pointer = &config_file_option_get_pointer;
new_plugin->config_option_is_null = &config_file_option_is_null;
new_plugin->config_option_default_is_null = &config_file_option_default_is_null;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 2a44d692d..9d3fe101c 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -59,7 +59,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20170401-01"
+#define WEECHAT_PLUGIN_API_VERSION "20170530-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -561,6 +561,8 @@ struct t_weechat_plugin
int (*config_option_unset) (struct t_config_option *option);
void (*config_option_rename) (struct t_config_option *option,
const char *new_name);
+ const char *(*config_option_get_string) (struct t_config_option *option,
+ const char *property);
void *(*config_option_get_pointer) (struct t_config_option *option,
const char *property);
int (*config_option_is_null) (struct t_config_option *option);
@@ -1492,6 +1494,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->config_option_unset)(__option)
#define weechat_config_option_rename(__option, __new_name) \
(weechat_plugin->config_option_rename)(__option, __new_name)
+#define weechat_config_option_get_string(__option, __property) \
+ (weechat_plugin->config_option_get_string)(__option, __property)
#define weechat_config_option_get_pointer(__option, __property) \
(weechat_plugin->config_option_get_pointer)(__option, __property)
#define weechat_config_option_is_null(__option) \