Commit ebae0d9b authored by Anders Blomdell's avatar Anders Blomdell
Browse files

More changes to facilitate reader/writer stacking.

parent 9ba10d17
......@@ -364,7 +364,7 @@ struct labcomm_encoder *labcomm_encoder_new(
result->lock = lock;
result->on_error = on_error_fprintf;
result->writer->action->alloc(result->writer,result->writer->context,
LABCOMM_VERSION);
result, LABCOMM_VERSION);
}
return result;
}
......@@ -572,7 +572,7 @@ struct labcomm_decoder *labcomm_decoder_new(
result->on_error = on_error_fprintf;
result->on_new_datatype = on_new_datatype;
result->reader->action->alloc(result->reader, result->reader->context,
LABCOMM_VERSION);
result, LABCOMM_VERSION);
}
return result;
}
......@@ -625,7 +625,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
struct labcomm_sample_entry *entry = NULL;
int index, err;
writer.action->alloc(&writer, writer.context, "");
writer.action->alloc(&writer, writer.context, NULL, "");
writer.action->start(&writer, writer.context, NULL, 0, NULL, NULL);
index = labcomm_read_packed32(d->reader); //int
signature.name = labcomm_read_string(d->reader);
......
......@@ -7,6 +7,7 @@
#include "labcomm_dynamic_buffer_writer.h"
static int dyn_alloc(struct labcomm_writer *w, void *context,
struct labcomm_encoder *encoder,
char *labcomm_version)
{
w->data_size = 1000;
......
......@@ -13,7 +13,9 @@ struct labcomm_fd_reader {
int close_fd_on_free;
};
static int fd_alloc(struct labcomm_reader *r, void *context, char *version)
static int fd_alloc(struct labcomm_reader *r, void *context,
struct labcomm_decoder *decoder,
char *version)
{
int result = 0;
......
......@@ -16,7 +16,9 @@ struct labcomm_fd_writer {
static int fd_flush(struct labcomm_writer *w, void *context);
static int fd_alloc(struct labcomm_writer *w, void *context, char *version)
static int fd_alloc(struct labcomm_writer *w, void *context,
struct labcomm_encoder *encoder,
char *version)
{
w->data = malloc(BUFFER_SIZE);
if (! w->data) {
......
......@@ -71,7 +71,8 @@ typedef void (*labcomm_decoder_function)(
void *context);
struct labcomm_reader_action {
int (*alloc)(struct labcomm_reader *r, void *context, char *labcomm_version);
int (*alloc)(struct labcomm_reader *r, void *context,
struct labcomm_decoder *decoder, char *labcomm_version);
int (*free)(struct labcomm_reader *r, void *context);
int (*start)(struct labcomm_reader *r, void *context);
int (*end)(struct labcomm_reader *r, void *context);
......@@ -196,7 +197,8 @@ typedef int (*labcomm_encoder_function)(
struct labcomm_writer;
struct labcomm_writer_action {
int (*alloc)(struct labcomm_writer *w, void *context, char *labcomm_version);
int (*alloc)(struct labcomm_writer *w, void *context,
struct labcomm_encoder *encoder, char *labcomm_version);
int (*free)(struct labcomm_writer *w, void *context);
int (*start)(struct labcomm_writer *w, void *context,
struct labcomm_encoder *encoder,
......
......@@ -12,6 +12,7 @@ static unsigned char buffer[128];
struct labcomm_writer *writer;
static int buf_writer_alloc(struct labcomm_writer *w, void *context,
struct labcomm_encoder *encoder,
char *labcomm_version)
{
writer = w; /* Hack */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment