1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 12:26:40 +02:00

Add some missing functions in API: hook_connect and infolist creation

This commit is contained in:
Sebastien Helleu
2008-09-26 13:26:41 +02:00
parent 8799fe6963
commit 471a7dda67
10 changed files with 1463 additions and 177 deletions
+4 -3
View File
@@ -120,7 +120,8 @@ struct t_hook_fd
int flags; /* fd flags (read,write,..) */
};
typedef int (t_hook_callback_connect)(void *data, int status, char *ip_address);
typedef int (t_hook_callback_connect)(void *data, int status,
const char *ip_address);
struct t_hook_connect
{
@@ -246,7 +247,7 @@ extern void hook_timer_exec ();
extern struct t_hook *hook_fd (struct t_weechat_plugin *plugin, int fd,
int flag_read, int flag_write,
int flag_exception,
t_hook_callback_fd * callback,
t_hook_callback_fd *callback,
void *callback_data);
extern int hook_fd_set (fd_set *read_fds, fd_set *write_fds,
fd_set *exception_fds);
@@ -256,7 +257,7 @@ extern struct t_hook *hook_connect (struct t_weechat_plugin *plugin,
const char *address, int port,
int sock, int ipv6, void *gnutls_session,
const char *local_hostname,
t_hook_callback_connect * callback,
t_hook_callback_connect *callback,
void *callback_data);
extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer,
+1 -1
View File
@@ -1969,7 +1969,7 @@ irc_server_switch_address (struct t_irc_server *server)
*/
int
irc_server_connect_cb (void *arg_server, int status, char *ip_address)
irc_server_connect_cb (void *arg_server, int status, const char *ip_address)
{
struct t_irc_server *server;
int config_proxy_use;
+439 -44
View File
@@ -1633,7 +1633,7 @@ static int
weechat_lua_api_config_string (lua_State *L)
{
const char *option;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -1657,9 +1657,9 @@ weechat_lua_api_config_string (lua_State *L)
option = lua_tostring (lua_current_interpreter, -1);
value = weechat_config_string (script_str2ptr (option));
result = weechat_config_string (script_str2ptr (option));
LUA_RETURN_STRING(value);
LUA_RETURN_STRING(result);
}
/*
@@ -1932,7 +1932,7 @@ static int
weechat_lua_api_config_get_plugin (lua_State *L)
{
const char *option;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -1956,11 +1956,11 @@ weechat_lua_api_config_get_plugin (lua_State *L)
option = lua_tostring (lua_current_interpreter, -1);
value = script_api_config_get_plugin (weechat_lua_plugin,
lua_current_script,
option);
result = script_api_config_get_plugin (weechat_lua_plugin,
lua_current_script,
option);
LUA_RETURN_STRING(value);
LUA_RETURN_STRING(result);
}
/*
@@ -2502,6 +2502,97 @@ weechat_lua_api_hook_fd (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_connect_cb: callback for connect hooked
*/
int
weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address)
{
struct t_script_callback *script_callback;
char *lua_argv[3], str_status[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
snprintf (str_status, sizeof (str_status), "%d", status);
lua_argv[0] = str_status;
lua_argv[1] = (char *)ip_address;
lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
{
ret = *rc;
free (rc);
}
return ret;
}
/*
* weechat_lua_api_hook_connect: hook a connection
*/
static int
weechat_lua_api_hook_connect (lua_State *L)
{
const char *address, *local_hostname, *function;
int n, port, sock, ipv6;
char *result;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
LUA_RETURN_EMPTY;
}
address = NULL;
port = 0;
sock = 0;
ipv6 = 0;
local_hostname = NULL;
function = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
LUA_RETURN_EMPTY;
}
address = lua_tostring (lua_current_interpreter, -6);
port = lua_tonumber (lua_current_interpreter, -5);
sock = lua_tonumber (lua_current_interpreter, -4);
ipv6 = lua_tonumber (lua_current_interpreter, -3);
local_hostname = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (script_api_hook_connect (weechat_lua_plugin,
lua_current_script,
address,
port,
sock,
ipv6,
NULL, /* gnutls session */
local_hostname,
&weechat_lua_api_hook_connect_cb,
function));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_print_cb: callback for print hooked
*/
@@ -3147,7 +3238,7 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
{
struct t_script_callback *script_callback;
char *lua_argv[4];
struct t_infolist *value;
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@@ -3156,15 +3247,15 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
lua_argv[2] = (char *)arguments;
lua_argv[3] = NULL;
value = (struct t_infolist *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
result = (struct t_infolist *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
if (lua_argv[1])
free (lua_argv[1]);
return value;
return result;
}
/*
@@ -3551,7 +3642,7 @@ static int
weechat_lua_api_buffer_get_string (lua_State *L)
{
const char *buffer, *property;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -3577,10 +3668,10 @@ weechat_lua_api_buffer_get_string (lua_State *L)
buffer = lua_tostring (lua_current_interpreter, -2);
property = lua_tostring (lua_current_interpreter, -1);
value = weechat_buffer_get_string (script_str2ptr (buffer),
property);
result = weechat_buffer_get_string (script_str2ptr (buffer),
property);
LUA_RETURN_STRING(value);
LUA_RETURN_STRING(result);
}
/*
@@ -3591,7 +3682,7 @@ static int
weechat_lua_api_buffer_get_pointer (lua_State *L)
{
const char *buffer, *property;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -3617,10 +3708,10 @@ weechat_lua_api_buffer_get_pointer (lua_State *L)
buffer = lua_tostring (lua_current_interpreter, -2);
property = lua_tostring (lua_current_interpreter, -1);
value = script_ptr2str (weechat_buffer_get_string (script_str2ptr (buffer),
property));
result = script_ptr2str (weechat_buffer_get_string (script_str2ptr (buffer),
property));
LUA_RETURN_STRING_FREE(value);
LUA_RETURN_STRING_FREE(result);
}
/*
@@ -4442,7 +4533,7 @@ static int
weechat_lua_api_info_get (lua_State *L)
{
const char *info_name, *arguments;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -4468,9 +4559,207 @@ weechat_lua_api_info_get (lua_State *L)
info_name = lua_tostring (lua_current_interpreter, -2);
arguments = lua_tostring (lua_current_interpreter, -1);
value = weechat_info_get (info_name, arguments);
result = weechat_info_get (info_name, arguments);
LUA_RETURN_STRING(value);
LUA_RETURN_STRING(result);
}
/*
* weechat_lua_api_infolist_new: create new infolist
*/
static int
weechat_lua_api_infolist_new (lua_State *L)
{
char *result;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new");
LUA_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new ());
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_infolist_new_var_integer: create new integer variable in
* infolist
*/
static int
weechat_lua_api_infolist_new_var_integer (lua_State *L)
{
const char *infolist, *name;
char *result;
int n, value;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer");
LUA_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = 0;
n = lua_gettop (lua_current_interpreter);
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer");
LUA_RETURN_EMPTY;
}
infolist = lua_tostring (lua_current_interpreter, -3);
name = lua_tostring (lua_current_interpreter, -2);
value = lua_tonumber (lua_current_interpreter, -1);
result = script_ptr2str (weechat_infolist_new_var_integer (script_str2ptr (infolist),
name,
value));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_infolist_new_var_string: create new string variable in
* infolist
*/
static int
weechat_lua_api_infolist_new_var_string (lua_State *L)
{
const char *infolist, *name, *value;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string");
LUA_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string");
LUA_RETURN_EMPTY;
}
infolist = lua_tostring (lua_current_interpreter, -3);
name = lua_tostring (lua_current_interpreter, -2);
value = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (infolist),
name,
value));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_infolist_new_var_pointer: create new pointer variable in
* infolist
*/
static int
weechat_lua_api_infolist_new_var_pointer (lua_State *L)
{
const char *infolist, *name, *value;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer");
LUA_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer");
LUA_RETURN_EMPTY;
}
infolist = lua_tostring (lua_current_interpreter, -3);
name = lua_tostring (lua_current_interpreter, -2);
value = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (infolist),
name,
script_str2ptr (value)));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_infolist_new_var_time: create new time variable in infolist
*/
static int
weechat_lua_api_infolist_new_var_time (lua_State *L)
{
const char *infolist, *name;
char *result;
int n, value;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time");
LUA_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = 0;
n = lua_gettop (lua_current_interpreter);
if (n < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time");
LUA_RETURN_EMPTY;
}
infolist = lua_tostring (lua_current_interpreter, -3);
name = lua_tostring (lua_current_interpreter, -2);
value = lua_tonumber (lua_current_interpreter, -1);
result = script_ptr2str (weechat_infolist_new_var_time (script_str2ptr (infolist),
name,
value));
LUA_RETURN_STRING_FREE(result);
}
/*
@@ -4481,7 +4770,7 @@ static int
weechat_lua_api_infolist_get (lua_State *L)
{
const char *name, *pointer, *arguments;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -4509,11 +4798,11 @@ weechat_lua_api_infolist_get (lua_State *L)
pointer = lua_tostring (lua_current_interpreter, -2);
arguments = lua_tostring (lua_current_interpreter, -1);
value = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer),
arguments));
result = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer),
arguments));
LUA_RETURN_STRING_FREE(value);
LUA_RETURN_STRING_FREE(result);
}
/*
@@ -4596,7 +4885,7 @@ static int
weechat_lua_api_infolist_fields (lua_State *L)
{
const char *infolist;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -4620,9 +4909,9 @@ weechat_lua_api_infolist_fields (lua_State *L)
infolist = lua_tostring (lua_current_interpreter, -1);
value = weechat_infolist_fields (script_str2ptr (infolist));
result = weechat_infolist_fields (script_str2ptr (infolist));
LUA_RETURN_STRING(value);
LUA_RETURN_STRING(result);
}
/*
@@ -4672,7 +4961,7 @@ static int
weechat_lua_api_infolist_string (lua_State *L)
{
const char *infolist, *variable;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -4698,10 +4987,10 @@ weechat_lua_api_infolist_string (lua_State *L)
infolist = lua_tostring (lua_current_interpreter, -2);
variable = lua_tostring (lua_current_interpreter, -1);
value = weechat_infolist_string (script_str2ptr (infolist),
result = weechat_infolist_string (script_str2ptr (infolist),
variable);
LUA_RETURN_STRING(value);
LUA_RETURN_STRING(result);
}
/*
@@ -4712,7 +5001,7 @@ static int
weechat_lua_api_infolist_pointer (lua_State *L)
{
const char *infolist, *variable;
char *value;
char *result;
int n;
/* make C compiler happy */
@@ -4738,10 +5027,10 @@ weechat_lua_api_infolist_pointer (lua_State *L)
infolist = lua_tostring (lua_current_interpreter, -2);
variable = lua_tostring (lua_current_interpreter, -1);
value = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist),
variable));
result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist),
variable));
LUA_RETURN_STRING_FREE(value);
LUA_RETURN_STRING_FREE(result);
}
/*
@@ -4753,7 +5042,7 @@ weechat_lua_api_infolist_time (lua_State *L)
{
const char *infolist, *variable;
time_t time;
char timebuffer[64], *value;
char timebuffer[64], *result;
int n;
/* make C compiler happy */
@@ -4782,9 +5071,9 @@ weechat_lua_api_infolist_time (lua_State *L)
time = weechat_infolist_time (script_str2ptr (infolist),
variable);
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
value = strdup (timebuffer);
result = strdup (timebuffer);
LUA_RETURN_STRING_FREE(value);
LUA_RETURN_STRING_FREE(result);
}
/*
@@ -5057,6 +5346,96 @@ weechat_lua_api_constant_weechat_hotlist_highlight (lua_State *L)
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_address_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_ip_address_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_connection_refused (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_proxy_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_PROXY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_local_hostname_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_gnutls_init_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_gnutls_handshake_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_memory_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_MEMORY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_signal_string (lua_State *L)
{
@@ -5144,6 +5523,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "hook_command", &weechat_lua_api_hook_command },
{ "hook_timer", &weechat_lua_api_hook_timer },
{ "hook_fd", &weechat_lua_api_hook_fd },
{ "hook_connect", &weechat_lua_api_hook_connect },
{ "hook_print", &weechat_lua_api_hook_print },
{ "hook_signal", &weechat_lua_api_hook_signal },
{ "hook_signal_send", &weechat_lua_api_hook_signal_send },
@@ -5182,6 +5562,11 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "bar_remove", &weechat_lua_api_bar_remove },
{ "command", &weechat_lua_api_command },
{ "info_get", &weechat_lua_api_info_get },
{ "infolist_new", &weechat_lua_api_infolist_new },
{ "infolist_new_var_integer", &weechat_lua_api_infolist_new_var_integer },
{ "infolist_new_var_string", &weechat_lua_api_infolist_new_var_string },
{ "infolist_new_var_pointer", &weechat_lua_api_infolist_new_var_pointer },
{ "infolist_new_var_time", &weechat_lua_api_infolist_new_var_time },
{ "infolist_get", &weechat_lua_api_infolist_get },
{ "infolist_next", &weechat_lua_api_infolist_next },
{ "infolist_prev", &weechat_lua_api_infolist_prev },
@@ -5205,7 +5590,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "WEECHAT_CONFIG_WRITE_MEMORY_ERROR", &weechat_lua_api_constant_weechat_config_write_memory_error },
{ "WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", &weechat_lua_api_constant_weechat_config_option_set_ok_changed },
{ "WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", &weechat_lua_api_constant_weechat_config_option_set_ok_same_value },
{ "WEECHAT_CONFIG_OPTION_SER_ERROR", &weechat_lua_api_constant_weechat_config_option_set_error },
{ "WEECHAT_CONFIG_OPTION_SET_ERROR", &weechat_lua_api_constant_weechat_config_option_set_error },
{ "WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", &weechat_lua_api_constant_weechat_config_option_set_option_not_found },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", &weechat_lua_api_constant_weechat_config_option_unset_ok_no_reset },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", &weechat_lua_api_constant_weechat_config_option_unset_ok_reset },
@@ -5221,6 +5606,16 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "WEECHAT_HOTLIST_PRIVATE", &weechat_lua_api_constant_weechat_hotlist_private },
{ "WEECHAT_HOTLIST_HIGHLIGHT", &weechat_lua_api_constant_weechat_hotlist_highlight },
{ "WEECHAT_HOOK_CONNECT_OK", &weechat_lua_api_constant_weechat_hook_connect_ok },
{ "WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", &weechat_lua_api_constant_weechat_hook_connect_address_not_found },
{ "WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", &weechat_lua_api_constant_weechat_hook_connect_ip_address_not_found },
{ "WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", &weechat_lua_api_constant_weechat_hook_connect_connection_refused },
{ "WEECHAT_HOOK_CONNECT_PROXY_ERROR", &weechat_lua_api_constant_weechat_hook_connect_proxy_error },
{ "WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", &weechat_lua_api_constant_weechat_hook_connect_local_hostname_error },
{ "WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", &weechat_lua_api_constant_weechat_hook_connect_gnutls_init_error },
{ "WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", &weechat_lua_api_constant_weechat_hook_connect_gnutls_handshake_error },
{ "WEECHAT_HOOK_CONNECT_MEMORY_ERROR", &weechat_lua_api_constant_weechat_hook_connect_memory_error },
{ "WEECHAT_HOOK_SIGNAL_STRING", &weechat_lua_api_constant_weechat_hook_signal_string },
{ "WEECHAT_HOOK_SIGNAL_INT", &weechat_lua_api_constant_weechat_hook_signal_int },
{ "WEECHAT_HOOK_SIGNAL_POINTER", &weechat_lua_api_constant_weechat_hook_signal_pointer },
+297 -42
View File
@@ -1360,7 +1360,7 @@ static XS (XS_weechat_config_integer)
static XS (XS_weechat_config_string)
{
char *value;
char *result;
dXSARGS;
/* make C compiler happy */
@@ -1378,9 +1378,9 @@ static XS (XS_weechat_config_string)
PERL_RETURN_EMPTY;
}
value = weechat_config_string (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
result = weechat_config_string (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_STRING(value);
PERL_RETURN_STRING(result);
}
/*
@@ -1597,7 +1597,7 @@ static XS (XS_weechat_config_get)
static XS (XS_weechat_config_get_plugin)
{
char *value;
char *result;
dXSARGS;
/* make C compiler happy */
@@ -1615,11 +1615,11 @@ static XS (XS_weechat_config_get_plugin)
PERL_RETURN_EMPTY;
}
value = script_api_config_get_plugin (weechat_perl_plugin,
perl_current_script,
SvPV (ST (0), PL_na));
result = script_api_config_get_plugin (weechat_perl_plugin,
perl_current_script,
SvPV (ST (0), PL_na));
PERL_RETURN_STRING(value);
PERL_RETURN_STRING(result);
}
/*
@@ -2062,6 +2062,83 @@ static XS (XS_weechat_hook_fd)
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_hook_connect_cb: callback for connect hooked
*/
int
weechat_perl_api_hook_connect_cb (void *data, int status,
const char *ip_address)
{
struct t_script_callback *script_callback;
char *perl_argv[3], str_status[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
snprintf (str_status, sizeof (str_status), "%d", status);
perl_argv[0] = str_status;
perl_argv[1] = (char *)ip_address;
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
{
ret = *rc;
free (rc);
}
return ret;
}
/*
* weechat::hook_connect: hook a connection
*/
static XS (XS_weechat_hook_connect)
{
char *address, *local_hostname, *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
PERL_RETURN_EMPTY;
}
if (items < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
PERL_RETURN_EMPTY;
}
address = SvPV (ST (0), PL_na);
local_hostname = SvPV (ST (4), PL_na);
result = script_ptr2str (script_api_hook_connect (weechat_perl_plugin,
perl_current_script,
address,
SvIV (ST (1)), /* port */
SvIV (ST (2)), /* sock */
SvIV (ST (3)), /* ipv6 */
NULL, /* gnutls session */
local_hostname,
&weechat_perl_api_hook_connect_cb,
SvPV (ST (5), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_hook_print_cb: callback for print hooked
*/
@@ -2632,7 +2709,7 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
{
struct t_script_callback *script_callback;
char *perl_argv[4];
struct t_infolist *value;
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@@ -2641,15 +2718,15 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
perl_argv[2] = (char *)arguments;
perl_argv[3] = NULL;
value = (struct t_infolist *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
result = (struct t_infolist *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
if (perl_argv[1])
free (perl_argv[1]);
return value;
return result;
}
/*
@@ -2976,7 +3053,7 @@ static XS (XS_weechat_buffer_get_integer)
static XS (XS_weechat_buffer_get_string)
{
char *value, *buffer, *property;
char *result, *buffer, *property;
dXSARGS;
/* make C compiler happy */
@@ -2996,9 +3073,9 @@ static XS (XS_weechat_buffer_get_string)
buffer = SvPV (ST (0), PL_na);
property = SvPV (ST (1), PL_na);
value = weechat_buffer_get_string (script_str2ptr (buffer), property);
result = weechat_buffer_get_string (script_str2ptr (buffer), property);
PERL_RETURN_STRING(value);
PERL_RETURN_STRING(result);
}
/*
@@ -3007,7 +3084,7 @@ static XS (XS_weechat_buffer_get_string)
static XS (XS_weechat_buffer_get_pointer)
{
char *value, *buffer, *property;
char *result, *buffer, *property;
dXSARGS;
/* make C compiler happy */
@@ -3027,10 +3104,10 @@ static XS (XS_weechat_buffer_get_pointer)
buffer = SvPV (ST (0), PL_na);
property = SvPV (ST (1), PL_na);
value = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer),
property));
result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer),
property));
PERL_RETURN_STRING_FREE(value);
PERL_RETURN_STRING_FREE(result);
}
/*
@@ -3685,7 +3762,7 @@ static XS (XS_weechat_command)
static XS (XS_weechat_info_get)
{
char *value;
char *result;
dXSARGS;
/* make C compiler happy */
@@ -3703,10 +3780,172 @@ static XS (XS_weechat_info_get)
PERL_RETURN_EMPTY;
}
value = weechat_info_get (SvPV (ST (0), PL_na),
SvPV (ST (1), PL_na));
result = weechat_info_get (SvPV (ST (0), PL_na),
SvPV (ST (1), PL_na));
PERL_RETURN_STRING(value);
PERL_RETURN_STRING(result);
}
/*
* weechat::infolist_new: create new infolist
*/
static XS (XS_weechat_infolist_new)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) items;
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new ());
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::infolist_new_var_integer: create new integer variable in infolist
*/
static XS (XS_weechat_infolist_new_var_integer)
{
char *infolist, *name, *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer");
PERL_RETURN_EMPTY;
}
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer");
PERL_RETURN_EMPTY;
}
infolist = SvPV (ST (0), PL_na);
name = SvPV (ST (1), PL_na);
result = script_ptr2str (weechat_infolist_new_var_integer (script_str2ptr (infolist),
name,
SvIV (ST (2)))); /* value */
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::infolist_new_var_string: create new string variable in infolist
*/
static XS (XS_weechat_infolist_new_var_string)
{
char *infolist, *name, *value, *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string");
PERL_RETURN_EMPTY;
}
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string");
PERL_RETURN_EMPTY;
}
infolist = SvPV (ST (0), PL_na);
name = SvPV (ST (1), PL_na);
value = SvPV (ST (2), PL_na);
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (infolist),
name,
value));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::infolist_new_var_pointer: create new pointer variable in infolist
*/
static XS (XS_weechat_infolist_new_var_pointer)
{
char *infolist, *name, *value, *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer");
PERL_RETURN_EMPTY;
}
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer");
PERL_RETURN_EMPTY;
}
infolist = SvPV (ST (0), PL_na);
name = SvPV (ST (1), PL_na);
value = SvPV (ST (2), PL_na);
result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (infolist),
name,
script_str2ptr (value)));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::infolist_new_var_time: create new time variable in infolist
*/
static XS (XS_weechat_infolist_new_var_time)
{
char *infolist, *name, *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time");
PERL_RETURN_EMPTY;
}
if (items < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time");
PERL_RETURN_EMPTY;
}
infolist = SvPV (ST (0), PL_na);
name = SvPV (ST (1), PL_na);
result = script_ptr2str (weechat_infolist_new_var_time (script_str2ptr (infolist),
name,
SvIV (ST (2)))); /* value */
PERL_RETURN_STRING_FREE(result);
}
/*
@@ -3715,7 +3954,7 @@ static XS (XS_weechat_info_get)
static XS (XS_weechat_infolist_get)
{
char *value, *name, *pointer, *arguments;
char *result, *name, *pointer, *arguments;
dXSARGS;
/* make C compiler happy */
@@ -3736,11 +3975,11 @@ static XS (XS_weechat_infolist_get)
name = SvPV (ST (0), PL_na);
pointer = SvPV (ST (1), PL_na);
arguments = SvPV (ST (2), PL_na);
value = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer),
arguments));
result = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer),
arguments));
PERL_RETURN_STRING_FREE(value);
PERL_RETURN_STRING_FREE(result);
}
/*
@@ -3807,7 +4046,7 @@ static XS (XS_weechat_infolist_prev)
static XS (XS_weechat_infolist_fields)
{
char *value;
char *result;
dXSARGS;
/* make C compiler happy */
@@ -3825,9 +4064,9 @@ static XS (XS_weechat_infolist_fields)
PERL_RETURN_EMPTY;
}
value = weechat_infolist_fields (script_str2ptr (SvPV (ST (0), PL_na))); /* infolist */
result = weechat_infolist_fields (script_str2ptr (SvPV (ST (0), PL_na))); /* infolist */
PERL_RETURN_STRING(value);
PERL_RETURN_STRING(result);
}
/*
@@ -3869,7 +4108,7 @@ static XS (XS_weechat_infolist_integer)
static XS (XS_weechat_infolist_string)
{
char *infolist, *variable;
char *value;
char *result;
dXSARGS;
/* make C compiler happy */
@@ -3889,9 +4128,9 @@ static XS (XS_weechat_infolist_string)
infolist = SvPV (ST (0), PL_na);
variable = SvPV (ST (1), PL_na);
value = weechat_infolist_string (script_str2ptr (infolist), variable);
result = weechat_infolist_string (script_str2ptr (infolist), variable);
PERL_RETURN_STRING(value);
PERL_RETURN_STRING(result);
}
/*
@@ -3901,7 +4140,7 @@ static XS (XS_weechat_infolist_string)
static XS (XS_weechat_infolist_pointer)
{
char *infolist, *variable;
char *value;
char *result;
dXSARGS;
/* make C compiler happy */
@@ -3921,9 +4160,9 @@ static XS (XS_weechat_infolist_pointer)
infolist = SvPV (ST (0), PL_na);
variable = SvPV (ST (1), PL_na);
value = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist), variable));
result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist), variable));
PERL_RETURN_STRING_FREE(value);
PERL_RETURN_STRING_FREE(result);
}
/*
@@ -3933,7 +4172,7 @@ static XS (XS_weechat_infolist_pointer)
static XS (XS_weechat_infolist_time)
{
time_t time;
char timebuffer[64], *value, *infolist, *variable;
char timebuffer[64], *result, *infolist, *variable;
dXSARGS;
/* make C compiler happy */
@@ -3955,9 +4194,9 @@ static XS (XS_weechat_infolist_time)
variable = SvPV (ST (1), PL_na);
time = weechat_infolist_time (script_str2ptr (infolist), variable);
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
value = strdup (timebuffer);
result = strdup (timebuffer);
PERL_RETURN_STRING_FREE(value);
PERL_RETURN_STRING_FREE(result);
}
/*
@@ -4052,6 +4291,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::hook_command", XS_weechat_hook_command, "weechat");
newXS ("weechat::hook_timer", XS_weechat_hook_timer, "weechat");
newXS ("weechat::hook_fd", XS_weechat_hook_fd, "weechat");
newXS ("weechat::hook_connect", XS_weechat_hook_connect, "weechat");
newXS ("weechat::hook_print", XS_weechat_hook_print, "weechat");
newXS ("weechat::hook_signal", XS_weechat_hook_signal, "weechat");
newXS ("weechat::hook_signal_send", XS_weechat_hook_signal_send, "weechat");
@@ -4090,6 +4330,11 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::bar_remove", XS_weechat_bar_remove, "weechat");
newXS ("weechat::command", XS_weechat_command, "weechat");
newXS ("weechat::info_get", XS_weechat_info_get, "weechat");
newXS ("weechat::infolist_new", XS_weechat_infolist_new, "weechat");
newXS ("weechat::infolist_new_var_integer", XS_weechat_infolist_new_var_integer, "weechat");
newXS ("weechat::infolist_new_var_string", XS_weechat_infolist_new_var_string, "weechat");
newXS ("weechat::infolist_new_var_pointer", XS_weechat_infolist_new_var_pointer, "weechat");
newXS ("weechat::infolist_new_var_time", XS_weechat_infolist_new_var_time, "weechat");
newXS ("weechat::infolist_get", XS_weechat_infolist_get, "weechat");
newXS ("weechat::infolist_next", XS_weechat_infolist_next, "weechat");
newXS ("weechat::infolist_prev", XS_weechat_infolist_prev, "weechat");
@@ -4128,6 +4373,16 @@ weechat_perl_api_init (pTHX)
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_MESSAGE", newSVpv (WEECHAT_HOTLIST_MESSAGE, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_PRIVATE", newSVpv (WEECHAT_HOTLIST_PRIVATE, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOTLIST_HIGHLIGHT", newSVpv (WEECHAT_HOTLIST_HIGHLIGHT, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_OK", newSViv (WEECHAT_HOOK_CONNECT_OK));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", newSViv (WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", newSViv (WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", newSViv (WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_PROXY_ERROR", newSViv (WEECHAT_HOOK_CONNECT_PROXY_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", newSViv (WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", newSViv (WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", newSViv (WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_CONNECT_MEMORY_ERROR", newSViv (WEECHAT_HOOK_CONNECT_MEMORY_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_SIGNAL_STRING", newSVpv (WEECHAT_HOOK_SIGNAL_STRING, PL_na));
newCONSTSUB (stash, "weechat::WEECHAT_HOOK_SIGNAL_INT", newSVpv (WEECHAT_HOOK_SIGNAL_INT, PL_na));
+308 -43
View File
@@ -1438,7 +1438,7 @@ weechat_python_api_config_integer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_config_string (PyObject *self, PyObject *args)
{
char *option, *value;
char *option, *result;
/* make C compiler happy */
(void) self;
@@ -1457,9 +1457,9 @@ weechat_python_api_config_string (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = weechat_config_string (script_str2ptr (option));
result = weechat_config_string (script_str2ptr (option));
PYTHON_RETURN_STRING(value);
PYTHON_RETURN_STRING(result);
}
/*
@@ -1698,7 +1698,7 @@ weechat_python_api_config_get (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
{
char *option, *value;
char *option, *result;
/* make C compiler happy */
(void) self;
@@ -1717,11 +1717,11 @@ weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = script_api_config_get_plugin (weechat_python_plugin,
python_current_script,
option);
result = script_api_config_get_plugin (weechat_python_plugin,
python_current_script,
option);
PYTHON_RETURN_STRING(value);
PYTHON_RETURN_STRING(result);
}
/*
@@ -2199,6 +2199,90 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_connect_cb: callback for connect hooked
*/
int
weechat_python_api_hook_connect_cb (void *data, int status,
const char *ip_address)
{
struct t_script_callback *script_callback;
char *python_argv[3], str_status[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
snprintf (str_status, sizeof (str_status), "%d", status);
python_argv[0] = str_status;
python_argv[1] = (char *)ip_address;
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
{
ret = *rc;
free (rc);
}
return ret;
}
/*
* weechat_python_api_hook_connect: hook a connection
*/
static PyObject *
weechat_python_api_hook_connect (PyObject *self, PyObject *args)
{
char *address, *local_hostname, *function, *result;
int port, sock, ipv6;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
PYTHON_RETURN_EMPTY;
}
address = NULL;
port = 0;
sock = 0;
ipv6 = 0;
local_hostname = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "siiiss", &address, &port, &sock, &ipv6,
&local_hostname, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (script_api_hook_connect (weechat_python_plugin,
python_current_script,
address,
port,
sock,
ipv6,
NULL, /* gnutls session */
local_hostname,
&weechat_python_api_hook_connect_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_print_cb: callback for print hooked
*/
@@ -2790,7 +2874,7 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
{
struct t_script_callback *script_callback;
char *python_argv[4];
struct t_infolist *value;
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@@ -2799,15 +2883,15 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
python_argv[2] = (char *)arguments;
python_argv[3] = NULL;
value = (struct t_infolist *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
result = (struct t_infolist *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
if (python_argv[1])
free (python_argv[1]);
return value;
return result;
}
/*
@@ -3154,7 +3238,7 @@ weechat_python_api_buffer_get_integer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_buffer_get_string (PyObject *self, PyObject *args)
{
char *buffer, *property, *value;
char *buffer, *property, *result;
/* make C compiler happy */
(void) self;
@@ -3174,9 +3258,9 @@ weechat_python_api_buffer_get_string (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = weechat_buffer_get_string (script_str2ptr (buffer), property);
result = weechat_buffer_get_string (script_str2ptr (buffer), property);
PYTHON_RETURN_STRING(value);
PYTHON_RETURN_STRING(result);
}
/*
@@ -3186,7 +3270,7 @@ weechat_python_api_buffer_get_string (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args)
{
char *buffer, *property, *value;
char *buffer, *property, *result;
PyObject *object;
/* make C compiler happy */
@@ -3207,10 +3291,10 @@ weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer),
property));
result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer),
property));
PYTHON_RETURN_STRING_FREE(value);
PYTHON_RETURN_STRING_FREE(result);
}
/*
@@ -3917,7 +4001,7 @@ weechat_python_api_command (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_info_get (PyObject *self, PyObject *args)
{
char *info_name, *arguments, *value;
char *info_name, *arguments, *result;
/* make C compiler happy */
(void) self;
@@ -3936,9 +4020,184 @@ weechat_python_api_info_get (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = weechat_info_get (info_name, arguments);
result = weechat_info_get (info_name, arguments);
PYTHON_RETURN_STRING(value);
PYTHON_RETURN_STRING(result);
}
/*
* weechat_python_api_infolist_new: create new infolist
*/
static PyObject *
weechat_python_api_infolist_new (PyObject *self, PyObject *args)
{
char *result;
PyObject *object;
/* make C compiler happy */
(void) self;
(void) args;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new ());
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_infolist_new_var_integer: create new integer variable in
* infolist
*/
static PyObject *
weechat_python_api_infolist_new_var_integer (PyObject *self, PyObject *args)
{
char *infolist, *name, *result;
int value;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = 0;
if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new_var_integer (script_str2ptr (infolist),
name,
value));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_infolist_new_var_string: create new string variable in
* infolist
*/
static PyObject *
weechat_python_api_infolist_new_var_string (PyObject *self, PyObject *args)
{
char *infolist, *name, *value, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = NULL;
if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (infolist),
name,
value));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_infolist_new_var_pointer: create new pointer variable in
* infolist
*/
static PyObject *
weechat_python_api_infolist_new_var_pointer (PyObject *self, PyObject *args)
{
char *infolist, *name, *value, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = NULL;
if (!PyArg_ParseTuple (args, "sss", &infolist, &name, &value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (infolist),
name,
script_str2ptr (value)));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_infolist_new_var_time: create new time variable in
* infolist
*/
static PyObject *
weechat_python_api_infolist_new_var_time (PyObject *self, PyObject *args)
{
char *infolist, *name, *result;
int value;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
name = NULL;
value = 0;
if (!PyArg_ParseTuple (args, "ssi", &infolist, &name, &value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new_var_time (script_str2ptr (infolist),
name,
value));
PYTHON_RETURN_STRING_FREE(result);
}
/*
@@ -3948,7 +4207,7 @@ weechat_python_api_info_get (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_get (PyObject *self, PyObject *args)
{
char *name, *pointer, *arguments, *value;
char *name, *pointer, *arguments, *result;
PyObject *object;
/* make C compiler happy */
@@ -3970,11 +4229,11 @@ weechat_python_api_infolist_get (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer),
arguments));
result = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer),
arguments));
PYTHON_RETURN_STRING_FREE(value);
PYTHON_RETURN_STRING_FREE(result);
}
/*
@@ -4048,7 +4307,7 @@ weechat_python_api_infolist_prev (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_fields (PyObject *self, PyObject *args)
{
char *infolist, *value;
char *infolist, *result;
/* make C compiler happy */
(void) self;
@@ -4067,9 +4326,9 @@ weechat_python_api_infolist_fields (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = weechat_infolist_fields (script_str2ptr (infolist));
result = weechat_infolist_fields (script_str2ptr (infolist));
PYTHON_RETURN_STRING(value);
PYTHON_RETURN_STRING(result);
}
/*
@@ -4113,7 +4372,7 @@ weechat_python_api_infolist_integer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_string (PyObject *self, PyObject *args)
{
char *infolist, *variable, *value;
char *infolist, *variable, *result;
/* make C compiler happy */
(void) self;
@@ -4133,10 +4392,10 @@ weechat_python_api_infolist_string (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = weechat_infolist_string (script_str2ptr (infolist),
variable);
result = weechat_infolist_string (script_str2ptr (infolist),
variable);
PYTHON_RETURN_STRING(value);
PYTHON_RETURN_STRING(result);
}
/*
@@ -4146,7 +4405,7 @@ weechat_python_api_infolist_string (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_pointer (PyObject *self, PyObject *args)
{
char *infolist, *variable, *value;
char *infolist, *variable, *result;
PyObject *object;
/* make C compiler happy */
@@ -4167,10 +4426,10 @@ weechat_python_api_infolist_pointer (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
value = script_ptr2str (weechat_infolist_string (script_str2ptr (infolist),
variable));
result = script_ptr2str (weechat_infolist_string (script_str2ptr (infolist),
variable));
PYTHON_RETURN_STRING_FREE(value);
PYTHON_RETURN_STRING_FREE(result);
}
/*
@@ -4180,7 +4439,7 @@ weechat_python_api_infolist_pointer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_time (PyObject *self, PyObject *args)
{
char *infolist, *variable, timebuffer[64], *value;
char *infolist, *variable, timebuffer[64], *result;
time_t time;
PyObject *object;
@@ -4205,9 +4464,9 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args)
time = weechat_infolist_time (script_str2ptr (infolist),
variable);
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
value = strdup (timebuffer);
result = strdup (timebuffer);
PYTHON_RETURN_STRING_FREE(value);
PYTHON_RETURN_STRING_FREE(result);
}
/*
@@ -4299,6 +4558,7 @@ PyMethodDef weechat_python_funcs[] =
{ "hook_command", &weechat_python_api_hook_command, METH_VARARGS, "" },
{ "hook_timer", &weechat_python_api_hook_timer, METH_VARARGS, "" },
{ "hook_fd", &weechat_python_api_hook_fd, METH_VARARGS, "" },
{ "hook_connect", &weechat_python_api_hook_connect, METH_VARARGS, "" },
{ "hook_print", &weechat_python_api_hook_print, METH_VARARGS, "" },
{ "hook_signal", &weechat_python_api_hook_signal, METH_VARARGS, "" },
{ "hook_signal_send", &weechat_python_api_hook_signal_send, METH_VARARGS, "" },
@@ -4337,6 +4597,11 @@ PyMethodDef weechat_python_funcs[] =
{ "bar_remove", &weechat_python_api_bar_remove, METH_VARARGS, "" },
{ "command", &weechat_python_api_command, METH_VARARGS, "" },
{ "info_get", &weechat_python_api_info_get, METH_VARARGS, "" },
{ "infolist_new", &weechat_python_api_infolist_new, METH_VARARGS, "" },
{ "infolist_new_var_integer", &weechat_python_api_infolist_new_var_integer, METH_VARARGS, "" },
{ "infolist_new_var_string", &weechat_python_api_infolist_new_var_string, METH_VARARGS, "" },
{ "infolist_new_var_pointer", &weechat_python_api_infolist_new_var_pointer, METH_VARARGS, "" },
{ "infolist_new_var_time", &weechat_python_api_infolist_new_var_time, METH_VARARGS, "" },
{ "infolist_get", &weechat_python_api_infolist_get, METH_VARARGS, "" },
{ "infolist_next", &weechat_python_api_infolist_next, METH_VARARGS, "" },
{ "infolist_prev", &weechat_python_api_infolist_prev, METH_VARARGS, "" },
@@ -360,6 +360,16 @@ weechat_python_load (const char *filename)
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_MESSAGE", PyString_FromString(WEECHAT_HOTLIST_MESSAGE));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_PRIVATE", PyString_FromString(WEECHAT_HOTLIST_PRIVATE));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_HIGHLIGHT", PyString_FromString(WEECHAT_HOTLIST_HIGHLIGHT));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_OK", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_PROXY_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_PROXY_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_CONNECT_MEMORY_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_CONNECT_MEMORY_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_STRING", PyString_FromString(WEECHAT_HOOK_SIGNAL_STRING));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_INT", PyString_FromString(WEECHAT_HOOK_SIGNAL_INT));
+352 -43
View File
@@ -1664,7 +1664,7 @@ weechat_ruby_api_config_integer (VALUE class, VALUE option)
static VALUE
weechat_ruby_api_config_string (VALUE class, VALUE option)
{
char *c_option, *value;
char *c_option, *result;
/* make C compiler happy */
(void) class;
@@ -1687,9 +1687,9 @@ weechat_ruby_api_config_string (VALUE class, VALUE option)
c_option = STR2CSTR (option);
value = weechat_config_string (script_str2ptr (c_option));
result = weechat_config_string (script_str2ptr (c_option));
RUBY_RETURN_STRING(value);
RUBY_RETURN_STRING(result);
}
/*
@@ -1959,7 +1959,7 @@ weechat_ruby_api_config_get (VALUE class, VALUE option)
static VALUE
weechat_ruby_api_config_get_plugin (VALUE class, VALUE option)
{
char *c_option, *value;
char *c_option, *result;
/* make C compiler happy */
(void) class;
@@ -1980,11 +1980,11 @@ weechat_ruby_api_config_get_plugin (VALUE class, VALUE option)
c_option = STR2CSTR (option);
value = script_api_config_get_plugin (weechat_ruby_plugin,
ruby_current_script,
c_option);
result = script_api_config_get_plugin (weechat_ruby_plugin,
ruby_current_script,
c_option);
RUBY_RETURN_STRING(value);
RUBY_RETURN_STRING(result);
}
/*
@@ -2542,6 +2542,106 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write,
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_connect_cb: callback for connect hooked
*/
int
weechat_ruby_api_hook_connect_cb (void *data, int status,
const char *ip_address)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], str_status[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
snprintf (str_status, sizeof (str_status), "%d", status);
ruby_argv[0] = str_status;
ruby_argv[1] = (char *)ip_address;
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
{
ret = *rc;
free (rc);
}
return ret;
}
/*
* weechat_ruby_api_hook_connect: hook a connection
*/
static VALUE
weechat_ruby_api_hook_connect (VALUE class, VALUE address, VALUE port,
VALUE sock, VALUE ipv6, VALUE local_hostname,
VALUE function)
{
char *c_address, *c_local_hostname, *c_function, *result;
int c_port, c_sock, c_ipv6;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
RUBY_RETURN_EMPTY;
}
c_address = NULL;
c_port = 0;
c_sock = 0;
c_ipv6 = 0;
c_local_hostname = NULL;
c_function = NULL;
if (NIL_P (address) || NIL_P (port) || NIL_P (sock) || NIL_P (ipv6)
|| NIL_P (local_hostname) || NIL_P (function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
RUBY_RETURN_EMPTY;
}
Check_Type (address, T_STRING);
Check_Type (port, T_FIXNUM);
Check_Type (sock, T_FIXNUM);
Check_Type (ipv6, T_FIXNUM);
Check_Type (local_hostname, T_STRING);
Check_Type (function, T_STRING);
c_address = STR2CSTR (address);
c_port = FIX2INT (port);
c_sock = FIX2INT (sock);
c_ipv6 = FIX2INT (ipv6);
c_local_hostname = STR2CSTR (local_hostname);
c_function = STR2CSTR (function);
result = script_ptr2str (script_api_hook_connect (weechat_ruby_plugin,
ruby_current_script,
c_address,
c_port,
c_sock,
c_ipv6,
NULL, /* gnutls session */
c_local_hostname,
&weechat_ruby_api_hook_connect_cb,
c_function));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_print_cb: callback for print hooked
*/
@@ -3209,7 +3309,7 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
{
struct t_script_callback *script_callback;
char *ruby_argv[4];
struct t_infolist *value;
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@@ -3218,15 +3318,15 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
ruby_argv[2] = (char *)arguments;
ruby_argv[3] = NULL;
value = (struct t_infolist *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
result = (struct t_infolist *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
if (ruby_argv[1])
free (ruby_argv[1]);
return value;
return result;
}
/*
@@ -3615,7 +3715,7 @@ weechat_ruby_api_buffer_get_integer (VALUE class, VALUE buffer, VALUE property)
static VALUE
weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property)
{
char *c_buffer, *c_property, *value;
char *c_buffer, *c_property, *result;
/* make C compiler happy */
(void) class;
@@ -3637,11 +3737,11 @@ weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property)
c_buffer = STR2CSTR (buffer);
c_property = STR2CSTR (property);
value = weechat_buffer_get_string (script_str2ptr (c_buffer),
result = weechat_buffer_get_string (script_str2ptr (c_buffer),
c_property);
RUBY_RETURN_STRING(value);
RUBY_RETURN_STRING(result);
}
/*
@@ -3651,7 +3751,7 @@ weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property)
static VALUE
weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property)
{
char *c_buffer, *c_property, *value;
char *c_buffer, *c_property, *result;
VALUE return_value;
/* make C compiler happy */
@@ -3674,11 +3774,11 @@ weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property)
c_buffer = STR2CSTR (buffer);
c_property = STR2CSTR (property);
value = script_ptr2str (weechat_buffer_get_string (script_str2ptr (c_buffer),
c_property));
RUBY_RETURN_STRING_FREE(value);
result = script_ptr2str (weechat_buffer_get_string (script_str2ptr (c_buffer),
c_property));
RUBY_RETURN_STRING_FREE(result);
}
/*
@@ -4516,7 +4616,7 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command)
static VALUE
weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments)
{
char *c_info_name, *c_arguments, *value;
char *c_info_name, *c_arguments, *result;
/* make C compiler happy */
(void) class;
@@ -4539,9 +4639,202 @@ weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments)
c_info_name = STR2CSTR (info_name);
c_arguments = STR2CSTR (arguments);
value = weechat_info_get (c_info_name, c_arguments);
result = weechat_info_get (c_info_name, c_arguments);
RUBY_RETURN_STRING(value);
RUBY_RETURN_STRING(result);
}
/*
* weechat_ruby_api_infolist_new: create new infolist
*/
static VALUE
weechat_ruby_api_infolist_new (VALUE class)
{
char *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new");
RUBY_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_new ());
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_infolist_new_var_integer: create new integer variable in
* infolist
*/
static VALUE
weechat_ruby_api_infolist_new_var_integer (VALUE class, VALUE infolist,
VALUE name, VALUE value)
{
char *c_infolist, *c_name, *result;
int c_value;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_integer");
RUBY_RETURN_EMPTY;
}
if (NIL_P (infolist) || NIL_P (name) || NIL_P (value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_integer");
RUBY_RETURN_EMPTY;
}
Check_Type (infolist, T_STRING);
Check_Type (name, T_STRING);
Check_Type (value, T_FIXNUM);
c_infolist = STR2CSTR (infolist);
c_name = STR2CSTR (name);
c_value = FIX2INT (value);
result = script_ptr2str (weechat_infolist_new_var_integer (script_str2ptr (c_infolist),
c_name,
c_value));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_infolist_new_var_string: create new string variable in
* infolist
*/
static VALUE
weechat_ruby_api_infolist_new_var_string (VALUE class, VALUE infolist,
VALUE name, VALUE value)
{
char *c_infolist, *c_name, *c_value, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_string");
RUBY_RETURN_EMPTY;
}
if (NIL_P (infolist) || NIL_P (name) || NIL_P (value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_string");
RUBY_RETURN_EMPTY;
}
Check_Type (infolist, T_STRING);
Check_Type (name, T_STRING);
Check_Type (value, T_STRING);
c_infolist = STR2CSTR (infolist);
c_name = STR2CSTR (name);
c_value = STR2CSTR (value);
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (c_infolist),
c_name,
c_value));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_infolist_new_var_pointer: create new pointer variable in
* infolist
*/
static VALUE
weechat_ruby_api_infolist_new_var_pointer (VALUE class, VALUE infolist,
VALUE name, VALUE value)
{
char *c_infolist, *c_name, *c_value, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_pointer");
RUBY_RETURN_EMPTY;
}
if (NIL_P (infolist) || NIL_P (name) || NIL_P (value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_pointer");
RUBY_RETURN_EMPTY;
}
Check_Type (infolist, T_STRING);
Check_Type (name, T_STRING);
Check_Type (value, T_STRING);
c_infolist = STR2CSTR (infolist);
c_name = STR2CSTR (name);
c_value = STR2CSTR (value);
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (c_infolist),
c_name,
script_str2ptr (c_value)));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_infolist_new_var_time: create new time variable in infolist
*/
static VALUE
weechat_ruby_api_infolist_new_var_time (VALUE class, VALUE infolist,
VALUE name, VALUE value)
{
char *c_infolist, *c_name, *result;
int c_value;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_new_var_time");
RUBY_RETURN_EMPTY;
}
if (NIL_P (infolist) || NIL_P (name) || NIL_P (value))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_new_var_time");
RUBY_RETURN_EMPTY;
}
Check_Type (infolist, T_STRING);
Check_Type (name, T_STRING);
Check_Type (value, T_FIXNUM);
c_infolist = STR2CSTR (infolist);
c_name = STR2CSTR (name);
c_value = FIX2INT (value);
result = script_ptr2str (weechat_infolist_new_var_time (script_str2ptr (c_infolist),
c_name,
c_value));
RUBY_RETURN_STRING_FREE(result);
}
/*
@@ -4552,7 +4845,7 @@ static VALUE
weechat_ruby_api_infolist_get (VALUE class, VALUE name, VALUE pointer,
VALUE arguments)
{
char *c_name, *c_pointer, *c_arguments, *value;
char *c_name, *c_pointer, *c_arguments, *result;
VALUE return_value;
/* make C compiler happy */
@@ -4578,11 +4871,11 @@ weechat_ruby_api_infolist_get (VALUE class, VALUE name, VALUE pointer,
c_pointer = STR2CSTR (pointer);
c_arguments = STR2CSTR (arguments);
value = script_ptr2str (weechat_infolist_get (c_name,
script_str2ptr (c_pointer),
c_arguments));
result = script_ptr2str (weechat_infolist_get (c_name,
script_str2ptr (c_pointer),
c_arguments));
RUBY_RETURN_STRING_FREE(value);
RUBY_RETURN_STRING_FREE(result);
}
/*
@@ -4660,7 +4953,7 @@ weechat_ruby_api_infolist_prev (VALUE class, VALUE infolist)
static VALUE
weechat_ruby_api_infolist_fields (VALUE class, VALUE infolist)
{
char *c_infolist, *value;
char *c_infolist, *result;
/* make C compiler happy */
(void) class;
@@ -4681,9 +4974,9 @@ weechat_ruby_api_infolist_fields (VALUE class, VALUE infolist)
c_infolist = STR2CSTR (infolist);
value = weechat_infolist_fields (script_str2ptr (c_infolist));
result = weechat_infolist_fields (script_str2ptr (c_infolist));
RUBY_RETURN_STRING(value);
RUBY_RETURN_STRING(result);
}
/*
@@ -4729,7 +5022,7 @@ weechat_ruby_api_infolist_integer (VALUE class, VALUE infolist, VALUE variable)
static VALUE
weechat_ruby_api_infolist_string (VALUE class, VALUE infolist, VALUE variable)
{
char *c_infolist, *c_variable, *value;
char *c_infolist, *c_variable, *result;
/* make C compiler happy */
(void) class;
@@ -4752,9 +5045,9 @@ weechat_ruby_api_infolist_string (VALUE class, VALUE infolist, VALUE variable)
c_infolist = STR2CSTR (infolist);
c_variable = STR2CSTR (variable);
value = weechat_infolist_string (script_str2ptr (c_infolist), c_variable);
result = weechat_infolist_string (script_str2ptr (c_infolist), c_variable);
RUBY_RETURN_STRING(value);
RUBY_RETURN_STRING(result);
}
/*
@@ -4764,7 +5057,7 @@ weechat_ruby_api_infolist_string (VALUE class, VALUE infolist, VALUE variable)
static VALUE
weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable)
{
char *c_infolist, *c_variable, *value;
char *c_infolist, *c_variable, *result;
VALUE return_value;
/* make C compiler happy */
@@ -4788,9 +5081,9 @@ weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable)
c_infolist = STR2CSTR (infolist);
c_variable = STR2CSTR (variable);
value = script_ptr2str (weechat_infolist_pointer (script_str2ptr (c_infolist), c_variable));
result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (c_infolist), c_variable));
RUBY_RETURN_STRING_FREE(value);
RUBY_RETURN_STRING_FREE(result);
}
/*
@@ -4800,7 +5093,7 @@ weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable)
static VALUE
weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable)
{
char *c_infolist, *c_variable, timebuffer[64], *value;
char *c_infolist, *c_variable, timebuffer[64], *result;
time_t time;
VALUE return_value;
@@ -4827,9 +5120,9 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable)
time = weechat_infolist_time (script_str2ptr (c_infolist), c_variable);
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
value = strdup (timebuffer);
result = strdup (timebuffer);
RUBY_RETURN_STRING_FREE(value);
RUBY_RETURN_STRING_FREE(result);
}
/*
@@ -4899,6 +5192,16 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_const(ruby_mWeechat, "WEECHAT_HOTLIST_PRIVATE", rb_str_new2(WEECHAT_HOTLIST_PRIVATE));
rb_define_const(ruby_mWeechat, "WEECHAT_HOTLIST_HIGHLIGHT", rb_str_new2(WEECHAT_HOTLIST_HIGHLIGHT));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_OK", INT2NUM(WEECHAT_HOOK_CONNECT_OK));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", INT2NUM(WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", INT2NUM(WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", INT2NUM(WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_PROXY_ERROR", INT2NUM(WEECHAT_HOOK_CONNECT_PROXY_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", INT2NUM(WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", INT2NUM(WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", INT2NUM(WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_CONNECT_MEMORY_ERROR", INT2NUM(WEECHAT_HOOK_CONNECT_MEMORY_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_STRING", rb_str_new2(WEECHAT_HOOK_SIGNAL_STRING));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_INT", rb_str_new2(WEECHAT_HOOK_SIGNAL_INT));
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_POINTER", rb_str_new2(WEECHAT_HOOK_SIGNAL_POINTER));
@@ -4955,6 +5258,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "hook_command", &weechat_ruby_api_hook_command, 6);
rb_define_module_function (ruby_mWeechat, "hook_timer", &weechat_ruby_api_hook_timer, 4);
rb_define_module_function (ruby_mWeechat, "hook_fd", &weechat_ruby_api_hook_fd, 5);
rb_define_module_function (ruby_mWeechat, "hook_connect", &weechat_ruby_api_hook_connect, 6);
rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 5);
rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 2);
rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3);
@@ -4993,6 +5297,11 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "bar_remove", &weechat_ruby_api_bar_remove, 1);
rb_define_module_function (ruby_mWeechat, "command", &weechat_ruby_api_command, 2);
rb_define_module_function (ruby_mWeechat, "info_get", &weechat_ruby_api_info_get, 2);
rb_define_module_function (ruby_mWeechat, "infolist_new", &weechat_ruby_api_infolist_new, 0);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_integer", &weechat_ruby_api_infolist_new_var_integer, 3);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_string", &weechat_ruby_api_infolist_new_var_string, 3);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_pointer", &weechat_ruby_api_infolist_new_var_pointer, 3);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_time", &weechat_ruby_api_infolist_new_var_time, 3);
rb_define_module_function (ruby_mWeechat, "infolist_get", &weechat_ruby_api_infolist_get, 3);
rb_define_module_function (ruby_mWeechat, "infolist_next", &weechat_ruby_api_infolist_next, 1);
rb_define_module_function (ruby_mWeechat, "infolist_prev", &weechat_ruby_api_infolist_prev, 1);
+39
View File
@@ -680,6 +680,45 @@ script_api_hook_fd (struct t_weechat_plugin *weechat_plugin,
return new_hook;
}
/*
* script_api_hook_connect: hook a connection
* return new hook, NULL if error
*/
struct t_hook *
script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *address, int port, int sock, int ipv6,
void *gnutls_sess, const char *local_hostname,
int (*callback)(void *data, int status, const char *ip_address),
const char *function)
{
struct t_script_callback *new_script_callback;
struct t_hook *new_hook;
new_script_callback = script_callback_alloc ();
if (!new_script_callback)
return NULL;
new_hook = weechat_hook_connect (address, port, sock, ipv6, gnutls_sess,
local_hostname, callback,
new_script_callback);
if (!new_hook)
{
script_callback_free_data (new_script_callback);
free (new_script_callback);
return NULL;
}
new_script_callback->script = script;
new_script_callback->function = strdup (function);
new_script_callback->hook = new_hook;
script_callback_add (script, new_script_callback);
return new_hook;
}
/*
* script_api_hook_print: hook a print
* return new hook, NULL if error
+12
View File
@@ -105,6 +105,18 @@ extern struct t_hook *script_api_hook_fd (struct t_weechat_plugin *weechat_plugi
int flag_write, int flag_exception,
int (*callback)(void *data),
const char *function);
extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *address,
int port,
int sock,
int ipv6,
void *gnutls_sess,
const char *local_hostname,
int (*callback)(void *data,
int status,
const char *ip_address),
const char *function);
extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
+1 -1
View File
@@ -328,7 +328,7 @@ struct t_weechat_plugin
const char *local_hostname,
int (*callback)(void *data,
int status,
char *ip_address),
const char *ip_address),
void *callback_data);
struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer,