X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=stdin.c;h=22f1dd97b2bb6b18d028b890dd6b73eab73fa567;hp=6b9c80988b365c76fe77e8a470004e2398739d5f;hb=899a19c03fc05f6fd98687e3eaa86841a4633a10;hpb=0610638110061ff05670a6c497b371bf2e1d4d0f diff --git a/stdin.c b/stdin.c index 6b9c8098..22f1dd97 100644 --- a/stdin.c +++ b/stdin.c @@ -14,6 +14,12 @@ void stdin_pre_select(struct sched *s, struct task *t) 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; @@ -31,10 +37,20 @@ void stdin_post_select(struct sched *s, struct task *t) 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"); }