plugin_init.c 717 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <string.h>
  2. #include "private.h"
  3. static char * trim(char *str)
  4. {
  5. size_t len = 0;
  6. const char *first = str;
  7. char *last = str + strlen(str) - 1;
  8. char *new = NULL;
  9. int i = 0;
  10. while (first < last && isspace(*first))
  11. ++first;
  12. while (first < last && isspace(*last))
  13. --last;
  14. len = last - first + 1;
  15. new = malloc(len + 1);
  16. bcopy(first, new, len);
  17. new[len] = '\0';
  18. return new;
  19. }
  20. CLISH_PLUGIN_INIT
  21. {
  22. char *conf = clish_plugin__get_conf(plugin);
  23. if (conf) {
  24. scripts_path = trim(conf);
  25. }
  26. if(clish_plugin_init_lua((clish_shell_t *)clish_shell))
  27. return (-1);
  28. clish_plugin__set_name(plugin, "lua_hooks");
  29. clish_plugin_add_sym(plugin, clish_plugin_lua_action, "hook_action");
  30. return 0;
  31. }