weechat-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Weechat-cvs] weechat/src/plugins/scripts luaweechat-lua.c pe...


From: kolter
Subject: [Weechat-cvs] weechat/src/plugins/scripts luaweechat-lua.c pe...
Date: Sat, 10 Jun 2006 21:34:16 +0000

CVSROOT:        /sources/weechat
Module name:    weechat
Changes by:     kolter <kolter> 06/06/10 21:34:16

Modified files:
        src/plugins/scripts/lua: weechat-lua.c 
        src/plugins/scripts/perl: weechat-perl.c 
        src/plugins/scripts/ruby: weechat-ruby.c 
        src/plugins/scripts/python: weechat-python.c 

Log message:
        add get_irc_color function in plugins/scripts

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/weechat/src/plugins/scripts/lua/weechat-lua.c?cvsroot=weechat&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/weechat/src/plugins/scripts/perl/weechat-perl.c?cvsroot=weechat&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/weechat/src/plugins/scripts/ruby/weechat-ruby.c?cvsroot=weechat&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/weechat/src/plugins/scripts/python/weechat-python.c?cvsroot=weechat&r1=1.36&r2=1.37

Patches:
Index: lua/weechat-lua.c
===================================================================
RCS file: /sources/weechat/weechat/src/plugins/scripts/lua/weechat-lua.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- lua/weechat-lua.c   29 May 2006 22:36:29 -0000      1.15
+++ lua/weechat-lua.c   10 Jun 2006 21:34:16 -0000      1.16
@@ -1504,6 +1504,48 @@
     return 1;
 }
 
+/*
+ * weechat_lua_get_irc_color:
+ *          get the numeric value which identify an irc color by its name
+ */
+
+static int
+weechat_lua_get_irc_color (lua_State *L)
+{
+    const char *color;
+    int n;
+    
+    /* make gcc happy */
+    (void) L;
+     
+    if (!lua_current_script)
+    {
+        lua_plugin->print_server (lua_plugin,
+                                  "Lua error: unable to get irc color, "
+                                  "script not initialized");
+        lua_pushnumber (lua_current_interpreter, -1);
+       return 1;
+    }
+    
+    color = NULL;
+ 
+    n = lua_gettop (lua_current_interpreter);
+    
+    if (n != 1)
+    {
+       lua_plugin->print_server (lua_plugin,
+                                  "Lua error: wrong parameters for "
+                                  "\"get_irc_color\" function");
+        lua_pushnumber (lua_current_interpreter, -1);
+       return 1;
+    }
+
+    color = lua_tostring (lua_current_interpreter, -1);
+    
+    lua_pushnumber (lua_current_interpreter,
+                   lua_plugin->get_irc_color (lua_plugin, (char *) color));
+    return 1;
+}
 
 /*
  * Lua constant as functions
@@ -1587,6 +1629,7 @@
     { "get_server_info", weechat_lua_get_server_info},
     { "get_channel_info", weechat_lua_get_channel_info},
     { "get_nick_info", weechat_lua_get_nick_info},
+    { "get_irc_color", weechat_lua_get_irc_color},
     /* define constants as function which returns values */
     { "PLUGIN_RC_OK", weechat_lua_constant_plugin_rc_ok},
     { "PLUGIN_RC_KO", weechat_lua_constant_plugin_rc_ko},

