2
* Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org>
3
* See README for License detail, AUTHORS for developers list.
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
/* weechat-python-api.c: Python API functions */
27
#include "../../weechat-plugin.h"
28
#include "../script.h"
29
#include "../script-api.h"
30
#include "../script-callback.h"
31
#include "weechat-python.h"
34
#define PYTHON_RETURN_OK return Py_BuildValue ("i", 1);
35
#define PYTHON_RETURN_ERROR return Py_BuildValue ("i", 0);
36
#define PYTHON_RETURN_EMPTY \
39
#define PYTHON_RETURN_STRING(__string) \
41
return Py_BuildValue ("s", __string); \
42
return Py_BuildValue ("s", "")
43
#define PYTHON_RETURN_STRING_FREE(__string) \
46
object = Py_BuildValue ("s", __string); \
50
return Py_BuildValue ("s", "")
51
#define PYTHON_RETURN_INT(__int) \
52
return Py_BuildValue("i", __int);
56
* weechat_python_api_register: startup function for all WeeChat Python scripts
60
weechat_python_api_register (PyObject *self, PyObject *args)
62
char *name, *author, *version, *license, *shutdown_func, *description;
65
/* make C compiler happy */
68
python_current_script = NULL;
78
if (!PyArg_ParseTuple (args, "sssssss", &name, &author, &version,
79
&license, &description, &shutdown_func, &charset))
81
WEECHAT_SCRIPT_MSG_WRONG_ARGS(python_current_script_filename, "register");
85
if (script_search (weechat_python_plugin, python_scripts, name))
87
/* error: another scripts already exists with this name! */
89
weechat_gettext ("%s%s: unable to register script "
90
"\"%s\" (another script already "
91
"exists with this name)"),
92
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, name);
97
python_current_script = script_add (weechat_python_plugin,
98
&python_scripts, &last_python_script,
99
(python_current_script_filename) ?
100
python_current_script_filename : "",
101
name, author, version, license,
102
description, shutdown_func, charset);
103
if (python_current_script)
105
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
107
weechat_printf (NULL,
108
weechat_gettext ("%s: registered script \"%s\", "
110
PYTHON_PLUGIN_NAME, name, version, description);
122
* weechat_python_api_plugin_get_name: get name of plugin (return "core" for
127
weechat_python_api_plugin_get_name (PyObject *self, PyObject *args)
132
/* make C compiler happy */
135
if (!python_current_script)
137
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "plugin_get_name");
143
if (!PyArg_ParseTuple (args, "s", &plugin))
145
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "plugin_get_name");
149
result = weechat_plugin_get_name (script_str2ptr (plugin));
151
PYTHON_RETURN_STRING(result);
155
* weechat_python_api_charset_set: set script charset
159
weechat_python_api_charset_set (PyObject *self, PyObject *args)
163
/* make C compiler happy */
166
if (!python_current_script)
168
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "charset_set");
174
if (!PyArg_ParseTuple (args, "s", &charset))
176
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "charset_set");
180
script_api_charset_set (python_current_script,
187
* weechat_python_api_iconv_to_internal: convert string to internal WeeChat charset
191
weechat_python_api_iconv_to_internal (PyObject *self, PyObject *args)
193
char *charset, *string, *result;
196
/* make C compiler happy */
199
if (!python_current_script)
201
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "iconv_to_internal");
208
if (!PyArg_ParseTuple (args, "ss", &charset, &string))
210
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "iconv_to_internal");
214
result = weechat_iconv_to_internal (charset, string);
216
PYTHON_RETURN_STRING_FREE(result);
220
* weechat_python_api_iconv_from_internal: convert string from WeeChat internal
221
* charset to another one
225
weechat_python_api_iconv_from_internal (PyObject *self, PyObject *args)
227
char *charset, *string, *result;
230
/* make C compiler happy */
233
if (!python_current_script)
235
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "iconv_from_internal");
242
if (!PyArg_ParseTuple (args, "ss", &charset, &string))
244
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "iconv_from_internal");
248
result = weechat_iconv_from_internal (charset, string);
250
PYTHON_RETURN_STRING_FREE(result);
254
* weechat_python_api_gettext: get translated string
258
weechat_python_api_gettext (PyObject *self, PyObject *args)
263
/* make C compiler happy */
266
if (!python_current_script)
268
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "gettext");
274
if (!PyArg_ParseTuple (args, "s", &string))
276
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "gettext");
280
result = weechat_gettext (string);
282
PYTHON_RETURN_STRING(result);
286
* weechat_python_api_ngettext: get translated string with plural form
290
weechat_python_api_ngettext (PyObject *self, PyObject *args)
292
char *single, *plural;
296
/* make C compiler happy */
299
if (!python_current_script)
301
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "ngettext");
309
if (!PyArg_ParseTuple (args, "ssi", &single, &plural, &count))
311
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "ngettext");
315
result = weechat_ngettext (single, plural, count);
317
PYTHON_RETURN_STRING(result);
321
* weechat_python_api_string_remove_color: remove WeeChat color codes from string
325
weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
327
char *string, *replacement, *result;
330
/* make C compiler happy */
333
if (!python_current_script)
335
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "string_remove_color");
342
if (!PyArg_ParseTuple (args, "ss", &string, &replacement))
344
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "string_remove_color");
348
result = weechat_string_remove_color (string, replacement);
350
PYTHON_RETURN_STRING_FREE(result);
354
* weechat_python_api_mkdir_home: create a directory in WeeChat home
358
weechat_python_api_mkdir_home (PyObject *self, PyObject *args)
363
/* make C compiler happy */
366
if (!python_current_script)
368
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_home");
375
if (!PyArg_ParseTuple (args, "si", &directory, &mode))
377
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_home");
381
if (weechat_mkdir_home (directory, mode))
388
* weechat_python_api_mkdir: create a directory
392
weechat_python_api_mkdir (PyObject *self, PyObject *args)
397
/* make C compiler happy */
400
if (!python_current_script)
402
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "mkdir");
409
if (!PyArg_ParseTuple (args, "si", &directory, &mode))
411
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "mkdir");
415
if (weechat_mkdir (directory, mode))
422
* weechat_python_api_mkdir_parents: create a directory and make parent
423
* directories as needed
427
weechat_python_api_mkdir_parents (PyObject *self, PyObject *args)
432
/* make C compiler happy */
435
if (!python_current_script)
437
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_parents");
444
if (!PyArg_ParseTuple (args, "si", &directory, &mode))
446
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "mkdir_parents");
450
if (weechat_mkdir_parents (directory, mode))
457
* weechat_python_api_list_new: create a new list
461
weechat_python_api_list_new (PyObject *self, PyObject *args)
466
/* make C compiler happy */
470
if (!python_current_script)
472
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_new");
476
result = script_ptr2str (weechat_list_new ());
478
PYTHON_RETURN_STRING_FREE(result);
482
* weechat_python_api_list_add: add a string to list
486
weechat_python_api_list_add (PyObject *self, PyObject *args)
488
char *weelist, *data, *where, *user_data, *result;
491
/* make C compiler happy */
494
if (!python_current_script)
496
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_add");
505
if (!PyArg_ParseTuple (args, "ssss", &weelist, &data, &where, &user_data))
507
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_add");
511
result = script_ptr2str (weechat_list_add (script_str2ptr (weelist),
514
script_str2ptr (user_data)));
516
PYTHON_RETURN_STRING_FREE(result);
520
* weechat_python_api_list_search: search a string in list
524
weechat_python_api_list_search (PyObject *self, PyObject *args)
526
char *weelist, *data, *result;
529
/* make C compiler happy */
532
if (!python_current_script)
534
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_search");
541
if (!PyArg_ParseTuple (args, "ss", &weelist, &data))
543
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_search");
547
result = script_ptr2str (weechat_list_search (script_str2ptr (weelist),
550
PYTHON_RETURN_STRING_FREE(result);
554
* weechat_python_api_list_casesearch: search a string in list (ignore case)
558
weechat_python_api_list_casesearch (PyObject *self, PyObject *args)
560
char *weelist, *data, *result;
563
/* make C compiler happy */
566
if (!python_current_script)
568
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch");
575
if (!PyArg_ParseTuple (args, "ss", &weelist, &data))
577
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch");
581
result = script_ptr2str (weechat_list_casesearch (script_str2ptr (weelist),
584
PYTHON_RETURN_STRING_FREE(result);
588
* weechat_python_api_list_get: get item by position
592
weechat_python_api_list_get (PyObject *self, PyObject *args)
594
char *weelist, *result;
598
/* make C compiler happy */
601
if (!python_current_script)
603
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_get");
610
if (!PyArg_ParseTuple (args, "si", &weelist, &position))
612
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_get");
616
result = script_ptr2str (weechat_list_get (script_str2ptr (weelist),
618
PYTHON_RETURN_STRING_FREE(result);
622
* weechat_python_api_list_set: set new value for item
626
weechat_python_api_list_set (PyObject *self, PyObject *args)
628
char *item, *new_value;
630
/* make C compiler happy */
633
if (!python_current_script)
635
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_set");
642
if (!PyArg_ParseTuple (args, "ss", &item, &new_value))
644
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_set");
648
weechat_list_set (script_str2ptr (item),
655
* weechat_python_api_list_next: get next item
659
weechat_python_api_list_next (PyObject *self, PyObject *args)
664
/* make C compiler happy */
667
if (!python_current_script)
669
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_next");
675
if (!PyArg_ParseTuple (args, "s", &item))
677
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_next");
681
result = script_ptr2str (weechat_list_next (script_str2ptr (item)));
683
PYTHON_RETURN_STRING_FREE(result);
687
* weechat_python_api_list_prev: get previous item
691
weechat_python_api_list_prev (PyObject *self, PyObject *args)
696
/* make C compiler happy */
699
if (!python_current_script)
701
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_prev");
707
if (!PyArg_ParseTuple (args, "s", &item))
709
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_prev");
713
result = script_ptr2str (weechat_list_prev (script_str2ptr (item)));
715
PYTHON_RETURN_STRING_FREE(result);
719
* weechat_python_api_list_string: get string value of item
723
weechat_python_api_list_string (PyObject *self, PyObject *args)
728
/* make C compiler happy */
731
if (!python_current_script)
733
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_string");
739
if (!PyArg_ParseTuple (args, "s", &item))
741
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_string");
745
result = weechat_list_string (script_str2ptr (item));
747
PYTHON_RETURN_STRING(result);
751
* weechat_python_api_list_size: get number of elements in list
755
weechat_python_api_list_size (PyObject *self, PyObject *args)
760
/* make C compiler happy */
763
if (!python_current_script)
765
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_size");
766
PYTHON_RETURN_INT(0);
771
if (!PyArg_ParseTuple (args, "s", &weelist))
773
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_size");
774
PYTHON_RETURN_INT(0);
777
size = weechat_list_size (script_str2ptr (weelist));
779
PYTHON_RETURN_INT(size);
783
* weechat_python_api_list_remove: remove item from list
787
weechat_python_api_list_remove (PyObject *self, PyObject *args)
789
char *weelist, *item;
791
/* make C compiler happy */
794
if (!python_current_script)
796
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_remove");
803
if (!PyArg_ParseTuple (args, "ss", &weelist, &item))
805
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_remove");
809
weechat_list_remove (script_str2ptr (weelist),
810
script_str2ptr (item));
816
* weechat_python_api_list_remove_all: remove all items from list
820
weechat_python_api_list_remove_all (PyObject *self, PyObject *args)
824
/* make C compiler happy */
827
if (!python_current_script)
829
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_remove_all");
835
if (!PyArg_ParseTuple (args, "s", &weelist))
837
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_remove_all");
841
weechat_list_remove_all (script_str2ptr (weelist));
847
* weechat_python_api_list_free: free list
851
weechat_python_api_list_free (PyObject *self, PyObject *args)
855
/* make C compiler happy */
858
if (!python_current_script)
860
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_free");
866
if (!PyArg_ParseTuple (args, "s", &weelist))
868
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_free");
872
weechat_list_free (script_str2ptr (weelist));
878
* weechat_python_api_config_reload_cb: callback for config reload
882
weechat_python_api_config_reload_cb (void *data,
883
struct t_config_file *config_file)
885
struct t_script_callback *script_callback;
886
char *python_argv[3], empty_arg[1] = { '\0' };
889
script_callback = (struct t_script_callback *)data;
891
if (script_callback && script_callback->function && script_callback->function[0])
893
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
894
python_argv[1] = script_ptr2str (config_file);
895
python_argv[2] = NULL;
897
rc = (int *) weechat_python_exec (script_callback->script,
898
WEECHAT_SCRIPT_EXEC_INT,
899
script_callback->function,
903
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
910
free (python_argv[1]);
915
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
919
* weechat_python_api_config_new: create a new configuration file
923
weechat_python_api_config_new (PyObject *self, PyObject *args)
925
char *name, *function, *data, *result;
928
/* make C compiler happy */
931
if (!python_current_script)
933
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_new");
941
if (!PyArg_ParseTuple (args, "sss", &name, &function, &data))
943
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_new");
947
result = script_ptr2str (script_api_config_new (weechat_python_plugin,
948
python_current_script,
950
&weechat_python_api_config_reload_cb,
954
PYTHON_RETURN_STRING_FREE(result);
958
* weechat_python_api_config_read_cb: callback for reading option in section
962
weechat_python_api_config_read_cb (void *data,
963
struct t_config_file *config_file,
964
struct t_config_section *section,
965
const char *option_name, const char *value)
967
struct t_script_callback *script_callback;
968
char *python_argv[6], empty_arg[1] = { '\0' };
971
script_callback = (struct t_script_callback *)data;
973
if (script_callback && script_callback->function && script_callback->function[0])
975
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
976
python_argv[1] = script_ptr2str (config_file);
977
python_argv[2] = script_ptr2str (section);
978
python_argv[3] = (option_name) ? (char *)option_name : empty_arg;
979
python_argv[4] = (value) ? (char *)value : empty_arg;
980
python_argv[5] = NULL;
982
rc = (int *) weechat_python_exec (script_callback->script,
983
WEECHAT_SCRIPT_EXEC_INT,
984
script_callback->function,
988
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
995
free (python_argv[1]);
997
free (python_argv[2]);
1002
return WEECHAT_CONFIG_OPTION_SET_ERROR;
1006
* weechat_python_api_config_section_write_cb: callback for writing section
1010
weechat_python_api_config_section_write_cb (void *data,
1011
struct t_config_file *config_file,
1012
const char *section_name)
1014
struct t_script_callback *script_callback;
1015
char *python_argv[4], empty_arg[1] = { '\0' };
1018
script_callback = (struct t_script_callback *)data;
1020
if (script_callback && script_callback->function && script_callback->function[0])
1022
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1023
python_argv[1] = script_ptr2str (config_file);
1024
python_argv[2] = (section_name) ? (char *)section_name : empty_arg;
1025
python_argv[3] = NULL;
1027
rc = (int *) weechat_python_exec (script_callback->script,
1028
WEECHAT_SCRIPT_EXEC_INT,
1029
script_callback->function,
1035
free (python_argv[1]);
1040
* weechat_python_api_config_section_write_default_cb: callback for writing
1041
* default values for section
1045
weechat_python_api_config_section_write_default_cb (void *data,
1046
struct t_config_file *config_file,
1047
const char *section_name)
1049
struct t_script_callback *script_callback;
1050
char *python_argv[4], empty_arg[1] = { '\0' };
1053
script_callback = (struct t_script_callback *)data;
1055
if (script_callback && script_callback->function && script_callback->function[0])
1057
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1058
python_argv[1] = script_ptr2str (config_file);
1059
python_argv[2] = (section_name) ? (char *)section_name : empty_arg;
1060
python_argv[3] = NULL;
1062
rc = (int *) weechat_python_exec (script_callback->script,
1063
WEECHAT_SCRIPT_EXEC_INT,
1064
script_callback->function,
1070
free (python_argv[1]);
1075
* weechat_python_api_config_section_create_option_cb: callback to create an option
1079
weechat_python_api_config_section_create_option_cb (void *data,
1080
struct t_config_file *config_file,
1081
struct t_config_section *section,
1082
const char *option_name,
1085
struct t_script_callback *script_callback;
1086
char *python_argv[6], empty_arg[1] = { '\0' };
1089
script_callback = (struct t_script_callback *)data;
1091
if (script_callback && script_callback->function && script_callback->function[0])
1093
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1094
python_argv[1] = script_ptr2str (config_file);
1095
python_argv[2] = script_ptr2str (section);
1096
python_argv[3] = (option_name) ? (char *)option_name : empty_arg;
1097
python_argv[4] = (value) ? (char *)value : empty_arg;
1098
python_argv[5] = NULL;
1100
rc = (int *) weechat_python_exec (script_callback->script,
1101
WEECHAT_SCRIPT_EXEC_INT,
1102
script_callback->function,
1106
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
1113
free (python_argv[1]);
1115
free (python_argv[2]);
1120
return WEECHAT_CONFIG_OPTION_SET_ERROR;
1124
* weechat_python_api_config_section_delete_option_cb: callback to delete an option
1128
weechat_python_api_config_section_delete_option_cb (void *data,
1129
struct t_config_file *config_file,
1130
struct t_config_section *section,
1131
struct t_config_option *option)
1133
struct t_script_callback *script_callback;
1134
char *python_argv[5], empty_arg[1] = { '\0' };
1137
script_callback = (struct t_script_callback *)data;
1139
if (script_callback && script_callback->function && script_callback->function[0])
1141
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1142
python_argv[1] = script_ptr2str (config_file);
1143
python_argv[2] = script_ptr2str (section);
1144
python_argv[3] = script_ptr2str (option);
1145
python_argv[4] = NULL;
1147
rc = (int *) weechat_python_exec (script_callback->script,
1148
WEECHAT_SCRIPT_EXEC_INT,
1149
script_callback->function,
1153
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
1160
free (python_argv[1]);
1162
free (python_argv[2]);
1164
free (python_argv[3]);
1169
return WEECHAT_CONFIG_OPTION_UNSET_ERROR;
1173
* weechat_python_api_config_new_section: create a new section in configuration file
1177
weechat_python_api_config_new_section (PyObject *self, PyObject *args)
1179
char *config_file, *name, *function_read, *data_read, *function_write;
1180
char *data_write, *function_write_default, *data_write_default;
1181
char *function_create_option, *data_create_option, *function_delete_option;
1182
char *data_delete_option, *result;
1183
int user_can_add_options, user_can_delete_options;
1186
/* make C compiler happy */
1189
if (!python_current_script)
1191
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_new_section");
1192
PYTHON_RETURN_EMPTY;
1197
user_can_add_options = 0;
1198
user_can_delete_options = 0;
1199
function_read = NULL;
1201
function_write = NULL;
1203
function_write_default = NULL;
1204
data_write_default = NULL;
1205
function_create_option = NULL;
1206
data_create_option = NULL;
1207
function_delete_option = NULL;
1208
data_delete_option = NULL;
1210
if (!PyArg_ParseTuple (args, "ssiissssssssss", &config_file, &name,
1211
&user_can_add_options, &user_can_delete_options,
1212
&function_read, &data_read, &function_write,
1213
&data_write, &function_write_default,
1214
&data_write_default, &function_create_option,
1215
&data_create_option, &function_delete_option,
1216
&data_delete_option))
1218
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_new_section");
1219
PYTHON_RETURN_EMPTY;
1222
result = script_ptr2str (script_api_config_new_section (weechat_python_plugin,
1223
python_current_script,
1224
script_str2ptr (config_file),
1226
user_can_add_options,
1227
user_can_delete_options,
1228
&weechat_python_api_config_read_cb,
1231
&weechat_python_api_config_section_write_cb,
1234
&weechat_python_api_config_section_write_default_cb,
1235
function_write_default,
1237
&weechat_python_api_config_section_create_option_cb,
1238
function_create_option,
1240
&weechat_python_api_config_section_delete_option_cb,
1241
function_delete_option,
1242
data_delete_option));
1244
PYTHON_RETURN_STRING_FREE(result);
1248
* weechat_python_api_config_search_section: search section in configuration file
1252
weechat_python_api_config_search_section (PyObject *self, PyObject *args)
1254
char *config_file, *section_name, *result;
1257
/* make C compiler happy */
1260
if (!python_current_script)
1262
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_search_section");
1263
PYTHON_RETURN_EMPTY;
1267
section_name = NULL;
1269
if (!PyArg_ParseTuple (args, "ss", &config_file, §ion_name))
1271
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_search_section");
1272
PYTHON_RETURN_EMPTY;
1275
result = script_ptr2str (weechat_config_search_section (script_str2ptr (config_file),
1278
PYTHON_RETURN_STRING_FREE(result);
1282
* weechat_python_api_config_option_check_cb: callback for checking new value
1287
weechat_python_api_config_option_check_value_cb (void *data,
1288
struct t_config_option *option,
1291
struct t_script_callback *script_callback;
1292
char *python_argv[4], empty_arg[1] = { '\0' };
1295
script_callback = (struct t_script_callback *)data;
1297
if (script_callback && script_callback->function && script_callback->function[0])
1299
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1300
python_argv[1] = script_ptr2str (option);
1301
python_argv[2] = (value) ? (char *)value : empty_arg;
1302
python_argv[3] = NULL;
1304
rc = (int *) weechat_python_exec (script_callback->script,
1305
WEECHAT_SCRIPT_EXEC_INT,
1306
script_callback->function,
1317
free (python_argv[1]);
1326
* weechat_python_api_config_option_change_cb: callback for option changed
1330
weechat_python_api_config_option_change_cb (void *data,
1331
struct t_config_option *option)
1333
struct t_script_callback *script_callback;
1334
char *python_argv[3], empty_arg[1] = { '\0' };
1337
script_callback = (struct t_script_callback *)data;
1339
if (script_callback && script_callback->function && script_callback->function[0])
1341
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1342
python_argv[1] = script_ptr2str (option);
1343
python_argv[2] = NULL;
1345
rc = (int *) weechat_python_exec (script_callback->script,
1346
WEECHAT_SCRIPT_EXEC_INT,
1347
script_callback->function,
1351
free (python_argv[1]);
1359
* weechat_python_api_config_option_delete_cb: callback when option is deleted
1363
weechat_python_api_config_option_delete_cb (void *data,
1364
struct t_config_option *option)
1366
struct t_script_callback *script_callback;
1367
char *python_argv[3], empty_arg[1] = { '\0' };
1370
script_callback = (struct t_script_callback *)data;
1372
if (script_callback && script_callback->function && script_callback->function[0])
1374
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
1375
python_argv[1] = script_ptr2str (option);
1376
python_argv[2] = NULL;
1378
rc = (int *) weechat_python_exec (script_callback->script,
1379
WEECHAT_SCRIPT_EXEC_INT,
1380
script_callback->function,
1384
free (python_argv[1]);
1392
* weechat_python_api_config_new_option: create a new option in section
1396
weechat_python_api_config_new_option (PyObject *self, PyObject *args)
1398
char *config_file, *section, *name, *type, *description, *string_values;
1399
char *default_value, *value, *result;
1400
char *function_check_value, *data_check_value, *function_change;
1401
char *data_change, *function_delete, *data_delete;
1402
int min, max, null_value_allowed;
1405
/* make C compiler happy */
1408
if (!python_current_script)
1410
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_new_option");
1411
PYTHON_RETURN_EMPTY;
1419
string_values = NULL;
1420
default_value = NULL;
1422
function_check_value = NULL;
1423
data_check_value = NULL;
1424
function_change = NULL;
1426
function_delete = NULL;
1429
if (!PyArg_ParseTuple (args, "ssssssiississssss", &config_file, §ion, &name,
1430
&type, &description, &string_values, &min, &max,
1431
&default_value, &value, &null_value_allowed,
1432
&function_check_value, &data_check_value,
1433
&function_change, &data_change, &function_delete,
1436
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_new_option");
1437
PYTHON_RETURN_EMPTY;
1440
result = script_ptr2str (script_api_config_new_option (weechat_python_plugin,
1441
python_current_script,
1442
script_str2ptr (config_file),
1443
script_str2ptr (section),
1453
&weechat_python_api_config_option_check_value_cb,
1454
function_check_value,
1456
&weechat_python_api_config_option_change_cb,
1459
&weechat_python_api_config_option_delete_cb,
1463
PYTHON_RETURN_STRING_FREE(result);
1467
* weechat_python_api_config_search_option: search option in configuration file or section
1471
weechat_python_api_config_search_option (PyObject *self, PyObject *args)
1473
char *config_file, *section, *option_name, *result;
1476
/* make C compiler happy */
1479
if (!python_current_script)
1481
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_search_option");
1482
PYTHON_RETURN_EMPTY;
1489
if (!PyArg_ParseTuple (args, "sss", &config_file, §ion, &option_name))
1491
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_search_option");
1492
PYTHON_RETURN_EMPTY;
1495
result = script_ptr2str (weechat_config_search_option (script_str2ptr (config_file),
1496
script_str2ptr (section),
1499
PYTHON_RETURN_STRING_FREE(result);
1503
* weechat_python_api_config_string_to_boolean: return boolean value of a string
1507
weechat_python_api_config_string_to_boolean (PyObject *self, PyObject *args)
1512
/* make C compiler happy */
1515
if (!python_current_script)
1517
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_string_to_boolean");
1518
PYTHON_RETURN_INT(0);
1523
if (!PyArg_ParseTuple (args, "s", &text))
1525
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_string_to_boolean");
1526
PYTHON_RETURN_INT(0);
1529
value = weechat_config_string_to_boolean (text);
1531
PYTHON_RETURN_INT(value);
1535
* weechat_python_api_config_option_reset: reset an option with default value
1539
weechat_python_api_config_option_reset (PyObject *self, PyObject *args)
1542
int run_callback, rc;
1544
/* make C compiler happy */
1547
if (!python_current_script)
1549
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_reset");
1550
PYTHON_RETURN_INT(0);
1556
if (!PyArg_ParseTuple (args, "si", &option, &run_callback))
1558
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_reset");
1559
PYTHON_RETURN_INT(0);
1562
rc = weechat_config_option_reset (script_str2ptr (option),
1565
PYTHON_RETURN_INT(rc);
1569
* weechat_python_api_config_option_set: set new value for option
1573
weechat_python_api_config_option_set (PyObject *self, PyObject *args)
1575
char *option, *new_value;
1576
int run_callback, rc;
1578
/* make C compiler happy */
1581
if (!python_current_script)
1583
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set");
1584
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
1591
if (!PyArg_ParseTuple (args, "ssi", &option, &new_value, &run_callback))
1593
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set");
1594
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
1597
rc = weechat_config_option_set (script_str2ptr (option),
1601
PYTHON_RETURN_INT(rc);
1605
* weechat_python_api_config_option_set_null: set null (undefined) value for
1610
weechat_python_api_config_option_set_null (PyObject *self, PyObject *args)
1613
int run_callback, rc;
1615
/* make C compiler happy */
1618
if (!python_current_script)
1620
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set_null");
1621
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
1627
if (!PyArg_ParseTuple (args, "si", &option, &run_callback))
1629
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_set_null");
1630
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
1633
rc = weechat_config_option_set_null (script_str2ptr (option),
1636
PYTHON_RETURN_INT(rc);
1640
* weechat_python_api_config_option_unset: unset an option
1644
weechat_python_api_config_option_unset (PyObject *self, PyObject *args)
1649
/* make C compiler happy */
1652
if (!python_current_script)
1654
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_unset");
1655
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
1660
if (!PyArg_ParseTuple (args, "s", &option))
1662
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_unset");
1663
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
1666
rc = weechat_config_option_unset (script_str2ptr (option));
1668
PYTHON_RETURN_INT(rc);
1672
* weechat_python_api_config_option_rename: rename an option
1676
weechat_python_api_config_option_rename (PyObject *self, PyObject *args)
1678
char *option, *new_name;
1680
/* make C compiler happy */
1683
if (!python_current_script)
1685
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_rename");
1686
PYTHON_RETURN_ERROR;
1692
if (!PyArg_ParseTuple (args, "ss", &option, &new_name))
1694
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_rename");
1695
PYTHON_RETURN_ERROR;
1698
weechat_config_option_rename (script_str2ptr (option),
1705
* weechat_python_api_config_option_is_null: return 1 if value of option is null
1709
weechat_python_api_config_option_is_null (PyObject *self, PyObject *args)
1714
/* make C compiler happy */
1717
if (!python_current_script)
1719
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_is_null");
1720
PYTHON_RETURN_INT(1);
1725
if (!PyArg_ParseTuple (args, "s", &option))
1727
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_is_null");
1728
PYTHON_RETURN_INT(1);
1731
value = weechat_config_option_is_null (script_str2ptr (option));
1733
PYTHON_RETURN_INT(value);
1737
* weechat_python_api_config_option_default_is_null: return 1 if default value
1742
weechat_python_api_config_option_default_is_null (PyObject *self, PyObject *args)
1747
/* make C compiler happy */
1750
if (!python_current_script)
1752
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_default_is_null");
1753
PYTHON_RETURN_INT(1);
1758
if (!PyArg_ParseTuple (args, "s", &option))
1760
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_default_is_null");
1761
PYTHON_RETURN_INT(1);
1764
value = weechat_config_option_default_is_null (script_str2ptr (option));
1766
PYTHON_RETURN_INT(value);
1770
* weechat_python_api_config_boolean: return boolean value of option
1774
weechat_python_api_config_boolean (PyObject *self, PyObject *args)
1779
/* make C compiler happy */
1782
if (!python_current_script)
1784
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean");
1785
PYTHON_RETURN_INT(0);
1790
if (!PyArg_ParseTuple (args, "s", &option))
1792
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean");
1793
PYTHON_RETURN_INT(0);
1796
value = weechat_config_boolean (script_str2ptr (option));
1798
PYTHON_RETURN_INT(value);
1802
* weechat_python_api_config_boolean_default: return default boolean value of option
1806
weechat_python_api_config_boolean_default (PyObject *self, PyObject *args)
1811
/* make C compiler happy */
1814
if (!python_current_script)
1816
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean_default");
1817
PYTHON_RETURN_INT(0);
1822
if (!PyArg_ParseTuple (args, "s", &option))
1824
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_boolean_default");
1825
PYTHON_RETURN_INT(0);
1828
value = weechat_config_boolean_default (script_str2ptr (option));
1830
PYTHON_RETURN_INT(value);
1834
* weechat_python_api_config_integer: return integer value of option
1838
weechat_python_api_config_integer (PyObject *self, PyObject *args)
1843
/* make C compiler happy */
1846
if (!python_current_script)
1848
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_integer");
1849
PYTHON_RETURN_INT(0);
1854
if (!PyArg_ParseTuple (args, "s", &option))
1856
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_integer");
1857
PYTHON_RETURN_INT(0);
1860
value = weechat_config_integer (script_str2ptr (option));
1862
PYTHON_RETURN_INT(value);
1866
* weechat_python_api_config_integer_default: return default integer value of option
1870
weechat_python_api_config_integer_default (PyObject *self, PyObject *args)
1875
/* make C compiler happy */
1878
if (!python_current_script)
1880
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_integer_default");
1881
PYTHON_RETURN_INT(0);
1886
if (!PyArg_ParseTuple (args, "s", &option))
1888
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_integer_default");
1889
PYTHON_RETURN_INT(0);
1892
value = weechat_config_integer_default (script_str2ptr (option));
1894
PYTHON_RETURN_INT(value);
1898
* weechat_python_api_config_string: return string value of option
1902
weechat_python_api_config_string (PyObject *self, PyObject *args)
1907
/* make C compiler happy */
1910
if (!python_current_script)
1912
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_string");
1913
PYTHON_RETURN_EMPTY;
1918
if (!PyArg_ParseTuple (args, "s", &option))
1920
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_string");
1921
PYTHON_RETURN_EMPTY;
1924
result = weechat_config_string (script_str2ptr (option));
1926
PYTHON_RETURN_STRING(result);
1930
* weechat_python_api_config_string_default: return default string value of option
1934
weechat_python_api_config_string_default (PyObject *self, PyObject *args)
1939
/* make C compiler happy */
1942
if (!python_current_script)
1944
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_string_default");
1945
PYTHON_RETURN_EMPTY;
1950
if (!PyArg_ParseTuple (args, "s", &option))
1952
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_string_default");
1953
PYTHON_RETURN_EMPTY;
1956
result = weechat_config_string_default (script_str2ptr (option));
1958
PYTHON_RETURN_STRING(result);
1962
* weechat_python_api_config_color: return color value of option
1966
weechat_python_api_config_color (PyObject *self, PyObject *args)
1971
/* make C compiler happy */
1974
if (!python_current_script)
1976
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_color");
1977
PYTHON_RETURN_INT(0);
1982
if (!PyArg_ParseTuple (args, "s", &option))
1984
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_color");
1985
PYTHON_RETURN_INT(0);
1988
result = weechat_config_color (script_str2ptr (option));
1990
PYTHON_RETURN_STRING(result);
1994
* weechat_python_api_config_color_default: return default color value of option
1998
weechat_python_api_config_color_default (PyObject *self, PyObject *args)
2003
/* make C compiler happy */
2006
if (!python_current_script)
2008
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_color_default");
2009
PYTHON_RETURN_INT(0);
2014
if (!PyArg_ParseTuple (args, "s", &option))
2016
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_color_default");
2017
PYTHON_RETURN_INT(0);
2020
result = weechat_config_color_default (script_str2ptr (option));
2022
PYTHON_RETURN_STRING(result);
2026
* weechat_python_api_config_write_option: write an option in configuration file
2030
weechat_python_api_config_write_option (PyObject *self, PyObject *args)
2032
char *config_file, *option;
2034
/* make C compiler happy */
2037
if (!python_current_script)
2039
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_write_option");
2040
PYTHON_RETURN_ERROR;
2046
if (!PyArg_ParseTuple (args, "ss", &config_file, &option))
2048
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_write_option");
2049
PYTHON_RETURN_ERROR;
2052
weechat_config_write_option (script_str2ptr (config_file),
2053
script_str2ptr (option));
2059
* weechat_python_api_config_write_line: write a line in configuration file
2063
weechat_python_api_config_write_line (PyObject *self, PyObject *args)
2065
char *config_file, *option_name, *value;
2067
/* make C compiler happy */
2070
if (!python_current_script)
2072
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_write_line");
2073
PYTHON_RETURN_ERROR;
2080
if (!PyArg_ParseTuple (args, "sss", &config_file, &option_name, &value))
2082
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_write_line");
2083
PYTHON_RETURN_ERROR;
2086
weechat_config_write_line (script_str2ptr (config_file),
2095
* weechat_python_api_config_write: write configuration file
2099
weechat_python_api_config_write (PyObject *self, PyObject *args)
2104
/* make C compiler happy */
2107
if (!python_current_script)
2109
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_write");
2110
PYTHON_RETURN_INT(-1);
2115
if (!PyArg_ParseTuple (args, "s", &config_file))
2117
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_write");
2118
PYTHON_RETURN_INT(-1);
2121
rc = weechat_config_write (script_str2ptr (config_file));
2123
PYTHON_RETURN_INT(rc);
2127
* weechat_python_api_config_read: read configuration file
2131
weechat_python_api_config_read (PyObject *self, PyObject *args)
2136
/* make C compiler happy */
2139
if (!python_current_script)
2141
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_read");
2142
PYTHON_RETURN_INT(-1);
2147
if (!PyArg_ParseTuple (args, "s", &config_file))
2149
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_read");
2150
PYTHON_RETURN_INT(-1);
2153
rc = weechat_config_read (script_str2ptr (config_file));
2155
PYTHON_RETURN_INT(rc);
2159
* weechat_python_api_config_reload: reload configuration file
2163
weechat_python_api_config_reload (PyObject *self, PyObject *args)
2168
/* make C compiler happy */
2171
if (!python_current_script)
2173
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_reload");
2174
PYTHON_RETURN_INT(-1);
2179
if (!PyArg_ParseTuple (args, "s", &config_file))
2181
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_reload");
2182
PYTHON_RETURN_INT(-1);
2185
rc = weechat_config_reload (script_str2ptr (config_file));
2187
PYTHON_RETURN_INT(rc);
2191
* weechat_python_api_config_option_free: free an option in configuration file
2195
weechat_python_api_config_option_free (PyObject *self, PyObject *args)
2199
/* make C compiler happy */
2202
if (!python_current_script)
2204
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_option_free");
2205
PYTHON_RETURN_ERROR;
2210
if (!PyArg_ParseTuple (args, "s", &option))
2212
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_option_free");
2213
PYTHON_RETURN_ERROR;
2216
script_api_config_option_free (weechat_python_plugin,
2217
python_current_script,
2218
script_str2ptr (option));
2224
* weechat_python_api_config_section_free_options: free all options of a section
2225
* in configuration file
2229
weechat_python_api_config_section_free_options (PyObject *self, PyObject *args)
2233
/* make C compiler happy */
2236
if (!python_current_script)
2238
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free_options");
2239
PYTHON_RETURN_ERROR;
2244
if (!PyArg_ParseTuple (args, "s", §ion))
2246
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free_options");
2247
PYTHON_RETURN_ERROR;
2250
script_api_config_section_free_options (weechat_python_plugin,
2251
python_current_script,
2252
script_str2ptr (section));
2258
* weechat_python_api_config_section_free: free section in configuration file
2262
weechat_python_api_config_section_free (PyObject *self, PyObject *args)
2266
/* make C compiler happy */
2269
if (!python_current_script)
2271
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free");
2272
PYTHON_RETURN_ERROR;
2277
if (!PyArg_ParseTuple (args, "s", §ion))
2279
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_section_free");
2280
PYTHON_RETURN_ERROR;
2283
script_api_config_section_free (weechat_python_plugin,
2284
python_current_script,
2285
script_str2ptr (section));
2291
* weechat_python_api_config_free: free configuration file
2295
weechat_python_api_config_free (PyObject *self, PyObject *args)
2299
/* make C compiler happy */
2302
if (!python_current_script)
2304
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_free");
2305
PYTHON_RETURN_ERROR;
2310
if (!PyArg_ParseTuple (args, "s", &config_file))
2312
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_free");
2313
PYTHON_RETURN_ERROR;
2316
script_api_config_free (weechat_python_plugin,
2317
python_current_script,
2318
script_str2ptr (config_file));
2324
* weechat_python_api_config_get: get config option
2328
weechat_python_api_config_get (PyObject *self, PyObject *args)
2330
char *option, *result;
2333
/* make C compiler happy */
2336
if (!python_current_script)
2338
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_get");
2339
PYTHON_RETURN_EMPTY;
2344
if (!PyArg_ParseTuple (args, "s", &option))
2346
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_get");
2347
PYTHON_RETURN_EMPTY;
2350
result = script_ptr2str (weechat_config_get (option));
2352
PYTHON_RETURN_STRING_FREE(result);
2356
* weechat_python_api_config_get_plugin: get value of a plugin option
2360
weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
2365
/* make C compiler happy */
2368
if (!python_current_script)
2370
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_get_plugin");
2371
PYTHON_RETURN_EMPTY;
2376
if (!PyArg_ParseTuple (args, "s", &option))
2378
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_get_plugin");
2379
PYTHON_RETURN_EMPTY;
2382
result = script_api_config_get_plugin (weechat_python_plugin,
2383
python_current_script,
2386
PYTHON_RETURN_STRING(result);
2390
* weechat_python_api_config_is_set_plugin: check if a plugin option is set
2394
weechat_python_api_config_is_set_plugin (PyObject *self, PyObject *args)
2399
/* make C compiler happy */
2402
if (!python_current_script)
2404
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
2405
PYTHON_RETURN_INT(0);
2410
if (!PyArg_ParseTuple (args, "s", &option))
2412
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
2413
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
2416
rc = script_api_config_is_set_plugin (weechat_python_plugin,
2417
python_current_script,
2420
PYTHON_RETURN_INT(rc);
2424
* weechat_python_api_config_set_plugin: set value of a plugin option
2428
weechat_python_api_config_set_plugin (PyObject *self, PyObject *args)
2430
char *option, *value;
2433
/* make C compiler happy */
2436
if (!python_current_script)
2438
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_set_plugin");
2439
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
2445
if (!PyArg_ParseTuple (args, "ss", &option, &value))
2447
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_set_plugin");
2448
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
2451
rc = script_api_config_set_plugin (weechat_python_plugin,
2452
python_current_script,
2456
PYTHON_RETURN_INT(rc);
2460
* weechat_python_api_config_unset_plugin: unset plugin option
2464
weechat_python_api_config_unset_plugin (PyObject *self, PyObject *args)
2469
/* make C compiler happy */
2472
if (!python_current_script)
2474
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_unset_plugin");
2475
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
2480
if (!PyArg_ParseTuple (args, "s", &option))
2482
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_unset_plugin");
2483
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
2486
rc = script_api_config_unset_plugin (weechat_python_plugin,
2487
python_current_script,
2490
PYTHON_RETURN_INT(rc);
2494
* weechat_python_api_prefix: get a prefix, used for display
2498
weechat_python_api_prefix (PyObject *self, PyObject *args)
2503
/* make C compiler happy */
2506
if (!python_current_script)
2508
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "prefix");
2509
PYTHON_RETURN_EMPTY;
2514
if (!PyArg_ParseTuple (args, "s", &prefix))
2516
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prefix");
2517
PYTHON_RETURN_EMPTY;
2520
result = weechat_prefix (prefix);
2522
PYTHON_RETURN_STRING(result);
2526
* weechat_python_api_color: get a color code, used for display
2530
weechat_python_api_color (PyObject *self, PyObject *args)
2535
/* make C compiler happy */
2538
if (!python_current_script)
2540
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "color");
2541
PYTHON_RETURN_EMPTY;
2546
if (!PyArg_ParseTuple (args, "s", &color))
2548
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "color");
2549
PYTHON_RETURN_EMPTY;
2552
result = weechat_color (color);
2554
PYTHON_RETURN_STRING(result);
2558
* weechat_python_api_prnt: print message in a buffer
2562
weechat_python_api_prnt (PyObject *self, PyObject *args)
2564
char *buffer, *message;
2566
/* make C compiler happy */
2572
if (!PyArg_ParseTuple (args, "ss", &buffer, &message))
2574
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prnt");
2575
PYTHON_RETURN_ERROR;
2578
script_api_printf (weechat_python_plugin,
2579
python_current_script,
2580
script_str2ptr (buffer),
2587
* weechat_python_api_prnt_date_tags: print message in a buffer with optional
2592
weechat_python_api_prnt_date_tags (PyObject *self, PyObject *args)
2594
char *buffer, *tags, *message;
2597
/* make C compiler happy */
2600
if (!python_current_script)
2602
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "prnt_date_tags");
2603
PYTHON_RETURN_ERROR;
2611
if (!PyArg_ParseTuple (args, "siss", &buffer, &date, &tags, &message))
2613
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prnt_date_tags");
2614
PYTHON_RETURN_ERROR;
2617
script_api_printf_date_tags (weechat_python_plugin,
2618
python_current_script,
2619
script_str2ptr (buffer),
2628
* weechat_python_api_prnt_y: print message in a buffer with free content
2632
weechat_python_api_prnt_y (PyObject *self, PyObject *args)
2634
char *buffer, *message;
2637
/* make C compiler happy */
2640
if (!python_current_script)
2642
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "prnt_y");
2643
PYTHON_RETURN_ERROR;
2650
if (!PyArg_ParseTuple (args, "sis", &buffer, &y, &message))
2652
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "prnt_y");
2653
PYTHON_RETURN_ERROR;
2656
script_api_printf_y (weechat_python_plugin,
2657
python_current_script,
2658
script_str2ptr (buffer),
2666
* weechat_python_api_log_print: print message in WeeChat log file
2670
weechat_python_api_log_print (PyObject *self, PyObject *args)
2674
/* make C compiler happy */
2677
if (!python_current_script)
2679
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "log_print");
2680
PYTHON_RETURN_ERROR;
2685
if (!PyArg_ParseTuple (args, "s", &message))
2687
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "log_print");
2688
PYTHON_RETURN_ERROR;
2691
script_api_log_printf (weechat_python_plugin,
2692
python_current_script,
2699
* weechat_python_api_hook_command_cb: callback for command hooked
2703
weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
2704
int argc, char **argv, char **argv_eol)
2706
struct t_script_callback *script_callback;
2707
char *python_argv[4], empty_arg[1] = { '\0' };
2710
/* make C compiler happy */
2713
script_callback = (struct t_script_callback *)data;
2715
if (script_callback && script_callback->function && script_callback->function[0])
2717
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
2718
python_argv[1] = script_ptr2str (buffer);
2719
python_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
2720
python_argv[3] = NULL;
2722
rc = (int *) weechat_python_exec (script_callback->script,
2723
WEECHAT_SCRIPT_EXEC_INT,
2724
script_callback->function,
2728
ret = WEECHAT_RC_ERROR;
2735
free (python_argv[1]);
2740
return WEECHAT_RC_ERROR;
2744
* weechat_python_api_hook_command: hook a command
2748
weechat_python_api_hook_command (PyObject *self, PyObject *args)
2750
char *command, *description, *arguments, *args_description, *completion;
2751
char *function, *data, *result;
2754
/* make C compiler happy */
2757
if (!python_current_script)
2759
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_command");
2760
PYTHON_RETURN_EMPTY;
2766
args_description = NULL;
2771
if (!PyArg_ParseTuple (args, "sssssss", &command, &description, &arguments,
2772
&args_description, &completion, &function, &data))
2774
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_command");
2775
PYTHON_RETURN_EMPTY;
2778
result = script_ptr2str (script_api_hook_command (weechat_python_plugin,
2779
python_current_script,
2785
&weechat_python_api_hook_command_cb,
2789
PYTHON_RETURN_STRING_FREE(result);
2793
* weechat_python_api_hook_command_run_cb: callback for command_run hooked
2797
weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
2798
const char *command)
2800
struct t_script_callback *script_callback;
2801
char *python_argv[4], empty_arg[1] = { '\0' };
2804
script_callback = (struct t_script_callback *)data;
2806
if (script_callback && script_callback->function && script_callback->function[0])
2808
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
2809
python_argv[1] = script_ptr2str (buffer);
2810
python_argv[2] = (command) ? (char *)command : empty_arg;
2811
python_argv[3] = NULL;
2813
rc = (int *) weechat_python_exec (script_callback->script,
2814
WEECHAT_SCRIPT_EXEC_INT,
2815
script_callback->function,
2819
ret = WEECHAT_RC_ERROR;
2826
free (python_argv[1]);
2831
return WEECHAT_RC_ERROR;
2835
* weechat_python_api_hook_command_run: hook a command_run
2839
weechat_python_api_hook_command_run (PyObject *self, PyObject *args)
2841
char *command, *function, *data, *result;
2844
/* make C compiler happy */
2847
if (!python_current_script)
2849
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_command_run");
2850
PYTHON_RETURN_EMPTY;
2857
if (!PyArg_ParseTuple (args, "sss", &command, &function, &data))
2859
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_command_run");
2860
PYTHON_RETURN_EMPTY;
2863
result = script_ptr2str (script_api_hook_command_run (weechat_python_plugin,
2864
python_current_script,
2866
&weechat_python_api_hook_command_run_cb,
2870
PYTHON_RETURN_STRING_FREE(result);
2874
* weechat_python_api_hook_timer_cb: callback for timer hooked
2878
weechat_python_api_hook_timer_cb (void *data, int remaining_calls)
2880
struct t_script_callback *script_callback;
2881
char *python_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' };
2884
script_callback = (struct t_script_callback *)data;
2886
if (script_callback && script_callback->function && script_callback->function[0])
2888
snprintf (str_remaining_calls, sizeof (str_remaining_calls),
2889
"%d", remaining_calls);
2891
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
2892
python_argv[1] = str_remaining_calls;
2893
python_argv[2] = NULL;
2895
rc = (int *) weechat_python_exec (script_callback->script,
2896
WEECHAT_SCRIPT_EXEC_INT,
2897
script_callback->function,
2901
ret = WEECHAT_RC_ERROR;
2911
return WEECHAT_RC_ERROR;
2915
* weechat_python_api_hook_timer: hook a timer
2919
weechat_python_api_hook_timer (PyObject *self, PyObject *args)
2921
int interval, align_second, max_calls;
2922
char *function, *data, *result;
2925
/* make C compiler happy */
2928
if (!python_current_script)
2930
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_timer");
2931
PYTHON_RETURN_EMPTY;
2940
if (!PyArg_ParseTuple (args, "iiiss", &interval, &align_second, &max_calls,
2943
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_timer");
2944
PYTHON_RETURN_EMPTY;
2947
result = script_ptr2str (script_api_hook_timer (weechat_python_plugin,
2948
python_current_script,
2952
&weechat_python_api_hook_timer_cb,
2956
PYTHON_RETURN_STRING_FREE(result);
2960
* weechat_python_api_hook_fd_cb: callback for fd hooked
2964
weechat_python_api_hook_fd_cb (void *data, int fd)
2966
struct t_script_callback *script_callback;
2967
char *python_argv[3], str_fd[32], empty_arg[1] = { '\0' };
2970
script_callback = (struct t_script_callback *)data;
2972
if (script_callback && script_callback->function && script_callback->function[0])
2974
snprintf (str_fd, sizeof (str_fd), "%d", fd);
2976
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
2977
python_argv[1] = str_fd;
2978
python_argv[2] = NULL;
2980
rc = (int *) weechat_python_exec (script_callback->script,
2981
WEECHAT_SCRIPT_EXEC_INT,
2982
script_callback->function,
2986
ret = WEECHAT_RC_ERROR;
2996
return WEECHAT_RC_ERROR;
3000
* weechat_python_api_hook_fd: hook a fd
3004
weechat_python_api_hook_fd (PyObject *self, PyObject *args)
3006
int fd, read, write, exception;
3007
char *function, *data, *result;
3010
/* make C compiler happy */
3013
if (!python_current_script)
3015
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_fd");
3016
PYTHON_RETURN_EMPTY;
3026
if (!PyArg_ParseTuple (args, "iiiiss", &fd, &read, &write, &exception,
3029
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_fd");
3030
PYTHON_RETURN_EMPTY;
3033
result = script_ptr2str (script_api_hook_fd (weechat_python_plugin,
3034
python_current_script,
3039
&weechat_python_api_hook_fd_cb,
3043
PYTHON_RETURN_STRING_FREE(result);
3047
* weechat_python_api_hook_process_cb: callback for process hooked
3051
weechat_python_api_hook_process_cb (void *data,
3052
const char *command, int return_code,
3053
const char *out, const char *err)
3055
struct t_script_callback *script_callback;
3056
char *python_argv[6], str_rc[32], empty_arg[1] = { '\0' };
3059
script_callback = (struct t_script_callback *)data;
3061
if (script_callback && script_callback->function && script_callback->function[0])
3063
snprintf (str_rc, sizeof (str_rc), "%d", return_code);
3065
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3066
python_argv[1] = (command) ? (char *)command : empty_arg;
3067
python_argv[2] = str_rc;
3068
python_argv[3] = (out) ? (char *)out : empty_arg;
3069
python_argv[4] = (err) ? (char *)err : empty_arg;
3070
python_argv[5] = NULL;
3072
rc = (int *) weechat_python_exec (script_callback->script,
3073
WEECHAT_SCRIPT_EXEC_INT,
3074
script_callback->function,
3078
ret = WEECHAT_RC_ERROR;
3088
return WEECHAT_RC_ERROR;
3092
* weechat_python_api_hook_process: hook a process
3096
weechat_python_api_hook_process (PyObject *self, PyObject *args)
3098
char *command, *function, *data, *result;
3102
/* make C compiler happy */
3105
if (!python_current_script)
3107
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_process");
3108
PYTHON_RETURN_EMPTY;
3116
if (!PyArg_ParseTuple (args, "siss", &command, &timeout, &function, &data))
3118
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_process");
3119
PYTHON_RETURN_EMPTY;
3122
result = script_ptr2str (script_api_hook_process (weechat_python_plugin,
3123
python_current_script,
3126
&weechat_python_api_hook_process_cb,
3130
PYTHON_RETURN_STRING_FREE(result);
3134
* weechat_python_api_hook_connect_cb: callback for connect hooked
3138
weechat_python_api_hook_connect_cb (void *data, int status,
3139
const char *error, const char *ip_address)
3141
struct t_script_callback *script_callback;
3142
char *python_argv[5], str_status[32], empty_arg[1] = { '\0' };
3145
script_callback = (struct t_script_callback *)data;
3147
if (script_callback && script_callback->function && script_callback->function[0])
3149
snprintf (str_status, sizeof (str_status), "%d", status);
3151
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3152
python_argv[1] = str_status;
3153
python_argv[2] = (ip_address) ? (char *)ip_address : empty_arg;
3154
python_argv[3] = (error) ? (char *)error : empty_arg;
3155
python_argv[4] = NULL;
3157
rc = (int *) weechat_python_exec (script_callback->script,
3158
WEECHAT_SCRIPT_EXEC_INT,
3159
script_callback->function,
3163
ret = WEECHAT_RC_ERROR;
3173
return WEECHAT_RC_ERROR;
3177
* weechat_python_api_hook_connect: hook a connection
3181
weechat_python_api_hook_connect (PyObject *self, PyObject *args)
3183
char *proxy, *address, *local_hostname, *function, *data, *result;
3184
int port, sock, ipv6;
3187
/* make C compiler happy */
3190
if (!python_current_script)
3192
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_connect");
3193
PYTHON_RETURN_EMPTY;
3201
local_hostname = NULL;
3205
if (!PyArg_ParseTuple (args, "ssiiisss", &proxy, &address, &port, &sock,
3206
&ipv6, &local_hostname, &function, &data))
3208
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_connect");
3209
PYTHON_RETURN_EMPTY;
3212
result = script_ptr2str (script_api_hook_connect (weechat_python_plugin,
3213
python_current_script,
3219
NULL, /* gnutls session */
3221
&weechat_python_api_hook_connect_cb,
3225
PYTHON_RETURN_STRING_FREE(result);
3229
* weechat_python_api_hook_print_cb: callback for print hooked
3233
weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
3235
int tags_count, const char **tags,
3236
int displayed, int highlight,
3237
const char *prefix, const char *message)
3239
struct t_script_callback *script_callback;
3240
char *python_argv[9], empty_arg[1] = { '\0' };
3241
static char timebuffer[64];
3244
/* make C compiler happy */
3247
script_callback = (struct t_script_callback *)data;
3249
if (script_callback && script_callback->function && script_callback->function[0])
3251
snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", (long int)date);
3253
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3254
python_argv[1] = script_ptr2str (buffer);
3255
python_argv[2] = timebuffer;
3256
python_argv[3] = weechat_string_build_with_split_string (tags, ",");
3257
if (!python_argv[3])
3258
python_argv[3] = strdup ("");
3259
python_argv[4] = (displayed) ? strdup ("1") : strdup ("0");
3260
python_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
3261
python_argv[6] = (prefix) ? (char *)prefix : empty_arg;
3262
python_argv[7] = (message) ? (char *)message : empty_arg;
3263
python_argv[8] = NULL;
3265
rc = (int *) weechat_python_exec (script_callback->script,
3266
WEECHAT_SCRIPT_EXEC_INT,
3267
script_callback->function,
3271
ret = WEECHAT_RC_ERROR;
3278
free (python_argv[1]);
3280
free (python_argv[3]);
3282
free (python_argv[4]);
3284
free (python_argv[5]);
3289
return WEECHAT_RC_ERROR;
3293
* weechat_python_api_hook_print: hook a print
3297
weechat_python_api_hook_print (PyObject *self, PyObject *args)
3299
char *buffer, *tags, *message, *function, *data, *result;
3303
/* make C compiler happy */
3306
if (!python_current_script)
3308
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_print");
3309
PYTHON_RETURN_EMPTY;
3319
if (!PyArg_ParseTuple (args, "sssiss", &buffer, &tags, &message,
3320
&strip_colors, &function, &data))
3322
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_print");
3323
PYTHON_RETURN_EMPTY;
3326
result = script_ptr2str(script_api_hook_print (weechat_python_plugin,
3327
python_current_script,
3328
script_str2ptr (buffer),
3332
&weechat_python_api_hook_print_cb,
3336
PYTHON_RETURN_STRING_FREE(result);
3340
* weechat_python_api_hook_signal_cb: callback for signal hooked
3344
weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *type_data,
3347
struct t_script_callback *script_callback;
3348
char *python_argv[4], empty_arg[1] = { '\0' };
3349
static char value_str[64];
3350
int *rc, ret, free_needed;
3352
script_callback = (struct t_script_callback *)data;
3354
if (script_callback && script_callback->function && script_callback->function[0])
3356
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3357
python_argv[1] = (signal) ? (char *)signal : empty_arg;
3359
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
3361
python_argv[2] = (signal_data) ? (char *)signal_data : empty_arg;
3363
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
3365
snprintf (value_str, sizeof (value_str) - 1,
3366
"%d", *((int *)signal_data));
3367
python_argv[2] = value_str;
3369
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
3371
python_argv[2] = script_ptr2str (signal_data);
3375
python_argv[2] = empty_arg;
3376
python_argv[3] = NULL;
3378
rc = (int *) weechat_python_exec (script_callback->script,
3379
WEECHAT_SCRIPT_EXEC_INT,
3380
script_callback->function,
3384
ret = WEECHAT_RC_ERROR;
3390
if (free_needed && python_argv[2])
3391
free (python_argv[2]);
3396
return WEECHAT_RC_ERROR;
3400
* weechat_python_api_hook_signal: hook a signal
3404
weechat_python_api_hook_signal (PyObject *self, PyObject *args)
3406
char *signal, *function, *data, *result;
3409
/* make C compiler happy */
3412
if (!python_current_script)
3414
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal");
3415
PYTHON_RETURN_EMPTY;
3422
if (!PyArg_ParseTuple (args, "sss", &signal, &function, &data))
3424
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal");
3425
PYTHON_RETURN_EMPTY;
3428
result = script_ptr2str (script_api_hook_signal (weechat_python_plugin,
3429
python_current_script,
3431
&weechat_python_api_hook_signal_cb,
3435
PYTHON_RETURN_STRING_FREE(result);
3439
* weechat_python_api_hook_signal_send: send a signal
3443
weechat_python_api_hook_signal_send (PyObject *self, PyObject *args)
3445
char *signal, *type_data, *signal_data, *error;
3448
/* make C compiler happy */
3451
if (!python_current_script)
3453
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal_send");
3454
PYTHON_RETURN_ERROR;
3461
if (!PyArg_ParseTuple (args, "sss", &signal, &type_data, &signal_data))
3463
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_signal_send");
3464
PYTHON_RETURN_ERROR;
3467
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
3469
weechat_hook_signal_send (signal, type_data, signal_data);
3472
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
3475
number = (int)strtol (signal_data, &error, 10);
3476
if (error && !error[0])
3478
weechat_hook_signal_send (signal, type_data, &number);
3482
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
3484
weechat_hook_signal_send (signal, type_data,
3485
script_str2ptr (signal_data));
3489
PYTHON_RETURN_ERROR;
3493
* weechat_python_api_hook_config_cb: callback for config option hooked
3497
weechat_python_api_hook_config_cb (void *data, const char *option, const char *value)
3499
struct t_script_callback *script_callback;
3500
char *python_argv[4], empty_arg[1] = { '\0' };
3503
script_callback = (struct t_script_callback *)data;
3505
if (script_callback && script_callback->function && script_callback->function[0])
3507
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3508
python_argv[1] = (option) ? (char *)option : empty_arg;
3509
python_argv[2] = (value) ? (char *)value : empty_arg;
3510
python_argv[3] = NULL;
3512
rc = (int *) weechat_python_exec (script_callback->script,
3513
WEECHAT_SCRIPT_EXEC_INT,
3514
script_callback->function,
3518
ret = WEECHAT_RC_ERROR;
3528
return WEECHAT_RC_ERROR;
3532
* weechat_python_api_hook_config: hook a config option
3536
weechat_python_api_hook_config (PyObject *self, PyObject *args)
3538
char *option, *function, *data, *result;
3541
/* make C compiler happy */
3544
if (!python_current_script)
3546
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_config");
3547
PYTHON_RETURN_EMPTY;
3554
if (!PyArg_ParseTuple (args, "sss", &option, &function, &data))
3556
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_config");
3557
PYTHON_RETURN_EMPTY;
3560
result = script_ptr2str(script_api_hook_config (weechat_python_plugin,
3561
python_current_script,
3563
&weechat_python_api_hook_config_cb,
3567
PYTHON_RETURN_STRING_FREE(result);
3571
* weechat_python_api_hook_completion_cb: callback for completion hooked
3575
weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
3576
struct t_gui_buffer *buffer,
3577
struct t_gui_completion *completion)
3579
struct t_script_callback *script_callback;
3580
char *python_argv[5], empty_arg[1] = { '\0' };
3583
script_callback = (struct t_script_callback *)data;
3585
if (script_callback && script_callback->function && script_callback->function[0])
3587
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3588
python_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
3589
python_argv[2] = script_ptr2str (buffer);
3590
python_argv[3] = script_ptr2str (completion);
3591
python_argv[4] = NULL;
3593
rc = (int *) weechat_python_exec (script_callback->script,
3594
WEECHAT_SCRIPT_EXEC_INT,
3595
script_callback->function,
3599
ret = WEECHAT_RC_ERROR;
3606
free (python_argv[2]);
3608
free (python_argv[3]);
3613
return WEECHAT_RC_ERROR;
3617
* weechat_python_api_hook_completion: hook a completion
3621
weechat_python_api_hook_completion (PyObject *self, PyObject *args)
3623
char *completion, *description, *function, *data, *result;
3626
/* make C compiler happy */
3629
if (!python_current_script)
3631
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion");
3632
PYTHON_RETURN_EMPTY;
3640
if (!PyArg_ParseTuple (args, "ssss", &completion, &description, &function,
3643
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion");
3644
PYTHON_RETURN_EMPTY;
3647
result = script_ptr2str(script_api_hook_completion (weechat_python_plugin,
3648
python_current_script,
3651
&weechat_python_api_hook_completion_cb,
3655
PYTHON_RETURN_STRING_FREE(result);
3659
* weechat_python_api_hook_completion_list_add: add a word to list for a completion
3663
weechat_python_api_hook_completion_list_add (PyObject *self, PyObject *args)
3665
char *completion, *word, *where;
3666
int nick_completion;
3668
/* make C compiler happy */
3671
if (!python_current_script)
3673
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion_list_add");
3674
PYTHON_RETURN_ERROR;
3679
nick_completion = 0;
3682
if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion,
3685
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_completion_list_add");
3686
PYTHON_RETURN_ERROR;
3689
weechat_hook_completion_list_add (script_str2ptr (completion),
3698
* weechat_python_api_hook_modifier_cb: callback for modifier hooked
3702
weechat_python_api_hook_modifier_cb (void *data, const char *modifier,
3703
const char *modifier_data, const char *string)
3705
struct t_script_callback *script_callback;
3706
char *python_argv[5], empty_arg[1] = { '\0' };
3708
script_callback = (struct t_script_callback *)data;
3710
if (script_callback && script_callback->function && script_callback->function[0])
3712
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3713
python_argv[1] = (modifier) ? (char *)modifier : empty_arg;
3714
python_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
3715
python_argv[3] = (string) ? (char *)string : empty_arg;
3716
python_argv[4] = NULL;
3718
return (char *)weechat_python_exec (script_callback->script,
3719
WEECHAT_SCRIPT_EXEC_STRING,
3720
script_callback->function,
3728
* weechat_python_api_hook_modifier: hook a modifier
3732
weechat_python_api_hook_modifier (PyObject *self, PyObject *args)
3734
char *modifier, *function, *data, *result;
3737
/* make C compiler happy */
3740
if (!python_current_script)
3742
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier");
3743
PYTHON_RETURN_EMPTY;
3750
if (!PyArg_ParseTuple (args, "sss", &modifier, &function, &data))
3752
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier");
3753
PYTHON_RETURN_EMPTY;
3756
result = script_ptr2str(script_api_hook_modifier (weechat_python_plugin,
3757
python_current_script,
3759
&weechat_python_api_hook_modifier_cb,
3763
PYTHON_RETURN_STRING_FREE(result);
3767
* weechat_python_api_hook_modifier_exec: execute a modifier hook
3771
weechat_python_api_hook_modifier_exec (PyObject *self, PyObject *args)
3773
char *modifier, *modifier_data, *string, *result;
3776
/* make C compiler happy */
3779
if (!python_current_script)
3781
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier_exec");
3782
PYTHON_RETURN_EMPTY;
3786
modifier_data = NULL;
3789
if (!PyArg_ParseTuple (args, "sss", &modifier, &modifier_data, &string))
3791
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_modifier_exec");
3792
PYTHON_RETURN_EMPTY;
3795
result = weechat_hook_modifier_exec (modifier, modifier_data, string);
3797
PYTHON_RETURN_STRING_FREE(result);
3801
* weechat_python_api_hook_info_cb: callback for info hooked
3805
weechat_python_api_hook_info_cb (void *data, const char *info_name,
3806
const char *arguments)
3808
struct t_script_callback *script_callback;
3809
char *python_argv[4], empty_arg[1] = { '\0' };
3811
script_callback = (struct t_script_callback *)data;
3813
if (script_callback && script_callback->function && script_callback->function[0])
3815
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3816
python_argv[1] = (info_name) ? (char *)info_name : empty_arg;
3817
python_argv[2] = (arguments) ? (char *)arguments : empty_arg;
3818
python_argv[3] = NULL;
3820
return (const char *)weechat_python_exec (script_callback->script,
3821
WEECHAT_SCRIPT_EXEC_STRING,
3822
script_callback->function,
3830
* weechat_python_api_hook_info: hook an info
3834
weechat_python_api_hook_info (PyObject *self, PyObject *args)
3836
char *info_name, *description, *function, *data, *result;
3839
/* make C compiler happy */
3842
if (!python_current_script)
3844
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_info");
3845
PYTHON_RETURN_EMPTY;
3853
if (!PyArg_ParseTuple (args, "ssss", &info_name, &description, &function,
3856
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_info");
3857
PYTHON_RETURN_EMPTY;
3860
result = script_ptr2str(script_api_hook_info (weechat_python_plugin,
3861
python_current_script,
3864
&weechat_python_api_hook_info_cb,
3868
PYTHON_RETURN_STRING_FREE(result);
3872
* weechat_python_api_hook_infolist_cb: callback for infolist hooked
3876
weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
3877
void *pointer, const char *arguments)
3879
struct t_script_callback *script_callback;
3880
char *python_argv[5], empty_arg[1] = { '\0' };
3881
struct t_infolist *result;
3883
script_callback = (struct t_script_callback *)data;
3885
if (script_callback && script_callback->function && script_callback->function[0])
3887
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
3888
python_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
3889
python_argv[2] = script_ptr2str (pointer);
3890
python_argv[3] = (arguments) ? (char *)arguments : empty_arg;
3891
python_argv[4] = NULL;
3893
result = (struct t_infolist *)weechat_python_exec (script_callback->script,
3894
WEECHAT_SCRIPT_EXEC_STRING,
3895
script_callback->function,
3899
free (python_argv[2]);
3908
* weechat_python_api_hook_infolist: hook an infolist
3912
weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
3914
char *infolist_name, *description, *function, *data, *result;
3917
/* make C compiler happy */
3920
if (!python_current_script)
3922
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_infolist");
3923
PYTHON_RETURN_EMPTY;
3926
infolist_name = NULL;
3931
if (!PyArg_ParseTuple (args, "ssss", &infolist_name, &description,
3934
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_infolist");
3935
PYTHON_RETURN_EMPTY;
3938
result = script_ptr2str(script_api_hook_infolist (weechat_python_plugin,
3939
python_current_script,
3942
&weechat_python_api_hook_infolist_cb,
3946
PYTHON_RETURN_STRING_FREE(result);
3950
* weechat_python_api_unhook: unhook something
3954
weechat_python_api_unhook (PyObject *self, PyObject *args)
3958
/* make C compiler happy */
3961
if (!python_current_script)
3963
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "unhook");
3964
PYTHON_RETURN_ERROR;
3969
if (!PyArg_ParseTuple (args, "s", &hook))
3971
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "unhook");
3972
PYTHON_RETURN_ERROR;
3975
script_api_unhook (weechat_python_plugin,
3976
python_current_script,
3977
script_str2ptr (hook));
3983
* weechat_python_api_unhook_all: unhook all for script
3987
weechat_python_api_unhook_all (PyObject *self, PyObject *args)
3989
/* make C compiler happy */
3993
if (!python_current_script)
3995
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "unhook_all");
3996
PYTHON_RETURN_ERROR;
3999
script_api_unhook_all (python_current_script);
4005
* weechat_python_api_buffer_input_data_cb: callback for input data in a buffer
4009
weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
4010
const char *input_data)
4012
struct t_script_callback *script_callback;
4013
char *python_argv[4], empty_arg[1] = { '\0' };
4016
script_callback = (struct t_script_callback *)data;
4018
if (script_callback && script_callback->function && script_callback->function[0])
4020
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
4021
python_argv[1] = script_ptr2str (buffer);
4022
python_argv[2] = (input_data) ? (char *)input_data : empty_arg;
4023
python_argv[3] = NULL;
4025
rc = (int *) weechat_python_exec (script_callback->script,
4026
WEECHAT_SCRIPT_EXEC_INT,
4027
script_callback->function,
4030
ret = WEECHAT_RC_ERROR;
4037
free (python_argv[1]);
4042
return WEECHAT_RC_ERROR;
4046
* weechat_python_api_buffer_close_cb: callback for buffer closed
4050
weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
4052
struct t_script_callback *script_callback;
4053
char *python_argv[3], empty_arg[1] = { '\0' };
4056
script_callback = (struct t_script_callback *)data;
4058
if (script_callback && script_callback->function && script_callback->function[0])
4060
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
4061
python_argv[1] = script_ptr2str (buffer);
4062
python_argv[2] = NULL;
4064
rc = (int *) weechat_python_exec (script_callback->script,
4065
WEECHAT_SCRIPT_EXEC_INT,
4066
script_callback->function,
4069
ret = WEECHAT_RC_ERROR;
4076
free (python_argv[1]);
4081
return WEECHAT_RC_ERROR;
4085
* weechat_python_api_buffer_new: create a new buffer
4089
weechat_python_api_buffer_new (PyObject *self, PyObject *args)
4091
char *name, *function_input, *data_input, *function_close, *data_close;
4095
/* make C compiler happy */
4098
if (!python_current_script)
4100
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_new");
4101
PYTHON_RETURN_EMPTY;
4105
function_input = NULL;
4107
function_close = NULL;
4110
if (!PyArg_ParseTuple (args, "sssss", &name, &function_input, &data_input,
4111
&function_close, &data_close))
4113
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_new");
4114
PYTHON_RETURN_EMPTY;
4117
result = script_ptr2str (script_api_buffer_new (weechat_python_plugin,
4118
python_current_script,
4120
&weechat_python_api_buffer_input_data_cb,
4123
&weechat_python_api_buffer_close_cb,
4127
PYTHON_RETURN_STRING_FREE(result);
4131
* weechat_python_api_buffer_search: search a buffer
4135
weechat_python_api_buffer_search (PyObject *self, PyObject *args)
4137
char *plugin, *name;
4141
/* make C compiler happy */
4144
if (!python_current_script)
4146
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search");
4147
PYTHON_RETURN_EMPTY;
4153
if (!PyArg_ParseTuple (args, "ss", &plugin, &name))
4155
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search");
4156
PYTHON_RETURN_EMPTY;
4159
result = script_ptr2str (weechat_buffer_search (plugin, name));
4161
PYTHON_RETURN_STRING_FREE(result);
4165
* weechat_python_api_buffer_search_main: search main buffer (WeeChat core buffer)
4169
weechat_python_api_buffer_search_main (PyObject *self, PyObject *args)
4174
/* make C compiler happy */
4178
if (!python_current_script)
4180
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search_main");
4181
PYTHON_RETURN_EMPTY;
4184
result = script_ptr2str (weechat_buffer_search_main ());
4186
PYTHON_RETURN_STRING_FREE(result);
4190
* weechat_python_api_current_buffer: get current buffer
4194
weechat_python_api_current_buffer (PyObject *self, PyObject *args)
4199
/* make C compiler happy */
4203
if (!python_current_script)
4205
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "current_buffer");
4206
PYTHON_RETURN_EMPTY;
4209
result = script_ptr2str (weechat_current_buffer ());
4211
PYTHON_RETURN_STRING_FREE(result);
4215
* weechat_python_api_buffer_clear: clear a buffer
4219
weechat_python_api_buffer_clear (PyObject *self, PyObject *args)
4223
/* make C compiler happy */
4226
if (!python_current_script)
4228
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_clear");
4229
PYTHON_RETURN_ERROR;
4234
if (!PyArg_ParseTuple (args, "s", &buffer))
4236
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_clear");
4237
PYTHON_RETURN_ERROR;
4240
weechat_buffer_clear (script_str2ptr (buffer));
4246
* weechat_python_api_buffer_close: close a buffer
4250
weechat_python_api_buffer_close (PyObject *self, PyObject *args)
4254
/* make C compiler happy */
4257
if (!python_current_script)
4259
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_close");
4260
PYTHON_RETURN_ERROR;
4265
if (!PyArg_ParseTuple (args, "s", &buffer))
4267
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_close");
4268
PYTHON_RETURN_ERROR;
4271
script_api_buffer_close (weechat_python_plugin,
4272
python_current_script,
4273
script_str2ptr (buffer));
4279
* weechat_python_api_buffer_merge: merge a buffer to another buffer
4283
weechat_python_api_buffer_merge (PyObject *self, PyObject *args)
4285
char *buffer, *target_buffer;
4287
/* make C compiler happy */
4290
if (!python_current_script)
4292
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_merge");
4293
PYTHON_RETURN_ERROR;
4297
target_buffer = NULL;
4299
if (!PyArg_ParseTuple (args, "ss", &buffer, &target_buffer))
4301
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_merge");
4302
PYTHON_RETURN_ERROR;
4305
weechat_buffer_merge (script_str2ptr (buffer),
4306
script_str2ptr (target_buffer));
4312
* weechat_python_api_buffer_unmerge: unmerge a buffer from group of merged
4317
weechat_python_api_buffer_unmerge (PyObject *self, PyObject *args)
4322
/* make C compiler happy */
4325
if (!python_current_script)
4327
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_unmerge");
4328
PYTHON_RETURN_ERROR;
4334
if (!PyArg_ParseTuple (args, "si", &buffer, &number))
4336
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_unmerge");
4337
PYTHON_RETURN_ERROR;
4340
weechat_buffer_unmerge (script_str2ptr (buffer), number);
4346
* weechat_python_api_buffer_get_integer get a buffer property as integer
4350
weechat_python_api_buffer_get_integer (PyObject *self, PyObject *args)
4352
char *buffer, *property;
4355
/* make C compiler happy */
4358
if (!python_current_script)
4360
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_integer");
4361
PYTHON_RETURN_INT(-1);
4367
if (!PyArg_ParseTuple (args, "ss", &buffer, &property))
4369
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_integer");
4370
PYTHON_RETURN_INT(-1);
4373
value = weechat_buffer_get_integer (script_str2ptr (buffer), property);
4375
PYTHON_RETURN_INT(value);
4379
* weechat_python_api_buffer_get_string: get a buffer property as string
4383
weechat_python_api_buffer_get_string (PyObject *self, PyObject *args)
4385
char *buffer, *property;
4388
/* make C compiler happy */
4391
if (!python_current_script)
4393
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_string");
4394
PYTHON_RETURN_ERROR;
4400
if (!PyArg_ParseTuple (args, "ss", &buffer, &property))
4402
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_string");
4403
PYTHON_RETURN_EMPTY;
4406
result = weechat_buffer_get_string (script_str2ptr (buffer), property);
4408
PYTHON_RETURN_STRING(result);
4412
* weechat_python_api_buffer_get_pointer: get a buffer property as pointer
4416
weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args)
4418
char *buffer, *property, *result;
4421
/* make C compiler happy */
4424
if (!python_current_script)
4426
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_pointer");
4427
PYTHON_RETURN_EMPTY;
4433
if (!PyArg_ParseTuple (args, "ss", &buffer, &property))
4435
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_get_pointer");
4436
PYTHON_RETURN_EMPTY;
4439
result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer),
4442
PYTHON_RETURN_STRING_FREE(result);
4446
* weechat_python_api_buffer_set: set a buffer property
4450
weechat_python_api_buffer_set (PyObject *self, PyObject *args)
4452
char *buffer, *property, *value;
4454
/* make C compiler happy */
4457
if (!python_current_script)
4459
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_set");
4460
PYTHON_RETURN_ERROR;
4467
if (!PyArg_ParseTuple (args, "sss", &buffer, &property, &value))
4469
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_set");
4470
PYTHON_RETURN_ERROR;
4473
weechat_buffer_set (script_str2ptr (buffer),
4481
* weechat_python_api_current_window: get current window
4485
weechat_python_api_current_window (PyObject *self, PyObject *args)
4490
/* make C compiler happy */
4494
if (!python_current_script)
4496
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "current_window");
4497
PYTHON_RETURN_EMPTY;
4500
result = script_ptr2str (weechat_current_window ());
4502
PYTHON_RETURN_STRING_FREE(result);
4506
* weechat_python_api_window_get_integer get a window property as integer
4510
weechat_python_api_window_get_integer (PyObject *self, PyObject *args)
4512
char *window, *property;
4515
/* make C compiler happy */
4518
if (!python_current_script)
4520
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_get_integer");
4521
PYTHON_RETURN_INT(-1);
4527
if (!PyArg_ParseTuple (args, "ss", &window, &property))
4529
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_get_integer");
4530
PYTHON_RETURN_INT(-1);
4533
value = weechat_window_get_integer (script_str2ptr (window), property);
4535
PYTHON_RETURN_INT(value);
4539
* weechat_python_api_window_get_string: get a window property as string
4543
weechat_python_api_window_get_string (PyObject *self, PyObject *args)
4545
char *window, *property;
4548
/* make C compiler happy */
4551
if (!python_current_script)
4553
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_get_string");
4554
PYTHON_RETURN_EMPTY;
4560
if (!PyArg_ParseTuple (args, "ss", &window, &property))
4562
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_get_string");
4563
PYTHON_RETURN_EMPTY;
4566
result = weechat_window_get_string (script_str2ptr (window), property);
4568
PYTHON_RETURN_STRING(result);
4572
* weechat_python_api_window_get_pointer: get a window property as pointer
4576
weechat_python_api_window_get_pointer (PyObject *self, PyObject *args)
4578
char *window, *property, *result;
4581
/* make C compiler happy */
4584
if (!python_current_script)
4586
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_get_pointer");
4587
PYTHON_RETURN_EMPTY;
4593
if (!PyArg_ParseTuple (args, "ss", &window, &property))
4595
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_get_pointer");
4596
PYTHON_RETURN_EMPTY;
4599
result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (window),
4602
PYTHON_RETURN_STRING_FREE(result);
4606
* weechat_python_api_window_set_title: set window title
4610
weechat_python_api_window_set_title (PyObject *self, PyObject *args)
4614
/* make C compiler happy */
4617
if (!python_current_script)
4619
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_set_title");
4620
PYTHON_RETURN_ERROR;
4625
if (!PyArg_ParseTuple (args, "s", &title))
4627
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_set_title");
4628
PYTHON_RETURN_ERROR;
4631
weechat_window_set_title (title);
4637
* weechat_python_api_nicklist_add_group: add a group in nicklist
4641
weechat_python_api_nicklist_add_group (PyObject *self, PyObject *args)
4643
char *buffer, *parent_group, *name, *color, *result;
4647
/* make C compiler happy */
4650
if (!python_current_script)
4652
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_group");
4653
PYTHON_RETURN_EMPTY;
4657
parent_group = NULL;
4662
if (!PyArg_ParseTuple (args, "ssssi", &buffer, &parent_group, &name,
4665
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_group");
4666
PYTHON_RETURN_EMPTY;
4669
result = script_ptr2str (weechat_nicklist_add_group (script_str2ptr (buffer),
4670
script_str2ptr (parent_group),
4675
PYTHON_RETURN_STRING_FREE(result);
4679
* weechat_python_api_nicklist_search_group: search a group in nicklist
4683
weechat_python_api_nicklist_search_group (PyObject *self, PyObject *args)
4685
char *buffer, *from_group, *name, *result;
4688
/* make C compiler happy */
4691
if (!python_current_script)
4693
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_group");
4694
PYTHON_RETURN_EMPTY;
4701
if (!PyArg_ParseTuple (args, "sss", &buffer, &from_group, &name))
4703
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_group");
4704
PYTHON_RETURN_EMPTY;
4707
result = script_ptr2str (weechat_nicklist_search_group (script_str2ptr (buffer),
4708
script_str2ptr (from_group),
4711
PYTHON_RETURN_STRING_FREE(result);
4715
* weechat_python_api_nicklist_add_nick: add a nick in nicklist
4719
weechat_python_api_nicklist_add_nick (PyObject *self, PyObject *args)
4721
char *buffer, *group, *name, *color, *prefix, *prefix_color, *result;
4725
/* make C compiler happy */
4728
if (!python_current_script)
4730
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_nick");
4731
PYTHON_RETURN_EMPTY;
4739
prefix_color = NULL;
4742
if (!PyArg_ParseTuple (args, "ssssssi", &buffer, &group, &name, &color,
4743
&prefix, &prefix_color, &visible))
4745
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_add_nick");
4746
PYTHON_RETURN_EMPTY;
4749
result = script_ptr2str (weechat_nicklist_add_nick (script_str2ptr (buffer),
4750
script_str2ptr (group),
4757
PYTHON_RETURN_STRING_FREE(result);
4761
* weechat_python_api_nicklist_search_nick: search a nick in nicklist
4765
weechat_python_api_nicklist_search_nick (PyObject *self, PyObject *args)
4767
char *buffer, *from_group, *name, *result;
4770
/* make C compiler happy */
4773
if (!python_current_script)
4775
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_nick");
4776
PYTHON_RETURN_EMPTY;
4783
if (!PyArg_ParseTuple (args, "sss", &buffer, &from_group, &name))
4785
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_search_nick");
4786
PYTHON_RETURN_EMPTY;
4789
result = script_ptr2str (weechat_nicklist_search_nick (script_str2ptr (buffer),
4790
script_str2ptr (from_group),
4793
PYTHON_RETURN_STRING_FREE(result);
4797
* weechat_python_api_nicklist_remove_group: remove a group from nicklist
4801
weechat_python_api_nicklist_remove_group (PyObject *self, PyObject *args)
4803
char *buffer, *group;
4805
/* make C compiler happy */
4808
if (!python_current_script)
4810
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_group");
4811
PYTHON_RETURN_ERROR;
4817
if (!PyArg_ParseTuple (args, "ss", &buffer, &group))
4819
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_group");
4820
PYTHON_RETURN_ERROR;
4823
weechat_nicklist_remove_group (script_str2ptr (buffer),
4824
script_str2ptr (group));
4830
* weechat_python_api_nicklist_remove_nick: remove a nick from nicklist
4834
weechat_python_api_nicklist_remove_nick (PyObject *self, PyObject *args)
4836
char *buffer, *nick;
4838
/* make C compiler happy */
4841
if (!python_current_script)
4843
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_nick");
4844
PYTHON_RETURN_ERROR;
4850
if (!PyArg_ParseTuple (args, "ss", &buffer, &nick))
4852
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_nick");
4853
PYTHON_RETURN_ERROR;
4856
weechat_nicklist_remove_group (script_str2ptr (buffer),
4857
script_str2ptr (nick));
4863
* weechat_python_api_nicklist_remove_all: remove all groups/nicks from nicklist
4867
weechat_python_api_nicklist_remove_all (PyObject *self, PyObject *args)
4871
/* make C compiler happy */
4874
if (!python_current_script)
4876
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_all");
4877
PYTHON_RETURN_ERROR;
4882
if (!PyArg_ParseTuple (args, "s", &buffer))
4884
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "nicklist_remove_all");
4885
PYTHON_RETURN_ERROR;
4888
weechat_nicklist_remove_all (script_str2ptr (buffer));
4894
* weechat_python_api_bar_item_search: search a bar item
4898
weechat_python_api_bar_item_search (PyObject *self, PyObject *args)
4900
char *name, *result;
4903
/* make C compiler happy */
4906
if (!python_current_script)
4908
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_search");
4909
PYTHON_RETURN_EMPTY;
4914
if (!PyArg_ParseTuple (args, "s", &name))
4916
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_search");
4917
PYTHON_RETURN_EMPTY;
4920
result = script_ptr2str (weechat_bar_item_search (name));
4922
PYTHON_RETURN_STRING_FREE(result);
4926
* weechat_python_api_bar_item_build_cb: callback for building bar item
4930
weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
4931
struct t_gui_window *window)
4933
struct t_script_callback *script_callback;
4934
char *python_argv[4], empty_arg[1] = { '\0' }, *ret;
4936
script_callback = (struct t_script_callback *)data;
4938
if (script_callback && script_callback->function && script_callback->function[0])
4940
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
4941
python_argv[1] = script_ptr2str (item);
4942
python_argv[2] = script_ptr2str (window);
4943
python_argv[3] = NULL;
4945
ret = (char *)weechat_python_exec (script_callback->script,
4946
WEECHAT_SCRIPT_EXEC_STRING,
4947
script_callback->function,
4951
free (python_argv[1]);
4953
free (python_argv[2]);
4962
* weechat_python_api_bar_item_new: add a new bar item
4966
weechat_python_api_bar_item_new (PyObject *self, PyObject *args)
4968
char *name, *function, *data, *result;
4971
/* make C compiler happy */
4974
if (!python_current_script)
4976
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_new");
4977
PYTHON_RETURN_EMPTY;
4984
if (!PyArg_ParseTuple (args, "sss", &name, &function, &data))
4986
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_new");
4987
PYTHON_RETURN_EMPTY;
4990
result = script_ptr2str (script_api_bar_item_new (weechat_python_plugin,
4991
python_current_script,
4993
&weechat_python_api_bar_item_build_cb,
4997
PYTHON_RETURN_STRING_FREE(result);
5001
* weechat_python_api_bar_item_update: update a bar item on screen
5005
weechat_python_api_bar_item_update (PyObject *self, PyObject *args)
5009
/* make C compiler happy */
5012
if (!python_current_script)
5014
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_update");
5015
PYTHON_RETURN_ERROR;
5020
if (!PyArg_ParseTuple (args, "s", &name))
5022
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_update");
5023
PYTHON_RETURN_ERROR;
5026
weechat_bar_item_update (name);
5032
* weechat_python_api_bar_item_remove: remove a bar item
5036
weechat_python_api_bar_item_remove (PyObject *self, PyObject *args)
5040
/* make C compiler happy */
5043
if (!python_current_script)
5045
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_remove");
5046
PYTHON_RETURN_ERROR;
5051
if (!PyArg_ParseTuple (args, "s", &item))
5053
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item_remove");
5054
PYTHON_RETURN_ERROR;
5057
script_api_bar_item_remove (weechat_python_plugin,
5058
python_current_script,
5059
script_str2ptr (item));
5065
* weechat_python_api_bar_search: search a bar
5069
weechat_python_api_bar_search (PyObject *self, PyObject *args)
5071
char *name, *result;
5074
/* make C compiler happy */
5077
if (!python_current_script)
5079
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_search");
5080
PYTHON_RETURN_EMPTY;
5085
if (!PyArg_ParseTuple (args, "s", &name))
5087
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_search");
5088
PYTHON_RETURN_EMPTY;
5091
result = script_ptr2str (weechat_bar_search (name));
5093
PYTHON_RETURN_STRING_FREE(result);
5097
* weechat_python_api_bar_new: add a new bar
5101
weechat_python_api_bar_new (PyObject *self, PyObject *args)
5103
char *name, *hidden, *priority, *type, *conditions, *position;
5104
char *filling_top_bottom, *filling_left_right, *size, *size_max;
5105
char *color_fg, *color_delim, *color_bg, *separator, *items, *result;
5108
/* make C compiler happy */
5111
if (!python_current_script)
5113
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_new");
5114
PYTHON_RETURN_EMPTY;
5123
filling_top_bottom = NULL;
5124
filling_left_right = NULL;
5133
if (!PyArg_ParseTuple (args, "sssssssssssssss", &name, &hidden, &priority,
5134
&type, &conditions, &position, &filling_top_bottom,
5135
&filling_left_right, &size, &size_max, &color_fg,
5136
&color_delim, &color_bg, &separator, &items))
5138
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_new");
5139
PYTHON_RETURN_EMPTY;
5142
result = script_ptr2str (weechat_bar_new (name,
5158
PYTHON_RETURN_STRING_FREE(result);
5162
* weechat_python_api_bar_set: set a bar property
5166
weechat_python_api_bar_set (PyObject *self, PyObject *args)
5168
char *bar, *property, *value;
5170
/* make C compiler happy */
5173
if (!python_current_script)
5175
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_set");
5176
PYTHON_RETURN_ERROR;
5183
if (!PyArg_ParseTuple (args, "sss", &bar, &property, &value))
5185
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_set");
5186
PYTHON_RETURN_ERROR;
5189
weechat_buffer_set (script_str2ptr (bar),
5197
* weechat_python_api_bar_update: update a bar on screen
5201
weechat_python_api_bar_update (PyObject *self, PyObject *args)
5205
/* make C compiler happy */
5208
if (!python_current_script)
5210
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_item");
5211
PYTHON_RETURN_ERROR;
5216
if (!PyArg_ParseTuple (args, "s", &name))
5218
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_item");
5219
PYTHON_RETURN_ERROR;
5222
weechat_bar_update (name);
5228
* weechat_python_api_bar_remove: remove a bar
5232
weechat_python_api_bar_remove (PyObject *self, PyObject *args)
5236
/* make C compiler happy */
5239
if (!python_current_script)
5241
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "bar_remove");
5242
PYTHON_RETURN_ERROR;
5247
if (!PyArg_ParseTuple (args, "s", &bar))
5249
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "bar_remove");
5250
PYTHON_RETURN_ERROR;
5253
weechat_bar_remove (script_str2ptr (bar));
5259
* weechat_python_api_command: send command to server
5263
weechat_python_api_command (PyObject *self, PyObject *args)
5265
char *buffer, *command;
5267
/* make C compiler happy */
5270
if (!python_current_script)
5272
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "command");
5273
PYTHON_RETURN_ERROR;
5279
if (!PyArg_ParseTuple (args, "ss", &buffer, &command))
5281
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "command");
5282
PYTHON_RETURN_ERROR;
5285
script_api_command (weechat_python_plugin,
5286
python_current_script,
5287
script_str2ptr (buffer),
5294
* weechat_python_api_info_get: get info about WeeChat
5298
weechat_python_api_info_get (PyObject *self, PyObject *args)
5300
char *info_name, *arguments;
5303
/* make C compiler happy */
5306
if (!python_current_script)
5308
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "info_get");
5309
PYTHON_RETURN_EMPTY;
5314
if (!PyArg_ParseTuple (args, "ss", &info_name, &arguments))
5316
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "info_get");
5317
PYTHON_RETURN_EMPTY;
5320
result = weechat_info_get (info_name, arguments);
5322
PYTHON_RETURN_STRING(result);
5326
* weechat_python_api_infolist_new: create new infolist
5330
weechat_python_api_infolist_new (PyObject *self, PyObject *args)
5335
/* make C compiler happy */
5339
if (!python_current_script)
5341
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new");
5342
PYTHON_RETURN_EMPTY;
5345
result = script_ptr2str (weechat_infolist_new ());
5347
PYTHON_RETURN_STRING_FREE(result);
5351
* weechat_python_api_infolist_new_var_integer: create new integer variable in
5356
weechat_python_api_infolist_new_var_integer (PyObject *self, PyObject *args)
5358
char *infolist, *name, *result;
5362
/* make C compiler happy */
5365
if (!python_current_script)
5367
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_integer");
5368
PYTHON_RETURN_EMPTY;
5375
if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value))
5377
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_integer");
5378
PYTHON_RETURN_EMPTY;
5381
result = script_ptr2str (weechat_infolist_new_var_integer (script_str2ptr (infolist),
5385
PYTHON_RETURN_STRING_FREE(result);
5389
* weechat_python_api_infolist_new_var_string: create new string variable in
5394
weechat_python_api_infolist_new_var_string (PyObject *self, PyObject *args)
5396
char *infolist, *name, *value, *result;
5399
/* make C compiler happy */
5402
if (!python_current_script)
5404
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_string");
5405
PYTHON_RETURN_EMPTY;
5412
if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value))
5414
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_string");
5415
PYTHON_RETURN_EMPTY;
5418
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (infolist),
5422
PYTHON_RETURN_STRING_FREE(result);
5426
* weechat_python_api_infolist_new_var_pointer: create new pointer variable in
5431
weechat_python_api_infolist_new_var_pointer (PyObject *self, PyObject *args)
5433
char *infolist, *name, *value, *result;
5436
/* make C compiler happy */
5439
if (!python_current_script)
5441
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer");
5442
PYTHON_RETURN_EMPTY;
5449
if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value))
5451
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_pointer");
5452
PYTHON_RETURN_EMPTY;
5455
result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (infolist),
5457
script_str2ptr (value)));
5459
PYTHON_RETURN_STRING_FREE(result);
5463
* weechat_python_api_infolist_new_var_time: create new time variable in
5468
weechat_python_api_infolist_new_var_time (PyObject *self, PyObject *args)
5470
char *infolist, *name, *result;
5474
/* make C compiler happy */
5477
if (!python_current_script)
5479
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_time");
5480
PYTHON_RETURN_EMPTY;
5487
if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value))
5489
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_new_var_time");
5490
PYTHON_RETURN_EMPTY;
5493
result = script_ptr2str (weechat_infolist_new_var_time (script_str2ptr (infolist),
5497
PYTHON_RETURN_STRING_FREE(result);
5501
* weechat_python_api_infolist_get: get list with infos
5505
weechat_python_api_infolist_get (PyObject *self, PyObject *args)
5507
char *name, *pointer, *arguments, *result;
5510
/* make C compiler happy */
5513
if (!python_current_script)
5515
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_get");
5516
PYTHON_RETURN_EMPTY;
5523
if (!PyArg_ParseTuple (args, "sss", &name, &pointer, &arguments))
5525
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_get");
5526
PYTHON_RETURN_EMPTY;
5529
result = script_ptr2str (weechat_infolist_get (name,
5530
script_str2ptr (pointer),
5533
PYTHON_RETURN_STRING_FREE(result);
5537
* weechat_python_api_infolist_next: move item pointer to next item in infolist
5541
weechat_python_api_infolist_next (PyObject *self, PyObject *args)
5546
/* make C compiler happy */
5549
if (!python_current_script)
5551
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_next");
5552
PYTHON_RETURN_INT(0);
5557
if (!PyArg_ParseTuple (args, "s", &infolist))
5559
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_next");
5560
PYTHON_RETURN_INT(0);
5563
value = weechat_infolist_next (script_str2ptr (infolist));
5565
PYTHON_RETURN_INT(value);
5569
* weechat_python_api_infolist_prev: move item pointer to previous item in infolist
5573
weechat_python_api_infolist_prev (PyObject *self, PyObject *args)
5578
/* make C compiler happy */
5581
if (!python_current_script)
5583
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_prev");
5584
PYTHON_RETURN_INT(0);
5589
if (!PyArg_ParseTuple (args, "s", &infolist))
5591
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_prev");
5592
PYTHON_RETURN_INT(0);
5595
value = weechat_infolist_prev (script_str2ptr (infolist));
5597
PYTHON_RETURN_INT(value);
5601
* weechat_python_api_infolist_fields: get list of fields for current item of infolist
5605
weechat_python_api_infolist_fields (PyObject *self, PyObject *args)
5610
/* make C compiler happy */
5613
if (!python_current_script)
5615
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_fields");
5616
PYTHON_RETURN_EMPTY;
5621
if (!PyArg_ParseTuple (args, "s", &infolist))
5623
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_fields");
5624
PYTHON_RETURN_EMPTY;
5627
result = weechat_infolist_fields (script_str2ptr (infolist));
5629
PYTHON_RETURN_STRING(result);
5633
* weechat_python_api_infolist_integer: get integer value of a variable in infolist
5637
weechat_python_api_infolist_integer (PyObject *self, PyObject *args)
5639
char *infolist, *variable;
5642
/* make C compiler happy */
5645
if (!python_current_script)
5647
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_integer");
5648
PYTHON_RETURN_INT(0);
5654
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
5656
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_integer");
5657
PYTHON_RETURN_INT(0);
5660
value = weechat_infolist_integer (script_str2ptr (infolist),
5663
PYTHON_RETURN_INT(value);
5667
* weechat_python_api_infolist_string: get string value of a variable in infolist
5671
weechat_python_api_infolist_string (PyObject *self, PyObject *args)
5673
char *infolist, *variable;
5676
/* make C compiler happy */
5679
if (!python_current_script)
5681
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_string");
5682
PYTHON_RETURN_EMPTY;
5688
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
5690
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_string");
5691
PYTHON_RETURN_EMPTY;
5694
result = weechat_infolist_string (script_str2ptr (infolist),
5697
PYTHON_RETURN_STRING(result);
5701
* weechat_python_api_infolist_pointer: get pointer value of a variable in infolist
5705
weechat_python_api_infolist_pointer (PyObject *self, PyObject *args)
5707
char *infolist, *variable, *result;
5710
/* make C compiler happy */
5713
if (!python_current_script)
5715
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_pointer");
5716
PYTHON_RETURN_EMPTY;
5722
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
5724
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_pointer");
5725
PYTHON_RETURN_EMPTY;
5728
result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist),
5731
PYTHON_RETURN_STRING_FREE(result);
5735
* weechat_python_api_infolist_time: get time value of a variable in infolist
5739
weechat_python_api_infolist_time (PyObject *self, PyObject *args)
5741
char *infolist, *variable, timebuffer[64], *result;
5745
/* make C compiler happy */
5748
if (!python_current_script)
5750
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_time");
5751
PYTHON_RETURN_EMPTY;
5757
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
5759
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_time");
5760
PYTHON_RETURN_EMPTY;
5763
time = weechat_infolist_time (script_str2ptr (infolist),
5765
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
5766
result = strdup (timebuffer);
5768
PYTHON_RETURN_STRING_FREE(result);
5772
* weechat_python_api_infolist_free: free infolist
5776
weechat_python_api_infolist_free (PyObject *self, PyObject *args)
5780
/* make C compiler happy */
5783
if (!python_current_script)
5785
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "infolist_free");
5786
PYTHON_RETURN_ERROR;
5791
if (!PyArg_ParseTuple (args, "s", &infolist))
5793
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "infolist_free");
5794
PYTHON_RETURN_ERROR;
5797
weechat_infolist_free (script_str2ptr (infolist));
5803
* weechat_python_api_upgrade_new: create an upgrade file
5807
weechat_python_api_upgrade_new (PyObject *self, PyObject *args)
5809
char *filename, *result;
5813
/* make C compiler happy */
5816
if (!python_current_script)
5818
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_new");
5819
PYTHON_RETURN_EMPTY;
5825
if (!PyArg_ParseTuple (args, "si", &filename, &write))
5827
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_new");
5828
PYTHON_RETURN_EMPTY;
5831
result = script_ptr2str (weechat_upgrade_new (filename, write));
5833
PYTHON_RETURN_STRING_FREE(result);
5837
* weechat_python_api_upgrade_write_object: write object in upgrade file
5841
weechat_python_api_upgrade_write_object (PyObject *self, PyObject *args)
5843
char *upgrade_file, *infolist;
5846
/* make C compiler happy */
5849
if (!python_current_script)
5851
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_write_object");
5852
PYTHON_RETURN_INT(0);
5855
upgrade_file = NULL;
5859
if (!PyArg_ParseTuple (args, "sis", &upgrade_file, &object_id, &infolist))
5861
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_write_object");
5862
PYTHON_RETURN_INT(0);
5865
rc = weechat_upgrade_write_object (script_str2ptr (upgrade_file),
5867
script_str2ptr (infolist));
5869
PYTHON_RETURN_INT(rc);
5873
* weechat_python_api_upgrade_read_cb: callback for reading object in upgrade file
5877
weechat_python_api_upgrade_read_cb (void *data,
5878
struct t_upgrade_file *upgrade_file,
5880
struct t_infolist *infolist)
5882
struct t_script_callback *script_callback;
5883
char *python_argv[5], empty_arg[1] = { '\0' }, str_object_id[32];
5886
script_callback = (struct t_script_callback *)data;
5888
if (script_callback && script_callback->function && script_callback->function[0])
5890
snprintf (str_object_id, sizeof (str_object_id), "%d", object_id);
5892
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
5893
python_argv[1] = script_ptr2str (upgrade_file);
5894
python_argv[2] = str_object_id;
5895
python_argv[3] = script_ptr2str (infolist);
5896
python_argv[4] = NULL;
5898
rc = (int *) weechat_python_exec (script_callback->script,
5899
WEECHAT_SCRIPT_EXEC_INT,
5900
script_callback->function,
5904
ret = WEECHAT_RC_ERROR;
5911
free (python_argv[1]);
5913
free (python_argv[3]);
5918
return WEECHAT_RC_ERROR;
5922
* weechat_python_api_upgrade_read: read upgrade file
5926
weechat_python_api_upgrade_read (PyObject *self, PyObject *args)
5928
char *upgrade_file, *function, *data;
5931
/* make C compiler happy */
5934
if (!python_current_script)
5936
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_read");
5937
PYTHON_RETURN_INT(0);
5940
upgrade_file = NULL;
5944
if (!PyArg_ParseTuple (args, "sss", &upgrade_file, &function, &data))
5946
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_read");
5947
PYTHON_RETURN_INT(0);
5950
rc = script_api_upgrade_read (weechat_python_plugin,
5951
python_current_script,
5952
script_str2ptr (upgrade_file),
5953
&weechat_python_api_upgrade_read_cb,
5957
PYTHON_RETURN_INT(rc);
5961
* weechat_python_api_upgrade_close: close upgrade file
5965
weechat_python_api_upgrade_close (PyObject *self, PyObject *args)
5969
/* make C compiler happy */
5972
if (!python_current_script)
5974
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_close");
5975
PYTHON_RETURN_ERROR;
5978
upgrade_file = NULL;
5980
if (!PyArg_ParseTuple (args, "s", &upgrade_file))
5982
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "upgrade_close");
5983
PYTHON_RETURN_ERROR;
5986
weechat_upgrade_close (script_str2ptr (upgrade_file));
5992
* Python subroutines
5995
PyMethodDef weechat_python_funcs[] =
5997
{ "register", &weechat_python_api_register, METH_VARARGS, "" },
5998
{ "plugin_get_name", &weechat_python_api_plugin_get_name, METH_VARARGS, "" },
5999
{ "charset_set", &weechat_python_api_charset_set, METH_VARARGS, "" },
6000
{ "iconv_to_internal", &weechat_python_api_iconv_to_internal, METH_VARARGS, "" },
6001
{ "iconv_from_internal", &weechat_python_api_iconv_from_internal, METH_VARARGS, "" },
6002
{ "gettext", &weechat_python_api_gettext, METH_VARARGS, "" },
6003
{ "ngettext", &weechat_python_api_ngettext, METH_VARARGS, "" },
6004
{ "string_remove_color", &weechat_python_api_string_remove_color, METH_VARARGS, "" },
6005
{ "mkdir_home", &weechat_python_api_mkdir_home, METH_VARARGS, "" },
6006
{ "mkdir", &weechat_python_api_mkdir, METH_VARARGS, "" },
6007
{ "mkdir_parents", &weechat_python_api_mkdir_parents, METH_VARARGS, "" },
6008
{ "list_new", &weechat_python_api_list_new, METH_VARARGS, "" },
6009
{ "list_add", &weechat_python_api_list_add, METH_VARARGS, "" },
6010
{ "list_search", &weechat_python_api_list_search, METH_VARARGS, "" },
6011
{ "list_casesearch", &weechat_python_api_list_casesearch, METH_VARARGS, "" },
6012
{ "list_get", &weechat_python_api_list_get, METH_VARARGS, "" },
6013
{ "list_set", &weechat_python_api_list_set, METH_VARARGS, "" },
6014
{ "list_next", &weechat_python_api_list_next, METH_VARARGS, "" },
6015
{ "list_prev", &weechat_python_api_list_prev, METH_VARARGS, "" },
6016
{ "list_string", &weechat_python_api_list_string, METH_VARARGS, "" },
6017
{ "list_size", &weechat_python_api_list_size, METH_VARARGS, "" },
6018
{ "list_remove", &weechat_python_api_list_remove, METH_VARARGS, "" },
6019
{ "list_remove_all", &weechat_python_api_list_remove_all, METH_VARARGS, "" },
6020
{ "list_free", &weechat_python_api_list_free, METH_VARARGS, "" },
6021
{ "config_new", &weechat_python_api_config_new, METH_VARARGS, "" },
6022
{ "config_new_section", &weechat_python_api_config_new_section, METH_VARARGS, "" },
6023
{ "config_search_section", &weechat_python_api_config_search_section, METH_VARARGS, "" },
6024
{ "config_new_option", &weechat_python_api_config_new_option, METH_VARARGS, "" },
6025
{ "config_search_option", &weechat_python_api_config_search_option, METH_VARARGS, "" },
6026
{ "config_string_to_boolean", &weechat_python_api_config_string_to_boolean, METH_VARARGS, "" },
6027
{ "config_option_reset", &weechat_python_api_config_option_reset, METH_VARARGS, "" },
6028
{ "config_option_set", &weechat_python_api_config_option_set, METH_VARARGS, "" },
6029
{ "config_option_set_null", &weechat_python_api_config_option_set_null, METH_VARARGS, "" },
6030
{ "config_option_unset", &weechat_python_api_config_option_unset, METH_VARARGS, "" },
6031
{ "config_option_rename", &weechat_python_api_config_option_rename, METH_VARARGS, "" },
6032
{ "config_option_is_null", &weechat_python_api_config_option_is_null, METH_VARARGS, "" },
6033
{ "config_option_default_is_null", &weechat_python_api_config_option_default_is_null, METH_VARARGS, "" },
6034
{ "config_boolean", &weechat_python_api_config_boolean, METH_VARARGS, "" },
6035
{ "config_boolean_default", &weechat_python_api_config_boolean_default, METH_VARARGS, "" },
6036
{ "config_integer", &weechat_python_api_config_integer, METH_VARARGS, "" },
6037
{ "config_integer_default", &weechat_python_api_config_integer_default, METH_VARARGS, "" },
6038
{ "config_string", &weechat_python_api_config_string, METH_VARARGS, "" },
6039
{ "config_string_default", &weechat_python_api_config_string_default, METH_VARARGS, "" },
6040
{ "config_color", &weechat_python_api_config_color, METH_VARARGS, "" },
6041
{ "config_color_default", &weechat_python_api_config_color_default, METH_VARARGS, "" },
6042
{ "config_write_option", &weechat_python_api_config_write_option, METH_VARARGS, "" },
6043
{ "config_write_line", &weechat_python_api_config_write_line, METH_VARARGS, "" },
6044
{ "config_write", &weechat_python_api_config_write, METH_VARARGS, "" },
6045
{ "config_read", &weechat_python_api_config_read, METH_VARARGS, "" },
6046
{ "config_reload", &weechat_python_api_config_reload, METH_VARARGS, "" },
6047
{ "config_option_free", &weechat_python_api_config_option_free, METH_VARARGS, "" },
6048
{ "config_section_free_options", &weechat_python_api_config_section_free_options, METH_VARARGS, "" },
6049
{ "config_section_free", &weechat_python_api_config_section_free, METH_VARARGS, "" },
6050
{ "config_free", &weechat_python_api_config_free, METH_VARARGS, "" },
6051
{ "config_get", &weechat_python_api_config_get, METH_VARARGS, "" },
6052
{ "config_get_plugin", &weechat_python_api_config_get_plugin, METH_VARARGS, "" },
6053
{ "config_is_set_plugin", &weechat_python_api_config_is_set_plugin, METH_VARARGS, "" },
6054
{ "config_set_plugin", &weechat_python_api_config_set_plugin, METH_VARARGS, "" },
6055
{ "config_unset_plugin", &weechat_python_api_config_unset_plugin, METH_VARARGS, "" },
6056
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
6057
{ "color", &weechat_python_api_color, METH_VARARGS, "" },
6058
{ "prnt", &weechat_python_api_prnt, METH_VARARGS, "" },
6059
{ "prnt_date_tags", &weechat_python_api_prnt_date_tags, METH_VARARGS, "" },
6060
{ "prnt_y", &weechat_python_api_prnt_y, METH_VARARGS, "" },
6061
{ "log_print", &weechat_python_api_log_print, METH_VARARGS, "" },
6062
{ "hook_command", &weechat_python_api_hook_command, METH_VARARGS, "" },
6063
{ "hook_command_run", &weechat_python_api_hook_command_run, METH_VARARGS, "" },
6064
{ "hook_timer", &weechat_python_api_hook_timer, METH_VARARGS, "" },
6065
{ "hook_fd", &weechat_python_api_hook_fd, METH_VARARGS, "" },
6066
{ "hook_process", &weechat_python_api_hook_process, METH_VARARGS, "" },
6067
{ "hook_connect", &weechat_python_api_hook_connect, METH_VARARGS, "" },
6068
{ "hook_print", &weechat_python_api_hook_print, METH_VARARGS, "" },
6069
{ "hook_signal", &weechat_python_api_hook_signal, METH_VARARGS, "" },
6070
{ "hook_signal_send", &weechat_python_api_hook_signal_send, METH_VARARGS, "" },
6071
{ "hook_config", &weechat_python_api_hook_config, METH_VARARGS, "" },
6072
{ "hook_completion", &weechat_python_api_hook_completion, METH_VARARGS, "" },
6073
{ "hook_completion_list_add", &weechat_python_api_hook_completion_list_add, METH_VARARGS, "" },
6074
{ "hook_modifier", &weechat_python_api_hook_modifier, METH_VARARGS, "" },
6075
{ "hook_modifier_exec", &weechat_python_api_hook_modifier_exec, METH_VARARGS, "" },
6076
{ "hook_info", &weechat_python_api_hook_info, METH_VARARGS, "" },
6077
{ "hook_infolist", &weechat_python_api_hook_infolist, METH_VARARGS, "" },
6078
{ "unhook", &weechat_python_api_unhook, METH_VARARGS, "" },
6079
{ "unhook_all", &weechat_python_api_unhook_all, METH_VARARGS, "" },
6080
{ "buffer_new", &weechat_python_api_buffer_new, METH_VARARGS, "" },
6081
{ "buffer_search", &weechat_python_api_buffer_search, METH_VARARGS, "" },
6082
{ "buffer_search_main", &weechat_python_api_buffer_search_main, METH_VARARGS, "" },
6083
{ "current_buffer", &weechat_python_api_current_buffer, METH_VARARGS, "" },
6084
{ "buffer_clear", &weechat_python_api_buffer_clear, METH_VARARGS, "" },
6085
{ "buffer_close", &weechat_python_api_buffer_close, METH_VARARGS, "" },
6086
{ "buffer_merge", &weechat_python_api_buffer_merge, METH_VARARGS, "" },
6087
{ "buffer_unmerge", &weechat_python_api_buffer_unmerge, METH_VARARGS, "" },
6088
{ "buffer_get_integer", &weechat_python_api_buffer_get_integer, METH_VARARGS, "" },
6089
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
6090
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
6091
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
6092
{ "current_window", &weechat_python_api_current_window, METH_VARARGS, "" },
6093
{ "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" },
6094
{ "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" },
6095
{ "window_get_pointer", &weechat_python_api_window_get_pointer, METH_VARARGS, "" },
6096
{ "window_set_title", &weechat_python_api_window_set_title, METH_VARARGS, "" },
6097
{ "nicklist_add_group", &weechat_python_api_nicklist_add_group, METH_VARARGS, "" },
6098
{ "nicklist_search_group", &weechat_python_api_nicklist_search_group, METH_VARARGS, "" },
6099
{ "nicklist_add_nick", &weechat_python_api_nicklist_add_nick, METH_VARARGS, "" },
6100
{ "nicklist_search_nick", &weechat_python_api_nicklist_search_nick, METH_VARARGS, "" },
6101
{ "nicklist_remove_group", &weechat_python_api_nicklist_remove_group, METH_VARARGS, "" },
6102
{ "nicklist_remove_nick", &weechat_python_api_nicklist_remove_nick, METH_VARARGS, "" },
6103
{ "nicklist_remove_all", &weechat_python_api_nicklist_remove_all, METH_VARARGS, "" },
6104
{ "bar_item_search", &weechat_python_api_bar_item_search, METH_VARARGS, "" },
6105
{ "bar_item_new", &weechat_python_api_bar_item_new, METH_VARARGS, "" },
6106
{ "bar_item_update", &weechat_python_api_bar_item_update, METH_VARARGS, "" },
6107
{ "bar_item_remove", &weechat_python_api_bar_item_remove, METH_VARARGS, "" },
6108
{ "bar_search", &weechat_python_api_bar_search, METH_VARARGS, "" },
6109
{ "bar_new", &weechat_python_api_bar_new, METH_VARARGS, "" },
6110
{ "bar_set", &weechat_python_api_bar_set, METH_VARARGS, "" },
6111
{ "bar_update", &weechat_python_api_bar_update, METH_VARARGS, "" },
6112
{ "bar_remove", &weechat_python_api_bar_remove, METH_VARARGS, "" },
6113
{ "command", &weechat_python_api_command, METH_VARARGS, "" },
6114
{ "info_get", &weechat_python_api_info_get, METH_VARARGS, "" },
6115
{ "infolist_new", &weechat_python_api_infolist_new, METH_VARARGS, "" },
6116
{ "infolist_new_var_integer", &weechat_python_api_infolist_new_var_integer, METH_VARARGS, "" },
6117
{ "infolist_new_var_string", &weechat_python_api_infolist_new_var_string, METH_VARARGS, "" },
6118
{ "infolist_new_var_pointer", &weechat_python_api_infolist_new_var_pointer, METH_VARARGS, "" },
6119
{ "infolist_new_var_time", &weechat_python_api_infolist_new_var_time, METH_VARARGS, "" },
6120
{ "infolist_get", &weechat_python_api_infolist_get, METH_VARARGS, "" },
6121
{ "infolist_next", &weechat_python_api_infolist_next, METH_VARARGS, "" },
6122
{ "infolist_prev", &weechat_python_api_infolist_prev, METH_VARARGS, "" },
6123
{ "infolist_fields", &weechat_python_api_infolist_fields, METH_VARARGS, "" },
6124
{ "infolist_integer", &weechat_python_api_infolist_integer, METH_VARARGS, "" },
6125
{ "infolist_string", &weechat_python_api_infolist_string, METH_VARARGS, "" },
6126
{ "infolist_pointer", &weechat_python_api_infolist_pointer, METH_VARARGS, "" },
6127
{ "infolist_time", &weechat_python_api_infolist_time, METH_VARARGS, "" },
6128
{ "infolist_free", &weechat_python_api_infolist_free, METH_VARARGS, "" },
6129
{ "upgrade_new", &weechat_python_api_upgrade_new, METH_VARARGS, "" },
6130
{ "upgrade_write_object", &weechat_python_api_upgrade_write_object, METH_VARARGS, "" },
6131
{ "upgrade_read", &weechat_python_api_upgrade_read, METH_VARARGS, "" },
6132
{ "upgrade_close", &weechat_python_api_upgrade_close, METH_VARARGS, "" },
6133
{ NULL, NULL, 0, NULL }