Browse Source

First resolved symbol.

Serj Kalichev 11 years ago
parent
commit
ba539af810

+ 3 - 2
clish/action.h

@@ -7,6 +7,7 @@
 typedef struct clish_action_s clish_action_t;
 
 #include "lub/bintree.h"
+#include "clish/plugin.h"
 
 /*=====================================
  * ACTION INTERFACE
@@ -27,8 +28,8 @@ void clish_action_dump(const clish_action_t *instance);
  *----------------- */
 void clish_action__set_script(clish_action_t *instance, const char *script);
 char *clish_action__get_script(const clish_action_t *instance);
-void clish_action__set_builtin(clish_action_t *instance, const char *builtin);
-const char *clish_action__get_builtin(const clish_action_t *instance);
+void clish_action__set_builtin(clish_action_t *instance, clish_sym_t *builtin);
+clish_sym_t *clish_action__get_builtin(const clish_action_t *instance);
 void clish_action__set_shebang(clish_action_t *instance, const char *shebang);
 const char *clish_action__get_shebang(const clish_action_t *instance);
 

+ 3 - 6
clish/action/action.c

@@ -27,7 +27,6 @@ static void clish_action_init(clish_action_t *this)
 static void clish_action_fini(clish_action_t *this)
 {
 	lub_string_free(this->script);
-	lub_string_free(this->builtin);
 	lub_string_free(this->shebang);
 }
 
@@ -70,15 +69,13 @@ char *clish_action__get_script(const clish_action_t *this)
 }
 
 /*--------------------------------------------------------- */
-void clish_action__set_builtin(clish_action_t *this, const char *builtin)
+void clish_action__set_builtin(clish_action_t *this, clish_sym_t *builtin)
 {
-	if (this->builtin)
-		lub_string_free(this->builtin);
-	this->builtin = lub_string_dup(builtin);
+	this->builtin = builtin;
 }
 
 /*--------------------------------------------------------- */
-const char *clish_action__get_builtin(const clish_action_t *this)
+clish_sym_t *clish_action__get_builtin(const clish_action_t *this)
 {
 	return this->builtin;
 }

+ 4 - 1
clish/action/action_dump.c

@@ -8,13 +8,16 @@
 /*--------------------------------------------------------- */
 void clish_action_dump(const clish_action_t *this)
 {
+	char *builtin_name;
+
 	lub_dump_printf("action(%p)\n", this);
 	lub_dump_indent();
 
 	lub_dump_printf("script  : %s\n",
 		this->script ? this->script : "(null)");
+	builtin_name = clish_sym__get_name(this->builtin);
 	lub_dump_printf("builtin : %s\n",
-		this->builtin ? this->builtin : "(null)");
+		builtin_name ? builtin_name : "(null)");
 	lub_dump_printf("shebang : %s\n",
 		this->shebang ? this->shebang : "(null)");
 

+ 1 - 1
clish/action/private.h

@@ -9,6 +9,6 @@
  *--------------------------------------------------------- */
 struct clish_action_s {
 	char *script;
-	char *builtin;
+	clish_sym_t *builtin;
 	char *shebang;
 };

+ 9 - 4
clish/plugin.h

@@ -11,11 +11,15 @@ typedef struct clish_plugin_s clish_plugin_t;
 
 /* Plugin types */
 
-typedef int clish_plugin_fn_t(void *context, char **out);
-typedef int clish_plugin_init_t(clish_plugin_t *plugin);
-
 /* Name of init function within plugin */
-#define CLISH_PLUGIN_INIT "clish_plugin_init"
+#define CLISH_PLUGIN_INIT_FNAME clish_plugin_init
+#define CLISH_PLUGIN_INIT_NAME "clish_plugin_init"
+#define CLISH_PLUGIN_INIT_FUNC(name) int name(clish_plugin_t *plugin)
+#define CLISH_PLUGIN_INIT CLISH_PLUGIN_INIT_FUNC(CLISH_PLUGIN_INIT_FNAME)
+#define CLISH_PLUGIN_SYM(name) int name(void *clish_context, const char *script, char **out)
+
+typedef CLISH_PLUGIN_SYM(clish_plugin_fn_t);
+typedef CLISH_PLUGIN_INIT_FUNC(clish_plugin_init_t);
 
 /* Symbol */
 
