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 34cea48c6a81ab2d7d6743e28706181415362824..818175a4ebb56117e58843844edca6b092cced48 100644 (file)
--- a/write.c
+++ b/write.c
@@ -9,6 +9,7 @@
 #include <regex.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <regex.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <stdbool.h>
 
 #include "para.h"
 #include "string.h"
 
 #include "para.h"
 #include "string.h"
@@ -21,6 +22,7 @@
 #include "write_common.h"
 #include "fd.h"
 #include "error.h"
 #include "write_common.h"
 #include "fd.h"
 #include "error.h"
+#include "buffer_tree.h"
 
 INIT_WRITE_ERRLISTS;
 
 
 INIT_WRITE_ERRLISTS;
 
@@ -179,6 +181,37 @@ __noreturn static void print_help_and_die(void)
        exit(0);
 }
 
        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.
  *
 /**
  * Para_write's main function.
  *
@@ -203,6 +236,10 @@ int main(int argc, char *argv[])
        if (conf.help_given || conf.detailed_help_given)
                print_help_and_die();
 
        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;
        wng = check_args();
        if (!wng)
                goto out;