]> git.tue.mpg.de Git - paraslash.git/commitdiff
write: Parse command line options also in btr mode.
authorAndre Noll <maan@systemlinux.org>
Thu, 31 Dec 2009 15:18:35 +0000 (16:18 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 31 Dec 2009 15:18:35 +0000 (16:18 +0100)
write.c

diff --git a/write.c b/write.c
index b92dd972e88051dcb0f1a5159cfbed0504615e62..def31334e5f89c0efc46055b8b28171a6107f614 100644 (file)
--- a/write.c
+++ b/write.c
@@ -282,10 +282,9 @@ __noreturn static void print_help_and_die(void)
  */
 static int main_btr(struct sched *s)
 {
-       struct writer_node *wn = para_malloc(sizeof(*wn));
-       struct writer *w = writers + DEFAULT_WRITER;
-       int ret;
+       int i, ret;
        struct check_wav_task_btr _cwt, *cwt = &_cwt;
+       struct writer_node **wns;
 
        sit.btrn = btr_new_node("stdin", NULL /* stdin has no parent */, NULL, NULL);
        stdin_set_defaults(&sit);
@@ -296,23 +295,43 @@ static int main_btr(struct sched *s)
        sprintf(cwt->task.status, "check wav");
        cwt->task.pre_select = check_wav_pre_select_btr;
        cwt->task.post_select = check_wav_post_select_btr;
+       cwt->task.error = 0;
        register_task(&cwt->task);
 
-       wn->writer_num = DEFAULT_WRITER;
-       wn->conf = writers[DEFAULT_WRITER].parse_config("-B");
-       wn->btrn = btr_new_node("writer", cwt->btrn, NULL, NULL);
-       sprintf(wn->task.status, "some writer");
-       w->open(wn);
-       wn->task.post_select = w->post_select_btr;
-       wn->task.pre_select = w->pre_select_btr;
-       register_task(&wn->task);
-
+       wns = para_malloc(conf.writer_given * sizeof(*wns));
 
+       for (i = 0; i < conf.writer_given; i++) {
+               struct writer_node *wn = para_calloc(sizeof(*wn));
+               struct writer *w;
+               const char *name;
+
+               ret = -E_WRITE_SYNTAX;
+               wn->conf = check_writer_arg(conf.writer_arg[i],
+                       &wn->writer_num);
+               if (!wn->conf)
+                       goto out;
+               w = writers + wn->writer_num;
+               name = writer_names[wn->writer_num];
+               wn->btrn = btr_new_node(name, cwt->btrn, w->execute, wn);
+               sprintf(wn->task.status, "%s", name);
+               w->open(wn);
+               wn->task.post_select = w->post_select_btr;
+               wn->task.pre_select = w->pre_select_btr;
+               register_task(&wn->task);
+               wns[i] = wn;
+       }
+       i--;
 
        s->default_timeout.tv_sec = 10;
        s->default_timeout.tv_usec = 50000;
        ret = schedule(s);
-       w->close(wn);
+out:
+       for (; i >= 0; i--) {
+               struct writer_node *wn = wns[i];
+               free(wn->conf);
+               free(wn);
+       }
+       free(wns);
        return ret;
 }