@@ -24,6 +28,7 @@ clish_sym_t *clish_sym_new(const char *name, clish_plugin_fn_t *func);
 void clish_sym_free(clish_sym_t *instance);
 void clish_sym__set_func(clish_sym_t *instance, clish_plugin_fn_t *func);
 clish_plugin_fn_t *clish_sym__get_func(clish_sym_t *instance);
+void clish_sym__set_name(clish_sym_t *instance, const char *name);
 char *clish_sym__get_name(clish_sym_t *instance);
 
 /* Plugin */

+ 12 - 5
clish/plugin/plugin.c

@@ -57,6 +57,13 @@ clish_plugin_fn_t *clish_sym__get_func(clish_sym_t *this)
 	return this->func;
 }
 
+/*--------------------------------------------------------- */
+void clish_sym__set_name(clish_sym_t *this, const char *name)
+{
+	lub_string_free(this->name);
+	this->name = lub_string_dup(name);
+}
+
 /*--------------------------------------------------------- */
 char *clish_sym__get_name(clish_sym_t *this)
 {
@@ -72,12 +79,12 @@ clish_plugin_t *clish_plugin_new(const char *name, const char *file)
 {
 	clish_plugin_t *this;
 
-	if (!file)
-		return NULL;
-
 	this = malloc(sizeof(*this));
 
-	this->file = lub_string_dup(file);
+	if (file)
+		this->file = lub_string_dup(file);
+	else
+		this->file = NULL; /* For main program binary */
 	if (name)
 		this->name = lub_string_dup(name);
 	else
@@ -162,7 +169,7 @@ void *clish_plugin_load(clish_plugin_t *this)
 
 	if (!(this->dlhan = dlopen(this->file, RTLD_NOW | RTLD_GLOBAL)))
 		return NULL;
-	plugin_init = (clish_plugin_init_t *)dlsym(this->dlhan, CLISH_PLUGIN_INIT);
+	plugin_init = (clish_plugin_init_t *)dlsym(this->dlhan, CLISH_PLUGIN_INIT_NAME);
 	if (!plugin_init) {
 		dlclose(this->dlhan);
 		this->dlhan = NULL;

+ 1 - 0
clish/shell/module.am

@@ -5,6 +5,7 @@ libclish_la_SOURCES += \
 	clish/shell/shell_command.c \
 	clish/shell/shell_dump.c \
 	clish/shell/shell_execute.c \
+	clish/shell/shell_internal.c \
 	clish/shell/shell_help.c \
 	clish/shell/shell_new.c \
 	clish/shell/shell_parse.c \

+ 13 - 231
clish/shell/shell_execute.c

@@ -17,161 +17,6 @@
 #include <signal.h>
 #include <fcntl.h>
 
-/*
- * These are the internal commands for this framework.
- */
-static clish_shell_builtin_fn_t
-    clish_close,
-    clish_overview,
-    clish_source,
-    clish_source_nostop,
-    clish_history,
-    clish_nested_up,
-    clish_nop,
-    clish_wdog;
-
-static clish_shell_builtin_t clish_cmd_list[] = {
-	{"clish_close", clish_close},
-	{"clish_overview", clish_overview},
-	{"clish_source", clish_source},
-	{"clish_source_nostop", clish_source_nostop},
-	{"clish_history", clish_history},
-	{"clish_nested_up", clish_nested_up},
-	{"clish_nop", clish_nop},
-	{"clish_wdog", clish_wdog},
-	{NULL, NULL}
-};
-
-/*----------------------------------------------------------- */
-/* Terminate the current shell session */
-static int clish_close(clish_context_t *context, const lub_argv_t * argv)
-{
-	/* the exception proves the rule... */
-	clish_shell_t *this = (clish_shell_t *)context->shell;
-
-	argv = argv; /* not used */
-	this->state = SHELL_STATE_CLOSING;
-
-	return 0;
-}
-
-/*----------------------------------------------------------- */
-/*
- Open a file and interpret it as a script in the context of a new
- thread. Whether the script continues after command, but not script, 
- errors depends on the value of the stop_on_error flag.
-*/
-static int clish_source_internal(clish_context_t *context,
-	const lub_argv_t * argv, bool_t stop_on_error)
-{
-	int result = -1;
-	const char *filename = lub_argv__get_arg(argv, 0);
-	struct stat fileStat;
-
-	/* the exception proves the rule... */
-	clish_shell_t *this = (clish_shell_t *)context->shell;
-
-	/*
-	 * Check file specified is not a directory 
-	 */
-	if ((0 == stat((char *)filename, &fileStat)) &&
-		(!S_ISDIR(fileStat.st_mode))) {
-		/*
-		 * push this file onto the file stack associated with this
-		 * session. This will be closed by clish_shell_pop_file() 
-		 * when it is finished with.
-		 */
-		result = clish_shell_push_file(this, filename,
-			stop_on_error);
-	}
-
-	return result ? -1 : 0;
-}
-
-/*----------------------------------------------------------- */
-/*
- Open a file and interpret it as a script in the context of a new
- thread. Invoking a script in this way will cause the script to
- stop on the first error
-*/
-static int clish_source(clish_context_t *context, const lub_argv_t * argv)
-{
-	return (clish_source_internal(context, argv, BOOL_TRUE));
-}
-
-/*----------------------------------------------------------- */
-/*
- Open a file and interpret it as a script in the context of a new
- thread. Invoking a script in this way will cause the script to
- continue after command, but not script, errors.
-*/
-static int clish_source_nostop(clish_context_t *context, const lub_argv_t * argv)
-{
-	return (clish_source_internal(context, argv, BOOL_FALSE));
-}
-
-/*----------------------------------------------------------- */
-/*
- Show the shell overview
-*/
-static int clish_overview(clish_context_t *context, const lub_argv_t * argv)
-{
-	clish_shell_t *this = context->shell;
-	argv = argv; /* not used */
-
-	tinyrl_printf(this->tinyrl, "%s\n", context->shell->overview);
-
-	return 0;
-}
-
-/*----------------------------------------------------------- */
-static int clish_history(clish_context_t *context, const lub_argv_t * argv)
-{
-	clish_shell_t *this = context->shell;
-	tinyrl_history_t *history = tinyrl__get_history(this->tinyrl);
-	tinyrl_history_iterator_t iter;
-	const tinyrl_history_entry_t *entry;
-	unsigned limit = 0;
-	const char *arg = lub_argv__get_arg(argv, 0);
-
-	if (arg && ('\0' != *arg)) {
-		limit = (unsigned)atoi(arg);
-		if (0 == limit) {
-			/* unlimit the history list */
-			(void)tinyrl_history_unstifle(history);
-		} else {
-			/* limit the scope of the history list */
-			tinyrl_history_stifle(history, limit);
-		}
-	}
-	for (entry = tinyrl_history_getfirst(history, &iter);
-		entry; entry = tinyrl_history_getnext(&iter)) {
-		/* dump the details of this entry */
-		tinyrl_printf(this->tinyrl,
-			"%5d  %s\n",
-			tinyrl_history_entry__get_index(entry),
-			tinyrl_history_entry__get_line(entry));
-	}
-	return 0;
-}
-
-/*----------------------------------------------------------- */
-/*
- * Searches for a builtin command to execute
- */
-static clish_shell_builtin_fn_t *find_builtin_callback(const
-	clish_shell_builtin_t * cmd_list, const char *name)
-{
-	const clish_shell_builtin_t *result;
-
-	/* search a list of commands */
-	for (result = cmd_list; result && result->name; result++) {
-		if (0 == strcmp(name, result->name))
-			break;
-	}
-	return (result && result->name) ? result->callback : NULL;
-}
-
 /*----------------------------------------------------------- */
 void clish_shell_cleanup_script(void *script)
 {
@@ -357,88 +202,26 @@ error:
 int clish_shell_exec_action(clish_action_t *action,
 	clish_context_t *context, char **out)
 {
-	clish_shell_t *this = context->shell;
-	int result = 0;
-	const char *builtin;
+	int result = -1;
+	clish_sym_t *sym;
 	char *script;
+	clish_plugin_fn_t *func = NULL;
 
-	builtin = clish_action__get_builtin(action);
+	if (!(sym = clish_action__get_builtin(action)))
+		return -1;
+	if (!(func = clish_sym__get_func(sym)))
+		return -1;
 	script = clish_shell_expand(clish_action__get_script(action), SHELL_VAR_ACTION, context);
-	if (builtin) {
-		clish_shell_builtin_fn_t *callback;
-		lub_argv_t *argv = script ? lub_argv_new(script, 0) : NULL;
-		result = -1;
-		/* search for an internal command */
-		callback = find_builtin_callback(clish_cmd_list, builtin);
-		if (!callback) {
-			/* search for a client command */
-			callback = find_builtin_callback(
-				this->client_hooks->cmd_list, builtin);
-		}
-		/* invoke the builtin callback */
-		if (callback)
-			result = callback(context, argv);
-		if (argv)
-			lub_argv_delete(argv);
-	} else if (script) {
-		/* now get the client to interpret the resulting script */
-		result = this->client_hooks->script_fn(context, action, script, out);
-	}
+	result = func(context, script, out);
 	lub_string_free(script);
 
 	return result;
-}
-
-/*----------------------------------------------------------- */
-/*
- * Find out the previous view in the stack and go to it
- */
-static int clish_nested_up(clish_context_t *context, const lub_argv_t *argv)
-{
-	clish_shell_t *this = context->shell;
-
-	if (!this)
-		return -1;
-
-	argv = argv; /* not used */
-
-	/* If depth=0 than exit */
-	if (0 == this->depth) {
-		this->state = SHELL_STATE_CLOSING;
-		return 0;
-	}
-	this->depth--;
-
-	return 0;
-}
-
-/*----------------------------------------------------------- */
-/*
- * Builtin: NOP function
- */
-static int clish_nop(clish_context_t *context, const lub_argv_t *argv)
-{
-	return 0;
-}
-
-/*----------------------------------------------------------- */
-/*
- * Builtin: Set watchdog timeout. The "0" to turn watchdog off.
- */
-static int clish_wdog(clish_context_t *context, const lub_argv_t *argv)
-{
-	const char *arg = lub_argv__get_arg(argv, 0);
-	clish_shell_t *this = context->shell;
-
-	/* Turn off watchdog if no args */
-	if (!arg || ('\0' == *arg)) {
-		this->wdog_timeout = 0;
-		return 0;
-	}
 
-	this->wdog_timeout = (unsigned int)atoi(arg);
-
-	return 0;
+/*		lub_argv_t *argv = script ? lub_argv_new(script, 0) : NULL;
+		if (argv)
+			lub_argv_delete(argv);
+		result = this->client_hooks->script_fn(context, action, script, out);
+*/
 }
 
 /*----------------------------------------------------------- */
@@ -488,5 +271,4 @@ bool_t clish_shell__get_log(const clish_shell_t *this)
 	return this->log;
 }
 
-
 /*----------------------------------------------------------- */

+ 203 - 0
clish/shell/shell_internal.c

@@ -0,0 +1,203 @@
+/*
+ * shell_internal.c
+ */
+#include "private.h"
+#include "lub/string.h"
+#include "lub/argv.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <signal.h>
+#include <fcntl.h>
+
+
+/*----------------------------------------------------------- */
+/* Terminate the current shell session */
+CLISH_PLUGIN_SYM(clish_close)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	clish_shell_t *this = (clish_shell_t *)context->shell;
+
+	this->state = SHELL_STATE_CLOSING;
+
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+/*
+ Open a file and interpret it as a script in the context of a new
+ thread. Whether the script continues after command, but not script, 
+ errors depends on the value of the stop_on_error flag.
+*/
+static int clish_source_internal(clish_context_t *context,
+	const char *fn, bool_t stop_on_error)
+{
+	int result = -1;
+	const char *filename = fn;
+	struct stat fileStat;
+
+	/* the exception proves the rule... */
+	clish_shell_t *this = (clish_shell_t *)context->shell;
+
+	/*
+	 * Check file specified is not a directory 
+	 */
+	if ((0 == stat((char *)filename, &fileStat)) &&
+		(!S_ISDIR(fileStat.st_mode))) {
+		/*
+		 * push this file onto the file stack associated with this
+		 * session. This will be closed by clish_shell_pop_file() 
+		 * when it is finished with.
+		 */
+		result = clish_shell_push_file(this, filename,
+			stop_on_error);
+	}
+
+	return result ? -1 : 0;
+}
+
+/*----------------------------------------------------------- */
+/*
+ Open a file and interpret it as a script in the context of a new
+ thread. Invoking a script in this way will cause the script to
+ stop on the first error
+*/
+CLISH_PLUGIN_SYM(clish_source)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	return (clish_source_internal(context, script, BOOL_TRUE));
+}
+
+/*----------------------------------------------------------- */
+/*
+ Open a file and interpret it as a script in the context of a new
+ thread. Invoking a script in this way will cause the script to
+ continue after command, but not script, errors.
+*/
+CLISH_PLUGIN_SYM(clish_source_nostop)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	return (clish_source_internal(context, script, BOOL_FALSE));
+}
+
+/*----------------------------------------------------------- */
+/*
+ Show the shell overview
+*/
+CLISH_PLUGIN_SYM(clish_overview)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	clish_shell_t *this = context->shell;
+
+	tinyrl_printf(this->tinyrl, "%s\n", context->shell->overview);
+
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+CLISH_PLUGIN_SYM(clish_history)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	clish_shell_t *this = context->shell;
+	tinyrl_history_t *history = tinyrl__get_history(this->tinyrl);
+	tinyrl_history_iterator_t iter;
+	const tinyrl_history_entry_t *entry;
+	unsigned limit = 0;
+	const char *arg = script;
+
+	if (arg && ('\0' != *arg)) {
+		limit = (unsigned)atoi(arg);
+		if (0 == limit) {
+			/* unlimit the history list */
+			(void)tinyrl_history_unstifle(history);
+		} else {
+			/* limit the scope of the history list */
+			tinyrl_history_stifle(history, limit);
+		}
+	}
+	for (entry = tinyrl_history_getfirst(history, &iter);
+		entry; entry = tinyrl_history_getnext(&iter)) {
+		/* dump the details of this entry */
+		tinyrl_printf(this->tinyrl,
+			"%5d  %s\n",
+			tinyrl_history_entry__get_index(entry),
+			tinyrl_history_entry__get_line(entry));
+	}
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+/*
+ * Find out the previous view in the stack and go to it
+ */
+CLISH_PLUGIN_SYM(clish_nested_up)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	clish_shell_t *this = context->shell;
+	if (!this)
+		return -1;
+
+	/* If depth=0 than exit */
+	if (0 == this->depth) {
+		this->state = SHELL_STATE_CLOSING;
+		return 0;
+	}
+	this->depth--;
+
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+/*
+ * Builtin: NOP function
+ */
+CLISH_PLUGIN_SYM(clish_nop)
+{
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+/*
+ * Builtin: Set watchdog timeout. The "0" to turn watchdog off.
+ */
+CLISH_PLUGIN_SYM(clish_wdog)
+{
+	clish_context_t *context = (clish_context_t *)clish_context;
+	const char *arg = script;
+	clish_shell_t *this = context->shell;
+
+	/* Turn off watchdog if no args */
+	if (!arg || ('\0' == *arg)) {
+		this->wdog_timeout = 0;
+		return 0;
+	}
+
+	this->wdog_timeout = (unsigned int)atoi(arg);
+
+	return 0;
+}
+
+/*----------------------------------------------------------- */
+/* Initialize internal pseudo-plugin */
+CLISH_PLUGIN_INIT
+{
+	clish_plugin_add_sym(plugin, clish_close, "clish_close");
+	clish_plugin_add_sym(plugin, clish_overview, "clish_overview");
+	clish_plugin_add_sym(plugin, clish_source, "clish_source");
+	clish_plugin_add_sym(plugin, clish_source_nostop, "clish_source_nostop");
+	clish_plugin_add_sym(plugin, clish_history, "clish_history");
+	clish_plugin_add_sym(plugin, clish_nested_up, "clish_nested_up");
+	clish_plugin_add_sym(plugin, clish_nop, "clish_nop");
+	clish_plugin_add_sym(plugin, clish_wdog, "clish_wdog");
+
+	return 0;
+}
+
+/*----------------------------------------------------------- */

+ 3 - 0
clish/shell/shell_new.c

@@ -21,6 +21,7 @@ static void clish_shell_init(clish_shell_t * this,
 	bool_t stop_on_error)
 {
 	clish_ptype_t *tmp_ptype = NULL;
+	clish_plugin_t *plugin = NULL;
 
 	/* initialise the tree of views */
 	lub_bintree_init(&this->view_tree,
@@ -39,6 +40,8 @@ static void clish_shell_init(clish_shell_t * this,
 
 	/* Initialize plugin list */
 	this->plugins = lub_list_new(NULL);
+	plugin = clish_plugin_new("clish", NULL);
+	lub_list_add(this->plugins, plugin);
 
 	/* Initialise the list of unresolved (yet) symbols */
 	this->syms = lub_list_new(clish_sym_compare);

+ 2 - 4
clish/shell/shell_plugin.c

@@ -161,17 +161,15 @@ int clish_shell_link_plugins(clish_shell_t *this)
 	/* Iterate elements */
 	for(iter = lub_list__get_head(this->syms);
 		iter; iter = lub_list_node__get_next(iter)) {
-//		int res;
 		sym = (clish_sym_t *)lub_list_node__get_data(iter);
 		sym_name = clish_sym__get_name(sym);
 		fn = plugins_find_sym(this, sym_name);
 		if (!fn) {
 			fprintf(stderr, "Error: Can't resolve symbol %s.\n",
 				sym_name);
-//			return 0;
+			return -1;
 		}
-//		fprintf(stderr, "sym: %s\n", sym_name);
-
+		clish_sym__set_func(sym, fn);
 	}
 
 	return 0;

+ 6 - 4
clish/shell/shell_xml.c

@@ -682,6 +682,7 @@ process_action(clish_shell_t * shell, clish_xmlnode_t * element, void *parent)
 	clish_xmlnode_t *pelement = clish_xmlnode_parent(element);
 	char *pname = clish_xmlnode_get_all_name(pelement);
 	char *text;
+	clish_sym_t *sym = NULL;
 
 	if (pname && lub_string_nocasecmp(pname, "VAR") == 0)
 		action = clish_var__get_action((clish_var_t *)parent);
@@ -701,10 +702,11 @@ process_action(clish_shell_t * shell, clish_xmlnode_t * element, void *parent)
 	if (text)
 		free(text);
 
-	if (builtin) {
-		clish_action__set_builtin(action, builtin);
-		clish_shell_add_unresolved_sym(shell, builtin);
-	}
+	if (builtin)
+		sym = clish_shell_add_unresolved_sym(shell, builtin);
+	else
+		sym = clish_shell_add_unresolved_sym(shell, builtin);
+	clish_action__set_builtin(action, sym);
 	if (shebang)
 		clish_action__set_shebang(action, shebang);
 

+ 2 - 2
examples/explugin/anplug.c

@@ -2,13 +2,13 @@
 #include <stdio.h>
 #include <clish/plugin.h>
 
-int anplug_fn(void *context, char **out)
+CLISH_PLUGIN_SYM(anplug_fn)
 {
 	printf("anplug: Another plugin\n");
 	return 0;
 }
 
-int clish_plugin_init(clish_plugin_t *plugin)
+CLISH_PLUGIN_INIT
 {
 	clish_plugin_add_sym(plugin, anplug_fn, "an_fn");
 }

+ 2 - 2
examples/explugin/explugin.c

@@ -2,13 +2,13 @@
 #include <stdio.h>
 #include <clish/plugin.h>
 
-int explugin_fn(void *context, char **out)
+CLISH_PLUGIN_SYM(explugin_fn)
 {
 	printf("explugin: Hello world\n");
 	return 0;
 }
 
-int clish_plugin_init(clish_plugin_t *plugin)
+CLISH_PLUGIN_INIT
 {
 	clish_plugin_add_sym(plugin, explugin_fn, "hello");
 }