int main() { watch_read(); g_temp = g_watch_me_read; watch_write(); g_watch_me_write = g_temp; return 0; }
EXPORTNOT int ekg_write(int fd, const char *buf, int len) { watch_t *wl = NULL; list_t l; if (fd == -1) return -1; /* first check if we have watch for this fd */ for (l = watches; l; l = l->next) { watch_t *w = l->data; if (w && w->fd == fd && w->type == WATCH_WRITE && w->buf) { wl = w; break; } } if (!wl) { /* if we have no watch, let's create it. */ /* XXX, first try write() ? */ wl = watch_add(NULL, fd, WATCH_WRITE_LINE, NULL, NULL); } return watch_write(wl, buf, len); }