tree.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * conf.h
  3. */
  4. /**
  5. \ingroup clish
  6. \defgroup clish_conf config
  7. @{
  8. \brief This class is a config in memory container.
  9. Use it to implement config in memory.
  10. */
  11. #ifndef _konf_tree_h
  12. #define _konf_tree_h
  13. #include <stdio.h>
  14. #include "lub/types.h"
  15. #include "lub/bintree.h"
  16. typedef struct konf_tree_s konf_tree_t;
  17. #define KONF_ENTRY_OK 0xffff
  18. #define KONF_ENTRY_DIRTY 0xfffe
  19. #define KONF_ENTRY_NEW 0xfffd
  20. /*=====================================
  21. * CONF INTERFACE
  22. *===================================== */
  23. /*-----------------
  24. * meta functions
  25. *----------------- */
  26. konf_tree_t *konf_tree_new(const char * line, unsigned short priority);
  27. int konf_tree_bt_compare(const void *clientnode, const void *clientkey);
  28. void konf_tree_bt_getkey(const void *clientnode, lub_bintree_key_t * key);
  29. size_t konf_tree_bt_offset(void);
  30. /*-----------------
  31. * methods
  32. *----------------- */
  33. void konf_tree_delete(konf_tree_t * instance);
  34. void konf_tree_fprintf(konf_tree_t * instance, FILE * stream,
  35. const char *pattern, int depth, bool_t seq, unsigned char prev_pri_hi);
  36. konf_tree_t *konf_tree_new_conf(konf_tree_t * instance,
  37. const char *line, unsigned short priority,
  38. bool_t seq, unsigned short seq_num);
  39. konf_tree_t *konf_tree_find_conf(konf_tree_t * instance,
  40. const char *line, unsigned short priority, unsigned short sequence);
  41. int konf_tree_del_pattern(konf_tree_t * instance,
  42. const char *pattern, unsigned short priority,
  43. bool_t seq, unsigned short seq_num);
  44. /*-----------------
  45. * attributes
  46. *----------------- */
  47. unsigned konf_tree__get_depth(const konf_tree_t * instance);
  48. unsigned short konf_tree__get_priority(const konf_tree_t * instance);
  49. unsigned char konf_tree__get_priority_hi(const konf_tree_t * instance);
  50. unsigned char konf_tree__get_priority_lo(const konf_tree_t * instance);
  51. bool_t konf_tree__get_splitter(const konf_tree_t * instance);
  52. void konf_tree__set_splitter(konf_tree_t *instance, bool_t splitter);
  53. unsigned short konf_tree__get_seq_num(const konf_tree_t * instance);
  54. void konf_tree__set_seq_num(konf_tree_t * instance, unsigned short seq_num);
  55. unsigned short konf_tree__get_sub_num(const konf_tree_t * instance);
  56. void konf_tree__set_sub_num(konf_tree_t * instance, unsigned short sub_num);
  57. const char * konf_tree__get_line(const konf_tree_t * instance);
  58. #endif /* _konf_tree_h */
  59. /** @} clish_conf */