kptype.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. void kptype_free(kptype_t *ptype);
  24. bool_t kptype_parse(kptype_t *ptype, const iptype_t *info, kptype_error_e *error);
  25. kptype_t *kptype_new(const iptype_t *info, kptype_error_e *error);
  26. const char *kptype_strerror(kptype_error_e error);
  27. const char *kptype_name(const kptype_t *ptype);
  28. bool_t kptype_set_name(kptype_t *ptype, const char *name);
  29. const char *kptype_help(const kptype_t *ptype);
  30. bool_t kptype_set_help(kptype_t *ptype, const char *help);
  31. bool_t kptype_nested_from_iptype(kptype_t *kptype, iptype_t *iptype,
  32. faux_error_t *error_stack);
  33. kptype_t *kptype_from_iptype(iptype_t *iptype, faux_error_t *error_stack);
  34. C_DECL_END
  35. #endif // _klish_kptype_h