kplugin.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // Plugin's options
  27. #define KPLUGIN_OPT_GLOBAL_FMT "kplugin_%s_opt_global"
  28. typedef struct kplugin_s kplugin_t;
  29. typedef faux_list_node_t kplugin_syms_node_t;
  30. C_DECL_BEGIN
  31. kplugin_t *kplugin_new(const char *name);
  32. void kplugin_free(kplugin_t *plugin);
  33. const char *kplugin_name(const kplugin_t *plugin);
  34. const char *kplugin_id(const kplugin_t *plugin);
  35. bool_t kplugin_set_id(kplugin_t *plugin, const char *id);
  36. const char *kplugin_file(const kplugin_t *plugin);
  37. bool_t kplugin_set_file(kplugin_t *plugin, const char *file);
  38. const char *kplugin_conf(const kplugin_t *plugin);
  39. bool_t kplugin_set_conf(kplugin_t *plugin, const char *conf);
  40. uint8_t kplugin_major(const kplugin_t *plugin);
  41. bool_t kplugin_set_major(kplugin_t *plugin, uint8_t major);
  42. uint8_t kplugin_minor(const kplugin_t *plugin);
  43. bool_t kplugin_set_minor(kplugin_t *plugin, uint8_t minor);
  44. void *kplugin_udata(const kplugin_t *plugin);
  45. bool_t kplugin_set_udata(kplugin_t *plugin, void *udata);
  46. bool_t kplugin_load(kplugin_t *plugin);
  47. ksym_fn kplugin_init_session_fn(const kplugin_t *plugin);
  48. bool_t kplugin_set_init_session_fn(kplugin_t *plugin, ksym_fn fn);
  49. ksym_fn kplugin_fini_session_fn(const kplugin_t *plugin);
  50. bool_t kplugin_set_fini_session_fn(kplugin_t *plugin, ksym_fn fn);
  51. int kplugin_init_session(kplugin_t *plugin, kcontext_t *context);
  52. int kplugin_fini_session(kplugin_t *plugin, kcontext_t *context);
  53. int kplugin_init(kplugin_t *plugin, kcontext_t *context);
  54. int kplugin_fini(kplugin_t *plugin, kcontext_t *context);
  55. // SYMs
  56. faux_list_t *kplugin_syms(const kplugin_t *plugin);
  57. bool_t kplugin_add_syms(kplugin_t *plugin, ksym_t *sym);
  58. ksym_t *kplugin_find_sym(const kplugin_t *plugin, const char *name);
  59. ssize_t kplugin_syms_len(const kplugin_t *plugin);
  60. kplugin_syms_node_t *kplugin_syms_iter(const kplugin_t *plugin);
  61. ksym_t *kplugin_syms_each(kplugin_syms_node_t **iter);
  62. C_DECL_END
  63. #endif // _klish_kplugin_h