Add new functions in plugin API (hashtable_get_string, hook_info_hashtable, info_get_hashtable), add IRC info_hashtable "irc_parse_message"

Note: tcl >= 8.5 is now required (for tcl plugin).
v2.8-utf8proc
Sebastien Helleu 2010-08-27 15:59:06 +02:00
parent bb42984f5d
commit 712623547f
55 changed files with 3753 additions and 856 deletions

View File

@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.4-dev, 2010-08-20
v0.3.4-dev, 2010-08-27
Version 0.3.4 (under dev!)
@ -10,6 +10,9 @@ Version 0.3.4 (under dev!)
* core: use similar behaviour for keys bound to local or global history
(bug #30759)
* api: add priority for hooks (task #10550)
* api: add new functions: hashtable_get_string, hook_info_hashtable,
info_get_hashtable
* irc: add new info_hashtable "irc_parse_message"
* irc: fix bug with hostmasks in command /ignore (bug #30716)
* rmodifier: new plugin "rmodifier": alter modifier strings with regular
expressions (bug #26964)

2
debian/control vendored
View File

@ -5,7 +5,7 @@ Maintainer: Emmanuel Bouthenot <kolter@openics.org>
Build-Depends-Indep: asciidoc (>= 8.2), source-highlight
Build-Depends: debhelper (>= 7.0.50), cmake, libncursesw5-dev,
ruby, ruby1.8-dev, libperl-dev, python-dev, libaspell-dev, liblua5.1-0-dev,
tcl-dev, libgnutls-dev, dpkg-dev (>= 1.13.19), pkg-config
tcl8.5-dev, libgnutls-dev, dpkg-dev (>= 1.13.19), pkg-config
Standards-Version: 3.8.3
Homepage: http://weechat.org/
Vcs-Git: git://git.debian.org/users/kolter-guest/weechat.git

View File

@ -0,0 +1,7 @@
[width="100%",cols="^1,^2,6,6,6",options="header"]
|========================================
| Erweiterung | Name | Beschreibung | Hashtable (input) | Hashtable (output)
| irc | irc_parse_message | parse an IRC message | "message": IRC message | "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel)
|========================================

View File

@ -279,7 +279,7 @@ Liste der Skript API Funktionen:
hook_command, hook_command_run, hook_timer, hook_fd, hook_process,
hook_connect, hook_print, hook_signal, hook_signal_send, hook_config,
hook_completion, hook_completion_list_add, hook_modifier, hook_modifier_exec,
hook_info, hook_infolist, unhook, unhook_all
hook_info, hook_info_hashtable, hook_infolist, unhook, unhook_all
| Buffer |
buffer_new, current_buffer, buffer_search, buffer_search_main, buffer_clear,
buffer_close, buffer_merge, buffer_unmerge, buffer_get_integer,
@ -298,7 +298,7 @@ Liste der Skript API Funktionen:
| Befehle |
command
| Informationen |
info_get
info_get, info_get_hashtable
| Infolisten |
infolist_new, infolist_new_item, infolist_new_var_integer,
infolist_new_var_string, infolist_new_var_pointer, infolist_new_var_time, +

View File

@ -98,7 +98,7 @@ welche Pakete optional genutzt werden können.
| python-dev | nein | python Erweiterung
| ruby1.8-dev | nein | ruby Erweiterung
| liblua5.1-0-dev | nein | lua Erweiterung
| tcl-dev | nein | tcl Erweiterung
| tcl-dev (>= 8.5) | nein | tcl Erweiterung
| asciidoc (>= 8.2) | nein | erstellt Dokumentation (HTML Dateien)
| source-highlight | nein | Syntax highlight für Quelltext in HTML Dokumentation
|========================================
@ -515,7 +515,7 @@ Tastenbefehle für die Befehlszeile
// TRANSLATION MISSING
| Ctrl + R |
Sucht nach einem Text in der Protokolldatei (zweimaliges Drücken: sucht nach exaktem Text),
next/previous occurences can be found with up and down arrows +
next/previous occurrences can be found with up and down arrows +
`/input search_text`
| Ctrl + T |

View File

@ -93,6 +93,9 @@ my @ignore_options = ("aspell\\.dict\\..*",
# infos to ignore
my @ignore_infos_plugins = ();
# infos (hashtable) to ignore
my @ignore_infos_hashtable_plugins = ();
# infolists to ignore
my @ignore_infolists_plugins = ();
@ -204,7 +207,7 @@ sub get_infos
my $plugin = weechat::infolist_string($infolist, "plugin_name");
$plugin = "weechat" if ($plugin eq "");
# check if infolist is ignored or not
# check if info is ignored or not
my $ignore = 0;
foreach my $mask (@ignore_infos_plugins)
{
@ -222,6 +225,38 @@ sub get_infos
return %infos;
}
# get list of infos (hashtable) hooked by plugins in a hash with 3 indexes: plugin, name, xxx
sub get_infos_hashtable
{
my %infos_hashtable;
# get infos hooked
my $infolist = weechat::infolist_get("hook", "", "info_hashtable");
while (weechat::infolist_next($infolist))
{
my $info_name = weechat::infolist_string($infolist, "info_name");
my $plugin = weechat::infolist_string($infolist, "plugin_name");
$plugin = "weechat" if ($plugin eq "");
# check if info_hashtable is ignored or not
my $ignore = 0;
foreach my $mask (@ignore_infos_hashtable_plugins)
{
$ignore = 1 if ($plugin =~ /${mask}/);
}
if ($ignore ne 1)
{
$infos_hashtable{$plugin}{$info_name}{"description"} = weechat::infolist_string($infolist, "description");
$infos_hashtable{$plugin}{$info_name}{"args_description"} = weechat::infolist_string($infolist, "args_description");
$infos_hashtable{$plugin}{$info_name}{"output_description"} = weechat::infolist_string($infolist, "output_description");
}
}
weechat::infolist_free($infolist);
return %infos_hashtable;
}
# get list of infolists hooked by plugins in a hash with 3 indexes: plugin, name, xxx
sub get_infolists
{
@ -313,6 +348,7 @@ sub docgen
my %plugin_commands = get_commands();
my %plugin_options = get_options();
my %plugin_infos = get_infos();
my %plugin_infos_hashtable = get_infos_hashtable();
my %plugin_infolists = get_infolists();
my %plugin_completions = get_completions();
@ -335,6 +371,8 @@ sub docgen
my $num_files_options_updated = 0;
my $num_files_infos = 0;
my $num_files_infos_updated = 0;
my $num_files_infos_hashtable = 0;
my $num_files_infos_hashtable_updated = 0;
my $num_files_infolists = 0;
my $num_files_infolists_updated = 0;
my $num_files_completions = 0;
@ -529,6 +567,55 @@ sub docgen
weechat::print("", weechat::prefix("error")."docgen error: unable to write file '$filename'");
}
# write infos (hashtable) hooked
$filename = $dir."plugin_api/infos_hashtable.txt";
if (open(FILE, ">".$filename.".tmp"))
{
print FILE "[width=\"100%\",cols=\"^1,^2,6,6,6\",options=\"header\"]\n";
print FILE "|========================================\n";
print FILE "| ".weechat_gettext("Plugin")." | ".weechat_gettext("Name")
." | ".weechat_gettext("Description")." | ".weechat_gettext("Hashtable (input)")
." | ".weechat_gettext("Hashtable (output)")."\n\n";
foreach my $plugin (sort keys %plugin_infos_hashtable)
{
foreach my $info (sort keys %{$plugin_infos_hashtable{$plugin}})
{
my $description = $plugin_infos_hashtable{$plugin}{$info}{"description"};
$description = $d->get($description) if ($description ne "");
my $args_description = $plugin_infos_hashtable{$plugin}{$info}{"args_description"};
$args_description = $d->get($args_description) if ($args_description ne "");
$args_description = "-" if ($args_description eq "");
my $output_description = $plugin_infos_hashtable{$plugin}{$info}{"output_description"};
$output_description = $d->get($output_description) if ($output_description ne "");
$output_description = "-" if ($output_description eq "");
print FILE "| ".escape_table($plugin)." | ".escape_table($info)
." | ".escape_table($description)." | ".escape_table($args_description)
." | ".escape_table($output_description)."\n\n";
}
}
print FILE "|========================================\n";
#weechat::print("", "docgen: file ok: '$filename'");
my $rc = system("diff ".$filename." ".$filename.".tmp >/dev/null 2>&1");
if ($rc != 0)
{
system("mv -f ".$filename.".tmp ".$filename);
$num_files_updated++;
$num_files_infos_hashtable_updated++;
}
else
{
system("rm ".$filename.".tmp");
}
$num_files++;
$num_files_infos_hashtable++;
close(FILE);
}
else
{
weechat::print("", weechat::prefix("error")."docgen error: unable to write file '$filename'");
}
# write infolists hooked
$filename = $dir."plugin_api/infolists.txt";
if (open(FILE, ">".$filename.".tmp"))
@ -624,20 +711,24 @@ sub docgen
weechat::print("", weechat::prefix("error")."docgen error: directory '$dir' does not exist");
}
my $total_files = $num_files_commands + $num_files_options
+ $num_files_infos + $num_files_infolists + $num_files_completions;
+ $num_files_infos + $num_files_infos_hashtable
+ $num_files_infolists + $num_files_completions;
my $total_files_updated = $num_files_commands_updated
+ $num_files_options_updated + $num_files_infos_updated
+ $num_files_infolists_updated + $num_files_completions_updated;
+ $num_files_infos_hashtable_updated + $num_files_infolists_updated
+ $num_files_completions_updated;
weechat::print("", "docgen: ".$locale.": ".$total_files." files ("
.$num_files_commands." cmd, "
.$num_files_options." opt, "
.$num_files_infos." infos, "
.$num_files_infos." infos (hashtable), "
.$num_files_infolists." infolists, "
.$num_files_completions." complt) -- "
.$total_files_updated." updated ("
.$num_files_commands_updated." cmd, "
.$num_files_options_updated." opt, "
.$num_files_infos_updated." infos, "
.$num_files_infos_hashtable_updated." infos (hashtable), "
.$num_files_infolists_updated." infolists, "
.$num_files_completions_updated." complt)");
}

View File

@ -0,0 +1,7 @@
[width="100%",cols="^1,^2,6,6,6",options="header"]
|========================================
| Plugin | Name | Description | Hashtable (input) | Hashtable (output)
| irc | irc_parse_message | parse an IRC message | "message": IRC message | "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel)
|========================================

View File

@ -505,6 +505,9 @@ char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_tolower
^^^^^^^^^^^^^^^^^^^^^^
@ -529,6 +532,9 @@ char *str = "AbCdé";
weechat_string_tolower (str); /* str is now: "abcdé" */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_toupper
^^^^^^^^^^^^^^^^^^^^^^
@ -553,6 +559,9 @@ char *str = "AbCdé";
weechat_string_tolower (str); /* str is now: "ABCDé" */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_strcasecmp
^^^^^^^^^^^^^^^^^^
@ -584,6 +593,9 @@ C example:
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_strncasecmp
^^^^^^^^^^^^^^^^^^^
@ -616,6 +628,9 @@ C example:
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_strcmp_ignore_chars
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -652,6 +667,9 @@ C example:
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_strcasestr
^^^^^^^^^^^^^^^^^^
@ -680,6 +698,9 @@ C example:
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_match
^^^^^^^^^^^^^^^^^^^^
@ -730,7 +751,7 @@ match4 = weechat.string_match("abcdef", "*de*", 0) # 1
weechat_string_replace
^^^^^^^^^^^^^^^^^^^^^^
Replace all occurences of a string by another string.
Replace all occurrences of a string by another string.
Prototype:
@ -760,6 +781,9 @@ char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_expand_home
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -794,6 +818,9 @@ char *str = weechat_string_expand_home ("~/file.txt");
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_remove_quotes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -827,6 +854,9 @@ char *str = weechat_string_remove_quotes (string, " 'I can't' ", "'");
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_strip
^^^^^^^^^^^^^^^^^^^^
@ -860,6 +890,9 @@ char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* result: ".abc" */
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_has_highlight
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -995,6 +1028,9 @@ argv = weechat_string_split ("abc de fghi", " ", 1, 0, &argc);
weechat_string_free_split (argv);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_free_split
^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1023,6 +1059,9 @@ argv = weechat_string_split (string, " ", 0, 0, &argc);
weechat_string_free_split (argv);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_build_with_split_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1059,6 +1098,9 @@ char *str = weechat_string_build_with_split_string (argv, ";");
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_split_command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1093,6 +1135,9 @@ char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
weechat_free_split_command (argv);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_free_split_command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1119,6 +1164,9 @@ char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
weechat_free_split_command (argv);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_format_size
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1163,6 +1211,9 @@ char *str = weechat_string_format_size (2097152); /* str == "2 MB" */
free (str);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_remove_color
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1243,6 +1294,9 @@ weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_decode_base64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1277,6 +1331,9 @@ length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_string_is_command_char
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1400,6 +1457,9 @@ if (weechat_utf8_has_8bits (string))
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_is_valid
^^^^^^^^^^^^^^^^^^^^^
@ -1437,6 +1497,9 @@ else
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_normalize
^^^^^^^^^^^^^^^^^^^^^^
@ -1461,6 +1524,9 @@ C example:
weechat_utf8_normalize (string, '?');
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_prev_char
^^^^^^^^^^^^^^^^^^^^^^
@ -1490,6 +1556,9 @@ C example:
char *prev_char = weechat_utf8_prev_char (string, ptr_in_string);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_next_char
^^^^^^^^^^^^^^^^^^^^^^
@ -1517,6 +1586,9 @@ C example:
char *next_char = weechat_utf8_next_char (string);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_char_int
^^^^^^^^^^^^^^^^^^^^^
@ -1544,6 +1616,9 @@ C example:
int char_int = weechat_utf8_char_int ("être"); /* "ê" as integer */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_char_size
^^^^^^^^^^^^^^^^^^^^^^
@ -1571,6 +1646,9 @@ C example:
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_strlen
^^^^^^^^^^^^^^^^^^^
@ -1598,6 +1676,9 @@ C example:
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_strnlen
^^^^^^^^^^^^^^^^^^^^
@ -1626,6 +1707,9 @@ C example:
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_strlen_screen
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1653,6 +1737,9 @@ C example:
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_charcmp
^^^^^^^^^^^^^^^^^^^^
@ -1684,6 +1771,9 @@ C example:
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_charcasecmp
^^^^^^^^^^^^^^^^^^^^^^^^
@ -1715,6 +1805,9 @@ C example:
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_char_size_screen
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1742,6 +1835,9 @@ C example:
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_add_offset
^^^^^^^^^^^^^^^^^^^^^^^
@ -1771,6 +1867,9 @@ char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_real_pos
^^^^^^^^^^^^^^^^^^^^^
@ -1799,6 +1898,9 @@ C example:
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_pos
^^^^^^^^^^^^^^^^
@ -1827,6 +1929,9 @@ C example:
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_utf8_strndup
^^^^^^^^^^^^^^^^^^^^
@ -1857,6 +1962,9 @@ char *string = weechat_utf8_strndup ("chêne", 3); /* returns "chê" */
free (string);
----------------------------------------
[NOTE]
This function is not available in scripting API.
[[directories]]
Directories
~~~~~~~~~~~
@ -2026,6 +2134,9 @@ void callback (void *data, const char *filename)
weechat_exec_on_files ("/tmp", 0, NULL, &callback);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_file_get_content
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2059,6 +2170,9 @@ content = weechat_file_get_content ("/tmp/test.txt");
free (content);
----------------------------------------
[NOTE]
This function is not available in scripting API.
[[util]]
Util
~~~~
@ -2098,6 +2212,9 @@ if (weechat_util_timeval_cmp (&tv1, &tv2) > 0)
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_util_timeval_diff
^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2126,6 +2243,9 @@ C example:
long diff = weechat_util_timeval_diff (&tv1, &tv2);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_util_timeval_add
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2150,6 +2270,9 @@ C example:
weechat_util_timeval_add (&tv, 2000); /* add 2 seconds */
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_util_get_time_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2177,6 +2300,9 @@ weechat_printf (NULL, "date: %s",
weechat_util_get_time_string (&date));
----------------------------------------
[NOTE]
This function is not available in scripting API.
[[sorted_lists]]
Sorted lists
~~~~~~~~~~~~
@ -2742,6 +2868,9 @@ struct t_hashtable *hashtable = weechat_hashtable_new (8,
NULL);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_set_with_size
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2780,6 +2909,9 @@ weechat_hashtable_set_with_size (hashtable, "my_key", 0,
my_buffer, sizeof (my_buffer_struct));
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_set
^^^^^^^^^^^^^^^^^^^^^
@ -2812,6 +2944,9 @@ C example:
weechat_hashtable_set (hashtable, "my_key", "my_value");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_get
^^^^^^^^^^^^^^^^^^^^^
@ -2842,6 +2977,9 @@ C example:
void *value = weechat_hashtable_get (hashtable, "my_key");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_map
^^^^^^^^^^^^^^^^^^^^^
@ -2884,6 +3022,9 @@ map_cb (void *data, struct t_hashtable *hashtable,
weechat_hashtable_map (hashtable, &map_cb, NULL);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_get_integer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2917,6 +3058,55 @@ C example:
int items_count = weechat_hashtable_get_integer (hashtable, "items_count");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_get_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_New in version 0.3.4._
Return string value of a hashtable property.
Prototype:
[source,C]
----------------------------------------
const char *weechat_hashtable_get_string (struct t_hashtable *hashtable,
void *property);
----------------------------------------
Arguments:
* 'hashtable': hashtable pointer
* 'property': property name:
** 'type_keys': type for keys:
*** 'integer': integer
*** 'string': string
*** 'pointer': pointer
*** 'buffer': buffer
*** 'time': time
** 'type_values': type for values:
*** 'integer': integer
*** 'string': string
*** 'pointer': pointer
*** 'buffer': buffer
*** 'time': time
Return value:
* string value of property
C example:
[source,C]
----------------------------------------
const char *type_keys = weechat_hashtable_get_string (hashtable, "type_keys");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_add_to_infolist
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2960,6 +3150,9 @@ weechat_hashtable_add_to_infolist (hashtable, infolist_item, "testhash");
*/
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_remove
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2986,6 +3179,9 @@ C example:
weechat_hashtable_remove (hashtable, "my_key");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_remove_all
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3011,6 +3207,9 @@ C example:
weechat_hashtable_remove_all (hashtable);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_hashtable_free
^^^^^^^^^^^^^^^^^^^^^^
@ -3036,6 +3235,9 @@ C example:
weechat_hashtable_free (hashtable);
----------------------------------------
[NOTE]
This function is not available in scripting API.
[[configuration_files]]
Configuration files
~~~~~~~~~~~~~~~~~~~
@ -3665,6 +3867,9 @@ else
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_config_search_with_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3712,6 +3917,9 @@ else
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_config_string_to_boolean
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -4084,6 +4292,9 @@ C example:
char *description = weechat_config_option_get_pointer (option, "description");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_config_option_is_null
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -5349,6 +5560,9 @@ C example:
weechat_printf_date (NULL, time (NULL) - 120, "Hello, 2 minutes ago");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_printf_tags
^^^^^^^^^^^^^^^^^^^
@ -5376,6 +5590,9 @@ weechat_printf_tags (NULL, "notify_message",
"Message with a tag 'notify_message'");
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_printf_date_tags
^^^^^^^^^^^^^^^^^^^^^^^^
@ -6870,7 +7087,7 @@ weechat.hook_modifier_exec("my_modifier", my_data, my_string)
weechat_hook_info
^^^^^^^^^^^^^^^^^
Hook an information.
Hook an information (callback takes and returns a string).
Prototype:
@ -6934,6 +7151,82 @@ hook = weechat.hook_info("my_info", "Some info", "Info about arguments",
"my_info_cb", "")
----------------------------------------
weechat_hook_info_hashtable
^^^^^^^^^^^^^^^^^^^^^^^^^^^
_New in version 0.3.4._
Hook an information (callback takes and returns a hashtable).
Prototype:
[source,C]
----------------------------------------
struct t_hook *weechat_hook_info_hashtable (const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
struct t_hashtable *(*callback)(void *data,
const char *info_name,
struct t_hashtable *hashtable),
void *callback_data);
----------------------------------------
Arguments:
* 'info_name': name of info
(priority allowed, see note about <<hook_priority,priority>>)
* 'description': description
* 'args_description': description of expected hashtable (optional, can be NULL)
* 'output_description': description of hashtable returned by callback
(optional, can be NULL)
* 'callback': function called when info is asked, arguments:
** 'void *data': pointer
** 'const char *info_name': name of info
** 'struct t_hashtable *hashtable': hashtable, depending on info
* 'callback_data': pointer given to callback when it is called by WeeChat
Return value:
* pointer to new hook, NULL if error occured
C example:
[source,C]
----------------------------------------
struct t_hashtable *
my_info_hashtable_cb (void *data, const char *info_name, struct t_hashtable *hashtable)
{
/* ... */
return pointer_to_new_hashtable;
}
/* add info "my_info_hashtable" */
struct t_hook *my_info_hook = weechat_hook_info_hashtable ("my_info_hashtable",
"Some info",
"Info about input hashtable",
"Info about output hashtable",
&my_info_hashtable_cb, NULL);
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
hook = weechat.hook_info_hashtable(info_name, description, args_description,
output_description, callback, callback_data)
# example
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_key": "test_value" }
hook = weechat.hook_info_hashtable("my_info_hashtable", "Some info",
"Info about input hashtable",
"Info about output hashtable",
"my_info_hashtable_cb", "")
----------------------------------------
weechat_hook_infolist
^^^^^^^^^^^^^^^^^^^^^
@ -7800,6 +8093,9 @@ my_close_cb (void *data, struct t_gui_buffer *buffer)
weechat_buffer_set_pointer (my_buffer, "close_callback", &my_close_cb);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_buffer_string_replace_local_var
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8903,6 +9199,9 @@ else
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_network_connect_to
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8953,6 +9252,9 @@ else
}
----------------------------------------
[NOTE]
This function is not available in scripting API.
[[infos]]
Infos
~~~~~
@ -8962,7 +9264,7 @@ Functions to get infos.
weechat_info_get
^^^^^^^^^^^^^^^^
Return info from WeeChat or a plugin.
Return info, as string, from WeeChat or a plugin.
Prototype:
@ -9006,6 +9308,75 @@ weechat.prnt("", "Current WeeChat version is: %s (compiled on %s)"
weechat.prnt("", "WeeChat home is: %s" % weechat.info_get("weechat_dir", ""))
----------------------------------------
weechat_info_get_hashtable
^^^^^^^^^^^^^^^^^^^^^^^^^^
_New in version 0.3.4._
Return info, as hashtable, from WeeChat or a plugin.
Prototype:
[source,C]
----------------------------------------
struct t_hashtable *weechat_info_get_hashtable (const char *info_name,
struct t_hashtable *hashtable);
----------------------------------------
Arguments:
* 'info_name': name of info to read:
include::autogen/plugin_api/infos_hashtable.txt[]
* 'hashtable': hashtable with arguments (depends on info asked) (optional, NULL
if no argument is needed)
Return value:
* hashtable with info asked, NULL if an error occured
C example:
[source,C]
----------------------------------------
struct t_hashtable *hashtable_in, *hashtable_out;
hashtable_in = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (hashtable_in)
{
weechat_hashtable_set (hashtable_in, "message",
":nick!user@host PRIVMSG #weechat :message here");
hashtable_out = weechat_info_get_hashtable ("irc_parse_message",
hashtable_in);
/*
* now hashtable_out has following keys/values:
* "nick" : "nick"
* "host" : "nick!user@host"
* "command" : "PRIVMSG"
* "channel" : "#weechat"
* "arguments": "#weechat :message here"
*/
weechat_hashtable_free (hashtable_in);
weechat_hashtable_free (hashtable_out);
}
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
dict = weechat.info_get_hashtable(info_name, dict_in)
# example
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message here" }
weechat.prnt("", "message parsed: %s"
% weechat.info_get_hashtable("irc_parse_message", dict_in))
----------------------------------------
[[infolists]]
Infolists
~~~~~~~~~
@ -9266,6 +9637,9 @@ struct t_infolist_var *var = weechat_infolist_new_variable_buffer (item,
sizeof (buffer));
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_infolist_new_var_time
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9687,6 +10061,9 @@ weechat_printf (NULL, "buffer = 0x%lx, size = %d",
pointer, size);
----------------------------------------
[NOTE]
This function is not available in scripting API.
weechat_infolist_time
^^^^^^^^^^^^^^^^^^^^^

View File

@ -272,7 +272,7 @@ List of functions in script API:
hook_command, hook_command_run, hook_timer, hook_fd, hook_process,
hook_connect, hook_print, hook_signal, hook_signal_send, hook_config,
hook_completion, hook_completion_list_add, hook_modifier, hook_modifier_exec,
hook_info, hook_infolist, unhook, unhook_all
hook_info, hook_info_hashtable, hook_infolist, unhook, unhook_all
| buffers |
buffer_new, current_buffer, buffer_search, buffer_search_main, buffer_clear,
buffer_close, buffer_merge, buffer_unmerge, buffer_get_integer,
@ -291,7 +291,7 @@ List of functions in script API:
| commands |
command
| infos |
info_get
info_get, info_get_hashtable
| infolists |
infolist_new, infolist_new_item, infolist_new_var_integer,
infolist_new_var_string, infolist_new_var_pointer, infolist_new_var_time, +

View File

@ -98,7 +98,7 @@ compile WeeChat.
| python-dev | no | python plugin
| ruby1.8-dev | no | ruby plugin
| liblua5.1-0-dev | no | lua plugin
| tcl-dev | no | tcl plugin
| tcl-dev (>= 8.5) | no | tcl plugin
| asciidoc (>= 8.2) | no | build documentation (HTML files)
| source-highlight | no | syntax highlight for sources in HTML documentation
|========================================
@ -515,7 +515,7 @@ Keys for command line
| Ctrl + R |
Search for text in buffer history (two times: search exact text),
next/previous occurences can be found with up and down arrows +
next/previous occurrences can be found with up and down arrows +
`/input search_text`
| Ctrl + T |

View File

@ -0,0 +1,7 @@
[width="100%",cols="^1,^2,6,6,6",options="header"]
|========================================
| Extension | Nom | Description | Hashtable (entrée) | Hashtable (sortie)
| irc | irc_parse_message | analyse un message IRC | "message": message IRC | "nick": pseudo, "host": nom d'hôte, "command": commande, "channel": canal, "arguments": paramètres (inclut le canal)
|========================================

View File

@ -512,6 +512,9 @@ char *str = weechat_strndup ("abcdef", 3); /* résultat : "abc" */
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_tolower
^^^^^^^^^^^^^^^^^^^^^^
@ -536,6 +539,9 @@ char *str = "AbCdé";
weechat_string_tolower (str); /* str vaut maintenant : "abcdé" */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_toupper
^^^^^^^^^^^^^^^^^^^^^^
@ -560,6 +566,9 @@ char *str = "AbCdé";
weechat_string_tolower (str); /* str vaut maintenant : "ABCDé" */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_strcasecmp
^^^^^^^^^^^^^^^^^^
@ -591,6 +600,9 @@ Exemple en C :
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_strncasecmp
^^^^^^^^^^^^^^^^^^^
@ -624,6 +636,9 @@ Exemple en C :
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_strcmp_ignore_chars
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -660,6 +675,9 @@ Exemple en C :
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_strcasestr
^^^^^^^^^^^^^^^^^^
@ -688,6 +706,9 @@ Exemple en C :
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* résultat : pointeur vers "DeF" */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_match
^^^^^^^^^^^^^^^^^^^^
@ -738,7 +759,7 @@ match4 = weechat.string_match("abcdef", "*de*", 0) # 1
weechat_string_replace
^^^^^^^^^^^^^^^^^^^^^^
Remplace toutes les occurences d'une chaîne par une autre chaîne.
Remplace toutes les occurrences d'une chaîne par une autre chaîne.
Prototype :
@ -768,6 +789,9 @@ char *str = weechat_string_replace ("test, test", "s", "x"); /* résultat : "tex
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_expand_home
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -802,6 +826,9 @@ char *str = weechat_string_expand_home ("~/fichier.txt");
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_remove_quotes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -835,6 +862,9 @@ char *str = weechat_string_remove_quotes (string, " 'aujourd'hui' ", "'");
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_strip
^^^^^^^^^^^^^^^^^^^^
@ -869,6 +899,9 @@ char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* résultat : ".abc"
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_has_highlight
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1008,6 +1041,9 @@ argv = weechat_string_split ("abc de fghi", " ", 1, 0, &argc);
weechat_string_free_split (argv);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_free_split
^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1036,6 +1072,9 @@ argv = weechat_string_split (string, " ", 0, 0, &argc);
weechat_string_free_split (argv);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_build_with_split_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1073,6 +1112,9 @@ char *str = weechat_string_build_with_split_string (argv, ";");
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_split_command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1107,6 +1149,9 @@ char **argv = weechat_string_split_command ("/commande1 arg;/commande2", ';');
weechat_free_split_command (argv);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_free_split_command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1133,6 +1178,9 @@ char **argv = weechat_string_split_command ("/commande1 arg;/commande2", ';');
weechat_free_split_command (argv);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_format_size
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1177,6 +1225,9 @@ char *str = weechat_string_format_size (2097152); /* str == "2 Mo" */
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_remove_color
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1258,6 +1309,9 @@ weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_decode_base64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1292,6 +1346,9 @@ length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_string_is_command_char
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1417,6 +1474,9 @@ if (weechat_utf8_has_8bits (string))
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_is_valid
^^^^^^^^^^^^^^^^^^^^^
@ -1454,6 +1514,9 @@ else
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_normalize
^^^^^^^^^^^^^^^^^^^^^^
@ -1479,6 +1542,9 @@ Exemple en C :
weechat_utf8_normalize (string, '?');
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_prev_char
^^^^^^^^^^^^^^^^^^^^^^
@ -1509,6 +1575,9 @@ Exemple en C :
char *prev_char = weechat_utf8_prev_char (string, ptr_in_string);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_next_char
^^^^^^^^^^^^^^^^^^^^^^
@ -1537,6 +1606,9 @@ Exemple en C :
char *next_char = weechat_utf8_next_char (string);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_char_int
^^^^^^^^^^^^^^^^^^^^^
@ -1564,6 +1636,9 @@ Exemple en C :
int char_int = weechat_utf8_char_int ("être"); /* "ê" comme entier */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_char_size
^^^^^^^^^^^^^^^^^^^^^^
@ -1591,6 +1666,9 @@ Exemple en C :
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_strlen
^^^^^^^^^^^^^^^^^^^
@ -1618,6 +1696,9 @@ Exemple en C :
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_strnlen
^^^^^^^^^^^^^^^^^^^^
@ -1647,6 +1728,9 @@ Exemple en C :
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_strlen_screen
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1675,6 +1759,9 @@ Exemple en C :
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_charcmp
^^^^^^^^^^^^^^^^^^^^
@ -1706,6 +1793,9 @@ Exemple en C :
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_charcasecmp
^^^^^^^^^^^^^^^^^^^^^^^^
@ -1737,6 +1827,9 @@ Exemple en C :
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_char_size_screen
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1765,6 +1858,9 @@ Exemple en C :
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_add_offset
^^^^^^^^^^^^^^^^^^^^^^^
@ -1795,6 +1891,9 @@ char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* pointe vers "ne" */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_real_pos
^^^^^^^^^^^^^^^^^^^^^
@ -1823,6 +1922,9 @@ Exemple en C :
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_pos
^^^^^^^^^^^^^^^^
@ -1851,6 +1953,9 @@ Exemple en C :
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_utf8_strndup
^^^^^^^^^^^^^^^^^^^^
@ -1881,6 +1986,9 @@ char *string = weechat_utf8_strndup ("chêne", 3); /* retourne "chê" */
free (str);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
[[directories]]
Répertoires
~~~~~~~~~~~
@ -2051,6 +2159,9 @@ void callback (void *data, const char *filename)
weechat_exec_on_files ("/tmp", 0, NULL, &callback);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_file_get_content
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2085,6 +2196,9 @@ contenu = weechat_file_get_content ("/tmp/test.txt");
free (contenu);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
[[util]]
Util
~~~~
@ -2124,6 +2238,9 @@ if (weechat_util_timeval_cmp (&tv1, &tv2) > 0)
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_util_timeval_diff
^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2152,6 +2269,9 @@ Exemple en C :
long diff = weechat_util_timeval_diff (&tv1, &tv2);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_util_timeval_add
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2176,6 +2296,9 @@ Exemple en C :
weechat_util_timeval_add (&tv, 2000); /* ajoute 2 secondes */
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_util_get_time_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2203,6 +2326,9 @@ weechat_printf (NULL, "date: %s",
weechat_util_get_time_string (&date));
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
[[sorted_lists]]
Listes triées
~~~~~~~~~~~~~
@ -2772,6 +2898,9 @@ struct t_hashtable *hashtable = weechat_hashtable_new (8,
NULL);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_set_with_size
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2811,6 +2940,9 @@ weechat_hashtable_set_with_size (hashtable, "ma_cle", 0,
my_buffer, sizeof (my_buffer_struct));
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_set
^^^^^^^^^^^^^^^^^^^^^
@ -2843,6 +2975,9 @@ Exemple en C :
weechat_hashtable_set (hashtable, "ma_cle", "ma_valeur");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_get
^^^^^^^^^^^^^^^^^^^^^
@ -2873,6 +3008,9 @@ Exemple en C :
void *value = weechat_hashtable_get (hashtable, "ma_cle");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_map
^^^^^^^^^^^^^^^^^^^^^
@ -2915,6 +3053,9 @@ map_cb (void *data, struct t_hashtable *hashtable,
weechat_hashtable_map (hashtable, &map_cb, NULL);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_get_integer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2939,7 +3080,7 @@ Paramètres :
Valeur en retour :
* valeur entière de l'option
* valeur de la propriété sous forme d'entier
Exemple en C :
@ -2948,6 +3089,55 @@ Exemple en C :
int items_count = weechat_hashtable_get_integer (hashtable, "items_count");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_get_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Nouveau dans la version 0.3.4._
Retourne une valeur pour une propriété d'une hashtable sous forme de chaîne.
Prototype:
[source,C]
----------------------------------------
const char *weechat_hashtable_get_string (struct t_hashtable *hashtable,
void *property);
----------------------------------------
Arguments:
* 'hashtable' : pointeur vers la hashtable
* 'property' : nom de la propriété :
** 'type_keys' : type pour les clés :
*** 'integer' : entier
*** 'string' : chaîne
*** 'pointer' : pointeur
*** 'buffer' : buffer
*** 'time' : heure
** 'type_values': type pour les valeurs :
*** 'integer' : entier
*** 'string' : chaîne
*** 'pointer' : pointeur
*** 'buffer' : buffer
*** 'time' : heure
Valeur en retour :
* valeur de la propriété sous forme de chaîne
Exemple en C :
[source,C]
----------------------------------------
const char *type_keys = weechat_hashtable_get_string (hashtable, "type_keys");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_add_to_infolist
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2991,6 +3181,9 @@ weechat_hashtable_add_to_infolist (hashtable, infolist_item, "testhash");
*/
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_remove
^^^^^^^^^^^^^^^^^^^^^^^^
@ -3017,6 +3210,9 @@ Exemple en C :
weechat_hashtable_remove (hashtable, "ma_cle");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_remove_all
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3042,6 +3238,9 @@ Exemple en C :
weechat_hashtable_remove_all (hashtable);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_hashtable_free
^^^^^^^^^^^^^^^^^^^^^^
@ -3067,6 +3266,9 @@ Exemple en C :
weechat_hashtable_free (hashtable);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
[[configuration_files]]
Fichiers de configuration
~~~~~~~~~~~~~~~~~~~~~~~~~
@ -3708,6 +3910,9 @@ else
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_config_search_with_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3756,6 +3961,9 @@ else
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_config_string_to_boolean
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -4134,6 +4342,9 @@ Exemple en C :
char *description = weechat_config_option_get_pointer (option, "description");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_config_option_is_null
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -4917,6 +5128,8 @@ Exemple en C :
weechat_config_section_free (section);
----------------------------------------
Script (Python) :
[source,python]
----------------------------------------
# prototype
@ -5408,6 +5621,9 @@ Exemple en C :
weechat_printf_date (NULL, time (NULL) - 120, "Bonjour, il y a 2 minutes");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_printf_tags
^^^^^^^^^^^^^^^^^^^
@ -5436,6 +5652,9 @@ weechat_printf_tags (NULL, "notify_message",
"Message avec une étiquette 'notify_message'");
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_printf_date_tags
^^^^^^^^^^^^^^^^^^^^^^^^
@ -6964,7 +7183,7 @@ weechat.hook_modifier_exec("mon_modifier", mes_donnees, ma_chaine)
weechat_hook_info
^^^^^^^^^^^^^^^^^
Accroche une information.
Accroche une information (le "callback" prend et retourne une chaîne).
Prototype :
@ -7031,6 +7250,84 @@ hook = weechat.hook_info("mon_info", "Une information", "Info sur les paramètre
"my_info_cb", "")
----------------------------------------
weechat_hook_info_hashtable
^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Nouveau dans la version 0.3.4._
Accroche une information (le "callback" prend et retourne une hashtable).
Prototype :
[source,C]
----------------------------------------
struct t_hook *weechat_hook_info_hashtable (const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
struct t_hashtable *(*callback)(void *data,
const char *info_name,
struct t_hashtable *hashtable),
void *callback_data);
----------------------------------------
Paramètres :
* 'info_name' : nom de l'information
(priorité autorisée, voir la note sur la <<hook_priority,priorité>>)
* 'description' : description
* 'args_description' : description de la hashtable attendue
(optionnel, peut être NULL)
* 'output_description' : description de la hashtable retournée par le "callback"
(optionnel, peut être NULL)
* 'callback' : fonction appelée quand l'information est demandée, paramètres :
** 'void *data' : pointeur
** 'const char *info_name': nom de l'information
** 'struct t_hashtable *hashtable' : hashtable, dépendant de l'information
* 'callback_data' : pointeur donné au "callback" lorsqu'il est appelé par
WeeChat
Valeur de retour :
* pointeur vers le nouveau "hook", NULL en cas d'erreur
Exemple en C :
[source,C]
----------------------------------------
struct t_hashtable *
my_info_hashtable_cb (void *data, const char *info_name, struct t_hashtable *hashtable)
{
/* ... */
return pointer_vers_nouvelle_hashtable;
}
/* ajoute l'information "mon_info_hashtable" */
struct t_hook *my_info_hook = weechat_hook_info_hashtable ("mon_info_hashtable",
"Une information",
"Info sur la hashtable en entrée",
"Info sur la hashtable en sortie",
&my_info_hashtable_cb, NULL);
----------------------------------------
Script (Python) :
[source,python]
----------------------------------------
# prototype
hook = weechat.hook_info_hashtable(info_name, description, args_description,
output_description, callback, callback_data)
# exemple
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_cle": "test_valeur" }
hook = weechat.hook_info_hashtable("mon_info_hashtable", "Une information",
"Info sur la hashtable en entrée",
"Info sur la hashtable en sortie",
"my_info_hashtable_cb", "")
----------------------------------------
weechat_hook_infolist
^^^^^^^^^^^^^^^^^^^^^
@ -7915,6 +8212,9 @@ my_close_cb (void *data, struct t_gui_buffer *buffer)
weechat_buffer_set_pointer (mon_tampon, "close_callback", &my_close_cb);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_buffer_string_replace_local_var
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9039,6 +9339,9 @@ else
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_network_connect_to
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9089,6 +9392,9 @@ else
}
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
[[infos]]
Infos
~~~~~
@ -9098,7 +9404,7 @@ Fonctions pour obtenir des informations.
weechat_info_get
^^^^^^^^^^^^^^^^
Retourne une information de WeeChat ou d'une extension.
Retourne une information, sous forme de chaîne, de WeeChat ou d'une extension.
Prototype :
@ -9142,6 +9448,75 @@ weechat.prnt("", "La version de WeeChat est : %s (compilée le %s)"
weechat.prnt("", "Le répertoire de WeeChat est : %s" % weechat.info_get("weechat_dir", ""))
----------------------------------------
weechat_info_get_hashtable
^^^^^^^^^^^^^^^^^^^^^^^^^^
_Nouveau dans la version 0.3.4._
Retourne une information, sous forme de hashtable, de WeeChat ou d'une extension.
Prototype:
[source,C]
----------------------------------------
struct t_hashtable *weechat_info_get_hashtable (const char *info_name,
struct t_hashtable *hashtable);
----------------------------------------
Paramètres :
* 'info_name' : nom de l'information à lire :
include::autogen/plugin_api/infos_hashtable.txt[]
* 'hashtable' : hashtable avec les paramètres (dépendant de l'information
demandée) (optionnel, NULL si aucun paramètre n'est nécessaire)
Valeur de retour :
* hashtable avec l'information demandée, NULL en cas d'erreur
Exemple en C :
[source,C]
----------------------------------------
struct t_hashtable *hashtable_in, *hashtable_out;
hashtable_in = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (hashtable_in)
{
weechat_hashtable_set (hashtable_in, "message",
":nick!user@host PRIVMSG #weechat :message ici");
hashtable_out = weechat_info_get_hashtable ("irc_parse_message",
hashtable_in);
/*
* maintenant hashtable_out a les clés/valeurs suivantes :
* "nick" : "nick"
* "host" : "nick!user@host"
* "command" : "PRIVMSG"
* "channel" : "#weechat"
* "arguments": "#weechat :message ici"
*/
weechat_hashtable_free (hashtable_in);
weechat_hashtable_free (hashtable_out);
}
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
dict = weechat.info_get_hashtable(info_name, dict_in)
# example
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message ici" }
weechat.prnt("", "message analysé: %s"
% weechat.info_get_hashtable("irc_parse_message", dict_in))
----------------------------------------
[[infolists]]
Infolists
~~~~~~~~~
@ -9404,6 +9779,9 @@ struct t_infolist_var *var = weechat_infolist_new_var_buffer (item,
sizeof (buffer));
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_infolist_new_var_time
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9834,6 +10212,9 @@ weechat_printf (NULL, "buffer = 0x%lx, taille = %d",
pointer, size);
----------------------------------------
[NOTE]
Cette fonction n'est pas disponible dans l'API script.
weechat_infolist_time
^^^^^^^^^^^^^^^^^^^^^

View File

@ -281,7 +281,7 @@ Liste des fonctions de l'API script :
hook_command, hook_command_run, hook_timer, hook_fd, hook_process,
hook_connect, hook_print, hook_signal, hook_signal_send, hook_config,
hook_completion, hook_completion_list_add, hook_modifier, hook_modifier_exec,
hook_info, hook_infolist, unhook, unhook_all
hook_info, hook_info_hashtable, hook_infolist, unhook, unhook_all
| tampons |
buffer_new, current_buffer, buffer_search, buffer_search_main, buffer_clear,
buffer_close, buffer_merge, buffer_unmerge, buffer_get_integer,
@ -300,7 +300,7 @@ Liste des fonctions de l'API script :
| commandes |
command
| infos |
info_get
info_get, info_get_hashtable
| infolists |
infolist_new, infolist_new_item, infolist_new_var_integer,
infolist_new_var_string, infolist_new_var_pointer, infolist_new_var_time, +

View File

@ -100,7 +100,7 @@ compiler WeeChat.
| python-dev | non | extension python
| ruby1.8-dev | non | extension ruby
| liblua5.1-0-dev | non | extension lua
| tcl-dev | non | extension tcl
| tcl-dev (>= 8.5) | non | extension tcl
| asciidoc (>= 8.2) | non | construction de la documentation (fichiers HTML)
| source-highlight | non | coloration des sources dans la documentation HTML
|========================================
@ -526,7 +526,7 @@ Touches pour la ligne de commande
| Ctrl + R |
Chercher du texte dans l'historique du tampon (deux appuis successifs pour
rechercher du texte exact), les occurences suivantes/précédentes peuvent être
rechercher du texte exact), les occurrences suivantes/précédentes peuvent être
trouvées avec les flèches haut et bas +
`/input search_text`

View File

@ -0,0 +1,7 @@
[width="100%",cols="^1,^2,6,6,6",options="header"]
|========================================
| Plugin | Nome | Descrizione | Hashtable (input) | Hashtable (output)
| irc | irc_parse_message | parse an IRC message | "message": IRC message | "nick": nick, "host": host, "command": command, "channel": channel, "arguments": arguments (includes channel)
|========================================

View File

@ -521,6 +521,10 @@ char *str = weechat_strndup ("abcdef", 3); /* result: "abc" */
free (str);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_tolower
^^^^^^^^^^^^^^^^^^^^^^
@ -545,6 +549,10 @@ char *str = "AbCdé";
weechat_string_tolower (str); /* str ora è: "abcdé" */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_toupper
^^^^^^^^^^^^^^^^^^^^^^
@ -569,6 +577,10 @@ char *str = "AbCdé";
weechat_string_tolower (str); /* str ora è: "ABCDé" */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_strcasecmp
^^^^^^^^^^^^^^^^^^
@ -601,6 +613,10 @@ Esempio in C:
int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_strncasecmp
^^^^^^^^^^^^^^^^^^^
@ -634,6 +650,10 @@ Esempio in C:
int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_strcmp_ignore_chars
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -671,6 +691,10 @@ Esempio in C:
int diff = weechat_strcmp_ignore_chars ("a-b", "--a-e", "-", 1); /* == -3 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_strcasestr
^^^^^^^^^^^^^^^^^^
@ -700,6 +724,10 @@ Esempio in C:
char *pos = weechat_strcasestr ("aBcDeF", "de"); /* risultato: puntatore a "DeF" */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_match
^^^^^^^^^^^^^^^^^^^^
@ -780,6 +808,10 @@ char *str = weechat_string_replace ("test", "s", "x"); /* result: "text" */
free (str);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_expand_home
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -814,6 +846,10 @@ char *str = weechat_string_expand_home ("~/file.txt");
free (str);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_remove_quotes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -847,6 +883,10 @@ char *str = weechat_string_remove_quotes (string, " 'Non posso' ", "'");
free (str);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_strip
^^^^^^^^^^^^^^^^^^^^
@ -880,6 +920,10 @@ char *str = weechat_string_strip (".abc -", 0, 1, "- ."); /* risultato: ".abc" *
free (str);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_has_highlight
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1046,6 +1090,10 @@ argv = weechat_string_split (string, " ", 0, 0, &argc);
weechat_string_free_split (argv);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_build_with_split_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1083,6 +1131,10 @@ char *str = weechat_string_build_with_split_string (argv, ";");
free (str);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_split_command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1117,6 +1169,10 @@ char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
weechat_free_split_command (argv);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_free_split_command
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1143,6 +1199,10 @@ char **argv = weechat_string_split_command ("/command1 arg;/command2", ';');
weechat_free_split_command (argv);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_format_size
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1268,6 +1328,10 @@ weechat_string_encode_base64 (string, strlen (string), result);
/* result == "YWJjZGVmZ2g=" */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_decode_base64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1302,6 +1366,10 @@ length = weechat_string_decode_base64 (string, result);
/* length == 8, result == "abcdefgh" */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_string_is_command_char
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1326,7 +1394,7 @@ Valore restituito:
* 1 se il primo carattere della stringa è un comando carattere,
altrimenti 0
C examples:
Esempi in C:
[source,C]
----------------------------------------
@ -1341,7 +1409,7 @@ Script (Python):
# prototype
is_cmdchar = weechat.string_is_command_char(string)
# examples
# esempi
command_char1 = weechat.string_is_command_char("/test") # == 1
command_char2 = weechat.string_is_command_char("test") # == 0
----------------------------------------
@ -1369,7 +1437,7 @@ Valore restituito:
* puntatore all'interno di "string", oppure NULL
C examples:
Esempi in C:
[source,C]
----------------------------------------
@ -1385,7 +1453,7 @@ Script (Python):
# prototype
str = weechat.string_input_for_buffer(string)
# examples
# esempi
str1 = weechat.string_input_for_buffer("test") # "test"
str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
@ -1427,6 +1495,10 @@ if (weechat_utf8_has_8bits (string))
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_is_valid
^^^^^^^^^^^^^^^^^^^^^
@ -1464,6 +1536,10 @@ else
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_normalize
^^^^^^^^^^^^^^^^^^^^^^
@ -1489,6 +1565,10 @@ Esempio in C:
weechat_utf8_normalize (string, '?');
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_prev_char
^^^^^^^^^^^^^^^^^^^^^^
@ -1519,6 +1599,10 @@ Esempio in C:
char *prev_char = weechat_utf8_prev_char (string, ptr_in_string);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_next_char
^^^^^^^^^^^^^^^^^^^^^^
@ -1547,6 +1631,10 @@ Esempio in C:
char *next_char = weechat_utf8_next_char (string);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_char_int
^^^^^^^^^^^^^^^^^^^^^
@ -1574,6 +1662,10 @@ Esempio in C:
int char_int = weechat_utf8_char_int ("être"); /* "ê" come intero */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_char_size
^^^^^^^^^^^^^^^^^^^^^^
@ -1601,6 +1693,10 @@ Esempio in C:
int char_size = weechat_utf8_char_size ("être"); /* == 2 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_strlen
^^^^^^^^^^^^^^^^^^^
@ -1628,6 +1724,10 @@ Esempio in C:
int length = weechat_utf8_strlen ("chêne"); /* == 5 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_strnlen
^^^^^^^^^^^^^^^^^^^^
@ -1657,6 +1757,10 @@ Esempio in C:
int length = weechat_utf8_strnlen ("chêne", 4); /* == 3 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_strlen_screen
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1686,6 +1790,10 @@ Esempio in C:
int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_charcmp
^^^^^^^^^^^^^^^^^^^^
@ -1717,6 +1825,10 @@ Esempio in C:
int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_charcasecmp
^^^^^^^^^^^^^^^^^^^^^^^^
@ -1748,6 +1860,10 @@ Esempio in C:
int diff = weechat_utf8_charcasecmp ("aaa", "CCC"); /* == -2 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_char_size_screen
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -1777,6 +1893,10 @@ Esempio in C:
int length_on_screen = weechat_utf8_char_size_screen ("é"); /* == 1 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_add_offset
^^^^^^^^^^^^^^^^^^^^^^^
@ -1806,6 +1926,10 @@ char *str = "chêne";
char *str2 = weechat_utf8_add_offset (str, 3); /* points to "ne" */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_real_pos
^^^^^^^^^^^^^^^^^^^^^
@ -1834,6 +1958,10 @@ Esempio in C:
int pos = weechat_utf8_real_pos ("chêne", 3); /* == 4 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_pos
^^^^^^^^^^^^^^^^
@ -1862,6 +1990,10 @@ Esempio in C:
int pos = weechat_utf8_pos ("chêne", 4); /* == 3 */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_utf8_strndup
^^^^^^^^^^^^^^^^^^^^
@ -1892,6 +2024,10 @@ char *string = weechat_utf8_strndup ("chêne", 3); /* restituisce "chê" */
free (string);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
[[directories]]
Cartelle
~~~~~~~~
@ -2061,6 +2197,10 @@ void callback (void *data, const char *filename)
weechat_exec_on_files ("/tmp", 0, NULL, &callback);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_file_get_content
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2095,6 +2235,10 @@ content = weechat_file_get_content ("/tmp/test.txt");
free (content);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
[[util]]
Utilità
~~~~~~~
@ -2134,6 +2278,10 @@ if (weechat_util_timeval_cmp (&tv1, &tv2) > 0)
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_util_timeval_diff
^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2162,6 +2310,10 @@ Esempio in C:
long diff = weechat_util_timeval_diff (&tv1, &tv2);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_util_timeval_add
^^^^^^^^^^^^^^^^^^^^^^^^
@ -2186,6 +2338,10 @@ Esempio in C:
weechat_util_timeval_add (&tv, 2000); /* aggiunge 2 secondi */
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_util_get_time_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2213,6 +2369,10 @@ weechat_printf (NULL, "date: %s",
weechat_util_get_time_string (&date));
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
[[sorted_lists]]
Elenchi ordinati
~~~~~~~~~~~~~~~~
@ -2783,6 +2943,10 @@ struct t_hashtable *hashtable = weechat_hashtable_new (8,
NULL);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_set_with_size
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2822,6 +2986,10 @@ weechat_hashtable_set_with_size (hashtable, "my_key", 0,
my_buffer, sizeof (my_buffer_struct));
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_set
^^^^^^^^^^^^^^^^^^^^^
@ -2884,6 +3052,10 @@ Esempio in C:
void *value = weechat_hashtable_get (hashtable, "my_key");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_map
^^^^^^^^^^^^^^^^^^^^^
@ -2926,6 +3098,10 @@ map_cb (void *data, struct t_hashtable *hashtable,
weechat_hashtable_map (hashtable, &map_cb, NULL);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_get_integer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -2959,6 +3135,58 @@ Esempio in C:
int items_count = weechat_hashtable_get_integer (hashtable, "items_count");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
// TRANSLATION MISSING
weechat_hashtable_get_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Novità nella versione 0.3.4._
Return string value of a hashtable property.
Prototype:
[source,C]
----------------------------------------
const char *weechat_hashtable_get_string (struct t_hashtable *hashtable,
void *property);
----------------------------------------
Arguments:
* 'hashtable': hashtable pointer
* 'property': property name:
** 'type_keys': type for keys:
*** 'integer': integer
*** 'string': string
*** 'pointer': pointer
*** 'buffer': buffer
*** 'time': time
** 'type_values': type for values:
*** 'integer': integer
*** 'string': string
*** 'pointer': pointer
*** 'buffer': buffer
*** 'time': time
Return value:
* string value of property
Esempio in C:
[source,C]
----------------------------------------
const char *type_keys = weechat_hashtable_get_string (hashtable, "type_keys");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_add_to_infolist
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3002,6 +3230,10 @@ weechat_hashtable_add_to_infolist (hashtable, infolist_item, "testhash");
*/
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_remove
^^^^^^^^^^^^^^^^^^^^^^^^
@ -3028,6 +3260,10 @@ Esempio in C:
weechat_hashtable_remove (hashtable, "my_key");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_remove_all
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3053,6 +3289,10 @@ Esempio in C:
weechat_hashtable_remove_all (hashtable);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_hashtable_free
^^^^^^^^^^^^^^^^^^^^^^
@ -3078,6 +3318,10 @@ Esempio in C:
weechat_hashtable_free (hashtable);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
[[configuration_files]]
File di configurazione
~~~~~~~~~~~~~~~~~~~~~~
@ -3707,6 +3951,10 @@ else
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_config_search_with_string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -3754,6 +4002,10 @@ else
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_config_string_to_boolean
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -4132,6 +4384,10 @@ Esempio in C:
char *description = weechat_config_option_get_pointer (option, "description");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_config_option_is_null
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -5403,6 +5659,10 @@ Esempio in C:
weechat_printf_date (NULL, time (NULL) - 120, "Ciao, 2 minuti fa");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_printf_tags
^^^^^^^^^^^^^^^^^^^
@ -5431,6 +5691,10 @@ weechat_printf_tags (NULL, "notify_message",
"Messaggio con tag 'notify_message'");
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_printf_date_tags
^^^^^^^^^^^^^^^^^^^^^^^^
@ -5576,7 +5840,7 @@ removed from string).
Default priority is 1000.
C example:
Esempio in C:
[source,C]
----------------------------------------
@ -6951,7 +7215,8 @@ weechat.hook_modifier_exec("my_modifier", my_data, my_string)
weechat_hook_info
^^^^^^^^^^^^^^^^^
Hook su una informazione.
// TRANSLATION MISSING
Hook su una informazione (callback takes and returns a string).
Prototipo:
@ -7016,6 +7281,83 @@ hook = weechat.hook_info("my_info", "Some info", "Info about arguments",
"my_info_cb", "")
----------------------------------------
// TRANSLATION MISSING
weechat_hook_info_hashtable
^^^^^^^^^^^^^^^^^^^^^^^^^^^
_Novità nella versione 0.3.4._
Hook an information (callback takes and returns a hashtable).
Prototype:
[source,C]
----------------------------------------
struct t_hook *weechat_hook_info_hashtable (const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
struct t_hashtable *(*callback)(void *data,
const char *info_name,
struct t_hashtable *hashtable),
void *callback_data);
----------------------------------------
Arguments:
* 'info_name': name of info
(priority allowed, see note about <<hook_priority,priority>>)
* 'description': description
* 'args_description': description of expected hashtable (optional, can be NULL)
* 'output_description': description of hashtable returned by callback
(optional, can be NULL)
* 'callback': function called when info is asked, arguments:
** 'void *data': pointer
** 'const char *info_name': name of info
** 'struct t_hashtable *hashtable': hashtable, depending on info
* 'callback_data': pointer given to callback when it is called by WeeChat
Return value:
* pointer to new hook, NULL if error occured
Esempio in C:
[source,C]
----------------------------------------
struct t_hashtable *
my_info_hashtable_cb (void *data, const char *info_name, struct t_hashtable *hashtable)
{
/* ... */
return pointer_to_new_hashtable;
}
/* add info "my_info_hashtable" */
struct t_hook *my_info_hook = weechat_hook_info_hashtable ("my_info_hashtable",
"Some info",
"Info about input hashtable",
"Info about output hashtable",
&my_info_hashtable_cb, NULL);
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
hook = weechat.hook_info_hashtable(info_name, description, args_description,
output_description, callback, callback_data)
# esempio
def my_info_hashtable_cb(data, info_name, hashtable):
return { "test_key": "test_value" }
hook = weechat.hook_info_hashtable("my_info_hashtable", "Some info",
"Info about input hashtable",
"Info about output hashtable",
"my_info_hashtable_cb", "")
----------------------------------------
weechat_hook_infolist
^^^^^^^^^^^^^^^^^^^^^
@ -7898,6 +8240,10 @@ my_close_cb (void *data, struct t_gui_buffer *buffer)
weechat_buffer_set_pointer (my_buffer, "close_callback", &my_close_cb);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_buffer_string_replace_local_var
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9017,6 +9363,10 @@ else
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_network_connect_to
^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9068,6 +9418,10 @@ else
}
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
[[infos]]
Info
~~~~
@ -9077,7 +9431,8 @@ Funzioni per ottenere info.
weechat_info_get
^^^^^^^^^^^^^^^^
Restituisce informazioni da WeeChat o da un plugin.
// TRANSLATION MISSING
Return info, as string, from WeeChat or a plugin.
Prototipo:
@ -9121,6 +9476,76 @@ weechat.prnt("", "Current WeeChat version is: %s (compiled on %s)"
weechat.prnt("", "WeeChat home is: %s" % weechat.info_get("weechat_dir"))
----------------------------------------
// TRANSLATION MISSING
weechat_info_get_hashtable
^^^^^^^^^^^^^^^^^^^^^^^^^^
_Novità nella versione 0.3.4._
Return info, as hashtable, from WeeChat or a plugin.
Prototype:
[source,C]
----------------------------------------
struct t_hashtable *weechat_info_get_hashtable (const char *info_name,
struct t_hashtable *hashtable);
----------------------------------------
Arguments:
* 'info_name': name of info to read:
include::autogen/plugin_api/infos_hashtable.txt[]
* 'hashtable': hashtable with arguments (depends on info asked) (optional, NULL
if no argument is needed)
Return value:
* hashtable with info asked, NULL if an error occured
Esempio in C:
[source,C]
----------------------------------------
struct t_hashtable *hashtable_in, *hashtable_out;
hashtable_in = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (hashtable_in)
{
weechat_hashtable_set (hashtable_in, "message",
":nick!user@host PRIVMSG #weechat :message here");
hashtable_out = weechat_info_get_hashtable ("irc_parse_message",
hashtable_in);
/*
* now hashtable_out has following keys/values:
* "nick" : "nick"
* "host" : "nick!user@host"
* "command" : "PRIVMSG"
* "channel" : "#weechat"
* "arguments": "#weechat :message here"
*/
weechat_hashtable_free (hashtable_in);
weechat_hashtable_free (hashtable_out);
}
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
dict = weechat.info_get_hashtable(info_name, dict_in)
# esempio
dict_in = { "message": ":nick!user@host PRIVMSG #weechat :message here" }
weechat.prnt("", "message parsed: %s"
% weechat.info_get_hashtable("irc_parse_message", dict_in))
----------------------------------------
[[infolists]]
Liste info
~~~~~~~~~~
@ -9385,6 +9810,10 @@ struct t_infolist_var *var = weechat_infolist_new_variable_buffer (item,
sizeof (buffer));
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_infolist_new_var_time
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9816,6 +10245,10 @@ weechat_printf (NULL, "buffer = 0x%lx, size = %d",
pointer, size);
----------------------------------------
[NOTE]
// TRANSLATION MISSING
This function is not available in scripting API.
weechat_infolist_time
^^^^^^^^^^^^^^^^^^^^^

View File

@ -281,7 +281,7 @@ Elenco di funzioni nelle API per gli script:
hook_command, hook_command_run, hook_timer, hook_fd, hook_process,
hook_connect, hook_print, hook_signal, hook_signal_send, hook_config,
hook_completion, hook_completion_list_add, hook_modifier, hook_modifier_exec,
hook_info, hook_infolist, unhook, unhook_all
hook_info, hook_info_hashtable, hook_infolist, unhook, unhook_all
| buffer |
buffer_new, current_buffer, buffer_search, buffer_search_main, buffer_clear,
buffer_close, buffer_merge, buffer_unmerge, buffer_get_integer,
@ -300,7 +300,7 @@ Elenco di funzioni nelle API per gli script:
| comandi |
comando
| info |
info_get
info_get, info_get_hashtable
| liste info |
infolist_new, infolist_new_item, infolist_new_var_integer,
infolist_new_var_string, infolist_new_var_pointer, infolist_new_var_time, +

View File

@ -102,7 +102,7 @@ compilare WeeChat.
| python-dev | no | plugin python
| ruby1.8-dev | no | plugin ruby
| liblua5.1-0-dev | no | plugin lua
| tcl-dev | no | plugin tcl
| tcl-dev (>= 8.5) | no | plugin tcl
| asciidoc (>= 8.2) | no | compilazione della documentazione (file HTML)
| source-highlight | no | evidenziazione della sintassi per i sorgenti nella documentazione HTML
|========================================
@ -525,7 +525,7 @@ Tasti per la riga di comando
// TRANSLATION MISSING
| Ctrl + R |
Cerca il testo nella cronologia del buffer (due volte: cerca testo esatto),
next/previous occurences can be found with up and down arrows +
next/previous occurrences can be found with up and down arrows +
`/input search_text`
| Ctrl + T |

View File

@ -20,14 +20,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: Czech\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: Czech\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#. TRANSLATORS: "%s %s" after "compiled on" is date and time
@ -4835,6 +4835,20 @@ msgstr "server,funkce"
msgid "value of feature, if supported by server (from IRC message 005)"
msgstr "hodnota funkce, pokud je podporována serverem (z IRC zprávy 005)"
#, fuzzy
msgid "parse an IRC message"
msgstr "zpráva: zpráva, která se má poslat"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "zpráva: zpráva, která se má poslat"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
msgid "list of IRC servers"
msgstr "seznam IRC serverů"
@ -5034,8 +5048,8 @@ msgstr[2] "minut"
msgid ""
"%s%s[%s%s%s]%s idle: %s%02d %s%s %s%02d %s%s %s%02d %s%s, signon at: %s%s"
msgstr ""
"%s%s[%s%s%s]%s nečinný: %s%02d %s%s %s%02d %s%s %s%02d %s%s, přihlášen v: %s%"
"s"
"%s%s[%s%s%s]%s nečinný: %s%02d %s%s %s%02d %s%s %s%02d %s%s, přihlášen v: %s"
"%s"
#, c-format
msgid "%sMode %s%s %s[%s%s%s]"
@ -5839,8 +5853,8 @@ msgstr "%sMůžete smazat tento soubor, pokud je plugin \"%s\" starý/neplatný"
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%sChyba: chyba API v pluginu \"%s\" (aktuální API: \"%s\", API pluginu: \"%s"
"\"), načtení selhalo"
@ -5941,8 +5955,8 @@ msgstr "Klienti pro přenos:"
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
"%3d. %s%s%s (%s%s%s), spuštěn v: %s, poslední aktivita: %s, bytů: %lu "
"přijato, %lu odebráno"
@ -6586,8 +6600,8 @@ msgstr "Xfer seznam:"
msgid ""
"%3d. %s (%s), file: \"%s\" (local: \"%s\"), %s %s, status: %s%s%s (%lu %%)"
msgstr ""
"%3d. %s (%s), soubor: \"%s\" (lokální: \"%s\"), %s %s, status: %s%s%s (%lu %"
"%)"
"%3d. %s (%s), soubor: \"%s\" (lokální: \"%s\"), %s %s, status: %s%s%s (%lu "
"%%)"
#. TRANSLATORS: "%s" after "started on" is date
#, c-format
@ -6600,8 +6614,8 @@ msgid ""
" plugin: %s (id: %s), file: %lu bytes (position: %lu), address: %d.%d.%d."
"%d (port %d)"
msgstr ""
" plugin: %s (id: %s), soubor: %lu bytů (pozice: %lu), adresa: %d.%d.%d.%"
"d (port %d)"
" plugin: %s (id: %s), soubor: %lu bytů (pozice: %lu), adresa: %d.%d.%d."
"%d (port %d)"
#. TRANSLATORS: "%s" after "started on" is date
#, c-format
@ -6714,8 +6728,8 @@ msgstr "konvertovat mezery na podtržítka při odesílání souborů"
msgid "rename incoming files if already exists (add \".1\", \".2\", ...)"
msgstr ""
"přejmenovat příchozí soubory, jestliže již existují (přídat \".1\", \".2"
"\", ...)"
"přejmenovat příchozí soubory, jestliže již existují (přídat \".1\", "
"\".2\", ...)"
msgid ""
"automatically resume file transfer if connection with remote host is lost"
@ -6791,6 +6805,12 @@ msgstr "Popis"
msgid "Arguments"
msgstr "Argumenty"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
msgid "Pointer"
msgstr "Ukazatel"

View File

@ -22,14 +22,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Nils G. <weechatter@arcor.de>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: German\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: KBabel 1.11.4\n"
"X-Poedit-Bookmarks: -1,-1,180,-1,-1,-1,-1,-1,-1,-1\n"
@ -5033,6 +5033,20 @@ msgstr ""
"Wert der Funktion, sofern es vom Server unterstützt wird (durch IRC Message "
"005)"
#, fuzzy
msgid "parse an IRC message"
msgstr "Message: zu sendende Nachricht"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "Message: zu sendende Nachricht"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
msgid "list of IRC servers"
msgstr "Liste der IRC-Server"
@ -5389,8 +5403,8 @@ msgstr ""
#, c-format
msgid "%s%s: nickname \"%s\" is unavailable, trying nickname #%d (\"%s\")"
msgstr ""
"%s%s: Der Nickname \"%s\" ist nicht verfügbar. Versuche nun den Nicknamen #%"
"d (\"%s\")"
"%s%s: Der Nickname \"%s\" ist nicht verfügbar. Versuche nun den Nicknamen #"
"%d (\"%s\")"
#, c-format
msgid "%s%s: command \"%s\" not found:"
@ -6060,8 +6074,8 @@ msgstr ""
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%sFehler: API Unverträglichkeit für Erweiterung \"%s\" (genutzte API: \"%s"
"\", Erweiterungs-API: \"%s\"), Installation fehlgeschlagen"
@ -6164,8 +6178,8 @@ msgstr "Clients für Relay:"
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
"%3d. %s%s%s (%s%s%s), gestartet am: %s, letzte Aktivität: %s, Bytes: %lu "
"empfangen, %lu gesendet"
@ -6826,8 +6840,8 @@ msgstr ""
#, c-format
msgid "%3d. %s, chat with %s (local nick: %s), started on %s, status: %s%s"
msgstr ""
"%3d. %s, Der Chat mit %s (lokaler Nick: %s), wurde am %s gestartet, Status: %"
"s%s"
"%3d. %s, Der Chat mit %s (lokaler Nick: %s), wurde am %s gestartet, Status: "
"%s%s"
#, c-format
msgid ""
@ -7031,6 +7045,12 @@ msgstr "Beschreibung"
msgid "Arguments"
msgstr "Argumente"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
msgid "Pointer"
msgstr "Pointer"

View File

@ -21,14 +21,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: Spanish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: Spanish\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. TRANSLATORS: "%s %s" after "compiled on" is date and time
@ -4900,6 +4900,20 @@ msgstr ""
"valor de la característica, si es soportada por el servidor (desde el "
"mensaje IRC 005)"
#, fuzzy
msgid "parse an IRC message"
msgstr "mensaje: mensaje a enviar"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "mensaje: mensaje a enviar"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
msgid "list of IRC servers"
msgstr "lista de servidores IRC"
@ -5914,8 +5928,8 @@ msgstr "%sSi el plugin \"%s\" es viejo/obsoleto, puedes borrar este archivo."
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%sError: API del plugin \"%s\" es incompatible (API actual: \"%s\", API del "
"plugin: \"%s\"), no se puede cargar"
@ -6019,8 +6033,8 @@ msgstr "Clientes para retransmitir:"
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
"%3d. %s%s%s (%s%s%s), iniciado en: %s, última actividad: %s, bytes: %lu "
"recibidos, %lu enviados"
@ -6687,8 +6701,8 @@ msgid ""
" plugin: %s (id: %s), file: %lu bytes (position: %lu), address: %d.%d.%d."
"%d (port %d)"
msgstr ""
" plugin: %s (id: %s), archivo: %lu bytes (posición: %lu), dirección: %d.%"
"d.%d.%d (puerto %d)"
" plugin: %s (id: %s), archivo: %lu bytes (posición: %lu), dirección: %d."
"%d.%d.%d (puerto %d)"
#. TRANSLATORS: "%s" after "started on" is date
#, c-format
@ -6882,6 +6896,12 @@ msgstr "Descripción"
msgid "Arguments"
msgstr "Argumentos"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
msgid "Pointer"
msgstr "Puntero"

View File

@ -21,14 +21,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"PO-Revision-Date: 2010-08-14 12:25+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-20 15:30+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: French\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. TRANSLATORS: "%s %s" after "compiled on" is date and time
@ -955,8 +955,8 @@ msgstr ""
" clear: efface le contenu du tampon (un numéro pour un tampon, -merged "
"pour les tampons mélangés, -all pour tous les tampons, ou rien pour le "
"tampon courant)\n"
" move: déplace le tampon dans la liste (peut être relatif, par exemple -"
"1)\n"
" move: déplace le tampon dans la liste (peut être relatif, par exemple "
"-1)\n"
" merge: mélange le tampon courant avec un autre tampon (la zone de "
"discussion sera un mélange des deux tampons)\n"
" (par défaut ctrl-x bascule entre les tampons mélangés)\n"
@ -4947,6 +4947,20 @@ msgid "value of feature, if supported by server (from IRC message 005)"
msgstr ""
"valeur de la fonctionnalité, si supportée par le serveur (du message IRC 005)"
msgid "parse an IRC message"
msgstr "analyse un message IRC"
msgid "\"message\": IRC message"
msgstr "\"message\": message IRC"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
"\"nick\": pseudo, \"host\": nom d'hôte, \"command\": commande, \"channel\": "
"canal, \"arguments\": paramètres (inclut le canal)"
msgid "list of IRC servers"
msgstr "liste des serveurs IRC"
@ -5144,8 +5158,8 @@ msgstr[1] "minutes"
msgid ""
"%s%s[%s%s%s]%s idle: %s%02d %s%s %s%02d %s%s %s%02d %s%s, signon at: %s%s"
msgstr ""
"%s%s[%s%s%s]%s inactivité: %s%02d %s%s %s%02d %s%s %s%02d %s%s, signé le: %s%"
"s"
"%s%s[%s%s%s]%s inactivité: %s%02d %s%s %s%02d %s%s %s%02d %s%s, signé le: %s"
"%s"
#, c-format
msgid "%sMode %s%s %s[%s%s%s]"
@ -5959,8 +5973,8 @@ msgstr ""
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%sErreur: API non concordante pour l'extension \"%s\" (API courante: \"%s\", "
"API extension: \"%s\"), échec de chargement"
@ -6064,8 +6078,8 @@ msgstr "Clients pour le relai:"
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
"%3d. %s%s%s (%s%s%s), démarré le: %s, dernière activité: %s, octets: %lu "
"reçus, %lu envoyés"
@ -6742,8 +6756,8 @@ msgid ""
" plugin: %s (id: %s), file: %lu bytes (position: %lu), address: %d.%d.%d."
"%d (port %d)"
msgstr ""
" extension: %s (id: %s), fichier: %lu octets (position: %lu), addresse: %"
"d.%d.%d.%d (port %d)"
" extension: %s (id: %s), fichier: %lu octets (position: %lu), addresse: "
"%d.%d.%d.%d (port %d)"
#. TRANSLATORS: "%s" after "started on" is date
#, c-format
@ -6940,5 +6954,11 @@ msgstr "Description"
msgid "Arguments"
msgstr "Paramètres"
msgid "Hashtable (input)"
msgstr "Hashtable (entrée)"
msgid "Hashtable (output)"
msgstr "Hashtable (sortie)"
msgid "Pointer"
msgstr "Pointeur"

View File

@ -20,14 +20,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: Hungarian\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: Hungarian\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
#. TRANSLATORS: "%s %s" after "compiled on" is date and time
@ -950,8 +950,8 @@ msgstr ""
" close: puffer bezárása (esetleges argumentum egy kilépő üzenet szoba "
"esetén)\n"
" list: nyitott pufferek listája (paraméter hiányában is ez fut le)\n"
" notify: értesítési szint beállítása (0=soha, 1=highlight, 2=1+üzenet, 3=2"
"+ki/belépés)\n"
" notify: értesítési szint beállítása (0=soha, 1=highlight, 2=1+üzenet, "
"3=2+ki/belépés)\n"
" (ha a szerver pufferben kerül lefuttatásra, akkor az egész "
"szerverre állítja az értesítési szintet)\n"
" scroll: puffertörténet görgetése (lehet relatív és végződhet betűvel: "
@ -4619,6 +4619,20 @@ msgstr "cél: szerver neve"
msgid "value of feature, if supported by server (from IRC message 005)"
msgstr ""
#, fuzzy
msgid "parse an IRC message"
msgstr "üzenet: küldendő üzenet"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "üzenet: küldendő üzenet"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
#, fuzzy
msgid "list of IRC servers"
msgstr "IRC szerver portja"
@ -5216,8 +5230,8 @@ msgstr ""
#, fuzzy, c-format
msgid "Connecting to server %s/%d%s%s via %s proxy %s/%d%s..."
msgstr ""
"Csatlakozás a(z) %s:%d%s%s szerverhez %s proxy kiszolgálón keresztül: %s:%d%"
"s...\n"
"Csatlakozás a(z) %s:%d%s%s szerverhez %s proxy kiszolgálón keresztül: %s:%d"
"%s...\n"
#, fuzzy, c-format
msgid "%s: connecting to server %s/%d%s%s..."
@ -5576,8 +5590,8 @@ msgstr ""
#, fuzzy, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%s a \"plugin_name\" szimbólum nem található a \"%s\" modulban, betöltés "
"sikertelen\n"
@ -5685,8 +5699,8 @@ msgstr ""
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
#, fuzzy, c-format
@ -6229,15 +6243,15 @@ msgstr "%s nincs elegendő memória új DCC számára\n"
#, fuzzy, c-format
msgid "%s: incoming file from %s (%d.%d.%d.%d): %s, %lu bytes (protocol: %s)"
msgstr ""
"Beérkező DCC fájl a következőtől: %s%s%s (%s%d.%d.%d.%d%s)%s: %s%s%s, %s%lu%"
"s bájt\n"
"Beérkező DCC fájl a következőtől: %s%s%s (%s%d.%d.%d.%d%s)%s: %s%s%s, %s%lu"
"%s bájt\n"
#, fuzzy, c-format
msgid ""
"%s: sending file to %s: %s (local filename: %s), %lu bytes (protocol: %s)"
msgstr ""
"DCC fájl küldése a következőnek: %s%s%s: %s%s%s (helyi fájlnév: %s%s%s), %s%"
"lu%s bájt\n"
"DCC fájl küldése a következőnek: %s%s%s: %s%s%s (helyi fájlnév: %s%s%s), %s"
"%lu%s bájt\n"
#, fuzzy, c-format
msgid "%s: incoming chat request from %s (%d.%d.%d.%d)"
@ -6290,8 +6304,8 @@ msgid ""
"%s%s: unable to resume file \"%s\" (port: %d, start position: %lu): xfer not "
"found or not ready for transfer"
msgstr ""
"%s nem sikerült a(z) \"%s\" fájlra visszatérni (port: %d, indulási pozíció: %"
"u): DCC nem található vagy véget ért\n"
"%s nem sikerült a(z) \"%s\" fájlra visszatérni (port: %d, indulási pozíció: "
"%u): DCC nem található vagy véget ért\n"
#, fuzzy, c-format
msgid "%s: file %s resumed at position %lu"
@ -6302,8 +6316,8 @@ msgid ""
"%s%s: unable to accept resume file \"%s\" (port: %d, start position: %lu): "
"xfer not found or not ready for transfer"
msgstr ""
"%s nem sikerült a(z) \"%s\" fájlra visszatérni (port: %d, indulási pozíció: %"
"u): DCC nem található vagy véget ért\n"
"%s nem sikerült a(z) \"%s\" fájlra visszatérni (port: %d, indulási pozíció: "
"%u): DCC nem található vagy véget ért\n"
#, fuzzy, c-format
msgid "%s%s: aborting active xfer: \"%s\" from %s"
@ -6540,6 +6554,12 @@ msgstr " . leírás : %s\n"
msgid "Arguments"
msgstr "fogadó típusa [paraméterek]"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
#, fuzzy
msgid "Pointer"
msgstr "perc"

View File

@ -20,14 +20,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: Italian\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: Italian\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. TRANSLATORS: "%s %s" after "compiled on" is date and time
@ -4909,6 +4909,20 @@ msgid "value of feature, if supported by server (from IRC message 005)"
msgstr ""
"valore della caratteristica, se supportata dal servre (dal messaggio IRC 005)"
#, fuzzy
msgid "parse an IRC message"
msgstr "messaggio: messaggio da inviare"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "messaggio: messaggio da inviare"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
msgid "list of IRC servers"
msgstr "elenco di server IRC"
@ -5106,8 +5120,8 @@ msgstr[1] "minuti"
msgid ""
"%s%s[%s%s%s]%s idle: %s%02d %s%s %s%02d %s%s %s%02d %s%s, signon at: %s%s"
msgstr ""
"%s%s[%s%s%s]%s inattivo: %s%02d %s%s %s%02d %s%s %s%02d %s%s, connesso dal: %"
"s%s"
"%s%s[%s%s%s]%s inattivo: %s%02d %s%s %s%02d %s%s %s%02d %s%s, connesso dal: "
"%s%s"
#, c-format
msgid "%sMode %s%s %s[%s%s%s]"
@ -5917,8 +5931,8 @@ msgstr ""
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%sErrore: API non corrispondente per il plugin \"%s\" (API corrente: \"%s\", "
"API del plugin: \"%s\"), impossibile effettuare il caricamento"
@ -6022,8 +6036,8 @@ msgstr "Client per relay:"
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
"%3d, %s%s%s (%s%s%s), avviato il %s, attività recente: %s byte: %lu "
"ricevuti, %lu inviati"
@ -6632,8 +6646,8 @@ msgid ""
"%s%s: unable to resume file \"%s\" (port: %d, start position: %lu): xfer not "
"found or not ready for transfer"
msgstr ""
"%s%s: impossibile riprendere il file \"%s\" (porta: %d, posizione di avvio: %"
"lu): xfer non trovato o non pronto per il trasferimento"
"%s%s: impossibile riprendere il file \"%s\" (porta: %d, posizione di avvio: "
"%lu): xfer non trovato o non pronto per il trasferimento"
#, c-format
msgid "%s: file %s resumed at position %lu"
@ -6682,8 +6696,8 @@ msgid ""
" plugin: %s (id: %s), file: %lu bytes (position: %lu), address: %d.%d.%d."
"%d (port %d)"
msgstr ""
" plugin: %s (id: %s), file: %lu byte (posizione: %lu), indirizzo: %d.%d.%"
"d.%d (porta %d)"
" plugin: %s (id: %s), file: %lu byte (posizione: %lu), indirizzo: %d.%d."
"%d.%d (porta %d)"
#. TRANSLATORS: "%s" after "started on" is date
#, c-format
@ -6872,6 +6886,12 @@ msgstr "Descrizione"
msgid "Arguments"
msgstr "Argomenti"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
msgid "Pointer"
msgstr "Puntatore"

View File

@ -21,14 +21,14 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: Polish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: Polish\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
"|| n%100>=20) ? 1 : 2);\n"
@ -750,8 +750,8 @@ msgstr[2] "dni"
#, c-format
msgid "WeeChat uptime: %s%d %s%s %s%02d%s:%s%02d%s:%s%02d%s, started on %s%s"
msgstr ""
"Czas działania WeeChat: %s%d %s%s %s%02d%s:%s%02d%s:%s%02d%s, uruchomiono %s%"
"s"
"Czas działania WeeChat: %s%d %s%s %s%02d%s:%s%02d%s:%s%02d%s, uruchomiono %s"
"%s"
msgid "compiled on"
msgstr "skompilowano"
@ -4875,6 +4875,20 @@ msgstr "serwer,właściwość"
msgid "value of feature, if supported by server (from IRC message 005)"
msgstr "wartość opcji, jeśli jest wpierana przez serwer (z wiadomości IRC 005)"
#, fuzzy
msgid "parse an IRC message"
msgstr "wiadomość: wiadomość do wysłania"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "wiadomość: wiadomość do wysłania"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
msgid "list of IRC servers"
msgstr "lista serwerów IRC"
@ -5862,8 +5876,8 @@ msgstr ""
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%sBłąd: niedopasowane API \"%s\" (obecne API: \"%s\", API wtyczki: \"%s\"), "
"nie udało się załadować"
@ -5966,8 +5980,8 @@ msgstr "Klienci do przekazania:"
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
"%3d. %s%s%s (%s%s%s), rozpoczęto: %s,ostatnia aktywność: %s, bajtów: %lu "
"odebrano, %lu wysłano"
@ -6439,8 +6453,8 @@ msgstr "%s: skryptów wyładowano"
msgid ""
"%s%s: unable to call function \"%s\", script is not initialized (script: %s)"
msgstr ""
"%s%s: nie można wywołać funcji \"%s\", skrypt nie zainicjalizowany (skrypt: %"
"s)"
"%s%s: nie można wywołać funcji \"%s\", skrypt nie zainicjalizowany (skrypt: "
"%s)"
#, c-format
msgid "%s%s: wrong arguments for function \"%s\" (script: %s)"
@ -6621,8 +6635,8 @@ msgid ""
" plugin: %s (id: %s), file: %lu bytes (position: %lu), address: %d.%d.%d."
"%d (port %d)"
msgstr ""
" wtyczka: %s (id: %s), plik: %lu bajtów (pozycja: %lu), adres: %d.%d.%d.%"
"d (port %d)"
" wtyczka: %s (id: %s), plik: %lu bajtów (pozycja: %lu), adres: %d.%d.%d."
"%d (port %d)"
#. TRANSLATORS: "%s" after "started on" is date
#, c-format
@ -6734,8 +6748,8 @@ msgstr "zamień spacje na podkreślenia wysyłając plik"
msgid "rename incoming files if already exists (add \".1\", \".2\", ...)"
msgstr ""
"zmień nazwę pliku przychodzącego jeśli juz istnieje (dodaj \".1\", \".2"
"\", ...)"
"zmień nazwę pliku przychodzącego jeśli juz istnieje (dodaj \".1\", "
"\".2\", ...)"
msgid ""
"automatically resume file transfer if connection with remote host is lost"
@ -6809,6 +6823,12 @@ msgstr "Opis"
msgid "Arguments"
msgstr "Argumenty"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
msgid "Pointer"
msgstr "Wskaźnik"

View File

@ -20,16 +20,16 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: 2010-08-07 10:46+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: Russian\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: Russian\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%"
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Poedit-Bookmarks: -1,-1,608,-1,-1,-1,-1,-1,-1,-1\n"
#. TRANSLATORS: "%s %s" after "compiled on" is date and time
@ -953,8 +953,8 @@ msgid ""
" /buffer +1"
msgstr ""
"действие: выполняемое действие:\n"
" move: передвинуть буфер в списке (может быть относительным, например -"
"1)\n"
" move: передвинуть буфер в списке (может быть относительным, например "
"-1)\n"
" close: закрыть буфер (необязательный аргумент - сообщение покидания "
"канала)\n"
" list: перечислить открытые буферы (отсутствие параметров подразумевает "
@ -4627,6 +4627,20 @@ msgstr "цель: название сервера"
msgid "value of feature, if supported by server (from IRC message 005)"
msgstr ""
#, fuzzy
msgid "parse an IRC message"
msgstr "сообщение: отправляемое сообщение"
#, fuzzy
msgid "\"message\": IRC message"
msgstr "сообщение: отправляемое сообщение"
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
#, fuzzy
msgid "list of IRC servers"
msgstr "порт IRC сервера"
@ -5585,8 +5599,8 @@ msgstr ""
#, fuzzy, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
"%s символ \"plugin_name\" не найден в plugin'е \"%s\", загрузка не удалась\n"
@ -5694,8 +5708,8 @@ msgstr ""
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
#, fuzzy, c-format
@ -6543,6 +6557,12 @@ msgstr " . описание: %s\n"
msgid "Arguments"
msgstr "адресат тип [аргументы]"
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
#, fuzzy
msgid "Pointer"
msgstr "минута"

View File

@ -7,10 +7,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-08-14 12:23+0200\n"
"POT-Creation-Date: 2010-08-27 12:41+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
@ -3952,6 +3953,18 @@ msgstr ""
msgid "value of feature, if supported by server (from IRC message 005)"
msgstr ""
msgid "parse an IRC message"
msgstr ""
msgid "\"message\": IRC message"
msgstr ""
#. TRANSLATORS: please do not translate key names (enclosed by quotes)
msgid ""
"\"nick\": nick, \"host\": host, \"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"
msgstr ""
msgid "list of IRC servers"
msgstr ""
@ -4848,8 +4861,8 @@ msgstr ""
#, c-format
msgid ""
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: \"%"
"s\"), failed to load"
"%sError: API mismatch for plugin \"%s\" (current API: \"%s\", plugin API: "
"\"%s\"), failed to load"
msgstr ""
#, c-format
@ -4946,8 +4959,8 @@ msgstr ""
#, c-format
msgid ""
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, %"
"lu sent"
"%3d. %s%s%s (%s%s%s), started on: %s, last activity: %s, bytes: %lu recv, "
"%lu sent"
msgstr ""
#, c-format
@ -5723,5 +5736,11 @@ msgstr ""
msgid "Arguments"
msgstr ""
msgid "Hashtable (input)"
msgstr ""
msgid "Hashtable (output)"
msgstr ""
msgid "Pointer"
msgstr ""

View File

@ -38,7 +38,9 @@
char *hashtable_type_string[HASHTABLE_NUM_TYPES] =
{ "integer", "string", "pointer", "buffer", "time" };
{ WEECHAT_HASHTABLE_INTEGER, WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER, WEECHAT_HASHTABLE_BUFFER,
WEECHAT_HASHTABLE_TIME };
/*
@ -402,6 +404,24 @@ hashtable_get_integer (struct t_hashtable *hashtable, const char *property)
return 0;
}
/*
* hashtable_get_string: get a hashtable property as string
*/
const char *
hashtable_get_string (struct t_hashtable *hashtable, const char *property)
{
if (hashtable && property)
{
if (string_strcasecmp (property, "type_keys") == 0)
return hashtable_type_string[hashtable->type_keys];
else if (string_strcasecmp (property, "type_values") == 0)
return hashtable_type_string[hashtable->type_values];
}
return NULL;
}
/*
* hashtable_add_to_infolist: add hashtable keys and values to infolist
* return 1 if ok, 0 if error

View File

@ -115,6 +115,8 @@ extern void hashtable_map (struct t_hashtable *hashtable,
void *callback_map_data);
extern int hashtable_get_integer (struct t_hashtable *hashtable,
const char *property);
extern const char *hashtable_get_string (struct t_hashtable *hashtable,
const char *property);
extern int hashtable_add_to_infolist (struct t_hashtable *hashtable,
struct t_infolist_item *infolist_item,
const char *prefix);

View File

@ -36,6 +36,7 @@
#include "weechat.h"
#include "wee-hook.h"
#include "wee-hashtable.h"
#include "wee-infolist.h"
#include "wee-list.h"
#include "wee-log.h"
@ -52,7 +53,8 @@
char *hook_type_string[HOOK_NUM_TYPES] =
{ "command", "command_run", "timer", "fd", "process", "connect", "print",
"signal", "config", "completion", "modifier", "info", "infolist" };
"signal", "config", "completion", "modifier", "info", "info_hashtable",
"infolist" };
struct t_hook *weechat_hooks[HOOK_NUM_TYPES]; /* list of hooks */
struct t_hook *last_weechat_hook[HOOK_NUM_TYPES]; /* last hook */
int hook_exec_recursion = 0; /* 1 when a hook is executed */
@ -2188,7 +2190,7 @@ hook_info (struct t_weechat_plugin *plugin, const char *info_name,
}
/*
* hook_info_get: get info via info hook
* hook_info_get: get info (as string) via info hook
*/
const char *
@ -2234,6 +2236,101 @@ hook_info_get (struct t_weechat_plugin *plugin, const char *info_name,
return NULL;
}
/*
* hook_info_hashtable: hook an info using hashtable
*/
struct t_hook *
hook_info_hashtable (struct t_weechat_plugin *plugin, const char *info_name,
const char *description, const char *args_description,
const char *output_description,
t_hook_callback_info_hashtable *callback,
void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_info_hashtable *new_hook_info_hashtable;
int priority;
const char *ptr_info_name;
if (!info_name || !info_name[0] || !callback)
return NULL;
new_hook = malloc (sizeof (*new_hook));
if (!new_hook)
return NULL;
new_hook_info_hashtable = malloc (sizeof (*new_hook_info_hashtable));
if (!new_hook_info_hashtable)
{
free (new_hook);
return NULL;
}
hook_get_priority_and_name (info_name, &priority, &ptr_info_name);
hook_init_data (new_hook, plugin, HOOK_TYPE_INFO_HASHTABLE, priority,
callback_data);
new_hook->hook_data = new_hook_info_hashtable;
new_hook_info_hashtable->callback = callback;
new_hook_info_hashtable->info_name = strdup ((ptr_info_name) ?
ptr_info_name : info_name);
new_hook_info_hashtable->description = strdup ((description) ? description : "");
new_hook_info_hashtable->args_description = strdup ((args_description) ?
args_description : "");
new_hook_info_hashtable->output_description = strdup ((output_description) ?
output_description : "");
hook_add_to_list (new_hook);
return new_hook;
}
/*
* hook_info_get_hashtable: get info (as hashtable) via info hook
*/
struct t_hashtable *
hook_info_get_hashtable (struct t_weechat_plugin *plugin, const char *info_name,
struct t_hashtable *hashtable)
{
struct t_hook *ptr_hook, *next_hook;
struct t_hashtable *value;
/* make C compiler happy */
(void) plugin;
if (!info_name || !info_name[0])
return NULL;
hook_exec_start ();
ptr_hook = weechat_hooks[HOOK_TYPE_INFO_HASHTABLE];
while (ptr_hook)
{
next_hook = ptr_hook->next_hook;
if (!ptr_hook->deleted
&& !ptr_hook->running
&& (string_strcasecmp (HOOK_INFO_HASHTABLE(ptr_hook, info_name),
info_name) == 0))
{
ptr_hook->running = 1;
value = (HOOK_INFO_HASHTABLE(ptr_hook, callback))
(ptr_hook->callback_data, info_name, hashtable);
ptr_hook->running = 0;
hook_exec_end ();
return value;
}
ptr_hook = next_hook;
}
hook_exec_end ();
/* info not found */
return NULL;
}
/*
* hook_infolist: hook an infolist
*/
@ -2478,6 +2575,16 @@ unhook (struct t_hook *hook)
if (HOOK_INFO(hook, args_description))
free (HOOK_INFO(hook, args_description));
break;
case HOOK_TYPE_INFO_HASHTABLE:
if (HOOK_INFO_HASHTABLE(hook, info_name))
free (HOOK_INFO_HASHTABLE(hook, info_name));
if (HOOK_INFO_HASHTABLE(hook, description))
free (HOOK_INFO_HASHTABLE(hook, description));
if (HOOK_INFO_HASHTABLE(hook, args_description))
free (HOOK_INFO_HASHTABLE(hook, args_description));
if (HOOK_INFO_HASHTABLE(hook, output_description))
free (HOOK_INFO_HASHTABLE(hook, output_description));
break;
case HOOK_TYPE_INFOLIST:
if (HOOK_INFOLIST(hook, infolist_name))
free (HOOK_INFOLIST(hook, infolist_name));
@ -2815,6 +2922,36 @@ hook_add_to_infolist_type (struct t_infolist *infolist,
return 0;
}
break;
case HOOK_TYPE_INFO_HASHTABLE:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO_HASHTABLE(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO_HASHTABLE(ptr_hook, info_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO_HASHTABLE(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFO_HASHTABLE(ptr_hook, description)
&& HOOK_INFO_HASHTABLE(ptr_hook, description)[0]) ?
_(HOOK_INFO_HASHTABLE(ptr_hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO_HASHTABLE(ptr_hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFO_HASHTABLE(ptr_hook, args_description)
&& HOOK_INFO_HASHTABLE(ptr_hook, args_description)[0]) ?
_(HOOK_INFO_HASHTABLE(ptr_hook, args_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "output_description", HOOK_INFO_HASHTABLE(ptr_hook, output_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "output_description_nls",
(HOOK_INFO_HASHTABLE(ptr_hook, output_description)
&& HOOK_INFO_HASHTABLE(ptr_hook, output_description)[0]) ?
_(HOOK_INFO_HASHTABLE(ptr_hook, output_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_INFOLIST:
if (!ptr_hook->deleted)
{
@ -3079,6 +3216,17 @@ hook_print_log ()
log_printf (" args_description. . . : '%s'", HOOK_INFO(ptr_hook, args_description));
}
break;
case HOOK_TYPE_INFO_HASHTABLE:
if (!ptr_hook->deleted)
{
log_printf (" info_hashtable data:");
log_printf (" callback. . . . . . . : 0x%lx", HOOK_INFO_HASHTABLE(ptr_hook, callback));
log_printf (" info_name . . . . . . : '%s'", HOOK_INFO_HASHTABLE(ptr_hook, info_name));
log_printf (" description . . . . . : '%s'", HOOK_INFO_HASHTABLE(ptr_hook, description));
log_printf (" args_description. . . : '%s'", HOOK_INFO_HASHTABLE(ptr_hook, args_description));
log_printf (" output_description. . : '%s'", HOOK_INFO_HASHTABLE(ptr_hook, output_description));
}
break;
case HOOK_TYPE_INFOLIST:
if (!ptr_hook->deleted)
{

View File

@ -28,6 +28,7 @@ struct t_gui_buffer;
struct t_gui_line;
struct t_gui_completion;
struct t_weelist;
struct t_hashtable;
struct t_infolist;
/* hook types */
@ -46,6 +47,7 @@ enum t_hook_type
HOOK_TYPE_COMPLETION, /* custom completions */
HOOK_TYPE_MODIFIER, /* string modifier */
HOOK_TYPE_INFO, /* get some info as string */
HOOK_TYPE_INFO_HASHTABLE, /* get some info as hashtable */
HOOK_TYPE_INFOLIST, /* get some info as infolist */
/* number of hook types */
HOOK_NUM_TYPES,
@ -78,6 +80,7 @@ enum t_hook_type
#define HOOK_COMPLETION(hook, var) (((struct t_hook_completion *)hook->hook_data)->var)
#define HOOK_MODIFIER(hook, var) (((struct t_hook_modifier *)hook->hook_data)->var)
#define HOOK_INFO(hook, var) (((struct t_hook_info *)hook->hook_data)->var)
#define HOOK_INFO_HASHTABLE(hook, var) (((struct t_hook_info_hashtable *)hook->hook_data)->var)
#define HOOK_INFOLIST(hook, var) (((struct t_hook_infolist *)hook->hook_data)->var)
struct t_hook
@ -300,6 +303,21 @@ struct t_hook_info
char *args_description; /* description of arguments */
};
/* hook info (hashtable) */
typedef struct t_hashtable *(t_hook_callback_info_hashtable)(void *data,
const char *info_name,
struct t_hashtable *hashtable);
struct t_hook_info_hashtable
{
t_hook_callback_info_hashtable *callback; /* info_hashtable callback */
char *info_name; /* name of info returned */
char *description; /* description */
char *args_description; /* description of arguments */
char *output_description; /* description of output (hashtable) */
};
/* hook infolist */
typedef struct t_infolist *(t_hook_callback_infolist)(void *data,
@ -425,6 +443,16 @@ extern struct t_hook *hook_info (struct t_weechat_plugin *plugin,
extern const char *hook_info_get (struct t_weechat_plugin *plugin,
const char *info_name,
const char *arguments);
extern struct t_hook *hook_info_hashtable (struct t_weechat_plugin *plugin,
const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
t_hook_callback_info_hashtable *callback,
void *callback_data);
extern struct t_hashtable *hook_info_get_hashtable (struct t_weechat_plugin *plugin,
const char *info_name,
struct t_hashtable *hashtable);
extern struct t_hook *hook_infolist (struct t_weechat_plugin *plugin,
const char *infolist_name,
const char *description,

View File

@ -377,7 +377,7 @@ string_replace (const char *string, const char *search, const char *replace)
if (!new_string)
return strdup (string);
/* replace all occurences */
/* replace all occurrences */
new_string[0] = '\0';
while (string && string[0])
{

View File

@ -228,6 +228,38 @@ irc_info_get_info_cb (void *data, const char *info_name,
return NULL;
}
/*
* irc_info_get_info_hashtable_cb: callback called when IRC info_hashtable is
* asked
*/
struct t_hashtable *
irc_info_get_info_hashtable_cb (void *data, const char *info_name,
struct t_hashtable *hashtable)
{
const char *message;
struct t_hashtable *value;
/* make C compiler happy */
(void) data;
if (weechat_strcasecmp (info_name, "irc_parse_message") == 0)
{
if (hashtable)
{
message = (const char *)weechat_hashtable_get (hashtable,
"message");
if (message)
{
value = irc_server_parse_message_to_hashtable (message);
return value;
}
}
}
return NULL;
}
/*
* irc_info_get_infolist_cb: callback called when IRC infolist is asked
*/
@ -448,48 +480,71 @@ void
irc_info_init ()
{
/* info hooks */
weechat_hook_info ("irc_is_channel", N_("1 if string is a valid IRC channel name"),
weechat_hook_info ("irc_is_channel",
N_("1 if string is a valid IRC channel name"),
N_("channel name"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_is_nick", N_("1 if string is a valid IRC nick name"),
weechat_hook_info ("irc_is_nick",
N_("1 if string is a valid IRC nick name"),
N_("nickname"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_nick", N_("get current nick on a server"),
weechat_hook_info ("irc_nick",
N_("get current nick on a server"),
N_("server name"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_nick_from_host", N_("get nick from IRC host"),
weechat_hook_info ("irc_nick_from_host",
N_("get nick from IRC host"),
N_("IRC host (like `:nick!name@server.com`)"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_nick_color", N_("get nick color code"),
weechat_hook_info ("irc_nick_color",
N_("get nick color code"),
N_("nickname"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_nick_color_name", N_("get nick color name"),
weechat_hook_info ("irc_nick_color_name",
N_("get nick color name"),
N_("nickname"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_buffer", N_("get buffer pointer for an IRC server/channel/nick"),
weechat_hook_info ("irc_buffer",
N_("get buffer pointer for an IRC server/channel/nick"),
N_("server,channel,nick (channel and nicks are optional)"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_server_isupport", N_("1 if server supports this feature (from IRC message 005)"),
weechat_hook_info ("irc_server_isupport",
N_("1 if server supports this feature (from IRC message 005)"),
N_("server,feature"),
&irc_info_get_info_cb, NULL);
weechat_hook_info ("irc_server_isupport_value", N_("value of feature, if supported by server (from IRC message 005)"),
weechat_hook_info ("irc_server_isupport_value",
N_("value of feature, if supported by server (from IRC message 005)"),
N_("server,feature"),
&irc_info_get_info_cb, NULL);
/* info_hashtable hooks */
weechat_hook_info_hashtable ("irc_parse_message",
N_("parse an IRC message"),
N_("\"message\": IRC message"),
/* TRANSLATORS: please do not translate key names (enclosed by quotes) */
N_("\"nick\": nick, \"host\": host, "
"\"command\": command, \"channel\": channel, "
"\"arguments\": arguments (includes channel)"),
&irc_info_get_info_hashtable_cb, NULL);
/* infolist hooks */
weechat_hook_infolist ("irc_server", N_("list of IRC servers"),
weechat_hook_infolist ("irc_server",
N_("list of IRC servers"),
N_("server pointer (optional)"),
N_("server name (can start or end with \"*\" as wildcard) (optional)"),
&irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_channel", N_("list of channels for an IRC server"),
weechat_hook_infolist ("irc_channel",
N_("list of channels for an IRC server"),
N_("channel pointer (optional)"),
N_("server name"),
&irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_nick", N_("list of nicks for an IRC channel"),
weechat_hook_infolist ("irc_nick",
N_("list of nicks for an IRC channel"),
N_("nick pointer (optional)"),
N_("server,channel,nick (channel and nick are optional)"),
&irc_info_get_infolist_cb, NULL);
weechat_hook_infolist ("irc_ignore", N_("list of IRC ignores"),
weechat_hook_infolist ("irc_ignore",
N_("list of IRC ignores"),
N_("ignore pointer (optional)"),
NULL,
&irc_info_get_infolist_cb, NULL);

View File

@ -1215,6 +1215,9 @@ irc_server_parse_message (const char *message, char **nick, char **host,
if (arguments)
*arguments = NULL;
if (!message)
return;
/*
* we will use this message as example:
* :FlashCode!n=FlashCod@host.com PRIVMSG #channel :hello!
@ -1323,6 +1326,46 @@ irc_server_parse_message (const char *message, char **nick, char **host,
}
}
/*
* irc_server_parse_message_to_hashtable: parse IRC message and return hashtable
* with keys: nick, host, command,
* channel, arguments
* Note: hashtable has to be free()
* after use
*/
struct t_hashtable *
irc_server_parse_message_to_hashtable (const char *message)
{
char *nick, *host, *command, *channel, *arguments;
char empty_str[1] = { '\0' };
struct t_hashtable *hashtable;
irc_server_parse_message (message, &nick, &host, &command, &channel,
&arguments);
hashtable = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
weechat_hashtable_set (hashtable, "nick",
(nick) ? (void *)nick : (void *)empty_str);
weechat_hashtable_set (hashtable, "host",
(host) ? (void *)host : (void *)empty_str);
weechat_hashtable_set (hashtable, "command",
(command) ? (void *)command : (void *)empty_str);
weechat_hashtable_set (hashtable, "channel",
(channel) ? (void *)channel : (void *)empty_str);
weechat_hashtable_set (hashtable, "arguments",
(arguments) ? (void *)arguments : (void *)empty_str);
return hashtable;
}
/*
* irc_server_send_one_msg: send one message to IRC server
* if queue_msg > 0, then messages are in a queue and

View File

@ -203,6 +203,7 @@ extern int irc_server_rename (struct t_irc_server *server, const char *new_name)
extern void irc_server_send_signal (struct t_irc_server *server,
const char *signal, const char *command,
const char *full_message);
extern struct t_hashtable *irc_server_parse_message_to_hashtable (const char *message);
extern void irc_server_sendf (struct t_irc_server *server, int queue_msg,
const char *format, ...);
extern struct t_irc_server *irc_server_search (const char *server_name);

View File

@ -527,6 +527,7 @@ plugin_load (const char *filename)
new_plugin->hashtable_get = &hashtable_get;
new_plugin->hashtable_map = &hashtable_map;
new_plugin->hashtable_get_integer = &hashtable_get_integer;
new_plugin->hashtable_get_string = &hashtable_get_string;
new_plugin->hashtable_add_to_infolist = &hashtable_add_to_infolist;
new_plugin->hashtable_remove = &hashtable_remove;
new_plugin->hashtable_remove_all = &hashtable_remove_all;
@ -592,6 +593,7 @@ plugin_load (const char *filename)
new_plugin->hook_modifier = &hook_modifier;
new_plugin->hook_modifier_exec = &hook_modifier_exec;
new_plugin->hook_info = &hook_info;
new_plugin->hook_info_hashtable = &hook_info_hashtable;
new_plugin->hook_infolist = &hook_infolist;
new_plugin->unhook = &unhook;
new_plugin->unhook_all = &unhook_all_plugin;
@ -639,6 +641,7 @@ plugin_load (const char *filename)
new_plugin->network_connect_to = &network_connect_to;
new_plugin->info_get = &hook_info_get;
new_plugin->info_get_hashtable = &hook_info_get_hashtable;
new_plugin->infolist_new = &infolist_new;
new_plugin->infolist_new_item = &infolist_new_item;

View File

@ -1218,7 +1218,8 @@ weechat_lua_api_config_reload_cb (void *data,
struct t_config_file *config_file)
{
struct t_script_callback *script_callback;
char *lua_argv[3], empty_arg[1] = { '\0' };
void *lua_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1232,7 +1233,7 @@ weechat_lua_api_config_reload_cb (void *data,
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ss", lua_argv);
if (!rc)
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
@ -1307,7 +1308,8 @@ weechat_lua_api_config_read_cb (void *data,
const char *option_name, const char *value)
{
struct t_script_callback *script_callback;
char *lua_argv[6], empty_arg[1] = { '\0' };
void *lua_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1319,12 +1321,11 @@ weechat_lua_api_config_read_cb (void *data,
lua_argv[2] = script_ptr2str (section);
lua_argv[3] = (option_name) ? (char *)option_name : empty_arg;
lua_argv[4] = (value) ? (char *)value : empty_arg;
lua_argv[5] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sssss", lua_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1354,7 +1355,8 @@ weechat_lua_api_config_section_write_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1364,12 +1366,11 @@ weechat_lua_api_config_section_write_cb (void *data,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (config_file);
lua_argv[2] = (section_name) ? (char *)section_name : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1398,7 +1399,8 @@ weechat_lua_api_config_section_write_default_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1408,12 +1410,11 @@ weechat_lua_api_config_section_write_default_cb (void *data,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (config_file);
lua_argv[2] = (section_name) ? (char *)section_name : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1443,7 +1444,8 @@ weechat_lua_api_config_section_create_option_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *lua_argv[6], empty_arg[1] = { '\0' };
void *lua_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1455,12 +1457,11 @@ weechat_lua_api_config_section_create_option_cb (void *data,
lua_argv[2] = script_ptr2str (section);
lua_argv[3] = (option_name) ? (char *)option_name : empty_arg;
lua_argv[4] = (value) ? (char *)value : empty_arg;
lua_argv[5] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sssss", lua_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1491,7 +1492,8 @@ weechat_lua_api_config_section_delete_option_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *lua_argv[5], empty_arg[1] = { '\0' };
void *lua_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1502,12 +1504,11 @@ weechat_lua_api_config_section_delete_option_cb (void *data,
lua_argv[1] = script_ptr2str (config_file);
lua_argv[2] = script_ptr2str (section);
lua_argv[3] = script_ptr2str (option);
lua_argv[4] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ssss", lua_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@ -1667,7 +1668,8 @@ weechat_lua_api_config_option_check_value_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1677,12 +1679,11 @@ weechat_lua_api_config_option_check_value_cb (void *data,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (option);
lua_argv[2] = (value) ? (char *)value : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = 0;
@ -1709,7 +1710,8 @@ weechat_lua_api_config_option_change_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *lua_argv[3], empty_arg[1] = { '\0' };
void *lua_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1718,12 +1720,11 @@ weechat_lua_api_config_option_change_cb (void *data,
{
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (option);
lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ss", lua_argv);
if (lua_argv[1])
free (lua_argv[1]);
@ -1742,7 +1743,8 @@ weechat_lua_api_config_option_delete_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *lua_argv[3], empty_arg[1] = { '\0' };
void *lua_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1751,12 +1753,11 @@ weechat_lua_api_config_option_delete_cb (void *data,
{
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (option);
lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ss", lua_argv);
if (lua_argv[1])
free (lua_argv[1]);
@ -3276,7 +3277,8 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
/* make C compiler happy */
@ -3289,12 +3291,11 @@ weechat_lua_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (buffer);
lua_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3380,7 +3381,8 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3390,12 +3392,11 @@ weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (buffer);
lua_argv[2] = (command) ? (char *)command : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3467,7 +3468,8 @@ int
weechat_lua_api_hook_timer_cb (void *data, int remaining_calls)
{
struct t_script_callback *script_callback;
char *lua_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' };
void *lua_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3479,12 +3481,11 @@ weechat_lua_api_hook_timer_cb (void *data, int remaining_calls)
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = str_remaining_calls;
lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3560,7 +3561,8 @@ int
weechat_lua_api_hook_fd_cb (void *data, int fd)
{
struct t_script_callback *script_callback;
char *lua_argv[3], str_fd[32], empty_arg[1] = { '\0' };
void *lua_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3571,12 +3573,11 @@ weechat_lua_api_hook_fd_cb (void *data, int fd)
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = str_fd;
lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3657,7 +3658,8 @@ weechat_lua_api_hook_process_cb (void *data,
const char *out, const char *err)
{
struct t_script_callback *script_callback;
char *lua_argv[6], str_rc[32], empty_arg[1] = { '\0' };
void *lua_argv[5];
char str_rc[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3671,12 +3673,11 @@ weechat_lua_api_hook_process_cb (void *data,
lua_argv[2] = str_rc;
lua_argv[3] = (out) ? (char *)out : empty_arg;
lua_argv[4] = (err) ? (char *)err : empty_arg;
lua_argv[5] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sssss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3749,7 +3750,8 @@ weechat_lua_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
char *lua_argv[6], str_status[32], str_gnutls_rc[32];
void *lua_argv[5];
char str_status[32], str_gnutls_rc[32];
char empty_arg[1] = { '\0' };
int *rc, ret;
@ -3765,12 +3767,11 @@ weechat_lua_api_hook_connect_cb (void *data, int status, int gnutls_rc,
lua_argv[2] = str_gnutls_rc;
lua_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
lua_argv[4] = (error) ? (char *)error : empty_arg;
lua_argv[5] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sssss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3862,7 +3863,8 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
const char *prefix, const char *message)
{
struct t_script_callback *script_callback;
char *lua_argv[9], empty_arg[1] = { '\0' };
void *lua_argv[8];
char empty_arg[1] = { '\0' };
static char timebuffer[64];
int *rc, ret;
@ -3885,12 +3887,11 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
lua_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
lua_argv[6] = (prefix) ? (char *)prefix : empty_arg;
lua_argv[7] = (message) ? (char *)message : empty_arg;
lua_argv[8] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ssssssss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3978,7 +3979,8 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal,
const char *type_data, void *signal_data)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
static char value_str[64];
int *rc, ret, free_needed;
@ -4006,12 +4008,11 @@ weechat_lua_api_hook_signal_cb (void *data, const char *signal,
}
else
lua_argv[2] = empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4141,7 +4142,8 @@ weechat_lua_api_hook_config_cb (void *data, const char *option,
const char *value)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4151,12 +4153,11 @@ weechat_lua_api_hook_config_cb (void *data, const char *option,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = (option) ? (char *)option : empty_arg;
lua_argv[2] = (value) ? (char *)value : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4229,7 +4230,8 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *lua_argv[5], empty_arg[1] = { '\0' };
void *lua_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4240,12 +4242,11 @@ weechat_lua_api_hook_completion_cb (void *data, const char *completion_item,
lua_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
lua_argv[2] = script_ptr2str (buffer);
lua_argv[3] = script_ptr2str (completion);
lua_argv[4] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ssss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4369,7 +4370,8 @@ weechat_lua_api_hook_modifier_cb (void *data, const char *modifier,
const char *string)
{
struct t_script_callback *script_callback;
char *lua_argv[5], empty_arg[1] = { '\0' };
void *lua_argv[4];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4379,12 +4381,11 @@ weechat_lua_api_hook_modifier_cb (void *data, const char *modifier,
lua_argv[1] = (modifier) ? (char *)modifier : empty_arg;
lua_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
lua_argv[3] = (string) ? (char *)string : empty_arg;
lua_argv[4] = NULL;
return (char *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
"ssss", lua_argv);
}
return NULL;
@ -4486,7 +4487,8 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4495,12 +4497,11 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = (info_name) ? (char *)info_name : empty_arg;
lua_argv[2] = (arguments) ? (char *)arguments : empty_arg;
lua_argv[3] = NULL;
return (const char *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
"sss", lua_argv);
}
return NULL;
@ -4558,6 +4559,91 @@ weechat_lua_api_hook_info (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_info_hashtable_cb: callback for info_hashtable hooked
*/
struct t_hashtable *
weechat_lua_api_hook_info_hashtable_cb (void *data, const char *info_name,
struct t_hashtable *hashtable)
{
struct t_script_callback *script_callback;
void *lua_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = (info_name) ? (char *)info_name : empty_arg;
lua_argv[2] = hashtable;
return (struct t_hashtable *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
script_callback->function,
"ssh", lua_argv);
}
return NULL;
}
/*
* weechat_lua_api_hook_info_hashtable: hook an info_hashtable
*/
static int
weechat_lua_api_hook_info_hashtable (lua_State *L)
{
const char *info_name, *description, *args_description;
const char *output_description, *function, *data;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
LUA_RETURN_EMPTY;
}
info_name = NULL;
description = NULL;
args_description = NULL;
output_description = NULL;
function = NULL;
data = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
LUA_RETURN_EMPTY;
}
info_name = lua_tostring (lua_current_interpreter, -6);
description = lua_tostring (lua_current_interpreter, -5);
args_description = lua_tostring (lua_current_interpreter, -4);
output_description = lua_tostring (lua_current_interpreter, -3);
function = lua_tostring (lua_current_interpreter, -2);
data = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (script_api_hook_info_hashtable (weechat_lua_plugin,
lua_current_script,
info_name,
description,
args_description,
output_description,
&weechat_lua_api_hook_info_hashtable_cb,
function,
data));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_infolist_cb: callback for infolist hooked
*/
@ -4567,7 +4653,8 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
void *pointer, const char *arguments)
{
struct t_script_callback *script_callback;
char *lua_argv[5], empty_arg[1] = { '\0' };
void *lua_argv[4];
char empty_arg[1] = { '\0' };
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@ -4578,12 +4665,11 @@ weechat_lua_api_hook_infolist_cb (void *data, const char *info_name,
lua_argv[1] = (info_name) ? (char *)info_name : empty_arg;
lua_argv[2] = script_ptr2str (pointer);
lua_argv[3] = (arguments) ? (char *)arguments : empty_arg;
lua_argv[4] = NULL;
result = (struct t_infolist *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
"ssss", lua_argv);
if (lua_argv[2])
free (lua_argv[2]);
@ -4718,7 +4804,8 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' };
void *lua_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4728,12 +4815,11 @@ weechat_lua_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (buffer);
lua_argv[2] = (input_data) ? (char *)input_data : empty_arg;
lua_argv[3] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4759,7 +4845,8 @@ int
weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
struct t_script_callback *script_callback;
char *lua_argv[3], empty_arg[1] = { '\0' };
void *lua_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4768,12 +4855,11 @@ weechat_lua_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (buffer);
lua_argv[2] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -5806,7 +5892,8 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
struct t_script_callback *script_callback;
char *lua_argv[4], empty_arg[1] = { '\0' }, *ret;
void *lua_argv[3];
char empty_arg[1] = { '\0' }, *ret;
script_callback = (struct t_script_callback *)data;
@ -5815,12 +5902,11 @@ weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = script_ptr2str (item);
lua_argv[2] = script_ptr2str (window);
lua_argv[3] = NULL;
ret = (char *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
"sss", lua_argv);
if (lua_argv[1])
free (lua_argv[1]);
@ -6226,7 +6312,7 @@ weechat_lua_api_command (lua_State *L)
}
/*
* weechat_lua_api_info_get: get info about WeeChat
* weechat_lua_api_info_get: get info (as string)
*/
static int
@ -6263,6 +6349,53 @@ weechat_lua_api_info_get (lua_State *L)
LUA_RETURN_STRING(result);
}
/*
* weechat_lua_api_info_get_hashtable: get info (as hashtable)
*/
static int
weechat_lua_api_info_get_hashtable (lua_State *L)
{
const char *info_name;
struct t_hashtable *table, *result_hashtable;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "info_get_hashtable");
LUA_RETURN_EMPTY;
}
info_name = NULL;
table = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "info_get_hashtable");
LUA_RETURN_EMPTY;
}
info_name = lua_tostring (lua_current_interpreter, -2);
table = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
result_hashtable = weechat_info_get_hashtable (info_name, table);
weechat_lua_pushhashtable (lua_current_interpreter, result_hashtable);
if (table)
weechat_hashtable_free (table);
if (result_hashtable)
weechat_hashtable_free (result_hashtable);
return 1;
}
/*
* weechat_lua_api_infolist_new: create new infolist
*/
@ -6938,7 +7071,8 @@ weechat_lua_api_upgrade_read_cb (void *data,
struct t_infolist *infolist)
{
struct t_script_callback *script_callback;
char *lua_argv[5], empty_arg[1] = { '\0' }, str_object_id[32];
void *lua_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -6951,12 +7085,11 @@ weechat_lua_api_upgrade_read_cb (void *data,
lua_argv[1] = script_ptr2str (upgrade_file);
lua_argv[2] = str_object_id;
lua_argv[3] = script_ptr2str (infolist);
lua_argv[4] = NULL;
rc = (int *) weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
lua_argv);
"ssss", lua_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -7531,6 +7664,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "hook_modifier", &weechat_lua_api_hook_modifier },
{ "hook_modifier_exec", &weechat_lua_api_hook_modifier_exec },
{ "hook_info", &weechat_lua_api_hook_info },
{ "hook_info_hashtable", &weechat_lua_api_hook_info_hashtable },
{ "hook_infolist", &weechat_lua_api_hook_infolist },
{ "unhook", &weechat_lua_api_unhook },
{ "unhook_all", &weechat_lua_api_unhook_all },
@ -7570,6 +7704,7 @@ 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 },
{ "info_get_hashtable", &weechat_lua_api_info_get_hashtable },
{ "infolist_new", &weechat_lua_api_infolist_new },
{ "infolist_new_item", &weechat_lua_api_infolist_new_item },
{ "infolist_new_var_integer", &weechat_lua_api_infolist_new_var_integer },

View File

@ -70,15 +70,87 @@ char *lua_action_remove_list = NULL;
/*
* weechat_lua_exec: execute a Lua script
* weechat_lua_hashtable_map_cb: callback called for each key/value in a
* hashtable
*/
void
weechat_lua_hashtable_map_cb (void *data,
struct t_hashtable *hashtable,
const void *key,
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);
}
/*
* weechat_lua_pushhashtable: put a WeeChat hashtable on lua stack, as lua table
*/
void
weechat_lua_pushhashtable (lua_State *interpreter, struct t_hashtable *hashtable)
{
lua_newtable (interpreter);
weechat_hashtable_map (hashtable,
&weechat_lua_hashtable_map_cb,
interpreter);
}
/*
* weechat_lua_hash_to_hashtable: get WeeChat hashtable with lua hash (on stack)
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after use
* with call to weechat_hashtable_free()
*/
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,
NULL,
NULL);
if (!hashtable)
return NULL;
lua_pushnil (interpreter);
while (lua_next (interpreter, index - 1) != 0)
{
weechat_hashtable_set (hashtable,
(char *)lua_tostring (interpreter, -2),
(char *)lua_tostring (interpreter, -1));
/* remove value from stack (keep key for next iteration) */
lua_pop (interpreter, 1);
}
return hashtable;
}
/*
* weechat_lua_exec: execute a lua function
*/
void *
weechat_lua_exec (struct t_plugin_script *script,
int ret_type, const char *function, char **argv)
weechat_lua_exec (struct t_plugin_script *script, int ret_type,
const char *function,
const char *format, void **argv)
{
void *ret_value;
int argc, *ret_i;
int argc, i, *ret_i;
struct t_plugin_script *old_lua_current_script;
lua_current_interpreter = script->interpreter;
@ -87,47 +159,24 @@ weechat_lua_exec (struct t_plugin_script *script,
old_lua_current_script = lua_current_script;
lua_current_script = script;
argc = 0;
if (argv && argv[0])
if (format && format[0])
{
lua_pushstring (lua_current_interpreter, argv[0]);
argc = 1;
if (argv[1])
argc = strlen (format);
for (i = 0; i < argc; i++)
{
argc = 2;
lua_pushstring (lua_current_interpreter, argv[1]);
if (argv[2])
switch (format[i])
{
argc = 3;
lua_pushstring (lua_current_interpreter, argv[2]);
if (argv[3])
{
argc = 4;
lua_pushstring (lua_current_interpreter, argv[3]);
if (argv[4])
{
argc = 5;
lua_pushstring (lua_current_interpreter, argv[4]);
if (argv[5])
{
argc = 6;
lua_pushstring (lua_current_interpreter, argv[5]);
if (argv[6])
{
argc = 7;
lua_pushstring (lua_current_interpreter,
argv[6]);
if (argv[7])
{
argc = 8;
lua_pushstring (lua_current_interpreter,
argv[7]);
}
}
}
}
}
case 's': /* string */
lua_pushstring (lua_current_interpreter, (char *)argv[i]);
break;
case 'i': /* integer */
lua_pushnumber (lua_current_interpreter, *((int *)argv[i]));
break;
case 'h': /* hash */
weechat_lua_pushhashtable (lua_current_interpreter, (struct t_hashtable *)argv[i]);
break;
}
}
}
@ -154,6 +203,11 @@ weechat_lua_exec (struct t_plugin_script *script,
*ret_i = lua_tonumber (lua_current_interpreter, -1);
ret_value = ret_i;
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_lua_tohashtable (lua_current_interpreter, -1,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
}
else
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, function);
@ -166,6 +220,10 @@ weechat_lua_exec (struct t_plugin_script *script,
return ret_value;
}
/*
* weechat_lua_load: load a Lua script
*/
int
weechat_lua_load (const char *filename)
{
@ -308,7 +366,6 @@ void
weechat_lua_unload (struct t_plugin_script *script)
{
int *r;
char *lua_argv[1] = { NULL };
void *interpreter;
if ((weechat_lua_plugin->debug >= 1) || !lua_quiet)
@ -323,7 +380,7 @@ weechat_lua_unload (struct t_plugin_script *script)
r = weechat_lua_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func,
lua_argv);
NULL, NULL);
if (r)
free (r);
}

View File

@ -36,8 +36,13 @@ extern struct t_plugin_script *lua_registered_script;
extern const char *lua_current_script_filename;
extern lua_State *lua_current_interpreter;
extern void *weechat_lua_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char **argv);
extern void weechat_lua_pushhashtable (lua_State *interpreter,
struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_lua_tohashtable (lua_State *interpreter,
int index,
int hashtable_size);
extern void *weechat_lua_exec (struct t_plugin_script *script, int ret_type,
const char *function,
const char *format, void **argv);
#endif /* __WEECHAT_LUA_H */

View File

@ -56,8 +56,12 @@
} \
XST_mPV (0, ""); \
XSRETURN (1)
#define PERL_RETURN_INT(__int) \
XST_mIV (0, __int); \
#define PERL_RETURN_INT(__int) \
XST_mIV (0, __int); \
XSRETURN (1);
#define PERL_RETURN_OBJ(__obj) \
ST (0) = newRV_inc((SV *)__obj); \
if (SvREFCNT(ST(0))) sv_2mortal(ST(0)); \
XSRETURN (1);
@ -999,7 +1003,8 @@ weechat_perl_api_config_reload_cb (void *data,
struct t_config_file *config_file)
{
struct t_script_callback *script_callback;
char *perl_argv[3], empty_arg[1] = { '\0' };
void *perl_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1008,12 +1013,11 @@ weechat_perl_api_config_reload_cb (void *data,
{
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (config_file);
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ss", perl_argv);
if (!rc)
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
@ -1081,7 +1085,8 @@ weechat_perl_api_config_section_read_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *perl_argv[6], empty_arg[1] = { '\0' };
void *perl_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1093,12 +1098,11 @@ weechat_perl_api_config_section_read_cb (void *data,
perl_argv[2] = script_ptr2str (section);
perl_argv[3] = (option_name) ? (char *)option_name : empty_arg;
perl_argv[4] = (value) ? (char *)value : empty_arg;
perl_argv[5] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sssss", perl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1128,7 +1132,8 @@ weechat_perl_api_config_section_write_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1138,12 +1143,11 @@ weechat_perl_api_config_section_write_cb (void *data,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (config_file);
perl_argv[2] = (section_name) ? (char *)section_name : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1172,7 +1176,8 @@ weechat_perl_api_config_section_write_default_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1182,13 +1187,12 @@ weechat_perl_api_config_section_write_default_cb (void *data,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (config_file);
perl_argv[2] = (section_name) ? (char *)section_name : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
else
@ -1217,7 +1221,8 @@ weechat_perl_api_config_section_create_option_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *perl_argv[6], empty_arg[1] = { '\0' };
void *perl_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1229,12 +1234,11 @@ weechat_perl_api_config_section_create_option_cb (void *data,
perl_argv[2] = script_ptr2str (section);
perl_argv[3] = (option_name) ? (char *)option_name : empty_arg;
perl_argv[4] = (value) ? (char *)value : empty_arg;
perl_argv[5] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sssss", perl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1265,7 +1269,8 @@ weechat_perl_api_config_section_delete_option_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *perl_argv[5], empty_arg[1] = { '\0' };
void *perl_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1276,12 +1281,11 @@ weechat_perl_api_config_section_delete_option_cb (void *data,
perl_argv[1] = script_ptr2str (config_file);
perl_argv[2] = script_ptr2str (section);
perl_argv[3] = script_ptr2str (option);
perl_argv[4] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ssss", perl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@ -1413,7 +1417,8 @@ weechat_perl_api_config_option_check_value_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1423,12 +1428,11 @@ weechat_perl_api_config_option_check_value_cb (void *data,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (option);
perl_argv[2] = (value) ? (char *)value : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = 0;
@ -1455,7 +1459,8 @@ weechat_perl_api_config_option_change_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *perl_argv[3], empty_arg[1] = { '\0' };
void *perl_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1464,12 +1469,11 @@ weechat_perl_api_config_option_change_cb (void *data,
{
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (option);
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ss", perl_argv);
if (perl_argv[1])
free (perl_argv[1]);
@ -1488,7 +1492,8 @@ weechat_perl_api_config_option_delete_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *perl_argv[3], empty_arg[1] = { '\0' };
void *perl_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1497,12 +1502,11 @@ weechat_perl_api_config_option_delete_cb (void *data,
{
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (option);
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ss", perl_argv);
if (perl_argv[1])
free (perl_argv[1]);
@ -2741,7 +2745,8 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
/* make C compiler happy */
@ -2754,12 +2759,11 @@ weechat_perl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (buffer);
perl_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -2833,7 +2837,8 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -2843,12 +2848,11 @@ weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (buffer);
perl_argv[2] = (command) ? (char *)command : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -2912,7 +2916,8 @@ int
weechat_perl_api_hook_timer_cb (void *data, int remaining_calls)
{
struct t_script_callback *script_callback;
char *perl_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' };
void *perl_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -2924,12 +2929,11 @@ weechat_perl_api_hook_timer_cb (void *data, int remaining_calls)
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = str_remaining_calls;
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -2989,7 +2993,8 @@ int
weechat_perl_api_hook_fd_cb (void *data, int fd)
{
struct t_script_callback *script_callback;
char *perl_argv[3], str_fd[32], empty_arg[1] = { '\0' };
void *perl_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3000,12 +3005,11 @@ weechat_perl_api_hook_fd_cb (void *data, int fd)
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = str_fd;
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3068,7 +3072,8 @@ weechat_perl_api_hook_process_cb (void *data,
const char *out, const char *err)
{
struct t_script_callback *script_callback;
char *perl_argv[6], str_rc[32], empty_arg[1] = { '\0' };
void *perl_argv[5];
char str_rc[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3082,12 +3087,11 @@ weechat_perl_api_hook_process_cb (void *data,
perl_argv[2] = str_rc;
perl_argv[3] = (out) ? (char *)out : empty_arg;
perl_argv[4] = (err) ? (char *)err : empty_arg;
perl_argv[5] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sssss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3151,7 +3155,8 @@ weechat_perl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
char *perl_argv[6], str_status[32], str_gnutls_rc[32];
void *perl_argv[5];
char str_status[32], str_gnutls_rc[32];
char empty_arg[1] = { '\0' };
int *rc, ret;
@ -3167,12 +3172,11 @@ weechat_perl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
perl_argv[2] = str_gnutls_rc;
perl_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
perl_argv[4] = (error) ? (char *)error : empty_arg;
perl_argv[5] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sssss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3248,7 +3252,8 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
const char *prefix, const char *message)
{
struct t_script_callback *script_callback;
char *perl_argv[9], empty_arg[1] = { '\0' };
void *perl_argv[8];
char empty_arg[1] = { '\0' };
static char timebuffer[64];
int *rc, ret;
@ -3271,12 +3276,11 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
perl_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
perl_argv[6] = (prefix) ? (char *)prefix : empty_arg;
perl_argv[7] = (message) ? (char *)message : empty_arg;
perl_argv[8] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ssssssss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3352,7 +3356,8 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ
void *signal_data)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
static char value_str[64];
int *rc, ret, free_needed;
@ -3380,12 +3385,11 @@ weechat_perl_api_hook_signal_cb (void *data, const char *signal, const char *typ
}
else
perl_argv[2] = empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3502,7 +3506,8 @@ int
weechat_perl_api_hook_config_cb (void *data, const char *option, const char *value)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3512,12 +3517,11 @@ weechat_perl_api_hook_config_cb (void *data, const char *option, const char *val
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = (option) ? (char *)option : empty_arg;
perl_argv[2] = (value) ? (char *)value : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3581,7 +3585,8 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *perl_argv[5], empty_arg[1] = { '\0' };
void *perl_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3592,12 +3597,11 @@ weechat_perl_api_hook_completion_cb (void *data, const char *completion_item,
perl_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
perl_argv[2] = script_ptr2str (buffer);
perl_argv[3] = script_ptr2str (completion);
perl_argv[4] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ssss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3702,7 +3706,8 @@ weechat_perl_api_hook_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
{
struct t_script_callback *script_callback;
char *perl_argv[5], empty_arg[1] = { '\0' };
void *perl_argv[4];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -3712,12 +3717,11 @@ weechat_perl_api_hook_modifier_cb (void *data, const char *modifier,
perl_argv[1] = (modifier) ? (char *)modifier : empty_arg;
perl_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
perl_argv[3] = (string) ? (char *)string : empty_arg;
perl_argv[4] = NULL;
return (char *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
"ssss", perl_argv);
}
return NULL;
@ -3803,7 +3807,8 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -3812,12 +3817,11 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = (info_name) ? (char *)info_name : empty_arg;
perl_argv[2] = (arguments) ? (char *)arguments : empty_arg;
perl_argv[3] = NULL;
return (const char *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
"sss", perl_argv);
}
return NULL;
@ -3865,6 +3869,80 @@ XS (XS_weechat_api_hook_info)
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_hook_info_hashtable_cb: callback for info_hashtable hooked
*/
struct t_hashtable *
weechat_perl_api_hook_info_hashtable_cb (void *data, const char *info_name,
struct t_hashtable *hashtable)
{
struct t_script_callback *script_callback;
void *perl_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = (info_name) ? (char *)info_name : empty_arg;
perl_argv[2] = hashtable;
return (struct t_hashtable *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
script_callback->function,
"ssh", perl_argv);
}
return NULL;
}
/*
* weechat::hook_info_hashtable: hook an info_hashtable
*/
XS (XS_weechat_api_hook_info_hashtable)
{
char *result, *info_name, *description, *args_description;
char *output_description, *function, *data;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
PERL_RETURN_EMPTY;
}
if (items < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
PERL_RETURN_EMPTY;
}
info_name = SvPV (ST (0), PL_na);
description = SvPV (ST (1), PL_na);
args_description = SvPV (ST (2), PL_na);
output_description = SvPV (ST (3), PL_na);
function = SvPV (ST (4), PL_na);
data = SvPV (ST (5), PL_na);
result = script_ptr2str (script_api_hook_info_hashtable (weechat_perl_plugin,
perl_current_script,
info_name,
description,
args_description,
output_description,
&weechat_perl_api_hook_info_hashtable_cb,
function,
data));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_hook_infolist_cb: callback for infolist hooked
*/
@ -3874,7 +3952,8 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
void *pointer, const char *arguments)
{
struct t_script_callback *script_callback;
char *perl_argv[5], empty_arg[1] = { '\0' };
void *perl_argv[4];
char empty_arg[1] = { '\0' };
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@ -3885,12 +3964,11 @@ weechat_perl_api_hook_infolist_cb (void *data, const char *infolist_name,
perl_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
perl_argv[2] = script_ptr2str (pointer);
perl_argv[3] = (arguments) ? (char *)arguments : empty_arg;
perl_argv[4] = NULL;
result = (struct t_infolist *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
"ssss", perl_argv);
if (perl_argv[2])
free (perl_argv[2]);
@ -4008,7 +4086,8 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' };
void *perl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4018,12 +4097,11 @@ weechat_perl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (buffer);
perl_argv[2] = (input_data) ? (char *)input_data : empty_arg;
perl_argv[3] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
@ -4048,7 +4126,8 @@ int
weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
struct t_script_callback *script_callback;
char *perl_argv[3], empty_arg[1] = { '\0' };
void *perl_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4057,12 +4136,11 @@ weechat_perl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (buffer);
perl_argv[2] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
@ -4917,7 +4995,8 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
struct t_script_callback *script_callback;
char *perl_argv[4], empty_arg[1] = { '\0' }, *ret;
void *perl_argv[3];
char empty_arg[1] = { '\0' }, *ret;
script_callback = (struct t_script_callback *)data;
@ -4926,12 +5005,11 @@ weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = script_ptr2str (item);
perl_argv[2] = script_ptr2str (window);
perl_argv[3] = NULL;
ret = (char *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
"sss", perl_argv);
if (perl_argv[1])
free (perl_argv[1]);
@ -5255,7 +5333,7 @@ XS (XS_weechat_api_command)
}
/*
* weechat::info_get: get info about WeeChat
* weechat::info_get: get info (as string)
*/
XS (XS_weechat_api_info_get)
@ -5287,6 +5365,47 @@ XS (XS_weechat_api_info_get)
PERL_RETURN_STRING(result);
}
/*
* weechat::info_get_hashtable: get info (as hashtable)
*/
XS (XS_weechat_api_info_get_hashtable)
{
char *info_name;
struct t_hashtable *hashtable, *result_hashtable;
HV *result_hash;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "info_get_hashtable");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "info_get_hashtable");
PERL_RETURN_EMPTY;
}
info_name = SvPV (ST (0), PL_na);
hashtable = weechat_perl_hash_to_hashtable (ST (1),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
result_hashtable = weechat_info_get_hashtable (info_name, hashtable);
result_hash = weechat_perl_hashtable_to_hash (result_hashtable);
if (hashtable)
weechat_hashtable_free (hashtable);
if (result_hashtable)
weechat_hashtable_free (result_hashtable);
PERL_RETURN_OBJ(result_hash);
}
/*
* weechat::infolist_new: create new infolist
*/
@ -5841,7 +5960,8 @@ weechat_perl_api_upgrade_read_cb (void *data,
struct t_infolist *infolist)
{
struct t_script_callback *script_callback;
char *perl_argv[5], empty_arg[1] = { '\0' }, str_object_id[32];
void *perl_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -5854,12 +5974,11 @@ weechat_perl_api_upgrade_read_cb (void *data,
perl_argv[1] = script_ptr2str (upgrade_file);
perl_argv[2] = str_object_id;
perl_argv[3] = script_ptr2str (infolist);
perl_argv[4] = NULL;
rc = (int *) weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
perl_argv);
"ssss", perl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -6046,6 +6165,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::hook_modifier", XS_weechat_api_hook_modifier, "weechat");
newXS ("weechat::hook_modifier_exec", XS_weechat_api_hook_modifier_exec, "weechat");
newXS ("weechat::hook_info", XS_weechat_api_hook_info, "weechat");
newXS ("weechat::hook_info_hashtable", XS_weechat_api_hook_info_hashtable, "weechat");
newXS ("weechat::hook_infolist", XS_weechat_api_hook_infolist, "weechat");
newXS ("weechat::unhook", XS_weechat_api_unhook, "weechat");
newXS ("weechat::unhook_all", XS_weechat_api_unhook_all, "weechat");
@ -6085,6 +6205,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::bar_remove", XS_weechat_api_bar_remove, "weechat");
newXS ("weechat::command", XS_weechat_api_command, "weechat");
newXS ("weechat::info_get", XS_weechat_api_info_get, "weechat");
newXS ("weechat::info_get_hashtable", XS_weechat_api_info_get_hashtable, "weechat");
newXS ("weechat::infolist_new", XS_weechat_api_infolist_new, "weechat");
newXS ("weechat::infolist_new_item", XS_weechat_api_infolist_new_item, "weechat");
newXS ("weechat::infolist_new_var_integer", XS_weechat_api_infolist_new_var_integer, "weechat");

View File

@ -127,12 +127,130 @@ char *perl_weechat_code =
/*
* weechat_perl_exec: execute a Perl script
* weechat_perl_hashtable_map_cb: callback called for each key/value in a
* hashtable
*/
void
weechat_perl_hashtable_map_cb (void *data,
struct t_hashtable *hashtable,
const void *key,
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);
}
/*
* weechat_perl_hashtable_to_hash: get perl hash with a WeeChat hashtable
*/
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;
}
/*
* weechat_perl_hash_to_hashtable: get WeeChat hashtable with perl hash
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after use
* with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
{
struct t_hashtable *hashtable;
HV *hash2;
SV *value;
char *str_key;
I32 retlen;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
if ((hash) && SvROK(hash) && SvRV(hash) && (SvTYPE(SvRV(hash)) == SVt_PVHV))
{
hash2 = (HV *) SvRV(hash);
hv_iterinit (hash2);
while ((value = hv_iternextsv (hash2, &str_key, &retlen)))
{
weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
}
}
return hashtable;
}
/*
* weechat_perl_exec_pv: encapsulation of call to perl_call_pv
*/
int
weechat_perl_exec_pv (const char *func, const char *format, void **argv)
{
int i, argc;
HV *hash;
dSP;
PUSHMARK(SP);
if (format && format[0])
{
argc = strlen (format);
for (i = 0; i < argc; i++)
{
switch (format[i])
{
case 's': /* string */
XPUSHs(sv_2mortal(newSVpv((char *)argv[i], 0)));
break;
case 'i': /* integer */
XPUSHs(sv_2mortal(newSViv(*((int *)argv[i]))));
break;
case 'h': /* hash */
hash = weechat_perl_hashtable_to_hash (argv[i]);
XPUSHs(sv_2mortal((SV *)hash));
break;
}
}
PUTBACK;
}
return perl_call_pv (func, G_EVAL | G_SCALAR);
}
/*
* weechat_perl_exec: execute a perl function
*/
void *
weechat_perl_exec (struct t_plugin_script *script,
int ret_type, const char *function, char **argv)
int ret_type, const char *function,
const char *format, void **argv)
{
char *func;
unsigned int count;
@ -166,12 +284,12 @@ weechat_perl_exec (struct t_plugin_script *script,
ENTER;
SAVETMPS;
PUSHMARK(sp);
count = perl_call_argv (func, G_EVAL | G_SCALAR, argv);
count = weechat_perl_exec_pv (func, format, argv);
ret_value = NULL;
mem_err = 1;
SPAGAIN;
if (SvTRUE (ERRSV))
@ -209,6 +327,11 @@ weechat_perl_exec (struct t_plugin_script *script,
*ret_i = POPi;
ret_value = ret_i;
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_perl_hash_to_hashtable (POPs,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
}
else
{
weechat_printf (NULL,
@ -221,7 +344,6 @@ weechat_perl_exec (struct t_plugin_script *script,
}
}
PUTBACK;
FREETMPS;
LEAVE;
@ -255,7 +377,7 @@ weechat_perl_load (const char *filename)
struct t_plugin_script temp_script;
int *eval;
struct stat buf;
char *perl_argv[2];
void *perl_argv[2];
#ifdef MULTIPLICITY
PerlInterpreter *perl_current_interpreter;
@ -311,20 +433,22 @@ weechat_perl_load (const char *filename)
perl_args_count, perl_args, NULL);
eval_pv (perl_weechat_code, TRUE);
perl_argv[0] = (char *)filename;
perl_argv[1] = NULL;
perl_argv[0] = (void *)filename;
eval = weechat_perl_exec (&temp_script,
WEECHAT_SCRIPT_EXEC_INT,
"weechat_perl_load_eval_file",
"s", perl_argv);
#else
snprintf (pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, perl_num);
perl_num++;
temp_script.interpreter = "WeechatPerlScriptLoader";
perl_argv[0] = (char *)filename;
perl_argv[0] = (void *)filename;
perl_argv[1] = pkgname;
perl_argv[2] = NULL;
#endif
eval = weechat_perl_exec (&temp_script,
WEECHAT_SCRIPT_EXEC_INT,
"weechat_perl_load_eval_file",
perl_argv);
"ss", perl_argv);
#endif
if (!eval)
{
weechat_printf (NULL,
@ -434,7 +558,6 @@ void
weechat_perl_unload (struct t_plugin_script *script)
{
int *r;
char *perl_argv[1] = { NULL };
void *interpreter;
if ((weechat_perl_plugin->debug >= 1) || !perl_quiet)
@ -455,7 +578,7 @@ weechat_perl_unload (struct t_plugin_script *script)
r = (int *) weechat_perl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func,
perl_argv);
NULL, NULL);
if (r)
free (r);
}
@ -470,8 +593,11 @@ weechat_perl_unload (struct t_plugin_script *script)
script);
#ifdef MULTIPLICITY
perl_destruct (interpreter);
perl_free (interpreter);
if (interpreter)
{
perl_destruct (interpreter);
perl_free (interpreter);
}
#else
if (interpreter)
free (interpreter);

View File

@ -34,8 +34,11 @@ extern struct t_plugin_script *perl_current_script;
extern struct t_plugin_script *perl_registered_script;
extern const char *perl_current_script_filename;
extern HV *weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_perl_hash_to_hashtable (SV *hash,
int hashtable_size);
extern void *weechat_perl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char **argv);
const char *format, void **argv);
#endif /* __WEECHAT_PERL_H */

View File

@ -1064,7 +1064,8 @@ weechat_python_api_config_reload_cb (void *data,
struct t_config_file *config_file)
{
struct t_script_callback *script_callback;
char *python_argv[3], empty_arg[1] = { '\0' };
void *python_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1073,12 +1074,11 @@ weechat_python_api_config_reload_cb (void *data,
{
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (config_file);
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ss", python_argv);
if (!rc)
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
@ -1146,7 +1146,8 @@ weechat_python_api_config_read_cb (void *data,
const char *option_name, const char *value)
{
struct t_script_callback *script_callback;
char *python_argv[6], empty_arg[1] = { '\0' };
void *python_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1158,12 +1159,11 @@ weechat_python_api_config_read_cb (void *data,
python_argv[2] = script_ptr2str (section);
python_argv[3] = (option_name) ? (char *)option_name : empty_arg;
python_argv[4] = (value) ? (char *)value : empty_arg;
python_argv[5] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sssss", python_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1193,7 +1193,8 @@ weechat_python_api_config_section_write_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1203,12 +1204,11 @@ weechat_python_api_config_section_write_cb (void *data,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (config_file);
python_argv[2] = (section_name) ? (char *)section_name : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1237,7 +1237,8 @@ weechat_python_api_config_section_write_default_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1247,12 +1248,11 @@ weechat_python_api_config_section_write_default_cb (void *data,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (config_file);
python_argv[2] = (section_name) ? (char *)section_name : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1282,7 +1282,8 @@ weechat_python_api_config_section_create_option_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *python_argv[6], empty_arg[1] = { '\0' };
void *python_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1294,12 +1295,11 @@ weechat_python_api_config_section_create_option_cb (void *data,
python_argv[2] = script_ptr2str (section);
python_argv[3] = (option_name) ? (char *)option_name : empty_arg;
python_argv[4] = (value) ? (char *)value : empty_arg;
python_argv[5] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sssss", python_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1330,7 +1330,8 @@ weechat_python_api_config_section_delete_option_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *python_argv[5], empty_arg[1] = { '\0' };
void *python_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1341,12 +1342,11 @@ weechat_python_api_config_section_delete_option_cb (void *data,
python_argv[1] = script_ptr2str (config_file);
python_argv[2] = script_ptr2str (section);
python_argv[3] = script_ptr2str (option);
python_argv[4] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ssss", python_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@ -1488,7 +1488,8 @@ weechat_python_api_config_option_check_value_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1498,12 +1499,11 @@ weechat_python_api_config_option_check_value_cb (void *data,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (option);
python_argv[2] = (value) ? (char *)value : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = 0;
@ -1530,7 +1530,8 @@ weechat_python_api_config_option_change_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *python_argv[3], empty_arg[1] = { '\0' };
void *python_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1539,12 +1540,11 @@ weechat_python_api_config_option_change_cb (void *data,
{
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (option);
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ss", python_argv);
if (python_argv[1])
free (python_argv[1]);
@ -1563,7 +1563,8 @@ weechat_python_api_config_option_delete_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *python_argv[3], empty_arg[1] = { '\0' };
void *python_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1572,12 +1573,11 @@ weechat_python_api_config_option_delete_cb (void *data,
{
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (option);
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ss", python_argv);
if (python_argv[1])
free (python_argv[1]);
@ -2903,7 +2903,8 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
/* make C compiler happy */
@ -2916,12 +2917,11 @@ weechat_python_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (buffer);
python_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -2997,7 +2997,8 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3007,12 +3008,11 @@ weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (buffer);
python_argv[2] = (command) ? (char *)command : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3077,7 +3077,8 @@ int
weechat_python_api_hook_timer_cb (void *data, int remaining_calls)
{
struct t_script_callback *script_callback;
char *python_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' };
void *python_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3089,12 +3090,11 @@ weechat_python_api_hook_timer_cb (void *data, int remaining_calls)
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = str_remaining_calls;
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3163,7 +3163,8 @@ int
weechat_python_api_hook_fd_cb (void *data, int fd)
{
struct t_script_callback *script_callback;
char *python_argv[3], str_fd[32], empty_arg[1] = { '\0' };
void *python_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3174,12 +3175,11 @@ weechat_python_api_hook_fd_cb (void *data, int fd)
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = str_fd;
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3252,7 +3252,8 @@ weechat_python_api_hook_process_cb (void *data,
const char *out, const char *err)
{
struct t_script_callback *script_callback;
char *python_argv[6], str_rc[32], empty_arg[1] = { '\0' };
void *python_argv[5];
char str_rc[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3266,12 +3267,11 @@ weechat_python_api_hook_process_cb (void *data,
python_argv[2] = str_rc;
python_argv[3] = (out) ? (char *)out : empty_arg;
python_argv[4] = (err) ? (char *)err : empty_arg;
python_argv[5] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sssss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3338,8 +3338,8 @@ weechat_python_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
char *python_argv[6], str_status[32], str_gnutls_rc[32];
char empty_arg[1] = { '\0' };
void *python_argv[5];
char str_status[32], str_gnutls_rc[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3354,12 +3354,11 @@ weechat_python_api_hook_connect_cb (void *data, int status, int gnutls_rc,
python_argv[2] = str_gnutls_rc;
python_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
python_argv[4] = (error) ? (char *)error : empty_arg;
python_argv[5] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sssss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3441,7 +3440,8 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
const char *prefix, const char *message)
{
struct t_script_callback *script_callback;
char *python_argv[9], empty_arg[1] = { '\0' };
void *python_argv[8];
char empty_arg[1] = { '\0' };
static char timebuffer[64];
int *rc, ret;
@ -3464,12 +3464,11 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
python_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
python_argv[6] = (prefix) ? (char *)prefix : empty_arg;
python_argv[7] = (message) ? (char *)message : empty_arg;
python_argv[8] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ssssssss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3549,7 +3548,8 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t
void *signal_data)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
static char value_str[64];
int *rc, ret, free_needed;
@ -3577,12 +3577,11 @@ weechat_python_api_hook_signal_cb (void *data, const char *signal, const char *t
}
else
python_argv[2] = empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3701,7 +3700,8 @@ int
weechat_python_api_hook_config_cb (void *data, const char *option, const char *value)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3711,12 +3711,11 @@ weechat_python_api_hook_config_cb (void *data, const char *option, const char *v
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = (option) ? (char *)option : empty_arg;
python_argv[2] = (value) ? (char *)value : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3781,7 +3780,8 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *python_argv[5], empty_arg[1] = { '\0' };
void *python_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3792,12 +3792,11 @@ weechat_python_api_hook_completion_cb (void *data, const char *completion_item,
python_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
python_argv[2] = script_ptr2str (buffer);
python_argv[3] = script_ptr2str (completion);
python_argv[4] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ssss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3907,7 +3906,8 @@ weechat_python_api_hook_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
{
struct t_script_callback *script_callback;
char *python_argv[5], empty_arg[1] = { '\0' };
void *python_argv[4];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -3917,12 +3917,11 @@ weechat_python_api_hook_modifier_cb (void *data, const char *modifier,
python_argv[1] = (modifier) ? (char *)modifier : empty_arg;
python_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
python_argv[3] = (string) ? (char *)string : empty_arg;
python_argv[4] = NULL;
return (char *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
"ssss", python_argv);
}
return NULL;
@ -4010,7 +4009,8 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4019,12 +4019,11 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = (info_name) ? (char *)info_name : empty_arg;
python_argv[2] = (arguments) ? (char *)arguments : empty_arg;
python_argv[3] = NULL;
return (const char *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
"sss", python_argv);
}
return NULL;
@ -4074,6 +4073,89 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_info_hashtable_cb: callback for info_hashtable hooked
*/
struct t_hashtable *
weechat_python_api_hook_info_hashtable_cb (void *data, const char *info_name,
struct t_hashtable *hashtable)
{
struct t_script_callback *script_callback;
void *python_argv[3];
char empty_arg[1] = { '\0' };
struct t_hashtable *ret_hashtable;
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = (info_name) ? (char *)info_name : empty_arg;
python_argv[2] = weechat_python_hashtable_to_dict (hashtable);
ret_hashtable = weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
script_callback->function,
"ssO", python_argv);
if (python_argv[2])
Py_XDECREF(python_argv[2]);
return ret_hashtable;
}
return NULL;
}
/*
* weechat_python_api_hook_info_hashtable: hook an info_hashtable
*/
static PyObject *
weechat_python_api_hook_info_hashtable (PyObject *self, PyObject *args)
{
char *info_name, *description, *args_description, *output_description;
char *function, *data, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
PYTHON_RETURN_EMPTY;
}
info_name = NULL;
description = NULL;
args_description = NULL;
output_description = NULL;
function = NULL;
data = NULL;
if (!PyArg_ParseTuple (args, "ssssss", &info_name, &description,
&args_description, &output_description,
&function, &data))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str(script_api_hook_info_hashtable (weechat_python_plugin,
python_current_script,
info_name,
description,
args_description,
output_description,
&weechat_python_api_hook_info_hashtable_cb,
function,
data));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_infolist_cb: callback for infolist hooked
*/
@ -4083,7 +4165,8 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
void *pointer, const char *arguments)
{
struct t_script_callback *script_callback;
char *python_argv[5], empty_arg[1] = { '\0' };
void *python_argv[4];
char empty_arg[1] = { '\0' };
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@ -4094,12 +4177,11 @@ weechat_python_api_hook_infolist_cb (void *data, const char *infolist_name,
python_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
python_argv[2] = script_ptr2str (pointer);
python_argv[3] = (arguments) ? (char *)arguments : empty_arg;
python_argv[4] = NULL;
result = (struct t_infolist *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
"ssss", python_argv);
if (python_argv[2])
free (python_argv[2]);
@ -4222,7 +4304,8 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer
const char *input_data)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' };
void *python_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4232,12 +4315,11 @@ weechat_python_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (buffer);
python_argv[2] = (input_data) ? (char *)input_data : empty_arg;
python_argv[3] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"sss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
@ -4262,7 +4344,8 @@ int
weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
struct t_script_callback *script_callback;
char *python_argv[3], empty_arg[1] = { '\0' };
void *python_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4271,12 +4354,11 @@ weechat_python_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (buffer);
python_argv[2] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
@ -5177,7 +5259,8 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
struct t_script_callback *script_callback;
char *python_argv[4], empty_arg[1] = { '\0' }, *ret;
void *python_argv[3];
char empty_arg[1] = { '\0' }, *ret;
script_callback = (struct t_script_callback *)data;
@ -5186,12 +5269,11 @@ weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = script_ptr2str (item);
python_argv[2] = script_ptr2str (window);
python_argv[3] = NULL;
ret = (char *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
"sss", python_argv);
if (python_argv[1])
free (python_argv[1]);
@ -5537,7 +5619,7 @@ weechat_python_api_command (PyObject *self, PyObject *args)
}
/*
* weechat_python_api_info_get: get info about WeeChat
* weechat_python_api_info_get: get info (as string)
*/
static PyObject *
@ -5568,6 +5650,47 @@ weechat_python_api_info_get (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING(result);
}
/*
* weechat_python_api_info_get_hashtable: get info (as hashtable)
*/
static PyObject *
weechat_python_api_info_get_hashtable (PyObject *self, PyObject *args)
{
char *info_name;
struct t_hashtable *hashtable, *result_hashtable;
PyObject *dict, *result_dict;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "info_get_hashtable");
PYTHON_RETURN_EMPTY;
}
info_name = NULL;
if (!PyArg_ParseTuple (args, "sO", &info_name, &dict))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "info_get_hashtable");
PYTHON_RETURN_EMPTY;
}
hashtable = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
result_hashtable = weechat_info_get_hashtable (info_name, hashtable);
result_dict = weechat_python_hashtable_to_dict (result_hashtable);
if (hashtable)
weechat_hashtable_free (hashtable);
if (result_hashtable)
weechat_hashtable_free (result_hashtable);
return result_dict;
}
/*
* weechat_python_api_infolist_new: create new infolist
*/
@ -6158,7 +6281,8 @@ weechat_python_api_upgrade_read_cb (void *data,
struct t_infolist *infolist)
{
struct t_script_callback *script_callback;
char *python_argv[5], empty_arg[1] = { '\0' }, str_object_id[32];
void *python_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -6171,12 +6295,11 @@ weechat_python_api_upgrade_read_cb (void *data,
python_argv[1] = script_ptr2str (upgrade_file);
python_argv[2] = str_object_id;
python_argv[3] = script_ptr2str (infolist);
python_argv[4] = NULL;
rc = (int *) weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
python_argv);
"ssss", python_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -6357,6 +6480,7 @@ PyMethodDef weechat_python_funcs[] =
{ "hook_modifier", &weechat_python_api_hook_modifier, METH_VARARGS, "" },
{ "hook_modifier_exec", &weechat_python_api_hook_modifier_exec, METH_VARARGS, "" },
{ "hook_info", &weechat_python_api_hook_info, METH_VARARGS, "" },
{ "hook_info_hashtable", &weechat_python_api_hook_info_hashtable, METH_VARARGS, "" },
{ "hook_infolist", &weechat_python_api_hook_infolist, METH_VARARGS, "" },
{ "unhook", &weechat_python_api_unhook, METH_VARARGS, "" },
{ "unhook_all", &weechat_python_api_unhook_all, METH_VARARGS, "" },
@ -6396,6 +6520,7 @@ 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, "" },
{ "info_get_hashtable", &weechat_python_api_info_get_hashtable, METH_VARARGS, "" },
{ "infolist_new", &weechat_python_api_infolist_new, METH_VARARGS, "" },
{ "infolist_new_item", &weechat_python_api_infolist_new_item, METH_VARARGS, "" },
{ "infolist_new_var_integer", &weechat_python_api_infolist_new_var_integer, METH_VARARGS, "" },

View File

@ -68,12 +68,100 @@ char python_buffer_output[128];
/*
* weechat_python_exec: execute a Python script
* weechat_python_hashtable_map_cb: callback called for each key/value in a
* hashtable
*/
void
weechat_python_hashtable_map_cb (void *data,
struct t_hashtable *hashtable,
const void *key,
const void *value)
{
PyObject *dict, *dict_key, *dict_value;
/* 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);
}
/*
* weechat_python_hashtable_to_dict: get python dictionary with a WeeChat
* hashtable
*/
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;
}
/*
* weechat_python_dict_to_hashtable: get WeeChat hashtable with python
* dictionary
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after
* use with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
{
struct t_hashtable *hashtable;
PyObject *key, *value;
Py_ssize_t pos;
char *str_key, *str_value;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
pos = 0;
while (PyDict_Next (dict, &pos, &key, &value))
{
str_key = PyString_AsString (key);
str_value = PyString_AsString (value);
weechat_hashtable_set (hashtable, (void *)str_key, (void *)str_value);
}
return hashtable;
}
/*
* weechat_python_exec: execute a python function
*/
void *
weechat_python_exec (struct t_plugin_script *script,
int ret_type, const char *function, char **argv)
int ret_type, const char *function,
char *format, void **argv)
{
struct t_plugin_script *old_python_current_script;
PyThreadState *old_interpreter;
@ -81,8 +169,8 @@ weechat_python_exec (struct t_plugin_script *script,
PyObject *evDict;
PyObject *evFunc;
PyObject *rc;
void *ret_value;
int *ret_i;
void *argv2[16], *ret_value;
int i, argc, *ret_int;
/* PyEval_AcquireLock (); */
@ -110,78 +198,28 @@ weechat_python_exec (struct t_plugin_script *script,
}
python_current_script = script;
if (argv && argv[0])
{
if (argv[1])
argc = strlen (format);
for (i = 0; i < 16; i++)
{
if (argv[2])
{
if (argv[3])
{
if (argv[4])
{
if (argv[5])
{
if (argv[6])
{
if (argv[7])
{
rc = PyObject_CallFunction (evFunc, "ssssssss",
argv[0], argv[1],
argv[2], argv[3],
argv[4], argv[5],
argv[6], argv[7]);
}
else
{
rc = PyObject_CallFunction (evFunc, "sssssss",
argv[0], argv[1],
argv[2], argv[3],
argv[4], argv[5],
argv[6]);
}
}
else
{
rc = PyObject_CallFunction (evFunc, "ssssss",
argv[0], argv[1],
argv[2], argv[3],
argv[4], argv[5]);
}
}
else
{
rc = PyObject_CallFunction (evFunc, "sssss",
argv[0], argv[1],
argv[2], argv[3],
argv[4]);
}
}
else
{
rc = PyObject_CallFunction (evFunc, "ssss", argv[0],
argv[1], argv[2], argv[3]);
}
}
else
{
rc = PyObject_CallFunction (evFunc, "sss", argv[0],
argv[1], argv[2]);
}
}
else
{
rc = PyObject_CallFunction (evFunc, "ss", argv[0], argv[1]);
}
}
else
{
rc = PyObject_CallFunction (evFunc, "s", argv[0]);
argv2[i] = (i < argc) ? argv[i] : NULL;
}
rc = PyObject_CallFunction (evFunc, format,
argv2[0], argv2[1],
argv2[2], argv2[3],
argv2[4], argv2[5],
argv2[6], argv2[7],
argv2[8], argv2[9],
argv2[10], argv2[11],
argv2[12], argv2[13],
argv2[14], argv2[15]);
}
else
{
rc = PyObject_CallFunction (evFunc, NULL);
}
ret_value = NULL;
@ -197,22 +235,26 @@ weechat_python_exec (struct t_plugin_script *script,
PyErr_Print ();
Py_XDECREF(rc);
}
else if (PyString_Check (rc) && (ret_type == WEECHAT_SCRIPT_EXEC_STRING))
else if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (PyString_Check (rc)))
{
if (PyString_AsString (rc))
ret_value = strdup (PyString_AsString(rc));
else
ret_value = NULL;
Py_XDECREF(rc);
}
else if (PyInt_Check (rc) && (ret_type == WEECHAT_SCRIPT_EXEC_INT))
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (PyInt_Check (rc)))
{
ret_i = malloc (sizeof (*ret_i));
if (ret_i)
*ret_i = (int) PyInt_AsLong(rc);
ret_value = ret_i;
ret_int = malloc (sizeof (*ret_int));
if (ret_int)
*ret_int = (int) PyInt_AsLong(rc);
ret_value = ret_int;
Py_XDECREF(rc);
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_python_dict_to_hashtable (rc,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
Py_XDECREF(rc);
}
else
@ -241,7 +283,7 @@ weechat_python_exec (struct t_plugin_script *script,
}
/*
* weechat_python_output : redirection for stdout and stderr
* weechat_python_output: redirection for stdout and stderr
*/
static PyObject *
@ -552,7 +594,7 @@ weechat_python_unload (struct t_plugin_script *script)
if (script->shutdown_func && script->shutdown_func[0])
{
r = (int *) weechat_python_exec (script, WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func, NULL);
script->shutdown_func, NULL, NULL);
if (r)
free (r);
}

View File

@ -35,8 +35,11 @@ extern struct t_plugin_script *python_current_script;
extern struct t_plugin_script *python_registered_script;
extern const char *python_current_script_filename;
extern PyObject *weechat_python_hashtable_to_dict (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_python_dict_to_hashtable (PyObject *dict,
int hashtable_size);
extern void *weechat_python_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char **argv);
char *format, void **argv);
#endif /* __WEECHAT_PYTHON_H */

View File

@ -1224,7 +1224,8 @@ weechat_ruby_api_config_reload_cb (void *data,
struct t_config_file *config_file)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], empty_arg[1] = { '\0' };
void *ruby_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1233,12 +1234,11 @@ weechat_ruby_api_config_reload_cb (void *data,
{
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (config_file);
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ss", ruby_argv);
if (!rc)
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
@ -1315,7 +1315,8 @@ weechat_ruby_api_config_read_cb (void *data,
const char *option_name, const char *value)
{
struct t_script_callback *script_callback;
char *ruby_argv[6], empty_arg[1] = { '\0' };
void *ruby_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1327,12 +1328,11 @@ weechat_ruby_api_config_read_cb (void *data,
ruby_argv[2] = script_ptr2str (section);
ruby_argv[3] = (option_name) ? (char *)option_name : empty_arg;
ruby_argv[4] = (value) ? (char *)value : empty_arg;
ruby_argv[5] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sssss", ruby_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1362,7 +1362,8 @@ weechat_ruby_api_config_section_write_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1372,12 +1373,11 @@ weechat_ruby_api_config_section_write_cb (void *data,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (config_file);
ruby_argv[2] = (section_name) ? (char *)section_name : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1406,7 +1406,8 @@ weechat_ruby_api_config_section_write_default_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1416,12 +1417,11 @@ weechat_ruby_api_config_section_write_default_cb (void *data,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (config_file);
ruby_argv[2] = (section_name) ? (char *)section_name : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1451,7 +1451,8 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *ruby_argv[6], empty_arg[1] = { '\0' };
void *ruby_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1463,12 +1464,11 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
ruby_argv[2] = script_ptr2str (section);
ruby_argv[3] = (option_name) ? (char *)option_name : empty_arg;
ruby_argv[4] = (value) ? (char *)value : empty_arg;
ruby_argv[5] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sssss", ruby_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1499,7 +1499,8 @@ weechat_ruby_api_config_section_delete_option_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *ruby_argv[5], empty_arg[1] = { '\0' };
void *ruby_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1510,12 +1511,11 @@ weechat_ruby_api_config_section_delete_option_cb (void *data,
ruby_argv[1] = script_ptr2str (config_file);
ruby_argv[2] = script_ptr2str (section);
ruby_argv[3] = script_ptr2str (option);
ruby_argv[4] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ssss", ruby_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@ -1706,7 +1706,8 @@ weechat_ruby_api_config_option_check_value_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1716,12 +1717,11 @@ weechat_ruby_api_config_option_check_value_cb (void *data,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (option);
ruby_argv[2] = (value) ? (char *)value : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = 0;
@ -1748,7 +1748,8 @@ weechat_ruby_api_config_option_change_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], empty_arg[1] = { '\0' };
void *ruby_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1757,12 +1758,11 @@ weechat_ruby_api_config_option_change_cb (void *data,
{
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (option);
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ss", ruby_argv);
if (ruby_argv[1])
free (ruby_argv[1]);
@ -1781,7 +1781,8 @@ weechat_ruby_api_config_option_delete_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], empty_arg[1] = { '\0' };
void *ruby_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1790,12 +1791,11 @@ weechat_ruby_api_config_option_delete_cb (void *data,
{
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (option);
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ss", ruby_argv);
if (ruby_argv[1])
free (ruby_argv[1]);
@ -3348,7 +3348,8 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
/* make C compiler happy */
@ -3361,12 +3362,11 @@ weechat_ruby_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (buffer);
ruby_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3461,7 +3461,8 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3471,12 +3472,11 @@ weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (buffer);
ruby_argv[2] = (command) ? (char *)command : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3550,7 +3550,8 @@ int
weechat_ruby_api_hook_timer_cb (void *data, int remaining_calls)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' };
void *ruby_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3562,12 +3563,11 @@ weechat_ruby_api_hook_timer_cb (void *data, int remaining_calls)
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = str_remaining_calls;
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3649,7 +3649,8 @@ int
weechat_ruby_api_hook_fd_cb (void *data, int fd)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], str_fd[32], empty_arg[1] = { '\0' };
void *ruby_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3660,12 +3661,11 @@ weechat_ruby_api_hook_fd_cb (void *data, int fd)
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = str_fd;
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3753,7 +3753,8 @@ weechat_ruby_api_hook_process_cb (void *data,
const char *out, const char *err)
{
struct t_script_callback *script_callback;
char *ruby_argv[6], str_rc[32], empty_arg[1] = { '\0' };
void *ruby_argv[5];
char str_rc[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3767,12 +3768,11 @@ weechat_ruby_api_hook_process_cb (void *data,
ruby_argv[2] = str_rc;
ruby_argv[3] = (out) ? (char *)out : empty_arg;
ruby_argv[4] = (err) ? (char *)err : empty_arg;
ruby_argv[5] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sssss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3850,7 +3850,8 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
char *ruby_argv[6], str_status[32], str_gnutls_rc[32];
void *ruby_argv[5];
char str_status[32], str_gnutls_rc[32];
char empty_arg[1] = { '\0' };
int *rc, ret;
@ -3866,12 +3867,11 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, int gnutls_rc,
ruby_argv[2] = str_gnutls_rc;
ruby_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
ruby_argv[4] = (error) ? (char *)error : empty_arg;
ruby_argv[5] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sssss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3975,7 +3975,8 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
const char *prefix, const char *message)
{
struct t_script_callback *script_callback;
char *ruby_argv[9], empty_arg[1] = { '\0' };
void *ruby_argv[8];
char empty_arg[1] = { '\0' };
static char timebuffer[64];
int *rc, ret;
@ -3998,12 +3999,11 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
ruby_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
ruby_argv[6] = (prefix) ? (char *)prefix : empty_arg;
ruby_argv[7] = (message) ? (char *)message : empty_arg;
ruby_argv[8] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ssssssss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4099,7 +4099,8 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ
void *signal_data)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
static char value_str[64];
int *rc, ret, free_needed;
@ -4127,12 +4128,11 @@ weechat_ruby_api_hook_signal_cb (void *data, const char *signal, const char *typ
}
else
ruby_argv[2] = empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4268,7 +4268,8 @@ int
weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *value)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4278,12 +4279,11 @@ weechat_ruby_api_hook_config_cb (void *data, const char *option, const char *val
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = (option) ? (char *)option : empty_arg;
ruby_argv[2] = (value) ? (char *)value : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4357,7 +4357,8 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *ruby_argv[5], empty_arg[1] = { '\0' };
void *ruby_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4368,12 +4369,11 @@ weechat_ruby_api_hook_completion_cb (void *data, const char *completion_item,
ruby_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
ruby_argv[2] = script_ptr2str (buffer);
ruby_argv[3] = script_ptr2str (completion);
ruby_argv[4] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ssss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4507,7 +4507,8 @@ weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
{
struct t_script_callback *script_callback;
char *ruby_argv[5], empty_arg[1] = { '\0' };
void *ruby_argv[4];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4517,12 +4518,11 @@ weechat_ruby_api_hook_modifier_cb (void *data, const char *modifier,
ruby_argv[1] = (modifier) ? (char *)modifier : empty_arg;
ruby_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
ruby_argv[3] = (string) ? (char *)string : empty_arg;
ruby_argv[4] = NULL;
return (char *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
"ssss", ruby_argv);
}
return NULL;
@ -4628,7 +4628,8 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4637,12 +4638,11 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = (info_name) ? (char *)info_name : empty_arg;
ruby_argv[2] = (arguments) ? (char *)arguments : empty_arg;
ruby_argv[3] = NULL;
return (const char *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
}
return NULL;
@ -4706,6 +4706,101 @@ weechat_ruby_api_hook_info (VALUE class, VALUE info_name, VALUE description,
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_info_hashtable_cb: callback for info_hashtable hooked
*/
struct t_hashtable *
weechat_ruby_api_hook_info_hashtable_cb (void *data, const char *info_name,
struct t_hashtable *hashtable)
{
struct t_script_callback *script_callback;
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = (info_name) ? (char *)info_name : empty_arg;
ruby_argv[2] = (void *)weechat_ruby_hashtable_to_hash (hashtable);
return (struct t_hashtable *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
script_callback->function,
"ssh", ruby_argv);
}
return NULL;
}
/*
* weechat_ruby_api_hook_info_hashtable: hook an info_hashtable
*/
static VALUE
weechat_ruby_api_hook_info_hashtable (VALUE class, VALUE info_name,
VALUE description,
VALUE args_description,
VALUE output_description,
VALUE function, VALUE data)
{
char *c_info_name, *c_description, *c_args_description;
char *c_output_description, *c_function;
char *c_data, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
RUBY_RETURN_EMPTY;
}
c_info_name = NULL;
c_description = NULL;
c_args_description = NULL;
c_output_description = NULL;
c_function = NULL;
c_data = NULL;
if (NIL_P (info_name) || NIL_P (description) || NIL_P (args_description)
|| NIL_P (output_description) || NIL_P (function) || NIL_P (data))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
RUBY_RETURN_EMPTY;
}
Check_Type (info_name, T_STRING);
Check_Type (description, T_STRING);
Check_Type (args_description, T_STRING);
Check_Type (output_description, T_STRING);
Check_Type (function, T_STRING);
Check_Type (data, T_STRING);
c_info_name = STR2CSTR (info_name);
c_description = STR2CSTR (description);
c_args_description = STR2CSTR (args_description);
c_output_description = STR2CSTR (output_description);
c_function = STR2CSTR (function);
c_data = STR2CSTR (data);
result = script_ptr2str (script_api_hook_info_hashtable (weechat_ruby_plugin,
ruby_current_script,
c_info_name,
c_description,
c_args_description,
c_output_description,
&weechat_ruby_api_hook_info_hashtable_cb,
c_function,
c_data));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_infolist_cb: callback for infolist hooked
*/
@ -4715,7 +4810,8 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
void *pointer, const char *arguments)
{
struct t_script_callback *script_callback;
char *ruby_argv[5], empty_arg[1] = { '\0' };
void *ruby_argv[4];
char empty_arg[1] = { '\0' };
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@ -4726,12 +4822,11 @@ weechat_ruby_api_hook_infolist_cb (void *data, const char *infolist_name,
ruby_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
ruby_argv[2] = script_ptr2str (pointer);
ruby_argv[3] = (arguments) ? (char *)arguments : empty_arg;
ruby_argv[4] = NULL;
result = (struct t_infolist *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
"ssss", ruby_argv);
if (ruby_argv[2])
free (ruby_argv[2]);
@ -4874,7 +4969,8 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' };
void *ruby_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4884,12 +4980,11 @@ weechat_ruby_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (buffer);
ruby_argv[2] = (input_data) ? (char *)input_data : empty_arg;
ruby_argv[3] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4915,7 +5010,8 @@ int
weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
struct t_script_callback *script_callback;
char *ruby_argv[3], empty_arg[1] = { '\0' };
void *ruby_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4924,12 +5020,11 @@ weechat_ruby_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (buffer);
ruby_argv[2] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -5965,7 +6060,8 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
struct t_script_callback *script_callback;
char *ruby_argv[4], empty_arg[1] = { '\0' }, *ret;
void *ruby_argv[3];
char empty_arg[1] = { '\0' }, *ret;
script_callback = (struct t_script_callback *)data;
@ -5974,12 +6070,11 @@ weechat_ruby_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = script_ptr2str (item);
ruby_argv[2] = script_ptr2str (window);
ruby_argv[3] = NULL;
ret = (char *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
"sss", ruby_argv);
if (ruby_argv[1])
free (ruby_argv[1]);
@ -6392,7 +6487,7 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command)
}
/*
* weechat_ruby_api_info_get: get info about WeeChat
* weechat_ruby_api_info_get: get info (as string)
*/
static VALUE
@ -6427,6 +6522,51 @@ weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments)
RUBY_RETURN_STRING(result);
}
/*
* weechat_ruby_api_info_get_hashtable: get info (as hashtable)
*/
static VALUE
weechat_ruby_api_info_get_hashtable (VALUE class, VALUE info_name,
VALUE hash)
{
char *c_info_name;
struct t_hashtable *c_hashtable, *result_hashtable;
VALUE result_hash;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "info_get_hashtable");
RUBY_RETURN_EMPTY;
}
if (NIL_P (info_name) || NIL_P (hash))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "info_get_hashtable");
RUBY_RETURN_EMPTY;
}
Check_Type (info_name, T_STRING);
Check_Type (hash, T_HASH);
c_info_name = STR2CSTR (info_name);
c_hashtable = weechat_ruby_hash_to_hashtable (hash,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
result_hashtable = weechat_info_get_hashtable (c_info_name, c_hashtable);
result_hash = weechat_ruby_hashtable_to_hash (result_hashtable);
if (c_hashtable)
weechat_hashtable_free (c_hashtable);
if (result_hashtable)
weechat_hashtable_free (result_hashtable);
return result_hash;
}
/*
* weechat_ruby_api_infolist_new: create new infolist
*/
@ -7070,7 +7210,8 @@ weechat_ruby_api_upgrade_read_cb (void *data,
struct t_infolist *infolist)
{
struct t_script_callback *script_callback;
char *ruby_argv[5], empty_arg[1] = { '\0' }, str_object_id[32];
void *ruby_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -7083,12 +7224,11 @@ weechat_ruby_api_upgrade_read_cb (void *data,
ruby_argv[1] = script_ptr2str (upgrade_file);
ruby_argv[2] = str_object_id;
ruby_argv[3] = script_ptr2str (infolist);
ruby_argv[4] = NULL;
rc = (int *) weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
ruby_argv);
"ssss", ruby_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -7326,6 +7466,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "hook_modifier", &weechat_ruby_api_hook_modifier, 3);
rb_define_module_function (ruby_mWeechat, "hook_modifier_exec", &weechat_ruby_api_hook_modifier_exec, 3);
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 5);
rb_define_module_function (ruby_mWeechat, "hook_info_hashtable", &weechat_ruby_api_hook_info_hashtable, 6);
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 6);
rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1);
rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0);
@ -7365,6 +7506,7 @@ 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, "info_get_hashtable", &weechat_ruby_api_info_get_hashtable, 2);
rb_define_module_function (ruby_mWeechat, "infolist_new", &weechat_ruby_api_infolist_new, 0);
rb_define_module_function (ruby_mWeechat, "infolist_new_item", &weechat_ruby_api_infolist_new_item, 1);
rb_define_module_function (ruby_mWeechat, "infolist_new_var_integer", &weechat_ruby_api_infolist_new_var_integer, 3);

View File

@ -101,6 +101,88 @@ typedef struct protect_call_arg {
} protect_call_arg_t;
/*
* weechat_ruby_hashtable_map_cb: callback called for each key/value in a
* hashtable
*/
void
weechat_ruby_hashtable_map_cb (void *data,
struct t_hashtable *hashtable,
const void *key,
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));
}
/*
* weechat_ruby_hashtable_to_hash: get ruby hash with a WeeChat hashtable
*/
VALUE
weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable)
{
VALUE hash;
hash = rb_hash_new ();
if (NIL_P (hash))
return Qnil;
weechat_hashtable_map (hashtable,
&weechat_ruby_hashtable_map_cb,
&hash);
return hash;
}
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))
{
weechat_hashtable_set (hashtable, STR2CSTR(key), STR2CSTR(value));
}
return 0;
}
/*
* weechat_ruby_hash_to_hashtable: get WeeChat hashtable with ruby hashtable
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after use
* with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
{
struct t_hashtable *hashtable;
struct st_table *st;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
st = RHASH_TBL(hash);
rb_hash_foreach (hash, &weechat_ruby_hash_foreach_cb, (unsigned long)hashtable);
return hashtable;
}
/*
* protect_funcall0 : used to protect a function call
*/
@ -115,32 +197,19 @@ protect_funcall0 (VALUE arg)
}
/*
* rb_protect_funcall : function call in protect mode
* rb_protect_funcall: function call in protect mode
*/
VALUE
rb_protect_funcall (VALUE recv, ID mid, int *state, int argc, ...)
rb_protect_funcall (VALUE recv, ID mid, int *state, int argc, VALUE *argv)
{
va_list ap;
VALUE *argv;
struct protect_call_arg arg;
if (argc > 0)
{
int i;
argv = ALLOCA_N(VALUE, argc);
va_start(ap, argc);
for (i = 0; i < argc; i++)
argv[i] = va_arg(ap, VALUE);
va_end(ap);
}
else
argv = 0;
arg.recv = recv;
arg.mid = mid;
arg.argc = argc;
arg.argv = argv;
return rb_protect(protect_funcall0, (VALUE) &arg, state);
return rb_protect (protect_funcall0, (VALUE) &arg, state);
}
/*
@ -159,13 +228,13 @@ weechat_ruby_print_exception (VALUE err)
char* err_class;
backtrace = rb_protect_funcall (err, rb_intern("backtrace"),
&ruby_error, 0);
&ruby_error, 0, NULL);
err_msg = STR2CSTR(rb_protect_funcall(err, rb_intern("message"),
&ruby_error, 0));
&ruby_error, 0, NULL));
err_class = STR2CSTR(rb_protect_funcall(rb_protect_funcall(err,
rb_intern("class"),
&ruby_error, 0),
rb_intern("name"), &ruby_error, 0));
&ruby_error, 0, NULL),
rb_intern("name"), &ruby_error, 0, NULL));
if (strcmp (err_class, "SyntaxError") == 0)
{
@ -222,122 +291,55 @@ weechat_ruby_print_exception (VALUE err)
}
/*
* weechat_ruby_exec: call a ruby command
* weechat_ruby_exec: execute a ruby function
*/
void *
weechat_ruby_exec (struct t_plugin_script *script,
int ret_type, const char *function, char **argv)
int ret_type, const char *function,
const char *format, void **argv)
{
VALUE rc, err;
int ruby_error, *ret_i;
int ruby_error, i, argc, *ret_i;
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;
if (argv && argv[0])
argc = 0;
if (format && format[0])
{
if (argv[1])
argc = strlen (format);
for (i = 0; i < argc; i++)
{
if (argv[2])
switch (format[i])
{
if (argv[3])
{
if (argv[4])
{
if (argv[5])
{
if (argv[6])
{
if (argv[7])
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 8,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]),
rb_str_new2(argv[2]),
rb_str_new2(argv[3]),
rb_str_new2(argv[4]),
rb_str_new2(argv[5]),
rb_str_new2(argv[6]),
rb_str_new2(argv[7]));
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 7,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]),
rb_str_new2(argv[2]),
rb_str_new2(argv[3]),
rb_str_new2(argv[4]),
rb_str_new2(argv[5]),
rb_str_new2(argv[6]));
}
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 6,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]),
rb_str_new2(argv[2]),
rb_str_new2(argv[3]),
rb_str_new2(argv[4]),
rb_str_new2(argv[5]));
}
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 5,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]),
rb_str_new2(argv[2]),
rb_str_new2(argv[3]),
rb_str_new2(argv[4]));
}
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 4,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]),
rb_str_new2(argv[2]),
rb_str_new2(argv[3]));
}
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 3,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]),
rb_str_new2(argv[2]));
}
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 2,
rb_str_new2(argv[0]),
rb_str_new2(argv[1]));
case 's': /* string */
argv2[i] = rb_str_new2 ((char *)argv[i]);
break;
case 'i': /* integer */
argv2[i] = INT2FIX (*((int *)argv[i]));
break;
case 'h': /* hash */
argv2[i] = (VALUE)argv[i];
break;
}
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 1,
rb_str_new2(argv[0]));
}
}
if (argc > 0)
{
rc = rb_protect_funcall ((VALUE) script->interpreter,
rb_intern(function),
&ruby_error, argc, argv2);
}
else
{
rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function),
&ruby_error, 0);
rc = rb_protect_funcall ((VALUE) script->interpreter,
rb_intern(function),
&ruby_error, 0, NULL);
}
if (ruby_error)
@ -366,6 +368,11 @@ weechat_ruby_exec (struct t_plugin_script *script,
*ret_i = NUM2INT(rc);
ret_value = ret_i;
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_ruby_hash_to_hashtable (rc,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
}
else
{
weechat_printf (NULL,
@ -451,7 +458,6 @@ weechat_ruby_output_flush (VALUE self)
return Qnil;
}
/*
* weechat_ruby_load: load a Ruby script
*/
@ -460,7 +466,7 @@ int
weechat_ruby_load (const char *filename)
{
char modname[64];
VALUE curModule, ruby_retcode, err;
VALUE curModule, ruby_retcode, err, argv[1];
int ruby_error;
struct stat buf;
@ -488,9 +494,10 @@ weechat_ruby_load (const char *filename)
curModule = rb_define_module(modname);
ruby_current_script_filename = filename;
argv[0] = rb_str_new2 (filename);
ruby_retcode = rb_protect_funcall (curModule, rb_intern("load_eval_file"),
&ruby_error, 1, rb_str_new2(filename));
&ruby_error, 1, argv);
if (ruby_retcode == Qnil)
{
@ -536,7 +543,7 @@ weechat_ruby_load (const char *filename)
}
ruby_retcode = rb_protect_funcall (curModule, rb_intern("weechat_init"),
&ruby_error, 0);
&ruby_error, 0, NULL);
if (ruby_error)
{
@ -595,7 +602,6 @@ void
weechat_ruby_unload (struct t_plugin_script *script)
{
int *r;
char *ruby_argv[1] = { NULL };
void *interpreter;
if ((weechat_ruby_plugin->debug >= 1) || !ruby_quiet)
@ -610,7 +616,7 @@ weechat_ruby_unload (struct t_plugin_script *script)
r = (int *) weechat_ruby_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func,
ruby_argv);
0, NULL);
if (r)
free (r);
}

View File

@ -35,8 +35,11 @@ extern struct t_plugin_script *ruby_current_script;
extern struct t_plugin_script *ruby_registered_script;
extern const char *ruby_current_script_filename;
extern void *weechat_ruby_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char **argv);
extern VALUE weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_ruby_hash_to_hashtable (VALUE dict,
int hashtable_size);
void *weechat_ruby_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
#endif /* __WEECHAT_RUBY_H */

View File

@ -1202,6 +1202,50 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
return new_hook;
}
/*
* script_api_hook_info_hashtable: hook an info_hashtable
* return new hook, NULL if error
*/
struct t_hook *
script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
struct t_hashtable *(*callback)(void *data,
const char *info_name,
struct t_hashtable *hashtable),
const char *function,
const char *data)
{
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_info_hashtable (info_name, description,
args_description,
output_description,
callback, new_script_callback);
if (!new_hook)
{
script_callback_free_data (new_script_callback);
free (new_script_callback);
return NULL;
}
script_callback_init (new_script_callback, script, function, data);
new_script_callback->hook = new_hook;
script_callback_add (script, new_script_callback);
return new_hook;
}
/*
* script_api_hook_infolist: hook an infolist
* return new hook, NULL if error

View File

@ -243,6 +243,17 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu
const char *arguments),
const char *function,
const char *data);
extern struct t_hook *script_api_hook_info_hashtable (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
struct t_hashtable *(*callback)(void *data,
const char *info_name,
struct t_hashtable *hashtable),
const char *function,
const char *data);
extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *infolist_name,

View File

@ -21,8 +21,15 @@
#define __WEECHAT_SCRIPT_H 1
/* constants which defines return types for weechat_<lang>_exec functions */
#define WEECHAT_SCRIPT_EXEC_INT 1
#define WEECHAT_SCRIPT_EXEC_STRING 2
enum t_weechat_script_exec_type
{
WEECHAT_SCRIPT_EXEC_INT = 0,
WEECHAT_SCRIPT_EXEC_STRING,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
};
#define WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE 16
#define WEECHAT_SCRIPT_MSG_NOT_INIT(__current_script, \
__function) \

View File

@ -156,6 +156,11 @@
Tcl_SetIntObj (objp, __int); \
return TCL_OK; \
}
#define TCL_RETURN_OBJ(__obj) \
{ \
Tcl_SetObjResult (interp, __obj); \
return TCL_OK; \
}
/*
@ -1229,7 +1234,8 @@ weechat_tcl_api_config_reload_cb (void *data,
struct t_config_file *config_file)
{
struct t_script_callback *script_callback;
char *tcl_argv[3], empty_arg[1] = { '\0' };
void *tcl_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1239,12 +1245,11 @@ weechat_tcl_api_config_reload_cb (void *data,
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (config_file);
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
"ss", tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
@ -1315,7 +1320,8 @@ weechat_tcl_api_config_section_read_cb (void *data,
const char *option_name, const char *value)
{
struct t_script_callback *script_callback;
char *tcl_argv[6], empty_arg[1] = { '\0' };
void *tcl_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1327,12 +1333,11 @@ weechat_tcl_api_config_section_read_cb (void *data,
tcl_argv[2] = script_ptr2str (section);
tcl_argv[3] = (option_name) ? (char *)option_name : empty_arg;
tcl_argv[4] = (value) ? (char *)value : empty_arg;
tcl_argv[5] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
"sssss", tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1362,7 +1367,8 @@ weechat_tcl_api_config_section_write_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1372,12 +1378,11 @@ weechat_tcl_api_config_section_write_cb (void *data,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (config_file);
tcl_argv[2] = (section_name) ? (char *)section_name : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1406,7 +1411,8 @@ weechat_tcl_api_config_section_write_default_cb (void *data,
const char *section_name)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1416,12 +1422,11 @@ weechat_tcl_api_config_section_write_default_cb (void *data,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (config_file);
tcl_argv[2] = (section_name) ? (char *)section_name : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_WRITE_ERROR;
@ -1452,7 +1457,8 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *tcl_argv[6], empty_arg[1] = { '\0' };
void *tcl_argv[5];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1464,12 +1470,11 @@ weechat_tcl_api_config_section_create_option_cb (void *data,
tcl_argv[2] = script_ptr2str (section);
tcl_argv[3] = (option_name) ? (char *)option_name : empty_arg;
tcl_argv[4] = (value) ? (char *)value : empty_arg;
tcl_argv[5] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sssss", tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_SET_ERROR;
@ -1501,7 +1506,8 @@ weechat_tcl_api_config_section_delete_option_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *tcl_argv[5], empty_arg[1] = { '\0' };
void *tcl_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1512,12 +1518,11 @@ weechat_tcl_api_config_section_delete_option_cb (void *data,
tcl_argv[1] = script_ptr2str (config_file);
tcl_argv[2] = script_ptr2str (section);
tcl_argv[3] = script_ptr2str (option);
tcl_argv[4] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ssss", tcl_argv);
if (!rc)
ret = WEECHAT_CONFIG_OPTION_UNSET_ERROR;
@ -1663,7 +1668,8 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
const char *value)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -1673,12 +1679,11 @@ weechat_tcl_api_config_option_check_value_cb (void *data,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (option);
tcl_argv[2] = (value) ? (char *)value : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = 0;
@ -1705,7 +1710,8 @@ weechat_tcl_api_config_option_change_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *tcl_argv[3], empty_arg[1] = { '\0' };
void *tcl_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1714,12 +1720,11 @@ weechat_tcl_api_config_option_change_cb (void *data,
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (option);
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ss", tcl_argv);
if (tcl_argv[1])
free (tcl_argv[1]);
@ -1738,7 +1743,8 @@ weechat_tcl_api_config_option_delete_cb (void *data,
struct t_config_option *option)
{
struct t_script_callback *script_callback;
char *tcl_argv[3], empty_arg[1] = { '\0' };
void *tcl_argv[2];
char empty_arg[1] = { '\0' };
int *rc;
script_callback = (struct t_script_callback *)data;
@ -1747,12 +1753,11 @@ weechat_tcl_api_config_option_delete_cb (void *data,
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (option);
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ss", tcl_argv);
if (tcl_argv[1])
free (tcl_argv[1]);
@ -3141,7 +3146,8 @@ weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
/* make C compiler happy */
@ -3154,12 +3160,11 @@ weechat_tcl_api_hook_command_cb (void *data, struct t_gui_buffer *buffer,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (buffer);
tcl_argv[2] = (argc > 1) ? argv_eol[1] : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3236,7 +3241,8 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3246,12 +3252,11 @@ weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (buffer);
tcl_argv[2] = (command) ? (char *)command : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3318,7 +3323,8 @@ int
weechat_tcl_api_hook_timer_cb (void *data, int remaining_calls)
{
struct t_script_callback *script_callback;
char *tcl_argv[3], str_remaining_calls[32], empty_arg[1] = { '\0' };
void *tcl_argv[2];
char str_remaining_calls[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3330,12 +3336,11 @@ weechat_tcl_api_hook_timer_cb (void *data, int remaining_calls)
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = str_remaining_calls;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3407,7 +3412,8 @@ int
weechat_tcl_api_hook_fd_cb (void *data, int fd)
{
struct t_script_callback *script_callback;
char *tcl_argv[3], str_fd[32], empty_arg[1] = { '\0' };
void *tcl_argv[2];
char str_fd[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3418,12 +3424,11 @@ weechat_tcl_api_hook_fd_cb (void *data, int fd)
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = str_fd;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3498,7 +3503,8 @@ weechat_tcl_api_hook_process_cb (void *data,
const char *out, const char *err)
{
struct t_script_callback *script_callback;
char *tcl_argv[6], str_rc[32], empty_arg[1] = { '\0' };
void *tcl_argv[5];
char str_rc[32], empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3512,12 +3518,11 @@ weechat_tcl_api_hook_process_cb (void *data,
tcl_argv[2] = str_rc;
tcl_argv[3] = (out) ? (char *)out : empty_arg;
tcl_argv[4] = (err) ? (char *)err : empty_arg;
tcl_argv[5] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sssss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3590,7 +3595,8 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
char *tcl_argv[6], str_status[32], str_gnutls_rc[32];
void *tcl_argv[5];
char str_status[32], str_gnutls_rc[32];
char empty_arg[1] = { '\0' };
int *rc, ret;
@ -3606,12 +3612,11 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
tcl_argv[2] = str_gnutls_rc;
tcl_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
tcl_argv[4] = (error) ? (char *)error : empty_arg;
tcl_argv[5] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sssss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3698,7 +3703,8 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
const char *prefix, const char *message)
{
struct t_script_callback *script_callback;
char *tcl_argv[9], empty_arg[1] = { '\0' };
void *tcl_argv[8];
char empty_arg[1] = { '\0' };
static char timebuffer[64];
int *rc, ret;
@ -3721,12 +3727,11 @@ weechat_tcl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
tcl_argv[5] = (highlight) ? strdup ("1") : strdup ("0");
tcl_argv[6] = (prefix) ? (char *)prefix : empty_arg;
tcl_argv[7] = (message) ? (char *)message : empty_arg;
tcl_argv[8] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ssssssss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3811,7 +3816,8 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
void *signal_data)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
static char value_str[64];
int *rc, ret, free_needed;
@ -3839,12 +3845,11 @@ weechat_tcl_api_hook_signal_cb (void *data, const char *signal, const char *type
}
else
tcl_argv[2] = empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -3970,7 +3975,8 @@ int
weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *value)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -3980,12 +3986,11 @@ weechat_tcl_api_hook_config_cb (void *data, const char *option, const char *valu
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = (option) ? (char *)option : empty_arg;
tcl_argv[2] = (value) ? (char *)value : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4052,7 +4057,8 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item,
struct t_gui_completion *completion)
{
struct t_script_callback *script_callback;
char *tcl_argv[5], empty_arg[1] = { '\0' };
void *tcl_argv[4];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4063,12 +4069,11 @@ weechat_tcl_api_hook_completion_cb (void *data, const char *completion_item,
tcl_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
tcl_argv[2] = script_ptr2str (buffer);
tcl_argv[3] = script_ptr2str (completion);
tcl_argv[4] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ssss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -4185,7 +4190,8 @@ weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier,
const char *modifier_data, const char *string)
{
struct t_script_callback *script_callback;
char *tcl_argv[5], empty_arg[1] = { '\0' };
void *tcl_argv[4];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4195,12 +4201,11 @@ weechat_tcl_api_hook_modifier_cb (void *data, const char *modifier,
tcl_argv[1] = (modifier) ? (char *)modifier : empty_arg;
tcl_argv[2] = (modifier_data) ? (char *)modifier_data : empty_arg;
tcl_argv[3] = (string) ? (char *)string : empty_arg;
tcl_argv[4] = NULL;
return (char *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
tcl_argv);
"ssss", tcl_argv);
}
return NULL;
@ -4292,7 +4297,8 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
@ -4301,12 +4307,11 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = (info_name) ? (char *)info_name : empty_arg;
tcl_argv[2] = (arguments) ? (char *)arguments : empty_arg;
tcl_argv[3] = NULL;
return (const char *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
}
return NULL;
@ -4357,6 +4362,83 @@ weechat_tcl_api_hook_info (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_hook_info_hashtable_cb: callback for info_hashtable hooked
*/
struct t_hashtable *
weechat_tcl_api_hook_info_hashtable_cb (void *data, const char *info_name,
struct t_hashtable *hashtable)
{
struct t_script_callback *script_callback;
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
script_callback = (struct t_script_callback *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = (info_name) ? (char *)info_name : empty_arg;
tcl_argv[2] = hashtable;
return (struct t_hashtable *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
script_callback->function,
"ssh", tcl_argv);
}
return NULL;
}
/*
* weechat_tcl_api_hook_info_hashtable: hook an info_hashtable
*/
static int
weechat_tcl_api_hook_info_hashtable (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result, *info_name, *description, *args_description;
char *output_description, *function, *data;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
TCL_RETURN_EMPTY;
}
if (objc < 7)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_info_hashtable");
TCL_RETURN_EMPTY;
}
info_name = Tcl_GetStringFromObj (objv[1], &i);
description = Tcl_GetStringFromObj (objv[2], &i);
args_description = Tcl_GetStringFromObj (objv[3], &i);
output_description = Tcl_GetStringFromObj (objv[4], &i);
function = Tcl_GetStringFromObj (objv[5], &i);
data = Tcl_GetStringFromObj (objv[6], &i);
result = script_ptr2str (script_api_hook_info_hashtable (weechat_tcl_plugin,
tcl_current_script,
info_name,
description,
args_description,
output_description,
&weechat_tcl_api_hook_info_hashtable_cb,
function,
data));
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_hook_infolist_cb: callback for infolist hooked
*/
@ -4366,7 +4448,8 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name,
void *pointer, const char *arguments)
{
struct t_script_callback *script_callback;
char *tcl_argv[5], empty_arg[1] = { '\0' };
void *tcl_argv[4];
char empty_arg[1] = { '\0' };
struct t_infolist *result;
script_callback = (struct t_script_callback *)data;
@ -4377,12 +4460,11 @@ weechat_tcl_api_hook_infolist_cb (void *data, const char *infolist_name,
tcl_argv[1] = (infolist_name) ? (char *)infolist_name : empty_arg;
tcl_argv[2] = script_ptr2str (pointer);
tcl_argv[3] = (arguments) ? (char *)arguments : empty_arg;
tcl_argv[4] = NULL;
result = (struct t_infolist *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
tcl_argv);
"ssss", tcl_argv);
if (tcl_argv[2])
free (tcl_argv[2]);
@ -4509,7 +4591,8 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
const char *input_data)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' };
void *tcl_argv[3];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4519,12 +4602,11 @@ weechat_tcl_api_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (buffer);
tcl_argv[2] = (input_data) ? (char *)input_data : empty_arg;
tcl_argv[3] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
@ -4549,7 +4631,8 @@ int
weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
struct t_script_callback *script_callback;
char *tcl_argv[3], empty_arg[1] = { '\0' };
void *tcl_argv[2];
char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -4558,12 +4641,11 @@ weechat_tcl_api_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (buffer);
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
"ss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
@ -5518,7 +5600,8 @@ weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window)
{
struct t_script_callback *script_callback;
char *tcl_argv[4], empty_arg[1] = { '\0' }, *ret;
void *tcl_argv[3];
char empty_arg[1] = { '\0' }, *ret;
script_callback = (struct t_script_callback *)data;
@ -5527,12 +5610,11 @@ weechat_tcl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = script_ptr2str (item);
tcl_argv[2] = script_ptr2str (window);
tcl_argv[3] = NULL;
ret = (char *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
tcl_argv);
"sss", tcl_argv);
if (tcl_argv[1])
free (tcl_argv[1]);
@ -5883,7 +5965,7 @@ weechat_tcl_api_command (ClientData clientData, Tcl_Interp *interp,
}
/*
* weechat_tcl_api_info_get: get info about WeeChat
* weechat_tcl_api_info_get: get info (as string)
*/
static int
@ -5915,6 +5997,48 @@ weechat_tcl_api_info_get (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING(result);
}
/*
* weechat_tcl_api_info_get_hashtable: get info (as hashtable)
*/
static int
weechat_tcl_api_info_get_hashtable (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp, *result_dict;
struct t_hashtable *hashtable, *result_hashtable;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "info_get_hashtable");
TCL_RETURN_EMPTY;
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "info_get_hashtable");
TCL_RETURN_EMPTY;
}
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
result_hashtable = weechat_info_get_hashtable (Tcl_GetStringFromObj (objv[1], &i),
hashtable);
result_dict = weechat_tcl_hashtable_to_dict (interp, result_hashtable);
if (hashtable)
weechat_hashtable_free (hashtable);
if (result_hashtable)
weechat_hashtable_free (result_hashtable);
TCL_RETURN_OBJ(result_dict);
}
/*
* weechat_tcl_api_infolist_new: create a new infolist
*/
@ -6529,7 +6653,8 @@ weechat_tcl_api_upgrade_read_cb (void *data,
struct t_infolist *infolist)
{
struct t_script_callback *script_callback;
char *tcl_argv[5], empty_arg[1] = { '\0' }, str_object_id[32];
void *tcl_argv[4];
char empty_arg[1] = { '\0' }, str_object_id[32];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@ -6542,12 +6667,11 @@ weechat_tcl_api_upgrade_read_cb (void *data,
tcl_argv[1] = script_ptr2str (upgrade_file);
tcl_argv[2] = str_object_id;
tcl_argv[3] = script_ptr2str (infolist);
tcl_argv[4] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
"ssss", tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
@ -6917,6 +7041,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_hook_modifier_exec, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::hook_info",
weechat_tcl_api_hook_info, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::hook_info_hashtable",
weechat_tcl_api_hook_info_hashtable, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::hook_infolist",
weechat_tcl_api_hook_infolist, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::unhook",
@ -6995,6 +7121,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_command, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::info_get",
weechat_tcl_api_info_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::info_get_hashtable",
weechat_tcl_api_info_get_hashtable, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::infolist_new",
weechat_tcl_api_infolist_new, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::infolist_new_item",

View File

@ -72,14 +72,106 @@ Tcl_Interp* cinterp;
/*
* weechat_tcl_exec: execute a Tcl script
* weechat_tcl_hashtable_map_cb: callback called for each key/value in a
* hashtable
*/
void
weechat_tcl_hashtable_map_cb (void *data,
struct t_hashtable *hashtable,
const void *key,
const void *value)
{
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));
}
/*
* weechat_tcl_hashtable_to_dict: get tcl dict with a WeeChat hashtable
*/
Tcl_Obj *
weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
struct t_hashtable *hashtable)
{
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;
}
/*
* weechat_tcl_dict_to_hashtable: get WeeChat hashtable with tcl dict
* Hashtable returned has type string for
* both keys and values
* Note: hashtable has to be released after
* use with call to weechat_hashtable_free()
*/
struct t_hashtable *
weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
int hashtable_size)
{
struct t_hashtable *hashtable;
Tcl_DictSearch search;
Tcl_Obj *key, *value;
int done;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
if (Tcl_DictObjFirst (interp, dict, &search, &key, &value, &done) == TCL_OK)
{
for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done))
{
weechat_hashtable_set (hashtable,
(void *)Tcl_GetString (key),
(void *)Tcl_GetString (value));
}
}
Tcl_DictObjDone(&search);
return hashtable;
}
/*
* weechat_tcl_exec: execute a tcl function
*/
void *
weechat_tcl_exec (struct t_plugin_script *script,
int ret_type, const char *function, char **argv)
int ret_type, const char *function,
const char *format, void **argv)
{
int i, llength;
int argc, i, llength;
int *ret_i;
char *ret_cv;
void *ret_val;
@ -90,12 +182,12 @@ weechat_tcl_exec (struct t_plugin_script *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);
Tcl_IncrRefCount(cmdlist); /* +1 */
Tcl_ListObjAppendElement(interp,cmdlist,Tcl_NewStringObj(function,-1));
cmdlist = Tcl_NewListObj (0, NULL);
Tcl_IncrRefCount (cmdlist); /* +1 */
Tcl_ListObjAppendElement (interp, cmdlist, Tcl_NewStringObj (function,-1));
}
else
{
@ -103,20 +195,35 @@ weechat_tcl_exec (struct t_plugin_script *script,
return NULL;
}
if (argv)
if (format && format[0])
{
for (i = 0; argv[i]; i++)
argc = strlen (format);
for (i = 0; i < argc; i++)
{
Tcl_ListObjAppendElement(interp,cmdlist,Tcl_NewStringObj(argv[i],-1));
switch (format[i])
{
case 's': /* string */
Tcl_ListObjAppendElement (interp, cmdlist,
Tcl_NewStringObj (argv[i], -1));
break;
case 'i': /* integer */
Tcl_ListObjAppendElement (interp, cmdlist,
Tcl_NewStringObj (argv[i], -1));
break;
case 'h': /* hash */
Tcl_ListObjAppendElement (interp, cmdlist,
weechat_tcl_hashtable_to_dict (interp, argv[i]));
break;
}
}
}
if (Tcl_ListObjLength(interp,cmdlist,&llength) != TCL_OK)
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 */
Tcl_ListObjReplace (interp, cmdlist, 0, llength, 0, NULL); /* remove elements, decrement their ref count */
Tcl_DecrRefCount (cmdlist); /* -1 */
ret_val = NULL;
if (ret_type == WEECHAT_SCRIPT_EXEC_STRING)
@ -135,6 +242,12 @@ weechat_tcl_exec (struct t_plugin_script *script,
*ret_i = i;
ret_val = (void *)ret_i;
}
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_val = weechat_tcl_dict_to_hashtable (interp,
Tcl_GetObjResult (interp),
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
}
tcl_current_script = old_tcl_script;
if (ret_val)
@ -147,8 +260,8 @@ weechat_tcl_exec (struct t_plugin_script *script,
return NULL;
}
Tcl_ListObjReplace(interp,cmdlist,0,llength,0,NULL); /* remove elements, decrement their ref count */
Tcl_DecrRefCount(cmdlist); /* -1 */
Tcl_ListObjReplace (interp, cmdlist, 0, llength, 0, NULL); /* remove elements, decrement their ref count */
Tcl_DecrRefCount (cmdlist); /* -1 */
weechat_printf (NULL,
weechat_gettext ("%s%s: unable to run function \"%s\": %s"),
weechat_prefix ("error"), TCL_PLUGIN_NAME, function,
@ -258,7 +371,7 @@ weechat_tcl_unload (struct t_plugin_script *script)
pointer = weechat_tcl_exec (script,
WEECHAT_SCRIPT_EXEC_INT,
script->shutdown_func,
NULL);
NULL, NULL);
if (pointer)
free (pointer);
}

View File

@ -35,8 +35,13 @@ extern struct t_plugin_script *tcl_current_script;
extern struct t_plugin_script *tcl_registered_script;
extern const char *tcl_current_script_filename;
extern Tcl_Obj *weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_tcl_dict_to_hashtable (Tcl_Interp *interp,
Tcl_Obj *dict,
int hashtable_size);
extern void *weechat_tcl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char **argv);
int ret_type, const char *function,
const char *format, void **argv);
#endif /* __WEECHAT_TCL_H */

View File

@ -45,7 +45,7 @@ struct timeval;
*/
/* API version (used to check that plugin has same API and can be loaded) */
#define WEECHAT_PLUGIN_API_VERSION "20100717-01"
#define WEECHAT_PLUGIN_API_VERSION "20100827-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -273,6 +273,8 @@ struct t_weechat_plugin
void *callback_map_data);
int (*hashtable_get_integer) (struct t_hashtable *hashtable,
const char *property);
const char *(*hashtable_get_string) (struct t_hashtable *hashtable,
const char *property);
int (*hashtable_add_to_infolist) (struct t_hashtable *hashtable,
struct t_infolist_item *infolist_item,
const char *prefix);
@ -521,6 +523,15 @@ struct t_weechat_plugin
const char *info_name,
const char *arguments),
void *callback_data);
struct t_hook *(*hook_info_hashtable) (struct t_weechat_plugin *plugin,
const char *info_name,
const char *description,
const char *args_description,
const char *output_description,
struct t_hashtable *(*callback)(void *data,
const char *info_name,
struct t_hashtable *hashtable),
void *callback_data);
struct t_hook *(*hook_infolist) (struct t_weechat_plugin *plugin,
const char *infolist_name,
const char *description,
@ -643,6 +654,9 @@ struct t_weechat_plugin
const char *(*info_get) (struct t_weechat_plugin *plugin,
const char *info_name,
const char *arguments);
struct t_hashtable *(*info_get_hashtable) (struct t_weechat_plugin *plugin,
const char *info_name,
struct t_hashtable *hashtable);
/* infolists */
struct t_infolist *(*infolist_new) ();
@ -886,6 +900,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->hashtable_map(__hashtable, __cb_map, __cb_map_data)
#define weechat_hashtable_get_integer(__hashtable, __property) \
weechat_plugin->hashtable_get_integer(__hashtable, __property)
#define weechat_hashtable_get_string(__hashtable, __property) \
weechat_plugin->hashtable_get_string(__hashtable, __property)
#define weechat_hashtable_add_to_infolist(__hashtable, __infolist_item, \
__prefix) \
weechat_plugin->hashtable_add_to_infolist(__hashtable, \
@ -1117,6 +1133,16 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->hook_info(weechat_plugin, __info_name, \
__description, __args_description, \
__callback, __data)
#define weechat_hook_info_hashtable(__info_name, __description, \
__args_description, \
__output_description, \
__callback, \
__data) \
weechat_plugin->hook_info_hashtable(weechat_plugin, __info_name, \
__description, \
__args_description, \
__output_description, \
__callback, __data)
#define weechat_hook_infolist(__infolist_name, __description, \
__pointer_description, \
__args_description, __callback, __data) \
@ -1243,6 +1269,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* infos */
#define weechat_info_get(__info_name, __arguments) \
weechat_plugin->info_get(weechat_plugin, __info_name, __arguments)
#define weechat_info_get_hashtable(__info_name, __hashtable) \
weechat_plugin->info_get_hashtable(weechat_plugin, __info_name, \
__hashtable)
/* infolists */
#define weechat_infolist_new() \