private.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. pline_opts_t opts; // Settings
  14. } srp_udata_t;
  15. // Repository to edit with srp commands
  16. #define SRP_REPO_EDIT SR_DS_CANDIDATE
  17. C_DECL_BEGIN
  18. // Types
  19. int srp_PLINE_SET(kcontext_t *context);
  20. int srp_PLINE_DEL(kcontext_t *context);
  21. int srp_PLINE_EDIT(kcontext_t *context);
  22. int srp_PLINE_INSERT_FROM(kcontext_t *context);
  23. int srp_PLINE_INSERT_TO(kcontext_t *context);
  24. // Completion/Help/Prompt
  25. int srp_compl(kcontext_t *context);
  26. int srp_help(kcontext_t *context);
  27. int srp_compl_insert_to(kcontext_t *context);
  28. int srp_help_insert_to(kcontext_t *context);
  29. int srp_prompt_edit_path(kcontext_t *context);
  30. int srp_compl_xpath_running(kcontext_t *context);
  31. int srp_compl_xpath_candidate(kcontext_t *context);
  32. // Operations
  33. int srp_set(kcontext_t *context);
  34. int srp_del(kcontext_t *context);
  35. int srp_edit(kcontext_t *context);
  36. int srp_top(kcontext_t *context);
  37. int srp_up(kcontext_t *context);
  38. int srp_insert(kcontext_t *context);
  39. int srp_verify(kcontext_t *context);
  40. int srp_commit(kcontext_t *context);
  41. int srp_reset(kcontext_t *context);
  42. int srp_show(kcontext_t *context);
  43. int srp_show_running(kcontext_t *context);
  44. int srp_diff(kcontext_t *context);
  45. int srp_deactivate(kcontext_t *context);
  46. // Logging
  47. int srp_set_log_func(void);
  48. // Plugin's user-data service functions
  49. pline_opts_t *srp_udata_opts(kcontext_t *context);
  50. faux_argv_t *srp_udata_path(kcontext_t *context);
  51. void srp_udata_set_path(kcontext_t *context, faux_argv_t *path);
  52. // Private
  53. enum diff_op {
  54. DIFF_OP_CREATE,
  55. DIFF_OP_DELETE,
  56. DIFF_OP_REPLACE,
  57. DIFF_OP_NONE,
  58. };
  59. bool_t show_xpath(sr_session_ctx_t *sess, const char *xpath, pline_opts_t *opts);
  60. void show_subtree(const struct lyd_node *nodes_list, size_t level,
  61. enum diff_op op, pline_opts_t *opts);
  62. // Sysrepo copy-paste
  63. int sr_module_is_internal(const struct lys_module *ly_mod);
  64. // kly helper library
  65. typedef struct {
  66. const struct lysc_node *node;
  67. const char *value;
  68. const char *dflt;
  69. } klysc_key_t;
  70. int klysc_key_compare(const void *first, const void *second);
  71. int klysc_key_kcompare(const void *key, const void *list_item);
  72. bool_t klysc_node_ext(const struct lysc_node *node,
  73. const char *module, const char *name, const char **argument);
  74. bool_t klysc_node_ext_is_password(const struct lysc_node *node);
  75. const char *klysc_node_ext_completion(const struct lysc_node *node);
  76. const char *klysc_node_ext_default(const struct lysc_node *node);
  77. char *klyd_node_value(const struct lyd_node *node);
  78. const struct lysc_node *klysc_find_child(const struct lysc_node *node,
  79. const char *name);
  80. char *klysc_leafref_xpath(const struct lysc_node *node, const char *node_path);
  81. const char *klysc_identityref_prefix(struct lysc_type_identityref *type,
  82. const char *name);
  83. C_DECL_END
  84. #endif // _plugin_sysrepo_private_h