ktp.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /** @file ktp.h
  2. *
  3. * @brief Klish Transfer Protocol
  4. */
  5. #ifndef _klish_ktp_h
  6. #define _klish_ktp_h
  7. #include <faux/msg.h>
  8. #define KTP_MAGIC 0x4b545020
  9. #define KTP_MAJOR 0x01
  10. #define KTP_MINOR 0x00
  11. typedef enum {
  12. KTP_NULL = '\0',
  13. KTP_STDIN = 'i',
  14. KTP_STDOUT = 'o',
  15. KTP_STDERR = 'e',
  16. KTP_CMD = 'c',
  17. KTP_CMD_ACK = 'C',
  18. KTP_COMPLETION = 'v',
  19. KTP_COMPLETION_ACK = 'V',
  20. KTP_HELP = 'h',
  21. KTP_HELP_ACK = 'H',
  22. KTP_NOTIFICATION = 'n',
  23. KTP_EXIT = 'x',
  24. KTP_AUTH = 'a',
  25. KTP_AUTH_ACK = 'A',
  26. KTP_KEEPALIVE = 'k',
  27. } ktp_cmd_e;
  28. typedef enum {
  29. KTP_PARAM_NULL = '\0',
  30. KTP_PARAM_LINE = 'L',
  31. KTP_PARAM_ERROR = 'E',
  32. } ktp_param_e;
  33. // Status field. Bitmap
  34. #define KTP_STATUS_NONE (uint32_t)0x00000000
  35. #define KTP_STATUS_ERROR (uint32_t)0x00000001
  36. #define KTP_STATUS_IS_ERROR(status) (status & KTP_STATUS_ERROR)
  37. C_DECL_BEGIN
  38. int ktp_connect_unix(const char *sun_path);
  39. void ktp_disconnect(int fd);
  40. int ktp_accept(int listen_sock);
  41. faux_msg_t *ktp_msg_preform(ktp_cmd_e cmd, uint32_t status);
  42. C_DECL_END
  43. #endif // _klish_ktp_h