- int i, ret = -E_WRITE_SYNTAX;
- struct writer_node_group *g = NULL;
- struct initial_delay_task *idt = &the_initial_delay_task;
-
- loglevel = get_loglevel_by_name(conf.loglevel_arg);
- if (conf.start_time_given) {
- long unsigned sec, usec;
- if (sscanf(conf.start_time_arg, "%lu:%lu",
- &sec, &usec) != 2)
- goto out;
- idt->start_time.tv_sec = sec;
- idt->start_time.tv_usec = usec;
+ int i, n, ret, writer_given = OPT_GIVEN(WRITER, lpr);
+ struct btr_node *cw_btrn;
+ struct writer_node *wns;
+ static struct sched s;
+ struct wav_params wp;
+ struct write_task wt;
+
+ sit.btrn = btr_new_node(&(struct btr_node_description)
+ EMBRACE(.name = "stdin"));
+ stdin_task_register(&sit, &s);
+
+ LLS_COPY_WAV_PARMS(&wp, LSG_WRITE_PARA_WRITE, lpr);
+ wt.cwc = check_wav_init(sit.btrn, NULL, &wp, &cw_btrn);
+ wt.task = task_register(&(struct task_info) {
+ .name = "write",
+ .pre_select = write_pre_select,
+ .post_select = write_post_select,
+ .context = &wt,
+ }, &s);
+
+ n = writer_given? writer_given : 1;
+ wns = para_calloc(n * sizeof(*wns));
+ for (i = 0; i < n; i++) {
+ const char *arg = i < writer_given?
+ lls_string_val(i, OPT_RESULT(WRITER, lpr)) : NULL;
+ wns[i].wid = check_writer_arg_or_die(arg, &wns[i].lpr);
+ register_writer_node(wns + i, cw_btrn, &s);