12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.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;
- while (first < last && isspace(*first))
- ++first;
- while (first < last && isspace(*last))
- --last;
- len = last - first + 1;
- new = malloc(len + 1);
- memcpy(new, first, len);
- new[len] = '\0';
- return new;
- }
- CLISH_PLUGIN_INIT
- {
- char *conf = clish_plugin__get_conf(plugin);
- if (conf) {
- scripts_path = trim(conf);
- }
- if(clish_plugin_init_lua(clish_shell))
- return (-1);
- clish_plugin__set_name(plugin, LUA_PLUGIN_NAME);
- clish_plugin_add_sym(plugin, clish_plugin_lua_action, "lua");
- return 0;
- }
|