timer.h 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef WOE_TIMER_H
  2. #define WOE_TIMER_H
  3. #if !defined(_POSIX_C_SOURCE)
  4. #define _POSIX_C_SOURCE 200801L
  5. #endif
  6. #if !defined(_POSIX_SOURCE)
  7. #define _POSIX_SOURCE
  8. #endif
  9. #if !defined(_BSD_SOURCE)
  10. #define _BSD_SOURCE
  11. #endif
  12. #include <signal.h>
  13. #include <time.h>
  14. #include <errno.h>
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <stdlib.h>
  18. #include <ctype.h>
  19. struct woe_server;
  20. struct woe_timer {
  21. struct woe_server * server;
  22. int index;
  23. timer_t timer;
  24. int set;
  25. struct sigaction sa;
  26. };
  27. struct woe_timer * woe_timer_new(struct woe_server * server, int index);
  28. struct woe_timer * woe_timer_free(struct woe_timer * me);
  29. int woe_timer_get(struct woe_timer * me, double * value, double * interval);
  30. int woe_timer_set(struct woe_timer * me, double value, double interval);
  31. int woe_timer_passed(struct woe_timer * me);
  32. int woe_timer_callback(struct woe_timer * me);
  33. #endif