mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[select] Introduced get_handler_data
This commit is contained in:
parent
7fa9c6f7d9
commit
2e2737e6de
@ -377,13 +377,22 @@ get_handler(int fd, enum select_handler_type tp)
|
||||
case SELECT_HANDLER_READ: return threads[fd].read_func;
|
||||
case SELECT_HANDLER_WRITE: return threads[fd].write_func;
|
||||
case SELECT_HANDLER_ERROR: return threads[fd].error_func;
|
||||
case SELECT_HANDLER_DATA: return (select_handler_T)threads[fd].data;
|
||||
}
|
||||
|
||||
INTERNAL("get_handler: bad type %d", tp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *
|
||||
get_handler_data(int fd)
|
||||
{
|
||||
if (fd >= w_max) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return threads[fd].data;
|
||||
}
|
||||
|
||||
void
|
||||
set_handlers(int fd, select_handler_T read_func, select_handler_T write_func,
|
||||
select_handler_T error_func, void *data)
|
||||
|
@ -28,12 +28,13 @@ enum select_handler_type {
|
||||
SELECT_HANDLER_READ,
|
||||
SELECT_HANDLER_WRITE,
|
||||
SELECT_HANDLER_ERROR,
|
||||
SELECT_HANDLER_DATA,
|
||||
};
|
||||
|
||||
/* Get a registered select handler. */
|
||||
select_handler_T get_handler(int fd, enum select_handler_type type);
|
||||
|
||||
void *get_handler_data(int fd);
|
||||
|
||||
/* Set handlers and callback @data for the @fd descriptor. */
|
||||
void set_handlers(int fd,
|
||||
select_handler_T read_handler,
|
||||
|
@ -99,7 +99,7 @@ itrm_queue_write(struct itrm *itrm)
|
||||
get_handler(itrm->out.sock, SELECT_HANDLER_READ),
|
||||
NULL,
|
||||
get_handler(itrm->out.sock, SELECT_HANDLER_ERROR),
|
||||
get_handler(itrm->out.sock, SELECT_HANDLER_DATA));
|
||||
get_handler_data(itrm->out.sock));
|
||||
} else {
|
||||
assert(itrm->out.queue.len > 0);
|
||||
memmove(itrm->out.queue.data, itrm->out.queue.data + written, itrm->out.queue.len);
|
||||
|
Loading…
Reference in New Issue
Block a user