/** * Add a event source for a file descriptor. * * @param fd The file descriptor. * @param events Events to check for. * @param timeout Max time to wait before the callback is called, ignored if 0. * @param cb Callback function to add. Must not be NULL. * @param cb_data Data for the callback function. Can be NULL. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or * SR_ERR_MALLOC upon memory allocation errors. */ SR_API int sr_session_source_add(int fd, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data) { GPollFD p; p.fd = fd; p.events = events; return _sr_session_source_add(&p, timeout, cb, cb_data, (gintptr)fd); }
/** * Add an event source for a file descriptor. * * @param fd The file descriptor. * @param events Events to check for. * @param timeout Max time to wait before the callback is called, ignored if 0. * @param cb Callback function to add. Must not be NULL. * @param cb_data Data for the callback function. Can be NULL. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or * SR_ERR_MALLOC upon memory allocation errors. */ SR_API int sr_session_source_add(int fd, int events, int timeout, sr_receive_data_callback_t cb, const struct sr_dev_inst *sdi) { GPollFD p; p.fd = fd; p.events = events; return _sr_session_source_add(&p, timeout, cb, sdi, (gintptr)fd); }
/** * Add an event source for a GIOChannel. * * @param channel The GIOChannel. * @param events Events to poll on. * @param timeout Max time to wait before the callback is called, ignored if 0. * @param cb Callback function to add. Must not be NULL. * @param cb_data Data for the callback function. Can be NULL. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or * SR_ERR_MALLOC upon memory allocation errors. */ SR_API int sr_session_source_add_channel(GIOChannel *channel, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data) { GPollFD p; #ifdef _WIN32 g_io_channel_win32_make_pollfd(channel, events, &p); #else p.fd = g_io_channel_unix_get_fd(channel); p.events = events; #endif return _sr_session_source_add(&p, timeout, cb, cb_data, (gintptr)channel); }
/** * Add an event source for a GPollFD. * * TODO: More error checks etc. * * @param pollfd The GPollFD. * @param timeout Max time to wait before the callback is called, ignored if 0. * @param cb Callback function to add. Must not be NULL. * @param cb_data Data for the callback function. Can be NULL. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or * SR_ERR_MALLOC upon memory allocation errors. */ SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout, sr_receive_data_callback_t cb, void *cb_data) { return _sr_session_source_add(pollfd, timeout, cb, cb_data, (gintptr)pollfd); }
/** * Add an event source for a GPollFD. * * @param pollfd The GPollFD. * @param timeout Max time to wait before the callback is called, ignored if 0. * @param cb Callback function to add. Must not be NULL. * @param cb_data Data for the callback function. Can be NULL. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or * SR_ERR_MALLOC upon memory allocation errors. */ SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout, sr_receive_data_callback_t cb, const struct sr_dev_inst *sdi) { return _sr_session_source_add(pollfd, timeout, cb, sdi, (gintptr)pollfd); }