diff options
author | Emmanuel Bouthenot <kolter@openics.org> | 2006-06-10 21:34:16 +0000 |
---|---|---|
committer | Emmanuel Bouthenot <kolter@openics.org> | 2006-06-10 21:34:16 +0000 |
commit | b48fb5c0ec387cf5be61a80c51c4b95589c56179 (patch) | |
tree | d87b5156c9f7593ed8ee9907885fd765918321d4 /src/plugins/scripts/perl/weechat-perl.c | |
parent | 08aa5570d87b6a971933e1a85f5277543a1e0786 (diff) | |
download | weechat-b48fb5c0ec387cf5be61a80c51c4b95589c56179.zip |
add get_irc_color function in plugins/scripts
Diffstat (limited to 'src/plugins/scripts/perl/weechat-perl.c')
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 0b717b9ec..69e783510 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -1333,6 +1333,49 @@ static XS (XS_weechat_input_color) } /* + * weechat::get_irc_color: + * get the numeric value which identify an irc color by its name + */ + +static XS (XS_weechat_get_irc_color) +{ + char *color; + unsigned int integer; + dXSARGS; + + /* make gcc happy */ + (void) cv; + + if (!perl_current_script) + { + perl_plugin->print_server (perl_plugin, + "Perl error: unable to get irc color, " + "script not initialized"); + XST_mIV (0, -1); + XSRETURN (1); + } + + if (items != 1) + { + perl_plugin->print_server (perl_plugin, + "Perl error: wrong parameters for " + "\"get_irc_info\" function"); + XST_mIV (0, -1); + XSRETURN (1); + } + + color = SvPV (ST (0), integer); + if (color) + { + XST_mIV (0, perl_plugin->get_irc_color (perl_plugin, color)); + XSRETURN (1); + } + + XST_mIV (0, -1); + XSRETURN (-1); +} + +/* * weechat_perl_xs_init: initialize subroutines */ @@ -1367,7 +1410,8 @@ weechat_perl_xs_init (pTHX) newXS ("weechat::get_channel_info", XS_weechat_get_channel_info, "weechat"); newXS ("weechat::get_nick_info", XS_weechat_get_nick_info, "weechat"); newXS ("weechat::input_color", XS_weechat_input_color, "weechat"); - + newXS ("weechat::get_irc_color", XS_weechat_get_irc_color, "weechat"); + /* interface constants */ stash = gv_stashpv ("weechat", TRUE); newCONSTSUB (stash, "weechat::PLUGIN_RC_KO", newSViv (PLUGIN_RC_KO)); |