mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
Add function to get plugin name (return "core" for WeeChat core)
This commit is contained in:
@@ -132,6 +132,44 @@ weechat_lua_api_register (lua_State *L)
|
||||
LUA_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_plugin_get_name: get name of plugin (return "core" for
|
||||
* WeeChat core)
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_plugin_get_name (lua_State *L)
|
||||
{
|
||||
const char *plugin;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
plugin = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
plugin = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_plugin_get_name (script_str2ptr (plugin));
|
||||
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_charset_set: set script charset
|
||||
*/
|
||||
@@ -5554,6 +5592,7 @@ weechat_lua_api_constant_weechat_hook_signal_pointer (lua_State *L)
|
||||
|
||||
const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "register", &weechat_lua_api_register },
|
||||
{ "plugin_get_name", &weechat_lua_api_plugin_get_name },
|
||||
{ "charset_set", &weechat_lua_api_charset_set },
|
||||
{ "iconv_to_internal", &weechat_lua_api_iconv_to_internal },
|
||||
{ "iconv_from_internal", &weechat_lua_api_iconv_from_internal },
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -115,6 +115,38 @@ weechat_python_api_register (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_plugin_get_name: get name of plugin (return "core" for
|
||||
* WeeChat core)
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_plugin_get_name (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *plugin, *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
plugin = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &plugin))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_plugin_get_name (script_str2ptr (plugin));
|
||||
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_charset_set: set script charset
|
||||
*/
|
||||
@@ -4588,6 +4620,7 @@ weechat_python_api_infolist_free (PyObject *self, PyObject *args)
|
||||
PyMethodDef weechat_python_funcs[] =
|
||||
{
|
||||
{ "register", &weechat_python_api_register, METH_VARARGS, "" },
|
||||
{ "plugin_get_name", &weechat_python_api_plugin_get_name, METH_VARARGS, "" },
|
||||
{ "charset_set", &weechat_python_api_charset_set, METH_VARARGS, "" },
|
||||
{ "iconv_to_internal", &weechat_python_api_iconv_to_internal, METH_VARARGS, "" },
|
||||
{ "iconv_from_internal", &weechat_python_api_iconv_from_internal, METH_VARARGS, "" },
|
||||
|
||||
@@ -133,6 +133,42 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author,
|
||||
RUBY_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_plugin_get_name: get name of plugin (return "core" for
|
||||
* WeeChat core)
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_plugin_get_name (VALUE class, VALUE plugin)
|
||||
{
|
||||
char *c_plugin, *result;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
c_plugin = NULL;
|
||||
|
||||
if (NIL_P (plugin))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (plugin, T_STRING);
|
||||
|
||||
c_plugin = STR2CSTR (plugin);
|
||||
|
||||
result = weechat_plugin_get_name (script_str2ptr (c_plugin));
|
||||
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_charset_set: set script charset
|
||||
*/
|
||||
@@ -5294,6 +5330,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_POINTER", rb_str_new2(WEECHAT_HOOK_SIGNAL_POINTER));
|
||||
|
||||
rb_define_module_function (ruby_mWeechat, "register", &weechat_ruby_api_register, 7);
|
||||
rb_define_module_function (ruby_mWeechat, "plugin_get_name", &weechat_ruby_api_plugin_get_name, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "charset_set", &weechat_ruby_api_charset_set, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "iconv_to_internal", &weechat_ruby_api_iconv_to_internal, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "iconv_from_internal", &weechat_ruby_api_iconv_from_internal, 2);
|
||||
|
||||
@@ -219,6 +219,40 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc,
|
||||
TCL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::plugin_get_name: get name of plugin (return "core" for WeeChat core)
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_plugin_get_name (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
char *result, *plugin;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
plugin = Tcl_GetStringFromObj (objv[1], &i);
|
||||
|
||||
result = weechat_plugin_get_name (script_str2ptr (plugin));
|
||||
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::charset_set: set script charset
|
||||
*/
|
||||
@@ -4951,6 +4985,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
|
||||
/* interface functions */
|
||||
Tcl_CreateObjCommand (interp,"weechat::register",
|
||||
weechat_tcl_api_register, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::plugin_get_name",
|
||||
weechat_tcl_api_plugin_get_name, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::charset_set",
|
||||
weechat_tcl_api_charset_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::iconv_to_internal",
|
||||
|
||||
Reference in New Issue
Block a user