ES-2024 reverter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1011B

  1. #ifndef _EVENT_H_
  2. #define _EVENT_H_
  3. #include <sys/time.h>
  4. #define EVENT_NEW 0x1000
  5. #define EVENT_DELETE 0x2000
  6. #define FD_READ 0x0001
  7. #define FD_WRITE 0x0002
  8. #define FD_TYPES (FD_READ | FD_WRITE)
  9. #define event_add_readfd(entry, fd, callback, privdata) \
  10. event_add_fd(entry, fd, FD_READ, callback, privdata)
  11. #define event_add_writefd(entry, fd, callback, privdata) \
  12. event_add_fd(entry, fd, FD_WRITE, callback, privdata)
  13. /* inner details are not visible to external users (TODO: size unknown) */
  14. struct event_fd;
  15. struct event_timeout;
  16. struct event_fd * event_add_fd(
  17. struct event_fd *entry,
  18. int fd,
  19. int type,
  20. int (*callback)(int fd, void *privdata),
  21. void *privdata);
  22. int event_get_fd(struct event_fd *entry);
  23. void event_remove_fd(struct event_fd *entry);
  24. struct event_timeout * event_add_timeout(
  25. struct timeval *timeout,
  26. int (*callback)(void *privdata),
  27. void *privdata);
  28. void event_remove_timeout(struct event_timeout *entry);
  29. int event_loop(void);
  30. #endif /* _EVENT_H_ */