stdout.c: Add a flag to activate buffer tree API.
[paraslash.git] / stdout.c
index 87bf711f0d7a3794b7a6539c698a44457e984c28..4e3b6df9a2582e168c9f144aec44088eb9bc99cc 100644 (file)
--- a/stdout.c
+++ b/stdout.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -8,9 +8,9 @@
 
 #include <dirent.h> /* readdir() */
 #include <assert.h>
+#include <stdbool.h>
 
 #include "para.h"
-#include "string.h"
 #include "list.h"
 #include "sched.h"
 #include "fd.h"
@@ -68,14 +68,14 @@ static void stdout_post_select(struct sched *s, struct task *t)
        }
        if (!FD_ISSET(STDOUT_FILENO, &s->wfds))
                return;
-       ret = write(STDOUT_FILENO, sot->buf, *sot->loaded);
+       ret = write(STDOUT_FILENO, *sot->bufp, *sot->loaded);
        if (ret < 0) {
                t->error = -ERRNO_TO_PARA_ERROR(errno);
                return;
        }
        *sot->loaded -= ret;
        if (*sot->loaded)
-               memmove(sot->buf, sot->buf + ret, *sot->loaded);
+               memmove(*sot->bufp, *sot->bufp + ret, *sot->loaded);
 }
 
 /**
@@ -90,6 +90,7 @@ void stdout_set_defaults(struct stdout_task *sot)
 {
        int ret;
 
+       sot->use_buffer_tree = false;
        sot->task.pre_select = stdout_pre_select;
        sot->task.post_select = stdout_post_select;
        sprintf(sot->task.status, "stdout writer");