]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - write.c
buffer_tree: Add code to splice out a node of the buffer tree.
[paraslash.git] / write.c
diff --git a/write.c b/write.c
index cc1f716f8a962de165f93d0f090d21e591a43b11..818175a4ebb56117e58843844edca6b092cced48 100644 (file)
--- a/write.c
+++ b/write.c
@@ -6,8 +6,10 @@
 
 /** \file write.c Paraslash's standalone wav/raw player. */
 
+#include <regex.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <stdbool.h>
 
 #include "para.h"
 #include "string.h"
@@ -20,6 +22,7 @@
 #include "write_common.h"
 #include "fd.h"
 #include "error.h"
+#include "buffer_tree.h"
 
 INIT_WRITE_ERRLISTS;
 
@@ -153,7 +156,7 @@ static struct writer_node_group *check_args(void)
                        conf.writer_arg[i], &writer_num);
                if (!g->writer_nodes[i].conf)
                        goto out;
-               g->writer_nodes[i].writer = &writers[writer_num];
+               g->writer_nodes[i].writer_num = writer_num;
        }
        ret = 1;
 out:
@@ -178,6 +181,37 @@ __noreturn static void print_help_and_die(void)
        exit(0);
 }
 
+/*
+ TODO: check wav, initial delay, multiple writers, non-default writers
+ */
+static int main_btr(struct sched *s)
+{
+       struct writer_node *wn = para_malloc(sizeof(*wn));
+       struct writer *w = writers + DEFAULT_WRITER;
+       int ret;
+
+       sit.btrn = btr_new_node("stdin", NULL /* stdin has no parent */, NULL);
+       stdin_set_defaults(&sit);
+       register_task(&sit.task);
+
+       wn->writer_num = DEFAULT_WRITER;
+       wn->conf = writers[DEFAULT_WRITER].parse_config("-B");
+       wn->btrn = btr_new_node("writer", sit.btrn, 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);
+
+
+
+       s->default_timeout.tv_sec = 10;
+       s->default_timeout.tv_usec = 50000;
+       ret = schedule(s);
+       w->close(wn);
+       return ret;
+}
+
 /**
  * Para_write's main function.
  *
@@ -202,6 +236,10 @@ int main(int argc, char *argv[])
        if (conf.help_given || conf.detailed_help_given)
                print_help_and_die();
 
+       if (conf.buffer_tree_given) {
+               ret = main_btr(&s);
+               goto out;
+       }
        wng = check_args();
        if (!wng)
                goto out;