pline.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /** @file pline.h
  2. * @brief Plain line.
  3. */
  4. #ifndef _pline_h
  5. #define _pline_h
  6. #include <faux/list.h>
  7. #include <faux/argv.h>
  8. #include <sysrepo.h>
  9. #include <sysrepo/xpath.h>
  10. // Type of positional pline argument
  11. // P(line) A(rg) T(ype)
  12. typedef enum {
  13. PAT_NONE = 0x0001,
  14. PAT_CONTAINER = 0x0002,
  15. PAT_LIST = 0x0004,
  16. PAT_LIST_KEY = 0x0008,
  17. PAT_LIST_KEY_INCOMPLETED = 0x0010,
  18. PAT_LEAF = 0x0020,
  19. PAT_LEAF_VALUE = 0x0040,
  20. PAT_LEAF_EMPTY = 0x0080,
  21. PAT_LEAFLIST = 0x0100,
  22. PAT_LEAFLIST_VALUE = 0x0200,
  23. } pat_e;
  24. // Type of pline expression
  25. // P(line) T(ype)
  26. typedef enum {
  27. PT_SET =
  28. PAT_CONTAINER |
  29. PAT_LIST_KEY |
  30. PAT_LEAF_VALUE |
  31. PAT_LEAF_EMPTY |
  32. PAT_LEAFLIST_VALUE,
  33. PT_NOT_SET =
  34. 0,
  35. PT_DEL =
  36. PAT_CONTAINER |
  37. PAT_LIST_KEY |
  38. PAT_LEAF |
  39. PAT_LEAF_EMPTY |
  40. PAT_LEAFLIST |
  41. PAT_LEAFLIST_VALUE,
  42. PT_NOT_DEL =
  43. PAT_LEAF_VALUE,
  44. PT_EDIT =
  45. PAT_CONTAINER |
  46. PAT_LIST_KEY,
  47. PT_NOT_EDIT =
  48. PAT_LEAF |
  49. PAT_LEAF_VALUE |
  50. PAT_LEAFLIST |
  51. PAT_LEAFLIST_VALUE,
  52. } pt_e;
  53. // Plain EXPRession
  54. typedef struct {
  55. char *xpath;
  56. char *value;
  57. bool_t active;
  58. pat_e pat;
  59. size_t args_num;
  60. size_t list_pos;
  61. } pexpr_t;
  62. // Possible types of completion source
  63. typedef enum {
  64. PCOMPL_NODE = 0,
  65. PCOMPL_TYPE = 1,
  66. } pcompl_type_e;
  67. // Plain COMPLetion
  68. typedef struct {
  69. pcompl_type_e type;
  70. const struct lysc_node *node;
  71. char *xpath;
  72. } pcompl_t;
  73. // Plain LINE
  74. typedef struct pline_s {
  75. sr_session_ctx_t *sess;
  76. bool_t invalid;
  77. faux_list_t *exprs;
  78. faux_list_t *compls;
  79. } pline_t;
  80. C_DECL_BEGIN
  81. pline_t *pline_new(sr_session_ctx_t *sess);
  82. pline_t *pline_parse(sr_session_ctx_t *sess, faux_argv_t *argv, uint32_t flags);
  83. pexpr_t *pline_current_expr(pline_t *pline);
  84. void pline_free(pline_t *pline);
  85. void pline_debug(pline_t *pline);
  86. void pline_print_completions(const pline_t *pline, bool_t help);
  87. C_DECL_END
  88. #endif /* _pline_h */