pline.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_LEAFLIST = 0x0080,
  21. PAT_LEAFLIST_VALUE = 0x0100,
  22. } pat_e;
  23. // Type of pline expression
  24. // P(line) T(ype)
  25. typedef enum {
  26. PT_SET =
  27. PAT_CONTAINER |
  28. PAT_LIST_KEY |
  29. PAT_LEAF_VALUE |
  30. PAT_LEAFLIST_VALUE,
  31. PT_DEL =
  32. PAT_CONTAINER |
  33. PAT_LIST_KEY |
  34. PAT_LEAF |
  35. PAT_LEAFLIST |
  36. PAT_LEAFLIST_VALUE,
  37. PT_EDIT =
  38. PAT_CONTAINER |
  39. PAT_LIST_KEY,
  40. } pt_e;
  41. // Plain EXPRession
  42. typedef struct {
  43. char *xpath;
  44. char *value;
  45. bool_t active;
  46. } pexpr_t;
  47. // Possible types of completion source
  48. typedef enum {
  49. PCOMPL_NODE = 0,
  50. PCOMPL_TYPE = 1,
  51. } pcompl_type_e;
  52. // Plain COMPLetion
  53. typedef struct {
  54. pcompl_type_e type;
  55. const struct lysc_node *node;
  56. char *xpath;
  57. } pcompl_t;
  58. // Plain LINE
  59. typedef struct pline_s {
  60. sr_session_ctx_t *sess;
  61. faux_list_t *exprs;
  62. faux_list_t *compls;
  63. } pline_t;
  64. C_DECL_BEGIN
  65. pline_t *pline_new(sr_session_ctx_t *sess);
  66. pline_t *pline_parse(sr_session_ctx_t *sess, faux_argv_t *argv, uint32_t flags);
  67. void pline_free(pline_t *pline);
  68. void pline_debug(pline_t *pline);
  69. void pline_print_completions(const pline_t *pline, bool_t help);
  70. C_DECL_END
  71. #endif /* _pline_h */