kplugin.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include <klish/kcontext_base.h>
  11. // Current API version
  12. // Major and minor version numbers is uint8_t
  13. #define KPLUGIN_MAJOR 1
  14. #define KPLUGIN_MINOR 0
  15. // Shared object filename template. Insert plugin ID or plugin "name" field
  16. // instead "%s". Consider plugin ID as an "internal native name". The "name"
  17. // field can differ from ID and it's just used within scheme to refer plugin.
  18. // Consider it as alias of ID.
  19. #define KPLUGIN_SONAME_FMT "kplugin-%s.so"
  20. // Plugin's API version symbols
  21. #define KPLUGIN_MAJOR_FMT "kplugin_%s_major"
  22. #define KPLUGIN_MINOR_FMT "kplugin_%s_minor"
  23. // Plugin's init and fini functions
  24. #define KPLUGIN_INIT_FMT "kplugin_%s_init"
  25. #define KPLUGIN_FINI_FMT "kplugin_%s_fini"
  26. typedef struct kplugin_s kplugin_t;
  27. typedef faux_list_node_t kplugin_syms_node_t;
  28. C_DECL_BEGIN
  29. kplugin_t *kplugin_new(const char *name);
  30. void kplugin_free(kplugin_t *plugin);
  31. const char *kplugin_name(const kplugin_t *plugin);
  32. const char *kplugin_id(const kplugin_t *plugin);
  33. bool_t kplugin_set_id(kplugin_t *plugin, const char *id);
  34. const char *kplugin_file(const kplugin_t *plugin);
  35. bool_t kplugin_set_file(kplugin_t *plugin, const char *file);
  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. bool_t kplugin_load(kplugin_t *plugin);
  45. int kplugin_init(kplugin_t *plugin, kcontext_t *context);
  46. int kplugin_fini(kplugin_t *plugin, kcontext_t *context);
  47. // SYMs
  48. faux_list_t *kplugin_syms(const kplugin_t *plugin);
  49. bool_t kplugin_add_sym(kplugin_t *plugin, ksym_t *sym);
  50. ksym_t *kplugin_find_sym(const kplugin_t *plugin, const char *name);
  51. ssize_t kplugin_syms_len(const kplugin_t *plugin);
  52. kplugin_syms_node_t *kplugin_syms_iter(const kplugin_t *plugin);
  53. ksym_t *kplugin_syms_each(kplugin_syms_node_t **iter);
  54. C_DECL_END
  55. #endif // _klish_kplugin_h