diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-10-08 19:04:05 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-10-08 19:04:05 +0200 |
commit | 5d07aa14ed58bb7ba3a4566955d471861488f056 (patch) | |
tree | 59528af01029f965139a81bbf07bcd33007abbb6 /src/plugins/scripts/tcl/weechat-tcl-api.c | |
parent | 0e053e072b9eb8755e0bd9418d18a58e4ae8f96d (diff) | |
download | weechat-5d07aa14ed58bb7ba3a4566955d471861488f056.zip |
Add function to get plugin name (return "core" for WeeChat core)
Diffstat (limited to 'src/plugins/scripts/tcl/weechat-tcl-api.c')
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index dab0560a4..2de706169 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -220,6 +220,40 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc, } /* + * 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", |