plugin.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. typedef CLISH_PLUGIN_SYM(clish_plugin_fn_t);
  17. typedef CLISH_PLUGIN_INIT_FUNC(clish_plugin_init_t);
  18. /* Symbol */
  19. int clish_sym_compare(const void *first, const void *second);
  20. clish_sym_t *clish_sym_new(const char *name, clish_plugin_fn_t *func);
  21. void clish_sym_free(clish_sym_t *instance);
  22. void clish_sym__set_func(clish_sym_t *instance, clish_plugin_fn_t *func);
  23. clish_plugin_fn_t *clish_sym__get_func(clish_sym_t *instance);
  24. void clish_sym__set_name(clish_sym_t *instance, const char *name);
  25. char *clish_sym__get_name(clish_sym_t *instance);
  26. /* Plugin */
  27. clish_plugin_t *clish_plugin_new(const char *name, const char *file);
  28. void clish_plugin_free(clish_plugin_t *instance);
  29. void *clish_plugin_load(clish_plugin_t *instance);
  30. clish_plugin_fn_t *clish_plugin_get_sym(clish_plugin_t *instance,
  31. const char *name);
  32. int clish_plugin_add_sym(clish_plugin_t *instance,
  33. clish_plugin_fn_t *func, const char *name);
  34. void clish_plugin_dump(const clish_plugin_t *instance);
  35. char *clish_plugin__get_name(const clish_plugin_t *instance);
  36. char *clish_plugin__get_file(const clish_plugin_t *instance);
  37. #endif /* _clish_plugin_h */
  38. /** @} clish_plugin */