|
@@ -47,7 +47,7 @@ int clish_shell_load_plugins(clish_shell_t *this)
|
|
|
* mysym@plugin1
|
|
|
* The symbols with suffix will be resolved using specified plugin only.
|
|
|
*/
|
|
|
-static clish_sym_t *plugins_find_sym(clish_shell_t *this, const char *name)
|
|
|
+static clish_sym_t *plugins_find_sym(clish_shell_t *this, const char *name, int type)
|
|
|
{
|
|
|
lub_list_node_t *iter;
|
|
|
clish_plugin_t *plugin;
|
|
@@ -77,7 +77,7 @@ static clish_sym_t *plugins_find_sym(clish_shell_t *this, const char *name)
|
|
|
plugin = (clish_plugin_t *)lub_list_node__get_data(iter);
|
|
|
if (strcmp(clish_plugin__get_name(plugin), plugin_name))
|
|
|
continue;
|
|
|
- if ((sym = clish_plugin_get_sym(plugin, cmdn)))
|
|
|
+ if ((sym = clish_plugin_get_sym(plugin, cmdn, type)))
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
@@ -85,7 +85,7 @@ static clish_sym_t *plugins_find_sym(clish_shell_t *this, const char *name)
|
|
|
for(iter = lub_list__get_head(this->plugins);
|
|
|
iter; iter = lub_list_node__get_next(iter)) {
|
|
|
plugin = (clish_plugin_t *)lub_list_node__get_data(iter);
|
|
|
- if ((sym = clish_plugin_get_sym(plugin, cmdn)))
|
|
|
+ if ((sym = clish_plugin_get_sym(plugin, cmdn, type)))
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -96,7 +96,7 @@ static clish_sym_t *plugins_find_sym(clish_shell_t *this, const char *name)
|
|
|
|
|
|
|
|
|
|
|
|
-clish_sym_t *clish_shell_find_sym(clish_shell_t *this, const char *name)
|
|
|
+clish_sym_t *clish_shell_find_sym(clish_shell_t *this, const char *name, int type)
|
|
|
{
|
|
|
lub_list_node_t *iter;
|
|
|
clish_sym_t *sym;
|
|
@@ -107,7 +107,7 @@ clish_sym_t *clish_shell_find_sym(clish_shell_t *this, const char *name)
|
|
|
int res;
|
|
|
sym = (clish_sym_t *)lub_list_node__get_data(iter);
|
|
|
res = strcmp(clish_sym__get_name(sym), name);
|
|
|
- if (!res)
|
|
|
+ if (!res && ((CLISH_SYM_TYPE_NONE == type) || (clish_sym__get_type(sym) == type)))
|
|
|
return sym;
|
|
|
if (res > 0)
|
|
|
break;
|
|
@@ -119,15 +119,15 @@ clish_sym_t *clish_shell_find_sym(clish_shell_t *this, const char *name)
|
|
|
|
|
|
|
|
|
clish_sym_t *clish_shell_add_sym(clish_shell_t *this,
|
|
|
- clish_plugin_fn_t *func, const char *name)
|
|
|
+ clish_plugin_fn_t *func, const char *name, int type)
|
|
|
{
|
|
|
clish_sym_t *sym = NULL;
|
|
|
|
|
|
if (!name)
|
|
|
return NULL;
|
|
|
- if ((sym = clish_shell_find_sym(this, name)))
|
|
|
+ if ((sym = clish_shell_find_sym(this, name, type)))
|
|
|
return sym;
|
|
|
- if (!(sym = clish_sym_new(name, func)))
|
|
|
+ if (!(sym = clish_sym_new(name, func, type)))
|
|
|
return NULL;
|
|
|
lub_list_add(this->syms, sym);
|
|
|
|
|
@@ -136,9 +136,9 @@ clish_sym_t *clish_shell_add_sym(clish_shell_t *this,
|
|
|
|
|
|
|
|
|
clish_sym_t *clish_shell_add_unresolved_sym(clish_shell_t *this,
|
|
|
- const char *name)
|
|
|
+ const char *name, int type)
|
|
|
{
|
|
|
- return clish_shell_add_sym(this, NULL, name);
|
|
|
+ return clish_shell_add_sym(this, NULL, name, type);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -148,13 +148,15 @@ int clish_shell_link_plugins(clish_shell_t *this)
|
|
|
clish_sym_t *sym, *plugin_sym;
|
|
|
lub_list_node_t *iter;
|
|
|
char *sym_name = NULL;
|
|
|
+ int sym_type;
|
|
|
|
|
|
|
|
|
for(iter = lub_list__get_head(this->syms);
|
|
|
iter; iter = lub_list_node__get_next(iter)) {
|
|
|
sym = (clish_sym_t *)lub_list_node__get_data(iter);
|
|
|
sym_name = clish_sym__get_name(sym);
|
|
|
- plugin_sym = plugins_find_sym(this, sym_name);
|
|
|
+ sym_type = clish_sym__get_type(sym);
|
|
|
+ plugin_sym = plugins_find_sym(this, sym_name, sym_type);
|
|
|
if (!plugin_sym) {
|
|
|
fprintf(stderr, "Error: Can't resolve symbol %s.\n",
|
|
|
sym_name);
|