1
0

plugin.h 2.0 KB

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