Statistics
| Branch: | Revision:

streamers / input.c @ 72f8e6fe

History | View | Annotate | Download (879 Bytes)

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

    
6
#include <chunk.h>
7

    
8
#include "input.h"
9
#include "input-stream.h"
10
#include "dbg.h"
11

    
12
struct input_desc {
13
  struct input_stream *s;
14
  int id;
15
};
16

    
17
struct input_desc *input_open(const char *fname)
18
{
19
  struct input_desc *res;
20

    
21
  res = malloc(sizeof(struct input_desc));
22
  if (res == NULL) {
23
    return NULL;
24
  }
25
  res->id = 0;
26
  res->s = input_stream_open(fname);
27
  if (res->s == NULL) {
28
    free(res);
29
    res = NULL;
30
  }
31

    
32
  return res;
33
}
34

    
35
void input_close(struct input_desc *s)
36
{
37
  input_stream_close(s->s);
38
  free(s);
39
}
40

    
41
int input_get(struct input_desc *s, struct chunk *c)
42
{
43
  c->data = chunkise(s->s, s->id, &c->size, &c->timestamp);
44
  c->id = s->id++;
45
  c->attributes_size = 0;
46
  c->attributes = NULL;
47

    
48
  dprintf("Generate Chunk[%d] (TS: %llu): %s\n", c->id, c->timestamp, c->data);
49

    
50
  return 1;
51
}
52