Commit 1279cb03 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

c decoder still skips pragma, decoding is wip, see comment

parent 2720b0d8
...@@ -27,6 +27,7 @@ OBJS=labcomm_memory.o \ ...@@ -27,6 +27,7 @@ OBJS=labcomm_memory.o \
labcomm.o \ labcomm.o \
labcomm_dynamic_buffer_writer.o \ labcomm_dynamic_buffer_writer.o \
labcomm_fd_reader.o labcomm_fd_writer.o \ labcomm_fd_reader.o labcomm_fd_writer.o \
labcomm_bytearray_reader.o \
labcomm_pthread_scheduler.o labcomm_pthread_scheduler.o
#FIXME: labcomm_mem_reader.o labcomm_mem_writer.o #FIXME: labcomm_mem_reader.o labcomm_mem_writer.o
......
...@@ -34,9 +34,15 @@ struct labcomm_bytearray_reader { ...@@ -34,9 +34,15 @@ struct labcomm_bytearray_reader {
int bytearray_size; int bytearray_size;
}; };
#if 0
// XXX HERE BE DRAGONS: version removed?
static int bytearray_alloc(struct labcomm_reader *r, static int bytearray_alloc(struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context, struct labcomm_reader_action_context *action_context,
char *version) char *version)
#else
static int bytearray_alloc(struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context)
#endif
{ {
int result = 0; int result = 0;
......
...@@ -233,6 +233,7 @@ out: ...@@ -233,6 +233,7 @@ out:
static int decoder_skip(struct labcomm_decoder *d, int len) static int decoder_skip(struct labcomm_decoder *d, int len)
{ {
int i; int i;
printf("skipping %d bytes\n", len);
for(i = 0; i <len; i++){ for(i = 0; i <len; i++){
labcomm_read_byte(d->reader); labcomm_read_byte(d->reader);
if (d->reader->error < 0) { if (d->reader->error < 0) {
...@@ -252,6 +253,7 @@ static int decode_pragma(struct labcomm_decoder *d, int len) ...@@ -252,6 +253,7 @@ static int decode_pragma(struct labcomm_decoder *d, int len)
} }
int bytes = labcomm_size_string(pragma_type); int bytes = labcomm_size_string(pragma_type);
int psize = len-bytes; int psize = len-bytes;
printf("got pragma: %s\n", pragma_type);
if(0 /*d->pragma_handler*/) { if(0 /*d->pragma_handler*/) {
//read the entire packet to a buffer and then run //read the entire packet to a buffer and then run
// decode on that through a bytearray_reader. // decode on that through a bytearray_reader.
...@@ -265,11 +267,15 @@ static int decode_pragma(struct labcomm_decoder *d, int len) ...@@ -265,11 +267,15 @@ static int decode_pragma(struct labcomm_decoder *d, int len)
goto out; goto out;
} }
} }
printf("read %d bytes\n", psize);
//TODO: add wrapped decoders, and create pragma decoder that does not
// expect a version packet
struct labcomm_reader *pr = labcomm_bytearray_reader_new( struct labcomm_reader *pr = labcomm_bytearray_reader_new(
d->reader->memory, pragma_data, psize); d->reader->memory, pragma_data, psize);
struct labcomm_decoder *pd = labcomm_decoder_new( struct labcomm_decoder *pd = labcomm_decoder_new(
pr, d->error, d->memory, d->scheduler); pr, d->error, d->memory, d->scheduler);
/* d->prama_handler(pd, ptype, plen); */ /* d->prama_handler(pd, ptype, plen); */
labcomm_decoder_run(pd);
internal_labcomm_decoder_free(pd); internal_labcomm_decoder_free(pd);
result = 0; result = 0;
......
Markdown is supported
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