private.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * private.h
  3. */
  4. #ifndef _pligin_sysrepo_private_h
  5. #define _plugin_sysrepo_private_h
  6. #include <faux/faux.h>
  7. #include <faux/argv.h>
  8. #include <klish/kcontext_base.h>
  9. #include "pline.h"
  10. // Plugin's user-data structure
  11. typedef struct {
  12. faux_argv_t *path; // Current data hierarchy path ('edit' operation)
  13. uint32_t flags; // Parse/Show flags
  14. } srp_udata_t;
  15. // Repository to edit with srp commands
  16. #define SRP_REPO_EDIT SR_DS_CANDIDATE
  17. // Defaut parse options
  18. #define SRP_DEFAULT_PARSE_OPTS ( \
  19. PPARSE_MULTI_KEYS_W_STMT | \
  20. PPARSE_JUNIPER_SHOW \
  21. )
  22. C_DECL_BEGIN
  23. // Types
  24. int srp_PLINE_SET(kcontext_t *context);
  25. int srp_PLINE_DEL(kcontext_t *context);
  26. int srp_PLINE_EDIT(kcontext_t *context);
  27. int srp_PLINE_INSERT_FROM(kcontext_t *context);
  28. int srp_PLINE_INSERT_TO(kcontext_t *context);
  29. // Completion/Help/Prompt
  30. int srp_compl(kcontext_t *context);
  31. int srp_help(kcontext_t *context);
  32. int srp_compl_insert_to(kcontext_t *context);
  33. int srp_help_insert_to(kcontext_t *context);
  34. int srp_prompt_edit_path(kcontext_t *context);
  35. int srp_compl_xpath_running(kcontext_t *context);
  36. int srp_compl_xpath_candidate(kcontext_t *context);
  37. // Operations
  38. int srp_set(kcontext_t *context);
  39. int srp_del(kcontext_t *context);
  40. int srp_edit(kcontext_t *context);
  41. int srp_top(kcontext_t *context);
  42. int srp_up(kcontext_t *context);
  43. int srp_insert(kcontext_t *context);
  44. int srp_verify(kcontext_t *context);
  45. int srp_commit(kcontext_t *context);
  46. int srp_rollback(kcontext_t *context);
  47. int srp_show(kcontext_t *context);
  48. int srp_show_running(kcontext_t *context);
  49. int srp_diff(kcontext_t *context);
  50. int srp_deactivate(kcontext_t *context);
  51. // Plugin's user-data service functions
  52. uint32_t srp_udata_flags(kcontext_t *context);
  53. faux_argv_t *srp_udata_path(kcontext_t *context);
  54. void srp_udata_set_path(kcontext_t *context, faux_argv_t *path);
  55. // Private
  56. enum diff_op {
  57. DIFF_OP_CREATE,
  58. DIFF_OP_DELETE,
  59. DIFF_OP_REPLACE,
  60. DIFF_OP_NONE,
  61. };
  62. bool_t show_xpath(sr_session_ctx_t *sess, const char *xpath, uint32_t flags);
  63. void show_subtree(const struct lyd_node *nodes_list, size_t level,
  64. enum diff_op op, uint32_t flags);
  65. // Sysrepo copy-paste
  66. int sr_module_is_internal(const struct lys_module *ly_mod);
  67. C_DECL_END
  68. #endif // _plugin_sysrepo_private_h