plugin.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. void clish_sym__set_plugin(clish_sym_t *instance, clish_plugin_t *plugin);
  31. clish_plugin_t *clish_sym__get_plugin(clish_sym_t *instance);
  32. /* Plugin */
  33. clish_plugin_t *clish_plugin_new(const char *name, const char *file);
  34. void clish_plugin_free(clish_plugin_t *instance);
  35. void *clish_plugin_load(clish_plugin_t *instance);
  36. clish_sym_t *clish_plugin_get_sym(clish_plugin_t *instance,
  37. const char *name);
  38. clish_sym_t *clish_plugin_add_sym(clish_plugin_t *instance,
  39. clish_plugin_fn_t *func, const char *name);
  40. clish_sym_t *clish_plugin_add_psym(clish_plugin_t *instance,
  41. clish_plugin_fn_t *func, const char *name);
  42. void clish_plugin_dump(const clish_plugin_t *instance);
  43. char *clish_plugin__get_name(const clish_plugin_t *instance);
  44. char *clish_plugin__get_file(const clish_plugin_t *instance);
  45. #endif /* _clish_plugin_h */
  46. /** @} clish_plugin */