static void handle_fd0(Dispatcher *dis, int fd, void *udata) { char buffer[16]; int count = read(fd, buffer, sizeof(buffer)); make_sure_that(count == 4); make_sure_that(strncmp(buffer, "Hoi!", 4) == 0); disClose(dis); }
/* * Clear the contents of <dis> but don't free <dis> itself. */ void disClear(Dispatcher *dis) { disClose(dis); memset(dis, 0, sizeof(Dispatcher)); }
/* * Clear the contents of <dis> and then free <dis> itself. Do not call this from inside the disRun() * loop. Instead, call disClose(), wait for disRun() to return and then call disDestroy(). */ void disDestroy(Dispatcher *dis) { disClose(dis); /* Just to be sure. */ free(dis); }
/* * Close the network server <ns>. This removes all file descriptors and timers, which will cause * nsRun() to return. */ void nsClose(NS *ns) { disClose((Dispatcher *) ns); }