kplugin.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /** @file kplugin.h
  2. *
  3. * @brief Klish scheme's "plugin" entry
  4. */
  5. #ifndef _klish_kplugin_h
  6. #define _klish_kplugin_h
  7. #include <stdint.h>
  8. #include <faux/list.h>
  9. #include <klish/ksym.h>
  10. // Current API version
  11. #define KPLUGIN_MAJOR 1
  12. #define KPLUGIN_MINOR 0
  13. // Shared object filename template. Insert plugin ID or plugin "name" field
  14. // instead "%s". Consider plugin ID as an "internal native name". The "name"
  15. // field can differ from ID and it's just used within scheme to refer plugin.
  16. // Consider it as alias of ID.
  17. #define KPLUGIN_SONAME_FMT "kplugin_%s.so"
  18. // Plugin's API version symbols
  19. #define KPLUGIN_MAJOR_FMT "kplugin_%s_major"
  20. #define KPLUGIN_MINOR_FMT "kplugin_%s_minor"
  21. // Plugin's init and fini functions
  22. #define KPLUGIN_INIT_FMT "kplugin_%s_init"
  23. #define KPLUGIN_FINI_FMT "kplugin_%s_fini"
  24. typedef struct kplugin_s kplugin_t;
  25. typedef faux_list_node_t kplugin_syms_node_t;
  26. C_DECL_BEGIN
  27. kplugin_t *kplugin_new(const char *name);
  28. void kplugin_free(kplugin_t *plugin);
  29. const char *kplugin_name(const kplugin_t *plugin);
  30. const char *kplugin_id(const kplugin_t *plugin);
  31. bool_t kplugin_set_id(kplugin_t *plugin, const char *id);
  32. const char *kplugin_file(const kplugin_t *plugin);
  33. bool_t kplugin_set_file(kplugin_t *plugin, const char *file);
  34. bool_t kplugin_global(const kplugin_t *plugin);
  35. bool_t kplugin_set_global(kplugin_t *plugin, bool_t global);
  36. const char *kplugin_conf(const kplugin_t *plugin);
  37. bool_t kplugin_set_conf(kplugin_t *plugin, const char *conf);
  38. uint8_t kplugin_major(const kplugin_t *plugin);
  39. bool_t kplugin_set_major(kplugin_t *plugin, uint8_t major);
  40. uint8_t kplugin_minor(const kplugin_t *plugin);
  41. bool_t kplugin_set_minor(kplugin_t *plugin, uint8_t minor);
  42. void *kplugin_udata(const kplugin_t *plugin);
  43. bool_t kplugin_set_udata(kplugin_t *plugin, void *udata);
  44. // syms
  45. bool_t kplugin_add_sym(kplugin_t *plugin, ksym_t *sym);
  46. ksym_t *kplugin_find_sym(const kplugin_t *plugin, const char *name);
  47. ssize_t kplugin_syms_len(const kplugin_t *plugin);
  48. kplugin_syms_node_t *kplugin_syms_iter(const kplugin_t *plugin);
  49. ksym_t *kplugin_syms_each(kplugin_syms_node_t **iter);
  50. C_DECL_END
  51. #endif // _klish_kplugin_h