Index: perl/weechat-perl.c
===================================================================
RCS file: /sources/weechat/weechat/src/plugins/scripts/perl/weechat-perl.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- perl/weechat-perl.c 29 May 2006 22:42:07 -0000      1.35
+++ perl/weechat-perl.c 10 Jun 2006 21:34:16 -0000      1.36
@@ -1333,6 +1333,49 @@
 }
 
 /*
+ * 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,6 +1410,7 @@
     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);

Index: ruby/weechat-ruby.c
===================================================================
RCS file: /sources/weechat/weechat/src/plugins/scripts/ruby/weechat-ruby.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- ruby/weechat-ruby.c 29 May 2006 22:36:29 -0000      1.31
+++ ruby/weechat-ruby.c 10 Jun 2006 21:34:16 -0000      1.32
@@ -1491,6 +1491,44 @@
 }
 
 /*
+ * weechat_ruby_get_irc_color: 
+ *          get the numeric value which identify an irc color by its name
+ */
+
+static VALUE
+weechat_ruby_get_irc_color (VALUE class, VALUE color)
+{
+    char *c_color;
+    
+    /* make gcc happy */
+    (void) class;
+    
+    if (!ruby_current_script)
+    {
+        ruby_plugin->print_server (ruby_plugin,
+                                   "Ruby error: unable to get irc color, "
+                                   "script not initialized");
+        return INT2FIX (-1);
+    }
+    
+    c_color = NULL;
+    
+    if (NIL_P (color))
+    {
+        ruby_plugin->print_server (ruby_plugin,
+                                   "Ruby error: wrong parameters for "
+                                   "\"get_irc_color\" function");
+        return INT2FIX (-1);
+    }
+    
+    Check_Type (color, T_STRING);
+    
+    c_color = STR2CSTR (color);
+    
+    return INT2FIX (ruby_plugin->get_irc_color (ruby_plugin, c_color));
+}
+
+/*
  * weechat_ruby_output : redirection for stdout and stderr
  */
 
@@ -1952,6 +1990,7 @@
     rb_define_module_function (mWeechat, "get_server_info", 
weechat_ruby_get_server_info, 0);
     rb_define_module_function (mWeechat, "get_channel_info", 
weechat_ruby_get_channel_info, 1);
     rb_define_module_function (mWeechat, "get_nick_info", 
weechat_ruby_get_nick_info, 2);
+    rb_define_module_function (mWeechat, "get_irc_color", 
weechat_ruby_get_irc_color, 1);
     
     /* redirect stdin and stdout */
     mWeechatOutputs = rb_define_module("WeechatOutputs");

Index: python/weechat-python.c
===================================================================
RCS file: /sources/weechat/weechat/src/plugins/scripts/python/weechat-python.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- python/weechat-python.c     29 May 2006 22:36:29 -0000      1.36
+++ python/weechat-python.c     10 Jun 2006 21:34:16 -0000      1.37
@@ -1251,6 +1251,43 @@
 }
 
 /*
+ * weechat_python_get_irc_color: 
+ *          get the numeric value which identify an irc color by its name
+ */
+
+static PyObject *
+weechat_python_get_irc_color (PyObject *self, PyObject *args)
+{
+    char *color;
+    
+    /* make gcc happy */
+    (void) self;
+    
+    if (!python_current_script)
+    {
+        python_plugin->print_server (python_plugin,
+                                     "Python error: unable to get irc color, "
+                                     "script not initialized");
+        return Py_BuildValue ("i", -1);
+    }
+    
+    color = NULL;
+    
+    if (!PyArg_ParseTuple (args, "s", &color))
+    {
+        python_plugin->print_server (python_plugin,
+                                     "Python error: wrong parameters for "
+                                     "\"get_irc_color\" function");
+        return Py_BuildValue ("i", -1);
+    }
+    
+    if (color)
+       return Py_BuildValue ("i", python_plugin->get_irc_color (python_plugin, 
color));
+    
+    return Py_BuildValue ("i", -1);
+}
+
+/*
  * Python subroutines
  */
 
@@ -1278,6 +1315,7 @@
     { "get_server_info", weechat_python_get_server_info, METH_VARARGS, "" },
     { "get_channel_info", weechat_python_get_channel_info, METH_VARARGS, "" },
     { "get_nick_info", weechat_python_get_nick_info, METH_VARARGS, "" },
+    { "get_irc_color", weechat_python_get_irc_color, METH_VARARGS, "" },
     { NULL, NULL, 0, NULL }
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]