isrv.h 953 B

123456789101112131415161718192021222324252627282930313233
  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 Denis Vlasenko
  7. *
  8. * Licensed under GPL version 2, see file LICENSE in this tarball for details.
  9. */
  10. /* opaque structure */
  11. struct isrv_state_t;
  12. typedef struct isrv_state_t isrv_state_t;
  13. /* callbacks */
  14. void isrv_want_rd(isrv_state_t *state, int fd);
  15. void isrv_want_wr(isrv_state_t *state, int fd);
  16. void isrv_dont_want_rd(isrv_state_t *state, int fd);
  17. void isrv_dont_want_wr(isrv_state_t *state, int fd);
  18. int isrv_register_fd(isrv_state_t *state, int peer, int fd);
  19. void isrv_close_fd(isrv_state_t *state, int fd);
  20. int isrv_register_peer(isrv_state_t *state, void *param);
  21. /* driver */
  22. void isrv_run(
  23. int listen_fd,
  24. int (*new_peer)(isrv_state_t *state, int fd),
  25. int (*do_rd)(int fd, void **),
  26. int (*do_wr)(int fd, void **),
  27. int (*do_timeout)(void **),
  28. int timeout,
  29. int linger_timeout
  30. );