io.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. * Please read the file COPYING, README and AUTHORS for more information.
  7. */
  8. #ifndef io_H_included
  9. #define io_H_included
  10. /**
  11. * @file
  12. * I/O abstraction interface (header)
  13. */
  14. #include "portab.h"
  15. #include <sys/time.h>
  16. #define IO_WANTREAD 1
  17. #define IO_WANTWRITE 2
  18. /* init library.
  19. sets up epoll/kqueue descriptors and tries to allocate space for ioevlen
  20. file descriptors. ioevlen is just the _initial_ size, not a limit. */
  21. bool io_library_init PARAMS((unsigned int ioevlen));
  22. /* shutdown and free all internal data structures */
  23. void io_library_shutdown PARAMS((void));
  24. /* add fd to internal set, enable readability check, set callback */
  25. bool io_event_create PARAMS((int fd, short what, void (*cbfunc)(int, short)));
  26. /* change callback function associated with fd */
  27. bool io_event_setcb PARAMS((int fd, void (*cbfunc)(int, short)));
  28. /* watch fd for event of type what */
  29. bool io_event_add PARAMS((int fd, short what));
  30. /* do not watch fd for event of type what */
  31. bool io_event_del PARAMS((int fd, short what));
  32. /* remove fd from watchlist, close() fd. */
  33. bool io_close PARAMS((int fd));
  34. /* set O_NONBLOCK */
  35. bool io_setnonblock PARAMS((int fd));
  36. /* set O_CLOEXEC */
  37. bool io_setcloexec PARAMS((int fd));
  38. /* watch fds for activity */
  39. int io_dispatch PARAMS((struct timeval *tv));
  40. #endif /* io_H_included */