kview.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /** @file view.h
  2. *
  3. * @brief Klish scheme's "view" entry
  4. */
  5. #ifndef _klish_kview_h
  6. #define _klish_kview_h
  7. #include <faux/faux.h>
  8. #include <faux/error.h>
  9. #include <klish/kcommand.h>
  10. typedef struct kview_s kview_t;
  11. typedef struct iview_s {
  12. char *name;
  13. icommand_t * (*commands)[];
  14. } iview_t;
  15. typedef enum {
  16. KVIEW_ERROR_OK,
  17. KVIEW_ERROR_INTERNAL,
  18. KVIEW_ERROR_ALLOC,
  19. KVIEW_ERROR_ATTR_NAME,
  20. } kview_error_e;
  21. C_DECL_BEGIN
  22. // iview_t
  23. char *iview_to_text(const iview_t *iview, int level);
  24. // kview_t
  25. kview_t *kview_new(const iview_t *info, kview_error_e *error);
  26. void kview_free(kview_t *view);
  27. bool_t kview_parse(kview_t *view, const iview_t *info, kview_error_e *error);
  28. const char *kview_strerror(kview_error_e error);
  29. const char *kview_name(const kview_t *view);
  30. bool_t kview_set_name(kview_t *view, const char *name);
  31. bool_t kview_add_command(kview_t *view, kcommand_t *command);
  32. bool_t kview_nested_from_iview(kview_t *kview, iview_t *iview,
  33. faux_error_t *error_stack);
  34. kview_t *kview_from_iview(iview_t *iview, faux_error_t *error_stack);
  35. C_DECL_END
  36. #endif // _klish_kview_h