grapes / src / Chunkiser / input-stream-dummy.c @ fcc01ba5
History | View | Annotate | Download (880 Bytes)
1 |
/*
|
---|---|
2 |
* Copyright (c) 2010 Luca Abeni
|
3 |
*
|
4 |
* This is free software; see gpl-3.0.txt
|
5 |
*/
|
6 |
|
7 |
#include <stdint.h> |
8 |
#include <stdlib.h> |
9 |
#include <string.h> |
10 |
#include <stdio.h> |
11 |
|
12 |
#include "chunkiser_iface.h" |
13 |
|
14 |
struct chunkiser_ctx {
|
15 |
char buff[80]; |
16 |
}; |
17 |
|
18 |
static struct chunkiser_ctx *open(const char *fname, int *period, const char *config) |
19 |
{ |
20 |
fprintf(stderr, "WARNING: This is a dummy chunkiser, only good for debugging! Do not expect anything good from it!\n");
|
21 |
*period = 40000;
|
22 |
return malloc(sizeof(struct chunkiser_ctx)); |
23 |
} |
24 |
|
25 |
static void close(struct chunkiser_ctx *s) |
26 |
{ |
27 |
free(s); |
28 |
} |
29 |
|
30 |
static uint8_t *chunkise(struct chunkiser_ctx *s, int id, int *size, uint64_t *ts) |
31 |
{ |
32 |
sprintf(s->buff, "Chunk %d", id);
|
33 |
*ts = 40 * id * 1000; |
34 |
*size = strlen(s->buff); |
35 |
|
36 |
return strdup(s->buff);
|
37 |
} |
38 |
|
39 |
struct chunkiser_iface in_dummy = {
|
40 |
.open = open, |
41 |
.close = close, |
42 |
.chunkise = chunkise, |
43 |
}; |
44 |
|