Skip to content
Browse files

add accesor for callback

  • Loading branch information...
1 parent bb4baa8 commit a8565c42f67f62518771679e82f773d4d7ec60fa @kazuho committed Jan 26, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 picoev.h
View
22 picoev.h
@@ -274,6 +274,28 @@ extern "C" {
return 0;
}
+ /* returns callback for given descriptor */
+ PICOEV_INLINE
+ picoev_handler* picoev_get_callback(picoev_loop* loop __attribute__((unused)),
+ int fd, void** cb_arg) {
+ assert(PICOEV_IS_INITED_AND_FD_IN_RANGE(fd));
+ if (cb_arg != NULL) {
+ *cb_arg = picoev.fds[fd].cb_arg;
+ }
+ return picoev.fds[fd].callback;
+ }
+
+ /* sets callback for given descriptor */
+ PICOEV_INLINE
+ void picoev_set_callback(picoev_loop* loop __attribute__((unused)), int fd,
+ picoev_handler* callback, void** cb_arg) {
+ assert(PICOEV_IS_INITED_AND_FD_IN_RANGE(fd));
+ if (cb_arg != NULL) {
+ picoev.fds[fd].cb_arg = *cb_arg;
+ }
+ picoev.fds[fd].callback = callback;
+ }
+
/* function to iterate registered information. To start iteration, set curfd
to -1 and call the function until -1 is returned */
PICOEV_INLINE

0 comments on commit a8565c4

Please sign in to comment.
Something went wrong with that request. Please try again.