Browse Source

Add simple plugin examples

Serj Kalichev 11 years ago
parent
commit
70395cdf1e
4 changed files with 34 additions and 1 deletions
  1. 1 0
      .gitignore
  2. 1 1
      clish/plugin/plugin_dump.c
  3. 16 0
      examples/explugin/anplug.c
  4. 16 0
      examples/explugin/explugin.c

+ 1 - 0
.gitignore

@@ -4,6 +4,7 @@
 *.o
 *.lo
 *.la
+*.so
 *~
 
 /autom4te.cache

+ 1 - 1
clish/plugin/plugin_dump.c

@@ -9,7 +9,7 @@
 /*--------------------------------------------------------- */
 void clish_sym_dump(const clish_sym_t *this)
 {
-	lub_dump_printf("plugin(%p)\n", this);
+	lub_dump_printf("sym(%p)\n", this);
 
 	lub_dump_indent();
 	lub_dump_printf("name : %s\n", this->name);

+ 16 - 0
examples/explugin/anplug.c

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

+ 16 - 0
examples/explugin/explugin.c

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