Browse Source

Implement clish_shell_load_plugins()

Serj Kalichev 11 years ago
parent
commit
03f546bcec
4 changed files with 32 additions and 4 deletions
  1. 2 2
      clish/plugin.h
  2. 2 2
      clish/plugin/plugin.c
  3. 1 0
      clish/shell/module.am
  4. 27 0
      clish/shell/shell_plugin.c

+ 2 - 2
clish/plugin.h

@@ -18,9 +18,9 @@ typedef int clish_plugin_init_t(clish_plugin_t *plugin);
 clish_plugin_t *clish_plugin_new(const char *name, const char *file);
 void clish_plugin_free(clish_plugin_t *instance);
 void *clish_plugin_load(clish_plugin_t *instance);
-clish_plugin_fn_t *clish_plugin_dlsym(clish_plugin_t *instance,
+clish_plugin_fn_t *clish_plugin_get_sym(clish_plugin_t *instance,
 	const char *name);
-int clish_plugin_sym(clish_plugin_t *instance,
+int clish_plugin_add_sym(clish_plugin_t *instance,
 	clish_plugin_fn_t *func, const char *name);
 
 #endif				/* _clish_plugin_h */

+ 2 - 2
clish/plugin/plugin.c

@@ -98,7 +98,7 @@ void clish_plugin_free(clish_plugin_t *this)
 }
 
 /*--------------------------------------------------------- */
-int clish_plugin_sym(clish_plugin_t *this,
+int clish_plugin_add_sym(clish_plugin_t *this,
 	clish_plugin_fn_t *func, const char *name)
 {
 	clish_sym_t *sym;
@@ -114,7 +114,7 @@ int clish_plugin_sym(clish_plugin_t *this,
 }
 
 /*--------------------------------------------------------- */
-clish_plugin_fn_t *clish_plugin_dlsym(clish_plugin_t *this, const char *name)
+clish_plugin_fn_t *clish_plugin_get_sym(clish_plugin_t *this, const char *name)
 {
 	lub_list_node_t *iter;
 	clish_sym_t *sym;

+ 1 - 0
clish/shell/module.am

@@ -14,6 +14,7 @@ libclish_la_SOURCES += \
 	clish/shell/shell_wdog.c \
 	clish/shell/shell_pwd.c \
 	clish/shell/shell_tinyrl.c \
+	clish/shell/shell_plugin.c \
 	clish/shell/shell_xml.c \
 	clish/shell/private.h \
 	clish/shell/xmlapi.h \

+ 27 - 0
clish/shell/shell_plugin.c

@@ -0,0 +1,27 @@
+/*
+ * shell_plugin.c
+ */
+#include "private.h"
+#include <assert.h>
+
+#include "lub/list.h"
+#include "clish/plugin.h"
+
+/*----------------------------------------------------------------------- */
+int clish_shell_load_plugins(clish_shell_t *this)
+{
+	lub_list_node_t *iter;
+	clish_plugin_t *plugin;
+
+	assert(this);
+
+	/* Iterate elements */
+	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 (!clish_plugin_load(plugin))
+			return -1;
+	}
+
+	return 0;
+}