plugin.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * plugin.h
  3. */
  4. #ifndef _clish_plugin_h
  5. #define _clish_plugin_h
  6. /* Symbol types */
  7. typedef struct clish_sym_s clish_sym_t;
  8. typedef struct clish_plugin_s clish_plugin_t;
  9. /* Plugin types */
  10. /* Name of init function within plugin */
  11. #define CLISH_PLUGIN_INIT_FNAME clish_plugin_init
  12. #define CLISH_PLUGIN_INIT_NAME "clish_plugin_init"
  13. #define CLISH_PLUGIN_INIT_FUNC(name) int name(clish_plugin_t *plugin)
  14. #define CLISH_PLUGIN_INIT CLISH_PLUGIN_INIT_FUNC(CLISH_PLUGIN_INIT_FNAME)
  15. #define CLISH_PLUGIN_SYM(name) int name(void *clish_context, const char *script, char **out)
  16. #define CLISH_DEFAULT_SYM "clish_script@clish"
  17. typedef CLISH_PLUGIN_SYM(clish_plugin_fn_t);
  18. typedef CLISH_PLUGIN_INIT_FUNC(clish_plugin_init_t);
  19. /* Symbol */
  20. int clish_sym_compare(const void *first, const void *second);
  21. clish_sym_t *clish_sym_new(const char *name, clish_plugin_fn_t *func);
  22. void clish_sym_free(clish_sym_t *instance);
  23. void clish_sym__set_func(clish_sym_t *instance, clish_plugin_fn_t *func);
  24. clish_plugin_fn_t *clish_sym__get_func(clish_sym_t *instance);
  25. void clish_sym__set_name(clish_sym_t *instance, const char *name);
  26. char *clish_sym__get_name(clish_sym_t *instance);
  27. /* Plugin */
  28. clish_plugin_t *clish_plugin_new(const char *name, const char *file);
  29. void clish_plugin_free(clish_plugin_t *instance);
  30. void *clish_plugin_load(clish_plugin_t *instance);
  31. clish_plugin_fn_t *clish_plugin_get_sym(clish_plugin_t *instance,
  32. const char *name);
  33. int clish_plugin_add_sym(clish_plugin_t *instance,
  34. clish_plugin_fn_t *func, const char *name);
  35. void clish_plugin_dump(const clish_plugin_t *instance);
  36. char *clish_plugin__get_name(const clish_plugin_t *instance);
  37. char *clish_plugin__get_file(const clish_plugin_t *instance);
  38. #endif /* _clish_plugin_h */
  39. /** @} clish_plugin */