mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 22:06:38 +02:00
api: add function string_eval_path_home()
This commit is contained in:
@@ -479,6 +479,49 @@ weechat_guile_api_string_eval_expression (SCM expr, SCM pointers,
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_string_eval_path_home (SCM path, SCM pointers,
|
||||
SCM extra_vars, SCM options)
|
||||
{
|
||||
char *result;
|
||||
SCM return_value;
|
||||
struct t_hashtable *c_pointers, *c_extra_vars, *c_options;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY);
|
||||
if (!scm_is_string (path) || !scm_list_p (pointers)
|
||||
|| !scm_list_p (extra_vars) || !scm_list_p (options))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
c_pointers = weechat_guile_alist_to_hashtable (
|
||||
pointers,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
c_extra_vars = weechat_guile_alist_to_hashtable (
|
||||
extra_vars,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
c_options = weechat_guile_alist_to_hashtable (
|
||||
options,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (API_SCM_TO_STRING(path),
|
||||
c_pointers, c_extra_vars,
|
||||
c_options);
|
||||
|
||||
if (c_pointers)
|
||||
weechat_hashtable_free (c_pointers);
|
||||
if (c_extra_vars)
|
||||
weechat_hashtable_free (c_extra_vars);
|
||||
if (c_options)
|
||||
weechat_hashtable_free (c_options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_mkdir_home (SCM directory, SCM mode)
|
||||
{
|
||||
@@ -4660,6 +4703,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(string_is_command_char, 1);
|
||||
API_DEF_FUNC(string_input_for_buffer, 1);
|
||||
API_DEF_FUNC(string_eval_expression, 4);
|
||||
API_DEF_FUNC(string_eval_path_home, 4);
|
||||
API_DEF_FUNC(mkdir_home, 2);
|
||||
API_DEF_FUNC(mkdir, 2);
|
||||
API_DEF_FUNC(mkdir_parents, 2);
|
||||
|
||||
@@ -421,6 +421,43 @@ API_FUNC(string_eval_expression)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_eval_path_home)
|
||||
{
|
||||
struct t_hashtable *pointers, *extra_vars, *options;
|
||||
char *result;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", "shhh", API_RETURN_EMPTY);
|
||||
|
||||
v8::String::Utf8Value path(args[0]);
|
||||
pointers = weechat_js_object_to_hashtable (
|
||||
args[1]->ToObject(),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
extra_vars = weechat_js_object_to_hashtable (
|
||||
args[2]->ToObject(),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
options = weechat_js_object_to_hashtable (
|
||||
args[3]->ToObject(),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (*path, pointers, extra_vars,
|
||||
options);
|
||||
|
||||
if (pointers)
|
||||
weechat_hashtable_free (pointers);
|
||||
if (extra_vars)
|
||||
weechat_hashtable_free (extra_vars);
|
||||
if (options)
|
||||
weechat_hashtable_free (options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(mkdir_home)
|
||||
{
|
||||
int mode;
|
||||
@@ -4681,6 +4718,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
API_DEF_FUNC(string_input_for_buffer);
|
||||
API_DEF_FUNC(string_eval_expression);
|
||||
API_DEF_FUNC(string_eval_path_home);
|
||||
API_DEF_FUNC(mkdir_home);
|
||||
API_DEF_FUNC(mkdir);
|
||||
API_DEF_FUNC(mkdir_parents);
|
||||
|
||||
@@ -441,6 +441,43 @@ API_FUNC(string_eval_expression)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_eval_path_home)
|
||||
{
|
||||
const char *path;
|
||||
struct t_hashtable *pointers, *extra_vars, *options;
|
||||
char *result;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY);
|
||||
if (lua_gettop (L) < 4)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
path = lua_tostring (L, -4);
|
||||
pointers = weechat_lua_tohashtable (L, -3,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
extra_vars = weechat_lua_tohashtable (L, -2,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
options = weechat_lua_tohashtable (L, -1,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (path, pointers, extra_vars,
|
||||
options);
|
||||
|
||||
if (pointers)
|
||||
weechat_hashtable_free (pointers);
|
||||
if (extra_vars)
|
||||
weechat_hashtable_free (extra_vars);
|
||||
if (options)
|
||||
weechat_hashtable_free (options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(mkdir_home)
|
||||
{
|
||||
const char *directory;
|
||||
@@ -4957,6 +4994,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(string_is_command_char),
|
||||
API_DEF_FUNC(string_input_for_buffer),
|
||||
API_DEF_FUNC(string_eval_expression),
|
||||
API_DEF_FUNC(string_eval_path_home),
|
||||
API_DEF_FUNC(mkdir_home),
|
||||
API_DEF_FUNC(mkdir),
|
||||
API_DEF_FUNC(mkdir_parents),
|
||||
|
||||
@@ -437,6 +437,43 @@ API_FUNC(string_eval_expression)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_eval_path_home)
|
||||
{
|
||||
char *path, *result;
|
||||
struct t_hashtable *pointers, *extra_vars, *options;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY);
|
||||
if (items < 4)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
path = SvPV_nolen (ST (0));
|
||||
pointers = weechat_perl_hash_to_hashtable (ST (1),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
extra_vars = weechat_perl_hash_to_hashtable (ST (2),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
options = weechat_perl_hash_to_hashtable (ST (3),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (path, pointers, extra_vars,
|
||||
options);
|
||||
|
||||
if (pointers)
|
||||
weechat_hashtable_free (pointers);
|
||||
if (extra_vars)
|
||||
weechat_hashtable_free (extra_vars);
|
||||
if (options)
|
||||
weechat_hashtable_free (options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(mkdir_home)
|
||||
{
|
||||
dXSARGS;
|
||||
@@ -4899,6 +4936,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
API_DEF_FUNC(string_input_for_buffer);
|
||||
API_DEF_FUNC(string_eval_expression);
|
||||
API_DEF_FUNC(string_eval_path_home);
|
||||
API_DEF_FUNC(mkdir_home);
|
||||
API_DEF_FUNC(mkdir);
|
||||
API_DEF_FUNC(mkdir_parents);
|
||||
|
||||
@@ -614,6 +614,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->string_match = &string_match;
|
||||
new_plugin->string_replace = &string_replace;
|
||||
new_plugin->string_expand_home = &string_expand_home;
|
||||
new_plugin->string_eval_path_home = &string_eval_path_home;
|
||||
new_plugin->string_remove_quotes = &string_remove_quotes;
|
||||
new_plugin->string_strip = &string_strip;
|
||||
new_plugin->string_convert_escaped_chars = &string_convert_escaped_chars;
|
||||
|
||||
@@ -419,6 +419,45 @@ API_FUNC(string_eval_expression)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_eval_path_home)
|
||||
{
|
||||
char *path, *result;
|
||||
struct t_hashtable *pointers, *extra_vars, *options;
|
||||
PyObject *dict, *dict2, *dict3, *return_value;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY);
|
||||
path = NULL;
|
||||
pointers = NULL;
|
||||
extra_vars = NULL;
|
||||
options = NULL;
|
||||
if (!PyArg_ParseTuple (args, "sOOO", &path, &dict, &dict2, &dict3))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
pointers = weechat_python_dict_to_hashtable (dict,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
extra_vars = weechat_python_dict_to_hashtable (dict2,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
options = weechat_python_dict_to_hashtable (dict3,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (path, pointers, extra_vars,
|
||||
options);
|
||||
|
||||
if (pointers)
|
||||
weechat_hashtable_free (pointers);
|
||||
if (extra_vars)
|
||||
weechat_hashtable_free (extra_vars);
|
||||
if (options)
|
||||
weechat_hashtable_free (options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(mkdir_home)
|
||||
{
|
||||
char *directory;
|
||||
@@ -4880,6 +4919,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(string_is_command_char),
|
||||
API_DEF_FUNC(string_input_for_buffer),
|
||||
API_DEF_FUNC(string_eval_expression),
|
||||
API_DEF_FUNC(string_eval_path_home),
|
||||
API_DEF_FUNC(mkdir_home),
|
||||
API_DEF_FUNC(mkdir),
|
||||
API_DEF_FUNC(mkdir_parents),
|
||||
|
||||
@@ -507,6 +507,55 @@ weechat_ruby_api_string_eval_expression (VALUE class, VALUE expr,
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_eval_path_home (VALUE class, VALUE path,
|
||||
VALUE pointers, VALUE extra_vars,
|
||||
VALUE options)
|
||||
{
|
||||
char *c_path, *result;
|
||||
struct t_hashtable *c_pointers, *c_extra_vars, *c_options;
|
||||
VALUE return_value;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY);
|
||||
if (NIL_P (path) || NIL_P (pointers) || NIL_P (extra_vars)
|
||||
|| NIL_P (options))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
Check_Type (path, T_STRING);
|
||||
Check_Type (pointers, T_HASH);
|
||||
Check_Type (extra_vars, T_HASH);
|
||||
Check_Type (options, T_HASH);
|
||||
|
||||
c_path = StringValuePtr (path);
|
||||
c_pointers = weechat_ruby_hash_to_hashtable (
|
||||
pointers,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
c_extra_vars = weechat_ruby_hash_to_hashtable (
|
||||
extra_vars,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
c_options = weechat_ruby_hash_to_hashtable (
|
||||
options,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (c_path, c_pointers, c_extra_vars,
|
||||
c_options);
|
||||
|
||||
if (c_pointers)
|
||||
weechat_hashtable_free (c_pointers);
|
||||
if (c_extra_vars)
|
||||
weechat_hashtable_free (c_extra_vars);
|
||||
if (c_options)
|
||||
weechat_hashtable_free (c_options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_mkdir_home (VALUE class, VALUE directory, VALUE mode)
|
||||
{
|
||||
@@ -6005,6 +6054,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(string_is_command_char, 1);
|
||||
API_DEF_FUNC(string_input_for_buffer, 1);
|
||||
API_DEF_FUNC(string_eval_expression, 4);
|
||||
API_DEF_FUNC(string_eval_path_home, 4);
|
||||
API_DEF_FUNC(mkdir_home, 2);
|
||||
API_DEF_FUNC(mkdir, 2);
|
||||
API_DEF_FUNC(mkdir_parents, 2);
|
||||
|
||||
@@ -574,6 +574,47 @@ API_FUNC(string_eval_expression)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(string_eval_path_home)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *path, *result;
|
||||
struct t_hashtable *pointers, *extra_vars, *options;
|
||||
int i;
|
||||
|
||||
API_INIT_FUNC(1, "string_eval_path_home", API_RETURN_EMPTY);
|
||||
if (objc < 5)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
path = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointers = weechat_tcl_dict_to_hashtable (
|
||||
interp, objv[2],
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER);
|
||||
extra_vars = weechat_tcl_dict_to_hashtable (
|
||||
interp, objv[3],
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
options = weechat_tcl_dict_to_hashtable (
|
||||
interp, objv[4],
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = weechat_string_eval_path_home (path, pointers, extra_vars,
|
||||
options);
|
||||
|
||||
if (pointers)
|
||||
weechat_hashtable_free (pointers);
|
||||
if (extra_vars)
|
||||
weechat_hashtable_free (extra_vars);
|
||||
if (options)
|
||||
weechat_hashtable_free (options);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
API_FUNC(mkdir_home)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
@@ -5356,6 +5397,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(string_is_command_char);
|
||||
API_DEF_FUNC(string_input_for_buffer);
|
||||
API_DEF_FUNC(string_eval_expression);
|
||||
API_DEF_FUNC(string_eval_path_home);
|
||||
API_DEF_FUNC(mkdir_home);
|
||||
API_DEF_FUNC(mkdir);
|
||||
API_DEF_FUNC(mkdir_parents);
|
||||
|
||||
@@ -57,7 +57,7 @@ struct timeval;
|
||||
* please change the date with current one; for a second change at same
|
||||
* date, increment the 01, otherwise please keep 01.
|
||||
*/
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20150114-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20150624-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -276,6 +276,10 @@ struct t_weechat_plugin
|
||||
char *(*string_replace) (const char *string, const char *search,
|
||||
const char *replace);
|
||||
char *(*string_expand_home) (const char *path);
|
||||
char *(*string_eval_path_home) (const char *path,
|
||||
struct t_hashtable *pointers,
|
||||
struct t_hashtable *extra_vars,
|
||||
struct t_hashtable *options);
|
||||
char *(*string_remove_quotes) (const char *string, const char *quotes);
|
||||
char *(*string_strip) (const char *string, int left, int right,
|
||||
const char *chars);
|
||||
@@ -1040,6 +1044,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
(weechat_plugin->string_replace)(__string, __search, __replace)
|
||||
#define weechat_string_expand_home(__path) \
|
||||
(weechat_plugin->string_expand_home)(__path)
|
||||
#define weechat_string_eval_path_home(__path, __pointers, \
|
||||
__extra_vars, __options) \
|
||||
(weechat_plugin->string_eval_path_home)(__path, __pointers, \
|
||||
__extra_vars, __options)
|
||||
#define weechat_string_remove_quotes(__string, __quotes) \
|
||||
(weechat_plugin->string_remove_quotes)(__string, __quotes)
|
||||
#define weechat_string_strip(__string, __left, __right, __chars) \
|
||||
|
||||
Reference in New Issue
Block a user