From e6a1bb4694c2819da1c299826976fc7a9c7058fe Mon Sep 17 00:00:00 2001 From: Emmanuel Bouthenot Date: Sun, 30 Oct 2005 23:39:54 +0000 Subject: [PATCH] add constants for python return codes --- src/plugins/scripts/python/weechat-python.c | 10 +++++++++- src/plugins/weechat-plugin.h | 4 ++-- weechat/src/plugins/scripts/python/weechat-python.c | 10 +++++++++- weechat/src/plugins/weechat-plugin.h | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index cd947cd5a..cd8676f13 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -780,7 +780,7 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) { FILE *fp; PyThreadState *python_current_interpreter; - PyObject *weechat_module, *weechat_outputs; + PyObject *weechat_module, *weechat_outputs, *weechat_dict; plugin->printf_server (plugin, "Loading Python script \"%s\"", filename); @@ -825,6 +825,14 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) return 0; } + /* define some constants */ + weechat_dict = PyModule_GetDict(weechat_module); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK", PyInt_FromLong((long) PLUGIN_RC_OK)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_KO", PyInt_FromLong((long) PLUGIN_RC_KO)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK_IGNORE_WEECHAT", PyInt_FromLong((long) PLUGIN_RC_OK_IGNORE_WEECHAT)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK_IGNORE_PLUGINS", PyInt_FromLong((long) PLUGIN_RC_OK_IGNORE_PLUGINS)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK_IGNORE_ALL", PyInt_FromLong((long) PLUGIN_RC_OK_IGNORE_ALL)); + weechat_outputs = Py_InitModule("weechatOutputs", weechat_python_output_funcs); if (weechat_outputs == NULL) { diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 36d24f81a..c368d8846 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -30,8 +30,8 @@ WeeChat, for plugins, or both */ #define PLUGIN_RC_OK_IGNORE_WEECHAT 1 /* ignore WeeChat for this message */ #define PLUGIN_RC_OK_IGNORE_PLUGINS 2 /* ignore other plugins for this msg */ -#define PLUGIN_RC_OK_IGNORE_ALL (PLUGIN_RC_DISCARD_WEECHAT \ - | PLUGIN_RC_DISCARD_PLUGINS) +#define PLUGIN_RC_OK_IGNORE_ALL (PLUGIN_RC_OK_IGNORE_WEECHAT \ + | PLUGIN_RC_OK_IGNORE_PLUGINS) /* ignore WeeChat and other plugins */ typedef struct t_plugin_dcc_info t_plugin_dcc_info; diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c index cd947cd5a..cd8676f13 100644 --- a/weechat/src/plugins/scripts/python/weechat-python.c +++ b/weechat/src/plugins/scripts/python/weechat-python.c @@ -780,7 +780,7 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) { FILE *fp; PyThreadState *python_current_interpreter; - PyObject *weechat_module, *weechat_outputs; + PyObject *weechat_module, *weechat_outputs, *weechat_dict; plugin->printf_server (plugin, "Loading Python script \"%s\"", filename); @@ -825,6 +825,14 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) return 0; } + /* define some constants */ + weechat_dict = PyModule_GetDict(weechat_module); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK", PyInt_FromLong((long) PLUGIN_RC_OK)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_KO", PyInt_FromLong((long) PLUGIN_RC_KO)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK_IGNORE_WEECHAT", PyInt_FromLong((long) PLUGIN_RC_OK_IGNORE_WEECHAT)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK_IGNORE_PLUGINS", PyInt_FromLong((long) PLUGIN_RC_OK_IGNORE_PLUGINS)); + PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK_IGNORE_ALL", PyInt_FromLong((long) PLUGIN_RC_OK_IGNORE_ALL)); + weechat_outputs = Py_InitModule("weechatOutputs", weechat_python_output_funcs); if (weechat_outputs == NULL) { diff --git a/weechat/src/plugins/weechat-plugin.h b/weechat/src/plugins/weechat-plugin.h index 36d24f81a..c368d8846 100644 --- a/weechat/src/plugins/weechat-plugin.h +++ b/weechat/src/plugins/weechat-plugin.h @@ -30,8 +30,8 @@ WeeChat, for plugins, or both */ #define PLUGIN_RC_OK_IGNORE_WEECHAT 1 /* ignore WeeChat for this message */ #define PLUGIN_RC_OK_IGNORE_PLUGINS 2 /* ignore other plugins for this msg */ -#define PLUGIN_RC_OK_IGNORE_ALL (PLUGIN_RC_DISCARD_WEECHAT \ - | PLUGIN_RC_DISCARD_PLUGINS) +#define PLUGIN_RC_OK_IGNORE_ALL (PLUGIN_RC_OK_IGNORE_WEECHAT \ + | PLUGIN_RC_OK_IGNORE_PLUGINS) /* ignore WeeChat and other plugins */ typedef struct t_plugin_dcc_info t_plugin_dcc_info;