/* register a write handler */ static void register_write_handler(int fd, void (*fp)(int, void *), void *data) { int i; /* register our interest in this descriptor */ register_poll(POLLOUT, fd); /* if it's already in the list, just update the handler */ for (i = 0; i < nwhand; i++) { if (whand[i].fd == fd) { whand[i].handler = fp; whand[i].data = data; return; } } /* else add it to the list */ if (maxwhand == 0) { maxwhand++; whand = malloc(sizeof(struct handler_entry)); } else if (nwhand + 1 > maxwhand) { maxwhand++; whand = realloc(whand, sizeof(struct handler_entry) * maxwhand); } whand[nwhand].fd = fd; whand[nwhand].handler = fp; whand[nwhand].data = data; nwhand++; }
static int __uloop_fd_delete(struct uloop_fd *fd) { return register_poll(fd, 0); }
void timer_init() { register_poll(timer_poll); }