plugin.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. *
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <stdint.h>
  7. #include <assert.h>
  8. #include <faux/faux.h>
  9. #include <klish/kplugin.h>
  10. #include <klish/kcontext.h>
  11. #include <sysrepo.h>
  12. #include <sysrepo/xpath.h>
  13. #include "syms.h"
  14. const uint8_t kplugin_sysrepo_major = KPLUGIN_MAJOR;
  15. const uint8_t kplugin_sysrepo_minor = KPLUGIN_MINOR;
  16. int kplugin_sysrepo_init(kcontext_t *context)
  17. {
  18. kplugin_t *plugin = NULL;
  19. ksym_t *sym = NULL;
  20. int err = SR_ERR_OK;
  21. sr_conn_ctx_t *conn = NULL;
  22. sr_session_ctx_t *sess = NULL;
  23. assert(context);
  24. plugin = kcontext_plugin(context);
  25. assert(plugin);
  26. // Symbols
  27. // Types
  28. kplugin_add_syms(plugin, ksym_new_ext("PLINE_SET", srp_PLINE_SET,
  29. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  30. kplugin_add_syms(plugin, ksym_new_ext("PLINE_DEL", srp_PLINE_DEL,
  31. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  32. kplugin_add_syms(plugin, ksym_new_ext("PLINE_EDIT", srp_PLINE_EDIT,
  33. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  34. kplugin_add_syms(plugin, ksym_new_ext("PLINE_INSERT_FROM", srp_PLINE_INSERT_FROM,
  35. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  36. kplugin_add_syms(plugin, ksym_new_ext("PLINE_INSERT_TO", srp_PLINE_INSERT_TO,
  37. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  38. // Completion/Help/Prompt
  39. kplugin_add_syms(plugin, ksym_new_ext("srp_compl", srp_compl,
  40. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  41. kplugin_add_syms(plugin, ksym_new_ext("srp_help", srp_help,
  42. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  43. kplugin_add_syms(plugin, ksym_new_ext("srp_compl_insert_to", srp_compl_insert_to,
  44. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  45. kplugin_add_syms(plugin, ksym_new_ext("srp_help_insert_to", srp_help_insert_to,
  46. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  47. kplugin_add_syms(plugin, ksym_new_ext("srp_prompt_edit_path", srp_prompt_edit_path,
  48. KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
  49. // Operations
  50. kplugin_add_syms(plugin, ksym_new("srp_set", srp_set));
  51. kplugin_add_syms(plugin, ksym_new("srp_del", srp_del));
  52. // Note: 'edit', 'top', 'up' must be sync to set current path
  53. kplugin_add_syms(plugin, ksym_new_ext("srp_edit", srp_edit,
  54. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  55. kplugin_add_syms(plugin, ksym_new_ext("srp_top", srp_top,
  56. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  57. kplugin_add_syms(plugin, ksym_new_ext("srp_up", srp_up,
  58. KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
  59. kplugin_add_syms(plugin, ksym_new("srp_insert", srp_insert));
  60. kplugin_add_syms(plugin, ksym_new("srp_commit", srp_commit));
  61. kplugin_add_syms(plugin, ksym_new("srp_rollback", srp_rollback));
  62. kplugin_add_syms(plugin, ksym_new("srp_show", srp_show));
  63. return 0;
  64. }
  65. int kplugin_sysrepo_fini(kcontext_t *context)
  66. {
  67. context = context; // Happy compiler
  68. return 0;
  69. }