ktp_session.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef _klish_ktp_session_h
  2. #define _klish_ktp_session_h
  3. #include <faux/faux.h>
  4. #include <faux/list.h>
  5. #include <faux/eloop.h>
  6. #include <klish/ksession.h>
  7. #include <klish/ktp.h>
  8. #define USOCK_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
  9. #define KLISH_DEFAULT_UNIX_SOCKET_PATH "/tmp/klish-unix-socket"
  10. typedef struct ktpd_session_s ktpd_session_t;
  11. typedef struct ktp_session_s ktp_session_t;
  12. typedef bool_t (*ktpd_session_stall_cb_fn)(ktpd_session_t *session,
  13. void *user_data);
  14. C_DECL_BEGIN
  15. // Common KTP functions
  16. int ktp_connect_unix(const char *sun_path);
  17. void ktp_disconnect(int fd);
  18. int ktp_accept(int listen_sock);
  19. faux_msg_t *ktp_msg_preform(ktp_cmd_e cmd, uint32_t status);
  20. // Client KTP session
  21. ktp_session_t *ktp_session_new(int sock);
  22. void ktp_session_free(ktp_session_t *session);
  23. bool_t ktp_session_connected(ktp_session_t *session);
  24. int ktp_session_fd(const ktp_session_t *session);
  25. // Server KTP session
  26. ktpd_session_t *ktpd_session_new(int sock, const kscheme_t *scheme,
  27. const char *start_entry, faux_eloop_t *eloop);
  28. void ktpd_session_free(ktpd_session_t *session);
  29. bool_t ktpd_session_connected(ktpd_session_t *session);
  30. int ktpd_session_fd(const ktpd_session_t *session);
  31. bool_t ktpd_session_async_in(ktpd_session_t *session);
  32. bool_t ktpd_session_async_out(ktpd_session_t *session);
  33. C_DECL_END
  34. #endif // _klish_ktp_session_h