* 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_E
| 435 | * SR_ERR_MALLOC upon memory allocation errors. |
| 436 | */ |
| 437 | SR_PRIV int sr_session_source_add_channel(GIOChannel *channel, int events, |
| 438 | int timeout, sr_receive_data_callback_t cb, const struct sr_dev_inst *sdi) |
| 439 | { |
| 440 | GPollFD p; |
| 441 | |
| 442 | #ifdef _WIN32 |
| 443 | g_io_channel_win32_make_pollfd(channel, events, &p); |
| 444 | #else |
| 445 | p.fd = g_io_channel_unix_get_fd(channel); |
| 446 | p.events = events; |
| 447 | #endif |
| 448 | |
| 449 | return _sr_session_source_add(&p, timeout, cb, sdi, (gintptr)channel); |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Remove the source belonging to the specified channel. |
nothing calls this directly
no test coverage detected