kaction.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /** @file action.h
  2. *
  3. * @brief Klish scheme's "action" entry
  4. */
  5. #ifndef _klish_kaction_h
  6. #define _klish_kaction_h
  7. #include <faux/error.h>
  8. typedef struct kaction_s kaction_t;
  9. typedef struct iaction_s {
  10. char *sym;
  11. char *lock;
  12. char *interrupt;
  13. char *interactive;
  14. char *exec_on;
  15. char *update_retcode;
  16. char *script;
  17. } iaction_t;
  18. typedef enum {
  19. KACTION_ERROR_OK,
  20. KACTION_ERROR_INTERNAL,
  21. KACTION_ERROR_ALLOC,
  22. KACTION_ERROR_ATTR_SYM,
  23. KACTION_ERROR_ATTR_LOCK,
  24. KACTION_ERROR_ATTR_INTERRUPT,
  25. KACTION_ERROR_ATTR_INTERACTIVE,
  26. KACTION_ERROR_ATTR_EXEC_ON,
  27. KACTION_ERROR_ATTR_UPDATE_RETCODE,
  28. KACTION_ERROR_ATTR_SCRIPT,
  29. } kaction_error_e;
  30. typedef enum {
  31. KACTION_COND_FAIL,
  32. KACTION_COND_SUCCESS,
  33. KACTION_COND_ALWAYS
  34. } kaction_cond_e;
  35. C_DECL_BEGIN
  36. // iaction_t
  37. char *iaction_to_text(const iaction_t *iaction, int level);
  38. // kaction_t
  39. kaction_t *kaction_new(const iaction_t *info, kaction_error_e *error);
  40. void kaction_free(kaction_t *action);
  41. const char *kaction_strerror(kaction_error_e error);
  42. bool_t kaction_parse(kaction_t *action, const iaction_t *info, kaction_error_e *error);
  43. const char *kaction_sym_ref(const kaction_t *action);
  44. bool_t kaction_set_sym_ref(kaction_t *action, const char *sym_ref);
  45. const char *kaction_lock(const kaction_t *action);
  46. bool_t kaction_set_lock(kaction_t *action, const char *lock);
  47. bool_t kaction_interrupt(const kaction_t *action);
  48. bool_t kaction_set_interrupt(kaction_t *action, bool_t interrupt);
  49. bool_t kaction_interactive(const kaction_t *action);
  50. bool_t kaction_set_interactive(kaction_t *action, bool_t interactive);
  51. kaction_cond_e kaction_exec_on(const kaction_t *action);
  52. bool_t kaction_set_exec_on(kaction_t *action, kaction_cond_e exec_on);
  53. bool_t kaction_update_retcode(const kaction_t *action);
  54. bool_t kaction_set_update_retcode(kaction_t *action, bool_t update_retcode);
  55. const char *kaction_script(const kaction_t *action);
  56. bool_t kaction_set_script(kaction_t *action, const char *script);
  57. kaction_t *kaction_from_iaction(iaction_t *iaction, faux_error_t *error_stack);
  58. C_DECL_END
  59. #endif // _klish_kaction_h