polling.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* This file is part of libepistle.
  2. *
  3. * libepistle is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU Lesser General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * libepistle is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public License
  14. * along with libepistle. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef EPISTLE_POLLING_H
  17. #define EPISTLE_POLLING_H
  18. #include <stdint.h>
  19. #include <primo/err.h>
  20. #define POLLING_FATAL -1
  21. #define POLLING_OKAY 0
  22. #define POLLING_END 1
  23. typedef int (*Polling_react)(int epoll_fd, int fd, uint32_t events,
  24. Err *err, void *extra);
  25. enum {
  26. PM_ADD = 1,
  27. PM_REMOVE,
  28. PM_INPUT,
  29. PM_OUTPUT,
  30. };
  31. typedef int (*Pm_react)(int epoll_fd, int fd, int server_fd, int pm_event,
  32. Err *err, void *extra);
  33. typedef int (*Server_check)(int fd, void *extra);
  34. int
  35. poll_add(int epoll_fd, int fd, Err *err);
  36. int
  37. poll_remove(int epoll_fd, int fd, Err *err);
  38. int
  39. poll_out(int epoll_fd, int fd, Err *err);
  40. int
  41. poll_out_off(int epoll_fd, int fd, Err *err);
  42. int
  43. polling(int *epoll_fd, Polling_react react, int fds[], Err *err, void *extra);
  44. int
  45. polling_mode(Pm_react react, int *epoll_fd, int fds[], Server_check s_check,
  46. Err *err, void *extra);
  47. #endif