Revision 54b631d9 output.c

View differences:

output.c
6 6

  
7 7
#include <chunk.h>
8 8

  
9
#include "out-stream.h"
9 10
#include "dbg.h"
10 11

  
11 12
#define SIZE 8
12 13

  
13 14
static int next_chunk;
14
static int outfd = 1;
15 15
static int buff_size = SIZE;
16 16

  
17 17
static struct {
......
22 22

  
23 23
void buffer_free(int i)
24 24
{
25
#ifdef DEBUG
26
  fprintf(stderr, "\t\tFlush Buf %d: %s\n", i, buff[i].data);
27
#else
28
  write(outfd, buff[i].data, buff[i].size);
29
#endif
25
  dprintf(stderr, "\t\tFlush Buf %d: %s\n", i, buff[i].data);
26
  chunk_write(i, buff[i].data, buff[i].size);
30 27
  free(buff[i].data);
31 28
  buff[i].data = NULL;
32 29
  dprintf("Next Chunk: %d -> %d\n", next_chunk, buff[i].id + 1);
......
72 69

  
73 70
  dprintf("%d == %d?\n", c->id, next_chunk);
74 71
  if (c->id == next_chunk) {
75
#ifdef DEBUG
76
    fprintf(stderr, "\tOut Chunk[%d] - %d: %s\n", c->id, c->id % buff_size, c->data);
77
#else
78
    write(outfd, c->data, c->size);
79
#endif
72
    chunk_write(c->id, c->data, c->size);
80 73
    next_chunk++;
81 74
    buffer_flush(next_chunk);
82 75
  } else {

Also available in: Unified diff