isrv.h 1012 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Generic non-forking server infrastructure.
  4. * Intended to make writing telnetd-type servers easier.
  5. *
  6. * Copyright (C) 2007 Denys Vlasenko
  7. *
  8. * Licensed under GPLv2, see file LICENSE in this source tree.
  9. */
  10. PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
  11. /* opaque structure */
  12. struct isrv_state_t;
  13. typedef struct isrv_state_t isrv_state_t;
  14. /* callbacks */
  15. void isrv_want_rd(isrv_state_t *state, int fd);
  16. void isrv_want_wr(isrv_state_t *state, int fd);
  17. void isrv_dont_want_rd(isrv_state_t *state, int fd);
  18. void isrv_dont_want_wr(isrv_state_t *state, int fd);
  19. int isrv_register_fd(isrv_state_t *state, int peer, int fd);
  20. void isrv_close_fd(isrv_state_t *state, int fd);
  21. int isrv_register_peer(isrv_state_t *state, void *param);
  22. /* driver */
  23. void isrv_run(
  24. int listen_fd,
  25. int (*new_peer)(isrv_state_t *state, int fd),
  26. int (*do_rd)(int fd, void **),
  27. int (*do_wr)(int fd, void **),
  28. int (*do_timeout)(void **),
  29. int timeout,
  30. int linger_timeout
  31. );
  32. POP_SAVED_FUNCTION_VISIBILITY