kptype.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /** @file kptype.h
  2. *
  3. * @brief Klish scheme's "ptype" entry
  4. */
  5. #ifndef _klish_kptype_h
  6. #define _klish_kptype_h
  7. #include <faux/error.h>
  8. #include <klish/kaction.h>
  9. typedef struct kptype_s kptype_t;
  10. typedef struct iptype_s {
  11. char *name;
  12. char *help;
  13. iaction_t * (*actions)[];
  14. } iptype_t;
  15. typedef enum {
  16. KPTYPE_ERROR_OK,
  17. KPTYPE_ERROR_INTERNAL,
  18. KPTYPE_ERROR_ALLOC,
  19. KPTYPE_ERROR_ATTR_NAME,
  20. KPTYPE_ERROR_ATTR_HELP,
  21. } kptype_error_e;
  22. C_DECL_BEGIN
  23. // iptype_t
  24. char *iptype_to_text(const iptype_t *iptype, int level);
  25. // kptype_t
  26. void kptype_free(kptype_t *ptype);
  27. bool_t kptype_parse(kptype_t *ptype, const iptype_t *info, kptype_error_e *error);
  28. kptype_t *kptype_new(const iptype_t *info, kptype_error_e *error);
  29. const char *kptype_strerror(kptype_error_e error);
  30. const char *kptype_name(const kptype_t *ptype);
  31. bool_t kptype_set_name(kptype_t *ptype, const char *name);
  32. const char *kptype_help(const kptype_t *ptype);
  33. bool_t kptype_set_help(kptype_t *ptype, const char *help);
  34. bool_t kptype_nested_from_iptype(kptype_t *kptype, iptype_t *iptype,
  35. faux_error_t *error_stack);
  36. kptype_t *kptype_from_iptype(iptype_t *iptype, faux_error_t *error_stack);
  37. C_DECL_END
  38. #endif // _klish_kptype_h