1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 20:36:38 +02:00

core: remove unneeded whitespace

This commit is contained in:
Sebastien Helleu
2011-10-26 20:37:03 +02:00
parent 2a83aae85e
commit dfdf42e27b
176 changed files with 13151 additions and 13151 deletions
File diff suppressed because it is too large Load Diff
+68 -68
View File
@@ -102,7 +102,7 @@ SCM
weechat_guile_catch (void *procedure, void *data)
{
SCM value;
value = scm_internal_catch (SCM_BOOL_T,
(scm_t_catch_body)procedure,
data,
@@ -119,9 +119,9 @@ SCM
weechat_guile_scm_call_1 (void *proc)
{
struct t_guile_function *guile_function;
guile_function = (struct t_guile_function *)proc;
return scm_call_1 (guile_function->proc, guile_function->args);
}
@@ -135,7 +135,7 @@ weechat_guile_exec_function (const char *function, SCM args)
{
SCM func, func2, value;
struct t_guile_function guile_function;
func = weechat_guile_catch (scm_c_lookup, (void *)function);
func2 = weechat_guile_catch (scm_variable_ref, func);
@@ -148,8 +148,8 @@ weechat_guile_exec_function (const char *function, SCM args)
else
{
value = weechat_guile_catch (scm_call_0, func2);
}
}
return value;
}
@@ -165,16 +165,16 @@ weechat_guile_hashtable_map_cb (void *data,
const void *value)
{
SCM *alist, pair, list;
/* make C compiler happy */
(void) hashtable;
alist = (SCM *)data;
pair = scm_cons (scm_from_locale_string ((const char *)key),
scm_from_locale_string ((const char *)value));
list = scm_list_1 (pair);
*alist = scm_append (scm_list_2 (*alist, list));
}
@@ -186,13 +186,13 @@ SCM
weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
{
SCM alist;
alist = scm_list_n (SCM_UNDEFINED);
weechat_hashtable_map (hashtable,
&weechat_guile_hashtable_map_cb,
&alist);
return alist;
}
@@ -210,7 +210,7 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
struct t_hashtable *hashtable;
int length, i;
SCM pair;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -218,7 +218,7 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
NULL);
if (!hashtable)
return NULL;
length = scm_to_int (scm_length (alist));
for (i = 0; i < length; i++)
{
@@ -229,7 +229,7 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (1))));
}
return hashtable;
}
@@ -246,11 +246,11 @@ weechat_guile_exec (struct t_plugin_script *script,
SCM argv_list, rc;
void *argv2[17], *ret_value;
int i, argc, *ret_int;
old_guile_current_script = guile_current_script;
scm_set_current_module ((SCM)(script->interpreter));
guile_current_script = script;
if (argv && argv[0])
{
argc = strlen (format);
@@ -288,9 +288,9 @@ weechat_guile_exec (struct t_plugin_script *script,
{
rc = weechat_guile_exec_function (function, NULL);
}
ret_value = NULL;
if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (scm_is_string (rc)))
{
ret_value = scm_to_locale_string (rc);
@@ -314,19 +314,19 @@ weechat_guile_exec (struct t_plugin_script *script,
"a valid value"),
weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
}
if (ret_value == NULL)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: error in function \"%s\""),
weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
}
if (old_guile_current_script)
scm_set_current_module ((SCM)(old_guile_current_script->interpreter));
guile_current_script = old_guile_current_script;
return ret_value;
}
@@ -350,28 +350,28 @@ weechat_guile_load (const char *filename)
{
char *filename2, *ptr_base_name, *base_name;
SCM module;
if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
GUILE_PLUGIN_NAME, filename);
}
guile_current_script = NULL;
guile_registered_script = NULL;
guile_current_script_filename = filename;
filename2 = strdup (filename);
if (!filename2)
return 0;
ptr_base_name = basename (filename2);
base_name = strdup (ptr_base_name);
module = scm_c_define_module (base_name,
&weechat_guile_module_init_script, filename2);
free (filename2);
if (!guile_registered_script)
{
weechat_printf (NULL,
@@ -380,12 +380,12 @@ weechat_guile_load (const char *filename)
weechat_prefix ("error"), GUILE_PLUGIN_NAME, filename);
return 0;
}
scm_gc_protect_object (module);
guile_current_script = guile_registered_script;
guile_current_script->interpreter = (void *)module;
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
@@ -395,7 +395,7 @@ weechat_guile_load (const char *filename)
guile_current_script,
&weechat_guile_api_buffer_input_data_cb,
&weechat_guile_api_buffer_close_cb);
return 1;
}
@@ -408,7 +408,7 @@ weechat_guile_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_guile_load (filename);
}
@@ -420,14 +420,14 @@ void
weechat_guile_unload (struct t_plugin_script *script)
{
int *rc;
if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
GUILE_PLUGIN_NAME, script->name);
}
if (script->shutdown_func && script->shutdown_func[0])
{
rc = (int *)weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT,
@@ -435,13 +435,13 @@ weechat_guile_unload (struct t_plugin_script *script)
if (rc)
free (rc);
}
scm_gc_unprotect_object (script->interpreter);
if (guile_current_script == script)
guile_current_script = (guile_current_script->prev_script) ?
guile_current_script->prev_script : guile_current_script->next_script;
script_remove (weechat_guile_plugin, &guile_scripts, &last_guile_script,
script);
}
@@ -454,7 +454,7 @@ void
weechat_guile_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
if (ptr_script)
{
@@ -493,7 +493,7 @@ weechat_guile_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
if (ptr_script)
{
@@ -526,7 +526,7 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
{
char *path_script;
SCM value;
/* make C compiler happy */
(void) data;
(void) buffer;
@@ -613,7 +613,7 @@ weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
"guile");
}
}
return WEECHAT_RC_OK;
}
@@ -630,9 +630,9 @@ weechat_guile_completion_cb (void *data, const char *completion_item,
(void) data;
(void) completion_item;
(void) buffer;
script_completion (weechat_guile_plugin, completion, guile_scripts);
return WEECHAT_RC_OK;
}
@@ -646,17 +646,17 @@ weechat_guile_infolist_cb (void *data, const char *infolist_name,
{
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "guile_script") == 0)
{
return script_infolist_list_scripts (weechat_guile_plugin,
guile_scripts, pointer,
arguments);
}
return NULL;
}
@@ -673,13 +673,13 @@ weechat_guile_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, GUILE_PLUGIN_NAME) == 0))
{
script_print_log (weechat_guile_plugin, guile_scripts);
}
return WEECHAT_RC_OK;
}
@@ -697,10 +697,10 @@ weechat_guile_signal_buffer_closed_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (guile_scripts, signal_data);
return WEECHAT_RC_OK;
}
@@ -732,7 +732,7 @@ weechat_guile_timer_action_cb (void *data, int remaining_calls)
&guile_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -748,7 +748,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
{
/* make C compiler happy */
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (strcmp (signal, "guile_script_install") == 0)
@@ -768,7 +768,7 @@ weechat_guile_signal_script_action_cb (void *data, const char *signal,
&guile_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -781,7 +781,7 @@ weechat_guile_port_fill_input (SCM port)
{
/* make C compiler happy */
(void) port;
return ' ';
}
@@ -794,10 +794,10 @@ weechat_guile_port_write (SCM port, const void *data, size_t size)
{
char *new_stdout;
int length_stdout;
/* make C compiler happy */
(void) port;
/* concatenate str to guile_stdout */
if (guile_stdout)
{
@@ -821,7 +821,7 @@ weechat_guile_port_write (SCM port, const void *data, size_t size)
guile_stdout[size] = '\0';
}
}
/* flush stdout if at least "\n" is in string */
if (guile_stdout && (strchr (guile_stdout, '\n')))
weechat_guile_stdout_flush ();
@@ -835,17 +835,17 @@ int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
weechat_guile_plugin = plugin;
guile_stdout = NULL;
scm_init_guile ();
guile_module_weechat = scm_c_define_module ("weechat",
&weechat_guile_api_module_init,
NULL);
scm_c_use_module ("weechat");
scm_gc_protect_object (guile_module_weechat);
guile_quiet = 1;
script_init (weechat_guile_plugin,
argc,
@@ -858,10 +858,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
&weechat_guile_signal_script_action_cb,
&weechat_guile_load_cb);
guile_quiet = 0;
script_display_short_list (weechat_guile_plugin,
guile_scripts);
/* init ok */
return WEECHAT_RC_OK;
}
@@ -877,15 +877,15 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
guile_quiet = 1;
script_end (plugin, &guile_scripts, &weechat_guile_unload_all);
guile_quiet = 0;
/* unprotect module */
scm_gc_unprotect_object (guile_module_weechat);
/* free some data */
if (guile_action_install_list)
free (guile_action_install_list);
if (guile_action_remove_list)
free (guile_action_remove_list);
return WEECHAT_RC_OK;
}
File diff suppressed because it is too large Load Diff
+53 -53
View File
@@ -81,12 +81,12 @@ weechat_lua_hashtable_map_cb (void *data,
const void *value)
{
lua_State *interpreter;
/* make C compiler happy */
(void) hashtable;
interpreter = (lua_State *)data;
lua_pushstring (interpreter, (char *)key);
lua_pushstring (interpreter, (char *)value);
lua_rawset (interpreter, -3);
@@ -100,7 +100,7 @@ void
weechat_lua_pushhashtable (lua_State *interpreter, struct t_hashtable *hashtable)
{
lua_newtable (interpreter);
weechat_hashtable_map (hashtable,
&weechat_lua_hashtable_map_cb,
interpreter);
@@ -118,7 +118,7 @@ struct t_hashtable *
weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
{
struct t_hashtable *hashtable;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -126,7 +126,7 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
NULL);
if (!hashtable)
return NULL;
lua_pushnil (interpreter);
while (lua_next (interpreter, index - 1) != 0)
{
@@ -136,7 +136,7 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
/* remove value from stack (keep key for next iteration) */
lua_pop (interpreter, 1);
}
return hashtable;
}
@@ -153,10 +153,10 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
int argc, i, *ret_i;
lua_State *old_lua_current_interpreter;
struct t_plugin_script *old_lua_current_script;
old_lua_current_interpreter = lua_current_interpreter;
lua_current_interpreter = script->interpreter;
lua_getglobal (lua_current_interpreter, function);
old_lua_current_script = lua_current_script;
@@ -182,7 +182,7 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
}
}
}
if (lua_pcall (lua_current_interpreter, argc, 1, 0) != 0)
{
weechat_printf (NULL,
@@ -196,7 +196,7 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
lua_current_interpreter = old_lua_current_interpreter;
return NULL;
}
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
ret_value = strdup ((char *) lua_tostring (lua_current_interpreter, -1));
else if (ret_type == WEECHAT_SCRIPT_EXEC_INT)
@@ -218,10 +218,10 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
lua_current_interpreter = old_lua_current_interpreter;
return NULL;
}
lua_current_script = old_lua_current_script;
lua_current_interpreter = old_lua_current_interpreter;
return ret_value;
}
@@ -242,7 +242,7 @@ weechat_lua_load (const char *filename)
"io.stdout = weechat_outputs\n"
"io.stderr = weechat_outputs\n"
};
if ((fp = fopen (filename, "r")) == NULL)
{
weechat_printf (NULL,
@@ -250,17 +250,17 @@ weechat_lua_load (const char *filename)
weechat_prefix ("error"), LUA_PLUGIN_NAME, filename);
return 0;
}
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
LUA_PLUGIN_NAME, filename);
}
lua_current_script = NULL;
lua_registered_script = NULL;
lua_current_interpreter = lua_open ();
if (lua_current_interpreter == NULL)
@@ -283,7 +283,7 @@ weechat_lua_load (const char *filename)
luaopen_io (lua_current_interpreter);
luaopen_debug (lua_current_interpreter);
#endif
luaL_openlib (lua_current_interpreter, "weechat", weechat_lua_api_funcs, 0);
#ifdef LUA_VERSION_NUM
@@ -297,9 +297,9 @@ weechat_lua_load (const char *filename)
"and stderr"),
weechat_prefix ("error"), LUA_PLUGIN_NAME);
}
lua_current_script_filename = filename;
if (luaL_loadfile (lua_current_interpreter, filename) != 0)
{
weechat_printf (NULL,
@@ -313,7 +313,7 @@ weechat_lua_load (const char *filename)
fclose (fp);
return 0;
}
if (lua_pcall (lua_current_interpreter, 0, 0, 0) != 0)
{
weechat_printf (NULL,
@@ -333,7 +333,7 @@ weechat_lua_load (const char *filename)
return 0;
}
fclose (fp);
if (!lua_registered_script)
{
weechat_printf (NULL,
@@ -344,9 +344,9 @@ weechat_lua_load (const char *filename)
return 0;
}
lua_current_script = lua_registered_script;
lua_current_script->interpreter = (lua_State *) lua_current_interpreter;
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
@@ -356,7 +356,7 @@ weechat_lua_load (const char *filename)
lua_current_script,
&weechat_lua_api_buffer_input_data_cb,
&weechat_lua_api_buffer_close_cb);
return 1;
}
@@ -369,7 +369,7 @@ weechat_lua_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_lua_load (filename);
}
@@ -382,14 +382,14 @@ weechat_lua_unload (struct t_plugin_script *script)
{
int *rc;
void *interpreter;
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
LUA_PLUGIN_NAME, script->name);
}
if (script->shutdown_func && script->shutdown_func[0])
{
rc = (int *)weechat_lua_exec (script,
@@ -399,15 +399,15 @@ weechat_lua_unload (struct t_plugin_script *script)
if (rc)
free (rc);
}
interpreter = script->interpreter;
if (lua_current_script == script)
lua_current_script = (lua_current_script->prev_script) ?
lua_current_script->prev_script : lua_current_script->next_script;
script_remove (weechat_lua_plugin, &lua_scripts, &last_lua_script, script);
lua_close (interpreter);
}
@@ -419,7 +419,7 @@ void
weechat_lua_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_lua_plugin, lua_scripts, name);
if (ptr_script)
{
@@ -445,7 +445,7 @@ weechat_lua_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_lua_plugin, lua_scripts, name);
if (ptr_script)
{
@@ -490,11 +490,11 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
script_display_list (weechat_lua_plugin, lua_scripts,
@@ -565,7 +565,7 @@ weechat_lua_command_cb (void *data, struct t_gui_buffer *buffer,
weechat_prefix ("error"), LUA_PLUGIN_NAME, "lua");
}
}
return WEECHAT_RC_OK;
}
@@ -582,9 +582,9 @@ weechat_lua_completion_cb (void *data, const char *completion_item,
(void) data;
(void) completion_item;
(void) buffer;
script_completion (weechat_lua_plugin, completion, lua_scripts);
return WEECHAT_RC_OK;
}
@@ -598,17 +598,17 @@ weechat_lua_infolist_cb (void *data, const char *infolist_name,
{
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "lua_script") == 0)
{
return script_infolist_list_scripts (weechat_lua_plugin,
lua_scripts, pointer,
arguments);
}
return NULL;
}
@@ -624,13 +624,13 @@ weechat_lua_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, LUA_PLUGIN_NAME) == 0))
{
script_print_log (weechat_lua_plugin, lua_scripts);
}
return WEECHAT_RC_OK;
}
@@ -646,10 +646,10 @@ weechat_lua_signal_buffer_closed_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (lua_scripts, signal_data);
return WEECHAT_RC_OK;
}
@@ -681,7 +681,7 @@ weechat_lua_timer_action_cb (void *data, int remaining_calls)
&lua_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -697,7 +697,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
{
/* make C compiler happy */
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (strcmp (signal, "lua_script_install") == 0)
@@ -717,7 +717,7 @@ weechat_lua_signal_script_action_cb (void *data, const char *signal,
&lua_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -729,7 +729,7 @@ int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
weechat_lua_plugin = plugin;
lua_quiet = 1;
script_init (weechat_lua_plugin,
argc,
@@ -742,10 +742,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
&weechat_lua_signal_script_action_cb,
&weechat_lua_load_cb);
lua_quiet = 0;
script_display_short_list (weechat_lua_plugin,
lua_scripts);
/* init ok */
return WEECHAT_RC_OK;
}
@@ -761,6 +761,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
lua_quiet = 1;
script_end (plugin, &lua_scripts, &weechat_lua_unload_all);
lua_quiet = 0;
return WEECHAT_RC_OK;
}
File diff suppressed because it is too large Load Diff
+70 -70
View File
@@ -138,12 +138,12 @@ weechat_perl_hashtable_map_cb (void *data,
const void *value)
{
HV *hash;
/* make C compiler happy */
(void) hashtable;
hash = (HV *)data;
(void) hv_store (hash, (char *)key, strlen ((char *)key),
newSVpv ((char *)value, 0), 0);
}
@@ -156,15 +156,15 @@ HV *
weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable)
{
HV *hash;
hash = (HV *)newHV ();
if (!hash)
return NULL;
weechat_hashtable_map (hashtable,
&weechat_perl_hashtable_map_cb,
hash);
return hash;
}
@@ -184,7 +184,7 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
SV *value;
char *str_key;
I32 retlen;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -192,7 +192,7 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
NULL);
if (!hashtable)
return NULL;
if ((hash) && SvROK(hash) && SvRV(hash) && (SvTYPE(SvRV(hash)) == SVt_PVHV))
{
hash2 = (HV *) SvRV(hash);
@@ -202,7 +202,7 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
}
}
return hashtable;
}
@@ -225,10 +225,10 @@ weechat_perl_exec (struct t_plugin_script *script,
#ifdef MULTIPLICITY
void *old_context;
#endif
old_perl_current_script = perl_current_script;
perl_current_script = script;
#ifdef MULTIPLICITY
(void) length;
func = (char *) function;
@@ -245,11 +245,11 @@ weechat_perl_exec (struct t_plugin_script *script,
(char *) ((script->interpreter) ? script->interpreter : perl_main),
function);
#endif
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
if (format && format[0])
{
@@ -273,12 +273,12 @@ weechat_perl_exec (struct t_plugin_script *script,
}
PUTBACK;
count = perl_call_pv (func, G_EVAL | G_SCALAR);
ret_value = NULL;
mem_err = 1;
SPAGAIN;
if (SvTRUE (ERRSV))
{
weechat_printf (NULL,
@@ -334,7 +334,7 @@ weechat_perl_exec (struct t_plugin_script *script,
PUTBACK;
FREETMPS;
LEAVE;
perl_current_script = old_perl_current_script;
#ifdef MULTIPLICITY
PERL_SET_CONTEXT (old_context);
@@ -350,7 +350,7 @@ weechat_perl_exec (struct t_plugin_script *script,
weechat_prefix ("error"), PERL_PLUGIN_NAME, function);
return NULL;
}
return ret_value;
}
@@ -366,13 +366,13 @@ weechat_perl_load (const char *filename)
int *eval;
struct stat buf;
void *perl_argv[2];
#ifdef MULTIPLICITY
PerlInterpreter *perl_current_interpreter;
#else
char pkgname[64];
#endif
temp_script.filename = NULL;
temp_script.interpreter = NULL;
temp_script.name = NULL;
@@ -382,7 +382,7 @@ weechat_perl_load (const char *filename)
temp_script.description = NULL;
temp_script.shutdown_func = NULL;
temp_script.charset = NULL;
if (stat (filename, &buf) != 0)
{
weechat_printf (NULL,
@@ -390,21 +390,21 @@ weechat_perl_load (const char *filename)
weechat_prefix ("error"), PERL_PLUGIN_NAME, filename);
return 0;
}
if ((weechat_perl_plugin->debug >= 1) || !perl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
PERL_PLUGIN_NAME, filename);
}
perl_current_script = NULL;
perl_current_script_filename = filename;
perl_registered_script = NULL;
#ifdef MULTIPLICITY
perl_current_interpreter = perl_alloc();
if (!perl_current_interpreter)
{
weechat_printf (NULL,
@@ -413,13 +413,13 @@ weechat_perl_load (const char *filename)
weechat_prefix ("error"), PERL_PLUGIN_NAME);
return 0;
}
PERL_SET_CONTEXT (perl_current_interpreter);
perl_construct (perl_current_interpreter);
temp_script.interpreter = (PerlInterpreter *) perl_current_interpreter;
perl_parse (perl_current_interpreter, weechat_perl_api_init,
perl_args_count, perl_args, NULL);
eval_pv (perl_weechat_code, TRUE);
perl_argv[0] = (void *)filename;
eval = weechat_perl_exec (&temp_script,
@@ -445,7 +445,7 @@ weechat_perl_load (const char *filename)
weechat_prefix ("error"), PERL_PLUGIN_NAME, filename);
return 0;
}
if (*eval != 0)
{
if (*eval == 2)
@@ -499,9 +499,9 @@ weechat_perl_load (const char *filename)
free (eval);
return 0;
}
free (eval);
if (!perl_registered_script)
{
weechat_printf (NULL,
@@ -515,13 +515,13 @@ weechat_perl_load (const char *filename)
return 0;
}
perl_current_script = perl_registered_script;
#ifdef MULTIPLICITY
perl_current_script->interpreter = (PerlInterpreter *)perl_current_interpreter;
#else
perl_current_script->interpreter = strdup (pkgname);
#endif
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
@@ -531,7 +531,7 @@ weechat_perl_load (const char *filename)
perl_current_script,
&weechat_perl_api_buffer_input_data_cb,
&weechat_perl_api_buffer_close_cb);
return 1;
}
@@ -544,7 +544,7 @@ weechat_perl_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_perl_load (filename);
}
@@ -564,13 +564,13 @@ weechat_perl_unload (struct t_plugin_script *script)
weechat_gettext ("%s: unloading script \"%s\""),
PERL_PLUGIN_NAME, script->name);
}
#ifdef MULTIPLICITY
PERL_SET_CONTEXT (script->interpreter);
#else
eval_pv (script->interpreter, TRUE);
#endif
if (script->shutdown_func && script->shutdown_func[0])
{
rc = (int *)weechat_perl_exec (script,
@@ -580,16 +580,16 @@ weechat_perl_unload (struct t_plugin_script *script)
if (rc)
free (rc);
}
interpreter = script->interpreter;
if (perl_current_script == script)
perl_current_script = (perl_current_script->prev_script) ?
perl_current_script->prev_script : perl_current_script->next_script;
script_remove (weechat_perl_plugin, &perl_scripts, &last_perl_script,
script);
#ifdef MULTIPLICITY
if (interpreter)
{
@@ -610,7 +610,7 @@ void
weechat_perl_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_perl_plugin, perl_scripts, name);
if (ptr_script)
{
@@ -649,7 +649,7 @@ weechat_perl_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_perl_plugin, perl_scripts, name);
if (ptr_script)
{
@@ -681,11 +681,11 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
script_display_list (weechat_perl_plugin, perl_scripts,
@@ -756,7 +756,7 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
weechat_prefix ("error"), PERL_PLUGIN_NAME, "perl");
}
}
return WEECHAT_RC_OK;
}
@@ -773,9 +773,9 @@ weechat_perl_completion_cb (void *data, const char *completion_item,
(void) data;
(void) completion_item;
(void) buffer;
script_completion (weechat_perl_plugin, completion, perl_scripts);
return WEECHAT_RC_OK;
}
@@ -789,17 +789,17 @@ weechat_perl_infolist_cb (void *data, const char *infolist_name,
{
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "perl_script") == 0)
{
return script_infolist_list_scripts (weechat_perl_plugin,
perl_scripts, pointer,
arguments);
}
return NULL;
}
@@ -815,13 +815,13 @@ weechat_perl_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, PERL_PLUGIN_NAME) == 0))
{
script_print_log (weechat_perl_plugin, perl_scripts);
}
return WEECHAT_RC_OK;
}
@@ -837,10 +837,10 @@ weechat_perl_signal_buffer_closed_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (perl_scripts, signal_data);
return WEECHAT_RC_OK;
}
@@ -872,7 +872,7 @@ weechat_perl_timer_action_cb (void *data, int remaining_calls)
&perl_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -888,7 +888,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
{
/* make C compiler happy */
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (strcmp (signal, "perl_script_install") == 0)
@@ -908,7 +908,7 @@ weechat_perl_signal_script_action_cb (void *data, const char *signal,
&perl_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -927,9 +927,9 @@ weechat_perl_signal_quit_upgrade_cb (void *data, const char *signal,
(void) signal;
(void) type_data;
(void) signal_data;
perl_quit_or_upgrade = 1;
return WEECHAT_RC_OK;
}
@@ -951,12 +951,12 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
(void) perl_env;
PERL_SYS_INIT3 (&a, (char ***)&perl_args_local, (char ***)&perl_env);
#endif
weechat_perl_plugin = plugin;
#ifndef MULTIPLICITY
perl_main = perl_alloc ();
if (!perl_main)
{
weechat_printf (NULL,
@@ -965,13 +965,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
PERL_PLUGIN_NAME);
return WEECHAT_RC_ERROR;
}
perl_construct (perl_main);
perl_parse (perl_main, weechat_perl_api_init, perl_args_count,
perl_args, NULL);
eval_pv (perl_weechat_code, TRUE);
#endif
perl_quiet = 1;
script_init (weechat_perl_plugin,
argc,
@@ -984,13 +984,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
&weechat_perl_signal_script_action_cb,
&weechat_perl_load_cb);
perl_quiet = 0;
script_display_short_list (weechat_perl_plugin,
perl_scripts);
weechat_hook_signal ("quit", &weechat_perl_signal_quit_upgrade_cb, NULL);
weechat_hook_signal ("upgrade", &weechat_perl_signal_quit_upgrade_cb, NULL);
/* init ok */
return WEECHAT_RC_OK;
}
@@ -1006,7 +1006,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
perl_quiet = 1;
script_end (plugin, &perl_scripts, &weechat_perl_unload_all);
perl_quiet = 0;
#ifndef MULTIPLICITY
/* free perl intepreter */
if (perl_main)
@@ -1016,7 +1016,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
perl_main = NULL;
}
#endif
#if defined(PERL_SYS_TERM) && !defined(__FreeBSD__) && !defined(WIN32) && !defined(__CYGWIN__)
/*
* we call this function on all OS, but NOT on FreeBSD or Cygwin,
@@ -1025,6 +1025,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
if (perl_quit_or_upgrade)
PERL_SYS_TERM ();
#endif
return WEECHAT_RC_OK;
}
File diff suppressed because it is too large Load Diff
+92 -92
View File
@@ -83,12 +83,12 @@ weechat_python_set_python2_bin ()
char *versions[] = { "2", "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", NULL };
int num_paths, i, j, rc;
struct stat stat_buf;
python2_bin = NULL;
dir_separator = weechat_info_get ("dir_separator", "");
path = getenv ("PATH");
if (dir_separator && path)
{
paths = weechat_string_split (path, ":", 0, 0, &num_paths);
@@ -114,7 +114,7 @@ weechat_python_set_python2_bin ()
weechat_string_free_split (paths);
}
}
if (!python2_bin)
python2_bin = strdup ("python");
}
@@ -134,14 +134,14 @@ weechat_python_hashtable_map_cb (void *data,
/* make C compiler happy */
(void) hashtable;
dict = (PyObject *)data;
dict_key = Py_BuildValue ("s", (const char *)key);
dict_value = Py_BuildValue ("s", (const char *)value);
PyDict_SetItem (dict, dict_key, dict_value);
Py_DECREF (dict_key);
Py_DECREF (dict_value);
}
@@ -155,18 +155,18 @@ PyObject *
weechat_python_hashtable_to_dict (struct t_hashtable *hashtable)
{
PyObject *dict;
dict = PyDict_New ();
if (!dict)
{
Py_INCREF(Py_None);
return Py_None;
}
weechat_hashtable_map (hashtable,
&weechat_python_hashtable_map_cb,
dict);
return dict;
}
@@ -186,7 +186,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
PyObject *key, *value;
Py_ssize_t pos;
char *str_key, *str_value;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -194,7 +194,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
NULL);
if (!hashtable)
return NULL;
pos = 0;
while (PyDict_Next (dict, &pos, &key, &value))
{
@@ -202,7 +202,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
str_value = PyString_AsString (value);
weechat_hashtable_set (hashtable, str_key, str_value);
}
return hashtable;
}
@@ -223,9 +223,9 @@ weechat_python_exec (struct t_plugin_script *script,
PyObject *rc;
void *argv2[16], *ret_value;
int i, argc, *ret_int;
/* PyEval_AcquireLock (); */
old_python_current_script = python_current_script;
old_interpreter = NULL;
if (script->interpreter)
@@ -233,11 +233,11 @@ weechat_python_exec (struct t_plugin_script *script,
old_interpreter = PyThreadState_Swap (NULL);
PyThreadState_Swap (script->interpreter);
}
evMain = PyImport_AddModule ((char *) "__main__");
evDict = PyModule_GetDict (evMain);
evFunc = PyDict_GetItemString (evDict, function);
if ( !(evFunc && PyCallable_Check (evFunc)) )
{
weechat_printf (NULL,
@@ -248,7 +248,7 @@ weechat_python_exec (struct t_plugin_script *script,
PyThreadState_Swap (old_interpreter);
return NULL;
}
python_current_script = script;
if (argv && argv[0])
@@ -272,16 +272,16 @@ weechat_python_exec (struct t_plugin_script *script,
{
rc = PyObject_CallFunction (evFunc, NULL);
}
ret_value = NULL;
/*
* ugly hack : rc = NULL while 'return weechat.WEECHAT_RC_OK ....
* because of '#define WEECHAT_RC_OK 0'
*/
if (rc == NULL)
rc = PyInt_FromLong (0);
if (PyErr_Occurred())
{
PyErr_Print ();
@@ -316,21 +316,21 @@ weechat_python_exec (struct t_plugin_script *script,
"a valid value"),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function);
}
if (ret_value == NULL)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: error in function \"%s\""),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, function);
}
/* PyEval_ReleaseThread (python_current_script->interpreter); */
python_current_script = old_python_current_script;
if (old_interpreter)
PyThreadState_Swap (old_interpreter);
return ret_value;
}
@@ -342,10 +342,10 @@ static PyObject *
weechat_python_output (PyObject *self, PyObject *args)
{
char *msg, *m, *p;
/* make C compiler happy */
(void) self;
msg = NULL;
if (!PyArg_ParseTuple (args, "s", &msg))
@@ -385,7 +385,7 @@ weechat_python_output (PyObject *self, PyObject *args)
else
strcat (python_buffer_output, m);
}
Py_INCREF(Py_None);
return Py_None;
}
@@ -415,7 +415,7 @@ weechat_python_load (const char *filename)
const char *weechat_home;
char *p_home;
int len;
if ((fp = fopen (filename, "r")) == NULL)
{
weechat_printf (NULL,
@@ -423,21 +423,21 @@ weechat_python_load (const char *filename)
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename);
return 0;
}
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
PYTHON_PLUGIN_NAME, filename);
}
python_current_script = NULL;
python_registered_script = NULL;
/* PyEval_AcquireLock (); */
python_current_interpreter = Py_NewInterpreter ();
PySys_SetArgv(1, argv);
if (python_current_interpreter == NULL)
{
weechat_printf (NULL,
@@ -448,9 +448,9 @@ weechat_python_load (const char *filename)
/* PyEval_ReleaseLock (); */
return 0;
}
PyThreadState_Swap (python_current_interpreter);
weechat_module = Py_InitModule ("weechat", weechat_python_funcs);
if ( weechat_module == NULL)
@@ -460,7 +460,7 @@ weechat_python_load (const char *filename)
"module"),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
fclose (fp);
Py_EndInterpreter (python_current_interpreter);
/* PyEval_ReleaseLock (); */
@@ -486,13 +486,13 @@ weechat_python_load (const char *filename)
free (p_home);
}
}
/* define some constants */
weechat_dict = PyModule_GetDict(weechat_module);
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK", PyInt_FromLong((long) WEECHAT_RC_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_EAT", PyInt_FromLong((long) WEECHAT_RC_OK_EAT));
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_ERROR", PyInt_FromLong((long) WEECHAT_RC_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_OK", PyInt_FromLong((long) WEECHAT_CONFIG_READ_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_MEMORY_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_READ_MEMORY_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", PyInt_FromLong((long) WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
@@ -507,19 +507,19 @@ weechat_python_load (const char *filename)
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_RESET));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_OPTION_UNSET_ERROR", PyInt_FromLong((long) WEECHAT_CONFIG_OPTION_UNSET_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_SORT", PyString_FromString(WEECHAT_LIST_POS_SORT));
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_BEGINNING", PyString_FromString(WEECHAT_LIST_POS_BEGINNING));
PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_END", PyString_FromString(WEECHAT_LIST_POS_END));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOTLIST_LOW", PyString_FromString(WEECHAT_HOTLIST_LOW));
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_PROCESS_RUNNING", PyInt_FromLong((long) WEECHAT_HOOK_PROCESS_RUNNING));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_PROCESS_ERROR", PyInt_FromLong((long) WEECHAT_HOOK_PROCESS_ERROR));
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));
@@ -529,11 +529,11 @@ weechat_python_load (const char *filename)
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));
PyDict_SetItemString(weechat_dict, "WEECHAT_HOOK_SIGNAL_POINTER", PyString_FromString(WEECHAT_HOOK_SIGNAL_POINTER));
weechat_outputs = Py_InitModule("weechatOutputs",
weechat_python_output_funcs);
if (weechat_outputs == NULL)
@@ -558,9 +558,9 @@ weechat_python_load (const char *filename)
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
}
}
python_current_script_filename = filename;
if (PyRun_SimpleFile (fp, filename) != 0)
{
weechat_printf (NULL,
@@ -570,7 +570,7 @@ weechat_python_load (const char *filename)
if (PyErr_Occurred ())
PyErr_Print ();
/* if script was registered, removing from list */
if (python_current_script != NULL)
{
@@ -578,10 +578,10 @@ weechat_python_load (const char *filename)
&python_scripts, &last_python_script,
python_current_script);
}
Py_EndInterpreter (python_current_interpreter);
/* PyEval_ReleaseLock (); */
return 0;
}
@@ -589,14 +589,14 @@ weechat_python_load (const char *filename)
PyErr_Print ();
fclose (fp);
if (!python_registered_script)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"register\" not "
"found (or failed) in file \"%s\""),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME, filename);
if (PyErr_Occurred ())
PyErr_Print ();
Py_EndInterpreter (python_current_interpreter);
@@ -605,10 +605,10 @@ weechat_python_load (const char *filename)
return 0;
}
python_current_script = python_registered_script;
python_current_script->interpreter = (PyThreadState *) python_current_interpreter;
/* PyEval_ReleaseThread (python_current_script->interpreter); */
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
@@ -618,7 +618,7 @@ weechat_python_load (const char *filename)
python_current_script,
&weechat_python_api_buffer_input_data_cb,
&weechat_python_api_buffer_close_cb);
return 1;
}
@@ -631,7 +631,7 @@ weechat_python_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_python_load (filename);
}
@@ -645,14 +645,14 @@ weechat_python_unload (struct t_plugin_script *script)
int *rc;
void *interpreter;
PyThreadState *old_interpreter;
if ((weechat_python_plugin->debug >= 1) || !python_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
PYTHON_PLUGIN_NAME, script->name);
}
if (script->shutdown_func && script->shutdown_func[0])
{
rc = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT,
@@ -660,20 +660,20 @@ weechat_python_unload (struct t_plugin_script *script)
if (rc)
free (rc);
}
old_interpreter = PyThreadState_Swap (NULL);
interpreter = script->interpreter;
if (python_current_script == script)
python_current_script = (python_current_script->prev_script) ?
python_current_script->prev_script : python_current_script->next_script;
script_remove (weechat_python_plugin, &python_scripts, &last_python_script,
script);
PyThreadState_Swap (interpreter);
Py_EndInterpreter (interpreter);
if (old_interpreter)
PyThreadState_Swap (old_interpreter);
}
@@ -686,7 +686,7 @@ void
weechat_python_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_python_plugin, python_scripts, name);
if (ptr_script)
{
@@ -725,7 +725,7 @@ weechat_python_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_python_plugin, python_scripts, name);
if (ptr_script)
{
@@ -757,7 +757,7 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
/* make C compiler happy */
(void) data;
(void) buffer;
@@ -833,7 +833,7 @@ weechat_python_command_cb (void *data, struct t_gui_buffer *buffer,
"python");
}
}
return WEECHAT_RC_OK;
}
@@ -850,9 +850,9 @@ weechat_python_completion_cb (void *data, const char *completion_item,
(void) data;
(void) completion_item;
(void) buffer;
script_completion (weechat_python_plugin, completion, python_scripts);
return WEECHAT_RC_OK;
}
@@ -867,12 +867,12 @@ weechat_python_info_cb (void *data, const char *info_name,
/* make C compiler happy */
(void) data;
(void) arguments;
if (weechat_strcasecmp (info_name, "python2_bin") == 0)
{
return python2_bin;
}
return NULL;
}
@@ -886,17 +886,17 @@ weechat_python_infolist_cb (void *data, const char *infolist_name,
{
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "python_script") == 0)
{
return script_infolist_list_scripts (weechat_python_plugin,
python_scripts, pointer,
arguments);
}
return NULL;
}
@@ -913,13 +913,13 @@ weechat_python_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, PYTHON_PLUGIN_NAME) == 0))
{
script_print_log (weechat_python_plugin, python_scripts);
}
return WEECHAT_RC_OK;
}
@@ -937,10 +937,10 @@ weechat_python_signal_buffer_closed_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (python_scripts, signal_data);
return WEECHAT_RC_OK;
}
@@ -972,7 +972,7 @@ weechat_python_timer_action_cb (void *data, int remaining_calls)
&python_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -988,7 +988,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
{
/* make C compiler happy */
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (strcmp (signal, "python_script_install") == 0)
@@ -1008,7 +1008,7 @@ weechat_python_signal_script_action_cb (void *data, const char *signal,
&python_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -1020,7 +1020,7 @@ int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
weechat_python_plugin = plugin;
/*
* hook info to get path to python 2.x interpreter
* (some scripts using hook_process need that)
@@ -1030,10 +1030,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
N_("path to python 2.x interpreter"),
NULL,
&weechat_python_info_cb, NULL);
/* init stdout/stderr buffer */
python_buffer_output[0] = '\0';
Py_Initialize ();
if (Py_IsInitialized () == 0)
{
@@ -1043,7 +1043,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
return WEECHAT_RC_ERROR;
}
PyEval_InitThreads();
/* python_mainThreadState = PyThreadState_Swap(NULL); */
python_mainThreadState = PyEval_SaveThread();
@@ -1070,10 +1070,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
&weechat_python_signal_script_action_cb,
&weechat_python_load_cb);
python_quiet = 0;
script_display_short_list (weechat_python_plugin,
python_scripts);
/* init ok */
return WEECHAT_RC_OK;
}
@@ -1089,7 +1089,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
python_quiet = 1;
script_end (plugin, &python_scripts, &weechat_python_unload_all);
python_quiet = 0;
/* free Python interpreter */
if (python_mainThreadState != NULL)
{
@@ -1098,7 +1098,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
/* PyEval_ReleaseLock (); */
python_mainThreadState = NULL;
}
Py_Finalize ();
if (Py_IsInitialized () != 0)
{
@@ -1106,7 +1106,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
weechat_gettext ("%s%s: unable to free interpreter"),
weechat_prefix ("error"), PYTHON_PLUGIN_NAME);
}
/* free some data */
if (python2_bin)
free (python2_bin);
@@ -1114,6 +1114,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
free (python_action_install_list);
if (python_action_remove_list)
free (python_action_remove_list);
return WEECHAT_RC_OK;
}
File diff suppressed because it is too large Load Diff
+79 -79
View File
@@ -113,12 +113,12 @@ weechat_ruby_hashtable_map_cb (void *data,
const void *value)
{
VALUE *hash;
/* make C compiler happy */
(void) hashtable;
hash = (VALUE *)data;
rb_hash_aset (hash[0], rb_str_new2 ((char *)key),
rb_str_new2 ((char *)value));
}
@@ -139,7 +139,7 @@ weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable)
weechat_hashtable_map (hashtable,
&weechat_ruby_hashtable_map_cb,
&hash);
return hash;
}
@@ -147,7 +147,7 @@ int
weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
{
struct t_hashtable *hashtable;
hashtable = (struct t_hashtable *)arg;
if ((TYPE(key) == T_STRING) && (TYPE(value) == T_STRING))
{
@@ -169,7 +169,7 @@ struct t_hashtable *
weechat_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
{
struct t_hashtable *hashtable;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -177,10 +177,10 @@ weechat_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
NULL);
if (!hashtable)
return NULL;
rb_hash_foreach (hash, &weechat_ruby_hash_foreach_cb,
(unsigned long)hashtable);
return hashtable;
}
@@ -205,7 +205,7 @@ VALUE
rb_protect_funcall (VALUE recv, ID mid, int *state, int argc, VALUE *argv)
{
struct protect_call_arg arg;
arg.recv = recv;
arg.mid = mid;
arg.argc = argc;
@@ -227,7 +227,7 @@ weechat_ruby_print_exception (VALUE err)
char* cline;
char* err_msg;
char* err_class;
backtrace = rb_protect_funcall (err, rb_intern("backtrace"),
&ruby_error, 0, NULL);
@@ -238,7 +238,7 @@ weechat_ruby_print_exception (VALUE err)
&ruby_error, 0, NULL),
rb_intern("name"), &ruby_error, 0, NULL);
err_class = StringValuePtr(tmp2);
if (strcmp (err_class, "SyntaxError") == 0)
{
tmp3 = rb_inspect(err);
@@ -285,12 +285,12 @@ weechat_ruby_print_exception (VALUE err)
weechat_prefix ("error"), RUBY_PLUGIN_NAME,
cline);
}
if (cline)
free (cline);
}
}
return 0;
}
@@ -308,10 +308,10 @@ weechat_ruby_exec (struct t_plugin_script *script,
VALUE argv2[16];
void *ret_value;
struct t_plugin_script *old_ruby_current_script;
old_ruby_current_script = ruby_current_script;
ruby_current_script = script;
argc = 0;
if (format && format[0])
{
@@ -332,7 +332,7 @@ weechat_ruby_exec (struct t_plugin_script *script,
}
}
}
if (argc > 0)
{
rc = rb_protect_funcall ((VALUE) script->interpreter,
@@ -345,19 +345,19 @@ weechat_ruby_exec (struct t_plugin_script *script,
rb_intern(function),
&ruby_error, 0, NULL);
}
if (ruby_error)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to run function \"%s\""),
weechat_prefix ("error"), RUBY_PLUGIN_NAME, function);
err = rb_gv_get("$!");
weechat_ruby_print_exception(err);
return NULL;
}
if ((TYPE(rc) == T_STRING) && (ret_type == WEECHAT_SCRIPT_EXEC_STRING))
{
if (StringValuePtr (rc))
@@ -386,7 +386,7 @@ weechat_ruby_exec (struct t_plugin_script *script,
ruby_current_script = old_ruby_current_script;
return WEECHAT_RC_OK;
}
if (ret_value == NULL)
{
weechat_printf (NULL,
@@ -396,9 +396,9 @@ weechat_ruby_exec (struct t_plugin_script *script,
ruby_current_script = old_ruby_current_script;
return NULL;
}
ruby_current_script = old_ruby_current_script;
return ret_value;
}
@@ -410,12 +410,12 @@ static VALUE
weechat_ruby_output (VALUE self, VALUE str)
{
char *msg, *p, *m;
/* make C compiler happy */
(void) self;
msg = strdup(StringValuePtr(str));
m = msg;
while ((p = strchr (m, '\n')) != NULL)
{
@@ -431,7 +431,7 @@ weechat_ruby_output (VALUE self, VALUE str)
ruby_buffer_output[0] = '\0';
m = ++p;
}
if (strlen(m) + strlen(ruby_buffer_output) > sizeof(ruby_buffer_output))
{
weechat_printf (NULL,
@@ -445,7 +445,7 @@ weechat_ruby_output (VALUE self, VALUE str)
if (msg)
free (msg);
return Qnil;
}
@@ -458,7 +458,7 @@ weechat_ruby_output_flush (VALUE self)
{
/* make C compiler happy */
(void) self;
return Qnil;
}
@@ -473,7 +473,7 @@ weechat_ruby_load (const char *filename)
VALUE curModule, ruby_retcode, err, argv[1];
int ruby_error;
struct stat buf;
if (stat (filename, &buf) != 0)
{
weechat_printf (NULL,
@@ -481,17 +481,17 @@ weechat_ruby_load (const char *filename)
weechat_prefix ("error"), RUBY_PLUGIN_NAME, filename);
return 0;
}
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
RUBY_PLUGIN_NAME, filename);
}
ruby_current_script = NULL;
ruby_registered_script = NULL;
snprintf (modname, sizeof(modname), "%s%d", MOD_NAME_PREFIX, ruby_num);
ruby_num++;
@@ -502,14 +502,14 @@ weechat_ruby_load (const char *filename)
argv[0] = rb_str_new2 (filename);
ruby_retcode = rb_protect_funcall (curModule, rb_intern("load_eval_file"),
&ruby_error, 1, argv);
if (ruby_retcode == Qnil)
{
err = rb_gv_get("$!");
weechat_ruby_print_exception(err);
return 0;
}
if (NUM2INT(ruby_retcode) != 0)
{
switch (NUM2INT(ruby_retcode))
@@ -542,20 +542,20 @@ weechat_ruby_load (const char *filename)
{
weechat_ruby_print_exception(rb_iv_get(curModule, "@load_eval_file_error"));
}
return 0;
}
(void) rb_protect_funcall (curModule, rb_intern("weechat_init"),
&ruby_error, 0, NULL);
if (ruby_error)
{
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to eval function "
"\"weechat_init\" in file \"%s\""),
weechat_prefix ("error"), RUBY_PLUGIN_NAME, filename);
err = rb_gv_get("$!");
weechat_ruby_print_exception(err);
@@ -568,7 +568,7 @@ weechat_ruby_load (const char *filename)
return 0;
}
if (!ruby_registered_script)
{
weechat_printf (NULL,
@@ -578,10 +578,10 @@ weechat_ruby_load (const char *filename)
return 0;
}
ruby_current_script = ruby_registered_script;
ruby_current_script->interpreter = (VALUE *) curModule;
rb_gc_register_address (ruby_current_script->interpreter);
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
@@ -591,7 +591,7 @@ weechat_ruby_load (const char *filename)
ruby_current_script,
&weechat_ruby_api_buffer_input_data_cb,
&weechat_ruby_api_buffer_close_cb);
return 1;
}
@@ -604,7 +604,7 @@ weechat_ruby_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_ruby_load (filename);
}
@@ -617,14 +617,14 @@ weechat_ruby_unload (struct t_plugin_script *script)
{
int *rc;
void *interpreter;
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
RUBY_PLUGIN_NAME, script->name);
}
if (script->shutdown_func && script->shutdown_func[0])
{
rc = (int *)weechat_ruby_exec (script,
@@ -634,16 +634,16 @@ weechat_ruby_unload (struct t_plugin_script *script)
if (rc)
free (rc);
}
interpreter = script->interpreter;
if (ruby_current_script == script)
ruby_current_script = (ruby_current_script->prev_script) ?
ruby_current_script->prev_script : ruby_current_script->next_script;
script_remove (weechat_ruby_plugin, &ruby_scripts, &last_ruby_script,
script);
if (interpreter)
rb_gc_unregister_address (interpreter);
}
@@ -656,7 +656,7 @@ void
weechat_ruby_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name);
if (ptr_script)
{
@@ -682,7 +682,7 @@ weechat_ruby_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_ruby_plugin, ruby_scripts, name);
if (ptr_script)
{
@@ -727,11 +727,11 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
script_display_list (weechat_ruby_plugin, ruby_scripts,
@@ -802,7 +802,7 @@ weechat_ruby_command_cb (void *data, struct t_gui_buffer *buffer,
weechat_prefix ("error"), RUBY_PLUGIN_NAME, "ruby");
}
}
return WEECHAT_RC_OK;
}
@@ -819,9 +819,9 @@ weechat_ruby_completion_cb (void *data, const char *completion_item,
(void) data;
(void) completion_item;
(void) buffer;
script_completion (weechat_ruby_plugin, completion, ruby_scripts);
return WEECHAT_RC_OK;
}
@@ -835,17 +835,17 @@ weechat_ruby_infolist_cb (void *data, const char *infolist_name,
{
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "ruby_script") == 0)
{
return script_infolist_list_scripts (weechat_ruby_plugin,
ruby_scripts, pointer,
arguments);
}
return NULL;
}
@@ -861,13 +861,13 @@ weechat_ruby_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, RUBY_PLUGIN_NAME) == 0))
{
script_print_log (weechat_ruby_plugin, ruby_scripts);
}
return WEECHAT_RC_OK;
}
@@ -883,10 +883,10 @@ weechat_ruby_signal_buffer_closed_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (ruby_scripts, signal_data);
return WEECHAT_RC_OK;
}
@@ -918,7 +918,7 @@ weechat_ruby_timer_action_cb (void *data, int remaining_calls)
&ruby_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -934,7 +934,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
{
/* make C compiler happy */
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (strcmp (signal, "ruby_script_install") == 0)
@@ -954,7 +954,7 @@ weechat_ruby_signal_script_action_cb (void *data, const char *signal,
&ruby_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -1023,25 +1023,25 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
" end\n"
"end\n"
};
weechat_ruby_plugin = plugin;
ruby_error = 0;
/* init stdout/stderr buffer */
ruby_buffer_output[0] = '\0';
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
RUBY_INIT_STACK;
#endif
ruby_init ();
ruby_init_loadpath ();
ruby_script ("__weechat_plugin__");
ruby_mWeechat = rb_define_module("Weechat");
weechat_ruby_api_init (ruby_mWeechat);
/* redirect stdin and stdout */
ruby_mWeechatOutputs = rb_define_module("WeechatOutputs");
rb_define_singleton_method(ruby_mWeechatOutputs, "write",
@@ -1064,7 +1064,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_ruby_print_exception(err);
return WEECHAT_RC_ERROR;
}
ruby_quiet = 1;
script_init (weechat_ruby_plugin,
argc,
@@ -1077,10 +1077,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
&weechat_ruby_signal_script_action_cb,
&weechat_ruby_load_cb);
ruby_quiet = 0;
script_display_short_list (weechat_ruby_plugin,
ruby_scripts);
/* init ok */
return WEECHAT_RC_OK;
}
@@ -1096,8 +1096,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
ruby_quiet = 1;
script_end (plugin, &ruby_scripts, &weechat_ruby_unload_all);
ruby_quiet = 0;
ruby_cleanup (0);
return WEECHAT_RC_OK;
}
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -38,7 +38,7 @@ struct t_script_callback *
script_callback_alloc ()
{
struct t_script_callback *new_script_callback;
new_script_callback = malloc (sizeof (*new_script_callback));
if (new_script_callback)
{
@@ -54,7 +54,7 @@ script_callback_alloc ()
new_script_callback->upgrade_file = NULL;
return new_script_callback;
}
return NULL;
}
@@ -121,9 +121,9 @@ script_callback_remove (struct t_plugin_script *script,
script_callback->prev_callback;
if (script->callbacks == script_callback)
script->callbacks = script_callback->next_callback;
script_callback_free_data (script_callback);
free (script_callback);
}
+83 -83
View File
@@ -50,7 +50,7 @@ void
script_config_read (struct t_weechat_plugin *weechat_plugin)
{
const char *string;
string = weechat_config_get_plugin (SCRIPT_OPTION_CHECK_LICENSE);
if (!string)
{
@@ -73,9 +73,9 @@ script_config_cb (void *data, const char *option, const char *value)
/* make C compiler happy */
(void) option;
(void) value;
script_config_read (data);
return WEECHAT_RC_OK;
}
@@ -112,10 +112,10 @@ script_init (struct t_weechat_plugin *weechat_plugin,
char *string, *completion;
char signal_name[128];
int length, i, auto_load_scripts;
/* read script configuration */
script_config_read (weechat_plugin);
/* add hook for config option */
length = strlen (weechat_plugin->name) + 64;
string = malloc (length);
@@ -126,7 +126,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
weechat_hook_config (string, &script_config_cb, weechat_plugin);
free (string);
}
/* create directories in WeeChat home */
weechat_mkdir_home (weechat_plugin->name, 0755);
length = strlen (weechat_plugin->name) + strlen ("/autoload") + 1;
@@ -137,7 +137,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
weechat_mkdir_home (string, 0755);
free (string);
}
/* add command */
completion = NULL;
length = strlen (weechat_plugin->name) + 16;
@@ -182,7 +182,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
free (string);
if (completion)
free (completion);
/* add completion and infolist */
length = strlen (weechat_plugin->name) + 16;
string = malloc (length);
@@ -197,13 +197,13 @@ script_init (struct t_weechat_plugin *weechat_plugin,
callback_infolist, NULL);
free (string);
}
/* add signal for "debug_dump" */
weechat_hook_signal ("debug_dump", callback_signal_debug_dump, NULL);
/* add signal for "buffer_closed" */
weechat_hook_signal ("buffer_closed", callback_signal_buffer_closed, NULL);
/* add signal for a script action (install/remove) */
snprintf (signal_name, sizeof (signal_name), "%s_script_install",
weechat_plugin->name);
@@ -211,7 +211,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
snprintf (signal_name, sizeof (signal_name), "%s_script_remove",
weechat_plugin->name);
weechat_hook_signal (signal_name, callback_signal_script_action, NULL);
/* parse arguments */
auto_load_scripts = 1;
for (i = 0; i < argc; i++)
@@ -222,7 +222,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
auto_load_scripts = 0;
}
}
/* autoload scripts */
if (auto_load_scripts)
{
@@ -241,17 +241,17 @@ script_valid (struct t_plugin_script *scripts,
struct t_plugin_script *script)
{
struct t_plugin_script *ptr_script;
if (!script)
return 0;
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
if (ptr_script == script)
return 1;
}
/* script not found */
return 0;
}
@@ -266,13 +266,13 @@ char *
script_ptr2str (void *pointer)
{
char pointer_str[128];
if (!pointer)
return strdup ("");
snprintf (pointer_str, sizeof (pointer_str),
"0x%lx", (long unsigned int)pointer);
return strdup (pointer_str);
}
@@ -285,14 +285,14 @@ script_str2ptr (const char *pointer_str)
{
long unsigned int value;
int rc;
if (!pointer_str || (pointer_str[0] != '0') || (pointer_str[1] != 'x'))
return NULL;
rc = sscanf (pointer_str + 2, "%lx", &value);
if ((rc != EOF) && (rc >= 1))
return (void *)value;
return NULL;
}
@@ -307,7 +307,7 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
const char *dir_home;
char *dir_name;
int dir_length;
/* build directory, adding WeeChat home */
dir_home = weechat_info_get ("weechat_dir", "");
if (!dir_home)
@@ -316,11 +316,11 @@ script_auto_load (struct t_weechat_plugin *weechat_plugin,
dir_name = malloc (dir_length);
if (!dir_name)
return;
snprintf (dir_name, dir_length,
"%s/%s/autoload", dir_home, weechat_plugin->name);
weechat_exec_on_files (dir_name, 0, NULL, callback);
free (dir_name);
}
@@ -333,14 +333,14 @@ script_search (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts, const char *name)
{
struct t_plugin_script *ptr_script;
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
if (weechat_strcasecmp (ptr_script->name, name) == 0)
return ptr_script;
}
/* script not found */
return NULL;
}
@@ -356,7 +356,7 @@ script_search_by_full_name (struct t_plugin_script *scripts,
{
char *base_name;
struct t_plugin_script *ptr_script;
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
@@ -364,7 +364,7 @@ script_search_by_full_name (struct t_plugin_script *scripts,
if (strcmp (base_name, full_name) == 0)
return ptr_script;
}
/* script not found */
return NULL;
}
@@ -381,10 +381,10 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
const char *dir_home, *dir_system;
int length;
struct stat st;
if (filename[0] == '~')
return weechat_string_expand_home (filename);
dir_home = weechat_info_get ("weechat_dir", "");
if (dir_home)
{
@@ -414,7 +414,7 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
return final_name;
free (final_name);
}
/* try WeeChat user's dir */
length = strlen (dir_home) + strlen (filename) + 16;
final_name = malloc (length);
@@ -427,7 +427,7 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
free (final_name);
}
}
/* try WeeChat system dir */
dir_system = weechat_info_get ("weechat_sharedir", "");
if (dir_system)
@@ -444,7 +444,7 @@ script_search_path (struct t_weechat_plugin *weechat_plugin,
free (final_name);
}
}
return strdup (filename);
}
@@ -526,7 +526,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
const char *charset)
{
struct t_plugin_script *new_script;
if (strchr (name, ' '))
{
weechat_printf (NULL,
@@ -535,7 +535,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
weechat_plugin->name, name);
return NULL;
}
if (script_option_check_license
&& (weechat_strcmp_ignore_chars (weechat_plugin->license, license,
"0123456789-.,/\\()[]{}", 0) != 0))
@@ -546,7 +546,7 @@ script_add (struct t_weechat_plugin *weechat_plugin,
weechat_prefix ("error"), weechat_plugin->name,
license, name, weechat_plugin->license);
}
new_script = malloc (sizeof (*new_script));
if (new_script)
{
@@ -561,16 +561,16 @@ script_add (struct t_weechat_plugin *weechat_plugin,
strdup (shutdown_func) : NULL;
new_script->charset = (charset) ? strdup (charset) : NULL;
new_script->callbacks = NULL;
script_insert_sorted (weechat_plugin, scripts, last_script, new_script);
return new_script;
}
weechat_printf (NULL,
_("%s: error loading script \"%s\" (not enough memory)"),
weechat_plugin->name, name);
return NULL;
}
@@ -597,7 +597,7 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *ptr_script;
struct t_script_callback *new_script_callback_input;
struct t_script_callback *new_script_callback_close;
infolist = weechat_infolist_get ("buffer", NULL, NULL);
if (infolist)
{
@@ -621,7 +621,7 @@ script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
"localvar_script_close_cb");
script_close_cb_data = weechat_buffer_get_string (ptr_buffer,
"localvar_script_close_cb_data");
if (script_input_cb && script_input_cb[0])
{
new_script_callback_input = script_callback_alloc ();
@@ -681,7 +681,7 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts,
{
struct t_plugin_script *ptr_script;
struct t_script_callback *ptr_script_callback, *next_script_callback;
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
@@ -689,10 +689,10 @@ script_remove_buffer_callbacks (struct t_plugin_script *scripts,
while (ptr_script_callback)
{
next_script_callback = ptr_script_callback->next_callback;
if (ptr_script_callback->buffer == buffer)
script_callback_remove (ptr_script, ptr_script_callback);
ptr_script_callback = next_script_callback;
}
}
@@ -709,7 +709,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script)
{
struct t_script_callback *ptr_script_callback, *next_script_callback;
for (ptr_script_callback = script->callbacks; ptr_script_callback;
ptr_script_callback = ptr_script_callback->next_callback)
{
@@ -719,12 +719,12 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
weechat_unhook (ptr_script_callback->hook);
}
}
ptr_script_callback = script->callbacks;
while (ptr_script_callback)
{
next_script_callback = ptr_script_callback->next_callback;
/* free config file */
if (ptr_script_callback->config_file
&& !ptr_script_callback->config_section
@@ -734,11 +734,11 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
weechat_config_write (ptr_script_callback->config_file);
weechat_config_free (ptr_script_callback->config_file);
}
/* remove bar item */
if (ptr_script_callback->bar_item)
weechat_bar_item_remove (ptr_script_callback->bar_item);
/* remove buffer */
if (ptr_script_callback->buffer)
{
@@ -751,13 +751,13 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
}
weechat_buffer_close (ptr_script_callback->buffer);
}
ptr_script_callback = next_script_callback;
}
/* remove all callbacks created by this script */
script_callback_remove_all (script);
/* free data */
if (script->filename)
free (script->filename);
@@ -775,7 +775,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
free (script->shutdown_func);
if (script->charset)
free (script->charset);
/* remove script from list */
if (script->prev_script)
(script->prev_script)->next_script = script->next_script;
@@ -785,7 +785,7 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
*scripts = script->next_script;
if (*last_script == script)
*last_script = script->prev_script;
/* free script */
free (script);
}
@@ -818,9 +818,9 @@ script_action_add (char **action_list, const char *name)
{
int length;
char *action_list2;
length = strlen (name);
if (!(*action_list))
{
*action_list = malloc (length + 1);
@@ -853,7 +853,7 @@ script_remove_file (struct t_weechat_plugin *weechat_plugin, const char *name,
{
int num_found, i;
char *path_script;
num_found = 0;
i = 0;
while (i < 2)
@@ -915,7 +915,7 @@ script_action_install (struct t_weechat_plugin *weechat_plugin,
const char *dir_home, *dir_separator;
int argc, i, length, rc;
struct t_plugin_script *ptr_script;
if (*list)
{
argv = weechat_string_split (*list, ",", 0, 0, &argc);
@@ -934,10 +934,10 @@ script_action_install (struct t_weechat_plugin *weechat_plugin,
ptr_script = script_search_by_full_name (scripts, base_name);
if (ptr_script)
(*script_unload) (ptr_script);
/* remove script file(s) */
script_remove_file (weechat_plugin, base_name, 0);
/* move file from install dir to language dir */
dir_home = weechat_info_get ("weechat_dir", "");
length = strlen (dir_home) + strlen (weechat_plugin->name) +
@@ -974,7 +974,7 @@ script_action_install (struct t_weechat_plugin *weechat_plugin,
}
free (autoload_path);
}
/* load script */
(*script_load) (new_path);
}
@@ -1019,7 +1019,7 @@ script_action_remove (struct t_weechat_plugin *weechat_plugin,
char **argv;
int argc, i;
struct t_plugin_script *ptr_script;
if (*list)
{
argv = weechat_string_split (*list, ",", 0, 0, &argc);
@@ -1031,7 +1031,7 @@ script_action_remove (struct t_weechat_plugin *weechat_plugin,
ptr_script = script_search_by_full_name (scripts, argv[i]);
if (ptr_script)
(*script_unload) (ptr_script);
/* remove script file(s) */
script_remove_file (weechat_plugin, argv[i], 1);
}
@@ -1052,7 +1052,7 @@ script_display_list (struct t_weechat_plugin *weechat_plugin,
const char *name, int full)
{
struct t_plugin_script *ptr_script;
weechat_printf (NULL, "");
weechat_printf (NULL,
/* TRANSLATORS: "%s" is language (for example "perl") */
@@ -1101,21 +1101,21 @@ script_display_short_list (struct t_weechat_plugin *weechat_plugin,
char *buf;
int length;
struct t_plugin_script *ptr_script;
if (scripts)
{
/* TRANSLATORS: "%s" is language (for example "perl") */
scripts_loaded = _("%s scripts loaded:");
length = strlen (scripts_loaded) + strlen (weechat_plugin->name) + 1;
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
length += strlen (ptr_script->name) + 2;
}
length++;
buf = malloc (length);
if (buf)
{
@@ -1145,14 +1145,14 @@ script_add_to_infolist (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script)
{
struct t_infolist_item *ptr_item;
if (!infolist || !script)
return 0;
ptr_item = weechat_infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!weechat_infolist_new_var_pointer (ptr_item, "pointer", script))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "filename", script->filename))
@@ -1173,7 +1173,7 @@ script_add_to_infolist (struct t_weechat_plugin *weechat_plugin,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "charset", script->charset))
return 0;
return 1;
}
@@ -1189,10 +1189,10 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin,
{
struct t_infolist *ptr_infolist;
struct t_plugin_script *ptr_script;
if (pointer && !script_valid (scripts, pointer))
return NULL;
ptr_infolist = weechat_infolist_new ();
if (ptr_infolist)
{
@@ -1227,7 +1227,7 @@ script_infolist_list_scripts (struct t_weechat_plugin *weechat_plugin,
return ptr_infolist;
}
}
return NULL;
}
@@ -1241,11 +1241,11 @@ script_end (struct t_weechat_plugin *weechat_plugin,
void (*callback_unload_all)())
{
int scripts_loaded;
scripts_loaded = (*scripts) ? 1 : 0;
(void)(callback_unload_all) ();
if (scripts_loaded)
{
weechat_printf (NULL, _("%s: scripts unloaded"),
@@ -1263,11 +1263,11 @@ script_print_log (struct t_weechat_plugin *weechat_plugin,
{
struct t_plugin_script *ptr_script;
struct t_script_callback *ptr_script_callback;
weechat_log_printf ("");
weechat_log_printf ("***** \"%s\" plugin dump *****",
weechat_plugin->name);
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
@@ -1292,7 +1292,7 @@ script_print_log (struct t_weechat_plugin *weechat_plugin,
script_callback_print_log (weechat_plugin, ptr_script_callback);
}
}
weechat_log_printf ("");
weechat_log_printf ("***** End of \"%s\" plugin dump *****",
weechat_plugin->name);
+2 -2
View File
@@ -61,9 +61,9 @@ struct t_plugin_script
char *description; /* plugin description */
char *shutdown_func; /* function when script is unloaded*/
char *charset; /* script charset */
struct t_script_callback *callbacks; /* callbacks for script */
struct t_plugin_script *prev_script; /* link to previous script */
struct t_plugin_script *next_script; /* link to next script */
};
File diff suppressed because it is too large Load Diff
+56 -56
View File
@@ -85,14 +85,14 @@ weechat_tcl_hashtable_map_cb (void *data,
void **data_array;
Tcl_Interp *interp;
Tcl_Obj *dict;
/* make C compiler happy */
(void) hashtable;
data_array = (void **)data;
interp = data_array[0];
dict = data_array[1];
Tcl_DictObjPut (interp, dict,
Tcl_NewStringObj ((char *)key, -1),
Tcl_NewStringObj ((char *)value, -1));
@@ -108,18 +108,18 @@ weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
{
Tcl_Obj *dict;
void *data[2];
dict = Tcl_NewDictObj ();
if (!dict)
return NULL;
data[0] = interp;
data[1] = dict;
weechat_hashtable_map (hashtable,
&weechat_tcl_hashtable_map_cb,
data);
return dict;
}
@@ -139,7 +139,7 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
Tcl_DictSearch search;
Tcl_Obj *key, *value;
int done;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
@@ -147,7 +147,7 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
NULL);
if (!hashtable)
return NULL;
if (Tcl_DictObjFirst (interp, dict, &search, &key, &value, &done) == TCL_OK)
{
for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done))
@@ -158,7 +158,7 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
}
}
Tcl_DictObjDone(&search);
return hashtable;
}
@@ -178,11 +178,11 @@ weechat_tcl_exec (struct t_plugin_script *script,
Tcl_Obj *cmdlist;
Tcl_Interp *interp;
struct t_plugin_script *old_tcl_script;
old_tcl_script = tcl_current_script;
tcl_current_script = script;
interp = (Tcl_Interp*)script->interpreter;
if (function && function[0])
{
cmdlist = Tcl_NewListObj (0, NULL);
@@ -194,7 +194,7 @@ weechat_tcl_exec (struct t_plugin_script *script,
tcl_current_script = old_tcl_script;
return NULL;
}
if (format && format[0])
{
argc = strlen (format);
@@ -217,10 +217,10 @@ weechat_tcl_exec (struct t_plugin_script *script,
}
}
}
if (Tcl_ListObjLength (interp, cmdlist, &llength) != TCL_OK)
llength = 0;
if (Tcl_EvalObjEx (interp, cmdlist, TCL_EVAL_DIRECT) == TCL_OK)
{
Tcl_ListObjReplace (interp, cmdlist, 0, llength, 0, NULL); /* remove elements, decrement their ref count */
@@ -248,18 +248,18 @@ weechat_tcl_exec (struct t_plugin_script *script,
Tcl_GetObjResult (interp),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
}
tcl_current_script = old_tcl_script;
if (ret_val)
return ret_val;
weechat_printf (NULL,
weechat_gettext ("%s%s: function \"%s\" must return a "
"valid value"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, function);
return NULL;
}
Tcl_ListObjReplace (interp, cmdlist, 0, llength, 0, NULL); /* remove elements, decrement their ref count */
Tcl_DecrRefCount (cmdlist); /* -1 */
weechat_printf (NULL,
@@ -267,7 +267,7 @@ weechat_tcl_exec (struct t_plugin_script *script,
weechat_prefix ("error"), TCL_PLUGIN_NAME, function,
Tcl_GetStringFromObj (Tcl_GetObjResult (interp), &i));
tcl_current_script = old_tcl_script;
return NULL;
}
@@ -281,7 +281,7 @@ weechat_tcl_load (const char *filename)
int i;
Tcl_Interp *interp;
struct stat buf;
if (stat (filename, &buf) != 0)
{
weechat_printf (NULL,
@@ -289,17 +289,17 @@ weechat_tcl_load (const char *filename)
weechat_prefix ("error"), TCL_PLUGIN_NAME, filename);
return 0;
}
if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: loading script \"%s\""),
TCL_PLUGIN_NAME, filename);
}
tcl_current_script = NULL;
tcl_registered_script = NULL;
if (!(interp = Tcl_CreateInterp ())) {
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to create new "
@@ -308,7 +308,7 @@ weechat_tcl_load (const char *filename)
return 0;
}
tcl_current_script_filename = filename;
weechat_tcl_api_init (interp);
if (Tcl_EvalFile (interp, filename) != TCL_OK)
@@ -332,7 +332,7 @@ weechat_tcl_load (const char *filename)
return 0;
}
tcl_current_script = tcl_registered_script;
/*
* set input/close callbacks for buffers created by this script
* (to restore callbacks after upgrade)
@@ -342,7 +342,7 @@ weechat_tcl_load (const char *filename)
tcl_current_script,
&weechat_tcl_api_buffer_input_data_cb,
&weechat_tcl_api_buffer_close_cb);
return 1;
}
@@ -355,7 +355,7 @@ weechat_tcl_load_cb (void *data, const char *filename)
{
/* make C compiler happy */
(void) data;
weechat_tcl_load (filename);
}
@@ -368,14 +368,14 @@ weechat_tcl_unload (struct t_plugin_script *script)
{
Tcl_Interp* interp;
int *rc;
if ((weechat_tcl_plugin->debug >= 1) || !tcl_quiet)
{
weechat_printf (NULL,
weechat_gettext ("%s: unloading script \"%s\""),
TCL_PLUGIN_NAME, script->name);
}
if (script->shutdown_func && script->shutdown_func[0])
{
rc = (int *)weechat_tcl_exec (script,
@@ -385,27 +385,27 @@ weechat_tcl_unload (struct t_plugin_script *script)
if (rc)
free (rc);
}
interp = (Tcl_Interp*)script->interpreter;
if (tcl_current_script == script)
tcl_current_script = (tcl_current_script->prev_script) ?
tcl_current_script->prev_script : tcl_current_script->next_script;
script_remove (weechat_tcl_plugin, &tcl_scripts, &last_tcl_script, script);
Tcl_DeleteInterp(interp);
}
/*
* weechat_tcl_unload_name: unload a Tcl script by name
*/
void
weechat_tcl_unload_name (const char *name)
{
struct t_plugin_script *ptr_script;
ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name);
if (ptr_script)
{
@@ -444,7 +444,7 @@ weechat_tcl_reload_name (const char *name)
{
struct t_plugin_script *ptr_script;
char *filename;
ptr_script = script_search (weechat_tcl_plugin, tcl_scripts, name);
if (ptr_script)
{
@@ -476,11 +476,11 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
char *path_script;
/* make C compiler happy */
(void) data;
(void) buffer;
if (argc == 1)
{
script_display_list (weechat_tcl_plugin, tcl_scripts,
@@ -551,7 +551,7 @@ weechat_tcl_command_cb (void *data, struct t_gui_buffer *buffer,
weechat_prefix ("error"), TCL_PLUGIN_NAME, "tcl");
}
}
return WEECHAT_RC_OK;
}
@@ -568,9 +568,9 @@ weechat_tcl_completion_cb (void *data, const char *completion_item,
(void) data;
(void) completion_item;
(void) buffer;
script_completion (weechat_tcl_plugin, completion, tcl_scripts);
return WEECHAT_RC_OK;
}
@@ -584,17 +584,17 @@ weechat_tcl_infolist_cb (void *data, const char *infolist_name,
{
/* make C compiler happy */
(void) data;
if (!infolist_name || !infolist_name[0])
return NULL;
if (weechat_strcasecmp (infolist_name, "tcl_script") == 0)
{
return script_infolist_list_scripts (weechat_tcl_plugin,
tcl_scripts, pointer,
arguments);
}
return NULL;
}
@@ -610,13 +610,13 @@ weechat_tcl_signal_debug_dump_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (!signal_data
|| (weechat_strcasecmp ((char *)signal_data, TCL_PLUGIN_NAME) == 0))
{
script_print_log (weechat_tcl_plugin, tcl_scripts);
}
return WEECHAT_RC_OK;
}
@@ -632,10 +632,10 @@ weechat_tcl_signal_buffer_closed_cb (void *data, const char *signal,
(void) data;
(void) signal;
(void) type_data;
if (signal_data)
script_remove_buffer_callbacks (tcl_scripts, signal_data);
return WEECHAT_RC_OK;
}
@@ -667,7 +667,7 @@ weechat_tcl_timer_action_cb (void *data, int remaining_calls)
&tcl_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -683,7 +683,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
{
/* make C compiler happy */
(void) data;
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
if (strcmp (signal, "tcl_script_install") == 0)
@@ -703,7 +703,7 @@ weechat_tcl_signal_script_action_cb (void *data, const char *signal,
&tcl_action_remove_list);
}
}
return WEECHAT_RC_OK;
}
@@ -715,7 +715,7 @@ int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
weechat_tcl_plugin = plugin;
tcl_quiet = 1;
script_init (weechat_tcl_plugin,
argc,
@@ -728,10 +728,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
&weechat_tcl_signal_script_action_cb,
&weechat_tcl_load_cb);
tcl_quiet = 0;
script_display_short_list (weechat_tcl_plugin,
tcl_scripts);
/* init ok */
return WEECHAT_RC_OK;
}
@@ -747,6 +747,6 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
tcl_quiet = 1;
script_end (plugin, &tcl_scripts, &weechat_tcl_unload_all);
tcl_quiet = 0;
return WEECHAT_RC_OK;
}