private.h 2.1 KB

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