ktp_session.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _klish_ktp_session_h
  2. #define _klish_ktp_session_h
  3. #include <faux/faux.h>
  4. #include <faux/list.h>
  5. #define USOCK_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
  6. #define KLISH_DEFAULT_UNIX_SOCKET_PATH "/tmp/klish-unix-socket"
  7. typedef struct ktpd_session_s ktpd_session_t;
  8. typedef struct ktp_session_s ktp_session_t;
  9. typedef struct ktpd_clients_s ktpd_clients_t;
  10. typedef bool_t (*faux_session_stall_cb_fn)(ktpd_session_t *session,
  11. void *user_data);
  12. C_DECL_BEGIN
  13. // Client KTP session
  14. ktp_session_t *ktp_session_new(int sock);
  15. void ktp_session_free(ktp_session_t *session);
  16. bool_t ktp_session_connected(ktp_session_t *session);
  17. int ktp_session_fd(const ktp_session_t *session);
  18. // Server KTP session
  19. ktpd_session_t *ktpd_session_new(int sock);
  20. void ktpd_session_free(ktpd_session_t *session);
  21. bool_t ktpd_session_connected(ktpd_session_t *session);
  22. int ktpd_session_fd(const ktpd_session_t *session);
  23. bool_t ktpd_session_async_in(ktpd_session_t *session);
  24. bool_t ktpd_session_async_out(ktpd_session_t *session);
  25. void ktpd_session_set_stall_cb(ktpd_session_t *session,
  26. faux_session_stall_cb_fn stall_cb, void *user_data);
  27. // Server's KTP clients database
  28. ktpd_clients_t *ktpd_clients_new(void);
  29. void ktpd_clients_free(ktpd_clients_t *db);
  30. ktpd_session_t *ktpd_clients_find(const ktpd_clients_t *db, int fd);
  31. ktpd_session_t *ktpd_clients_add(ktpd_clients_t *db, int fd);
  32. int ktpd_clients_del(ktpd_clients_t *db, int fd);
  33. faux_list_node_t *ktpd_clients_init_iter(const ktpd_clients_t *db);
  34. ktpd_session_t *ktpd_clients_each(faux_list_node_t **iter);
  35. void ktpd_clients_debug(ktpd_clients_t *db);
  36. C_DECL_END
  37. #endif // _klish_ktp_session_h