int pollfd_in_cb (s_window_t *window, s_pollfd_t *pfd) { // do what ever you want with your fd // return -1 on error, 0 on success return 0; } int pollfd_in_err (s_window_t *window, s_pollfd_t *pfd) { // will be called if something bad happens on poll call // return -1 to stop client, otherwise return 0 return 0; } int pollfd_in_close (s_window_t *window, s_pollfd_t *pfd) { // will be called while uniting the window return 0; } s_pollfd_t *pfd; // initialize pfd struct s_pollfd_init(&pfd); // set fd to poll, and callback functions pfd->fd = fd; pfd->pf_in = pollfd_in_cb; pfd->pf_err = pollfd_err_cb; pfd->pf_close = pollfd_close_cb; // add pfd to the window s_pollfd_add(window, pfd); // del pfd from window s_pollfd_del(window, pfd); // uninitialize pfd struct s_pollfd_uninit(pfd);
Data Structures | |
| struct | s_pollfd_s |
| polfd struct More... | |
| struct | s_pollfds_s |
| polfds struct More... | |
Functions | |
| int | s_pollfd_init (s_pollfd_t **pfd) |
| initialize the pollfd struct. | |
| int | s_pollfd_uninit (s_pollfd_t *pfd) |
| uninitialize the pollfd struct | |
| s_pollfd_t * | s_pollfd_find (s_window_t *window, int fd) |
| finds the pollfd struct that is associated with fd | |
| int | s_pollfd_add (s_window_t *window, s_pollfd_t *pfd) |
| adds a pollfd to windows` pollfds list | |
| int | s_pollfd_del (s_window_t *window, s_pollfd_t *pfd) |
| deletes a pollfd from windows` pollfds list | |
| int | s_pollfds_init (s_window_t *window) |
| initialize the pollfds struct for given window | |
| int | s_pollfds_uninit (s_window_t *window) |
| uninitialize the pollfds struct for given window | |
| int s_pollfd_add | ( | s_window_t * | window, | |
| s_pollfd_t * | pfd | |||
| ) |
adds a pollfd to windows` pollfds list
| *window | - window to attach the pollfd | |
| *pfd | - the pollfd |
| int s_pollfd_del | ( | s_window_t * | window, | |
| s_pollfd_t * | pfd | |||
| ) |
deletes a pollfd from windows` pollfds list
| *window | - window that holds the pollfd | |
| *pfd | - the pollfd |
| s_pollfd_t* s_pollfd_find | ( | s_window_t * | window, | |
| int | fd | |||
| ) |
finds the pollfd struct that is associated with fd
| window | - the window that holds pollfd | |
| fd | - file descriptor to find |
| int s_pollfd_init | ( | s_pollfd_t ** | pfd | ) |
initialize the pollfd struct.
| **pfd | - address of the pollfd pointer. |
| int s_pollfd_uninit | ( | s_pollfd_t * | pfd | ) |
uninitialize the pollfd struct
| *pfd | - the pollfd |
| int s_pollfds_init | ( | s_window_t * | window | ) |
initialize the pollfds struct for given window
| *window | - window |
| int s_pollfds_uninit | ( | s_window_t * | window | ) |
uninitialize the pollfds struct for given window
| *window | - window |
1.4.7