Statistics
| Branch: | Revision:

grapes / src / Chunkiser / output-stream.c @ fd1d8d92

History | View | Annotate | Download (793 Bytes)

1
#include <stdint.h>
2
#include <stdlib.h>
3
#include <string.h>
4

    
5
#include "chunk.h"
6
#include "config.h"
7
#include "chunkiser.h"
8
#include "dechunkiser_iface.h"
9

    
10
extern struct dechunkiser_iface out_avf;
11
extern struct dechunkiser_iface out_raw;
12
static struct dechunkiser_iface *out;
13

    
14
struct output_stream *out_stream_init(const char *fname, const char *config)
15
{
16
  struct tag *cfg_tags;
17

    
18
#ifdef AVF
19
  out = &out_avf;
20
#else
21
  out = &out_raw;
22
#endif
23
  cfg_tags = config_parse(config);
24

    
25
  if (cfg_tags) {
26
    const char *type;
27

    
28
    type = config_value_str(cfg_tags, "dechunkiser");
29
    if (type && !strcmp(type, "raw")) {
30
      out = &out_raw;
31
    }
32
  }
33

    
34
  return out->open(fname, config);
35
}
36

    
37
void chunk_write(struct output_stream *o, const struct chunk *c)
38
{
39
  out->write(o, c->id, c->data, c->size);
40
}