private.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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(kcontext_t *context);
  36. // Operations
  37. int srp_set(kcontext_t *context);
  38. int srp_del(kcontext_t *context);
  39. int srp_edit(kcontext_t *context);
  40. int srp_top(kcontext_t *context);
  41. int srp_up(kcontext_t *context);
  42. int srp_insert(kcontext_t *context);
  43. int srp_verify(kcontext_t *context);
  44. int srp_commit(kcontext_t *context);
  45. int srp_rollback(kcontext_t *context);
  46. int srp_show(kcontext_t *context);
  47. int srp_show_running(kcontext_t *context);
  48. int srp_diff(kcontext_t *context);
  49. int srp_deactivate(kcontext_t *context);
  50. // Plugin's user-data service functions
  51. uint32_t srp_udata_flags(kcontext_t *context);
  52. faux_argv_t *srp_udata_path(kcontext_t *context);
  53. void srp_udata_set_path(kcontext_t *context, faux_argv_t *path);
  54. // Private
  55. enum diff_op {
  56. DIFF_OP_CREATE,
  57. DIFF_OP_DELETE,
  58. DIFF_OP_REPLACE,
  59. DIFF_OP_NONE,
  60. };
  61. bool_t show_xpath(sr_session_ctx_t *sess, const char *xpath, uint32_t flags);
  62. void show_subtree(const struct lyd_node *nodes_list, size_t level,
  63. enum diff_op op, uint32_t flags);
  64. // Sysrepo copy-paste
  65. int sr_module_is_internal(const struct lys_module *ly_mod);
  66. C_DECL_END
  67. #endif // _plugin_sysrepo_private_h