t->ret = 1; /* success */
}
+static void stdin_default_event_handler(struct task *t)
+{
+ PARA_NOTICE_LOG("%p: %s\n", t, PARA_STRERROR(-t->ret));
+ unregister_task(t);
+}
+
void stdin_post_select(struct sched *s, struct task *t)
{
struct stdin_task *sit = t->private_data;
sit->loaded += ret;
t->ret = ret;
} else
- t->ret = 0;
- if (ret <= 0)
+ t->ret = -E_STDIN_EOF;
+ if (t->ret < 0)
sit->eof = 1;
- sprintf(t->status,
- "%p stdin reader: loaded = %d, ret = %d",
- sit, sit->loaded, t->ret);
+}
+
+void stdin_set_defaults(struct stdin_task *sit)
+{
+ sit->bufsize = 16 * 1024,
+ sit->loaded = 0,
+ sit->eof = 0,
+ sit->task.flags = 0,
+ sit->task.pre_select = stdin_pre_select;
+ sit->task.post_select = stdin_post_select;
+ sit->task.event_handler = stdin_default_event_handler;
+ sit->task.private_data = sit;
+ sprintf(sit->task.status, "stdin reader");
}