|
@@ -1,13 +1,38 @@
|
|
|
+#include <string.h>
|
|
|
+
|
|
|
#include "private.h"
|
|
|
|
|
|
+static char * trim(char *str)
|
|
|
+{
|
|
|
+ size_t len = 0;
|
|
|
+ const char *first = str;
|
|
|
+ char *last = str + strlen(str) - 1;
|
|
|
+ char *new = NULL;
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ while (first < last && isspace(*first))
|
|
|
+ ++first;
|
|
|
+ while (first < last && isspace(*last))
|
|
|
+ --last;
|
|
|
+
|
|
|
+ len = last - first + 1;
|
|
|
+ new = malloc(len + 1);
|
|
|
+ bcopy(first, new, len);
|
|
|
+ new[len] = '\0';
|
|
|
+
|
|
|
+ return new;
|
|
|
+}
|
|
|
+
|
|
|
CLISH_PLUGIN_INIT
|
|
|
{
|
|
|
char *conf = clish_plugin__get_conf(plugin);
|
|
|
|
|
|
- if (conf)
|
|
|
- scripts_path = conf;
|
|
|
+ if (conf) {
|
|
|
+ scripts_path = trim(conf);
|
|
|
+ }
|
|
|
|
|
|
- clish_plugin_init_lua((clish_shell_t *)clish_shell);
|
|
|
+ if(clish_plugin_init_lua((clish_shell_t *)clish_shell))
|
|
|
+ return (-1);
|
|
|
|
|
|
clish_plugin__set_name(plugin, "lua_hooks");
|
|
|
|