diff --git a/compiler/C_CodeGen.jrag b/compiler/C_CodeGen.jrag
index a6f54aec44e438906e98893c78ec8d8f7b69a5ea..65f8a2dab9e449651bedac5c96fb6e7daa985733 100644
--- a/compiler/C_CodeGen.jrag
+++ b/compiler/C_CodeGen.jrag
@@ -443,7 +443,7 @@ aspect C_Decoder {
env = env.nestStruct("v");
env.println("static void decode_" + getName() + "(");
env.indent();
- env.println("labcomm_decoder_t *d,");
+ env.println("struct labcomm_decoder *d,");
env.println("void (*handle)(");
env.indent();
env.println(env.prefix + getName() + " *v,");
@@ -637,8 +637,8 @@ aspect C_Decoder {
env.indent();
env.println("d,");
env.println("&labcomm_signature_" + env.prefix + getName() + ",");
- env.println("(labcomm_decoder_typecast_t)decode_" + getName() + ",");
- env.println("(labcomm_handler_typecast_t)handler,");
+ env.println("(labcomm_decoder_function)decode_" + getName() + ",");
+ env.println("(labcomm_handler_function)handler,");
env.println("context");
env.unindent();
env.println(");");
@@ -700,7 +700,7 @@ aspect C_Encoder {
env = env.nestStruct("(*v)");
env.println("static int encode_" + getName() + "(");
env.indent();
- env.println("labcomm_encoder_t *e,");
+ env.println("struct labcomm_encoder *e,");
env.println(env.prefix + getName() + " *v");
env.unindent();
env.println(")");
@@ -714,7 +714,7 @@ aspect C_Encoder {
// Typesafe encode wrapper
env.println("int labcomm_encode_" + env.prefix + getName() + "(");
- env.println("labcomm_encoder_t *e,");
+ env.println("struct labcomm_encoder *e,");
env.println(env.prefix + getName() + " *v");
env.unindent();
env.println(")");
@@ -905,7 +905,7 @@ aspect C_Signature {
env.prefix + getName() + ") = {");
env.indent();
env.println("LABCOMM_SAMPLE, \"" + getName() + "\",");
- env.println("(int (*)(labcomm_signature_t *, void *))labcomm_sizeof_" +
+ env.println("(int (*)(struct labcomm_signature *, void *))labcomm_sizeof_" +
env.prefix + getName() + ",");
env.println("sizeof(signature_bytes_" + getName() + "),");
env.println("signature_bytes_"+ getName());
@@ -1003,7 +1003,7 @@ aspect C_Sizeof {
public void SampleDecl.C_emitSizeofDeclaration(C_env env) {
env.println("extern int labcomm_sizeof_" + env.prefix + getName() +
- "(labcomm_signature_t *sig, " + env.prefix + getName() + " *v);");
+ "(struct labcomm_signature *sig, " + env.prefix + getName() + " *v);");
}
public int Decl.C_fixedSizeof() {
@@ -1064,7 +1064,7 @@ aspect C_Sizeof {
public void SampleDecl.C_emitSizeof(C_env env) {
env = env.nestStruct("(*v)");
env.println("int labcomm_sizeof_" + env.prefix + getName() +
- "(labcomm_signature_t *sig, " + env.prefix + getName() + " *v)");
+ "(struct labcomm_signature *sig, " + env.prefix + getName() + " *v)");
env.println("{");
env.indent();
if (C_isDynamic()) {
diff --git a/lib/c/labcomm.c b/lib/c/labcomm.c
index 30fadd8df1d29dc2aff2f998db5d8171811d2ff3..4c36cfdc9f733175be8bdb0cbbbb1a3a87af5454 100644
--- a/lib/c/labcomm.c
+++ b/lib/c/labcomm.c
@@ -36,33 +36,33 @@
#define LABCOMM_VERSION "LabComm2013"
-typedef struct labcomm_sample_entry {
+struct labcomm_sample_entry {
struct labcomm_sample_entry *next;
int index;
- labcomm_signature_t *signature;
- labcomm_decoder_typecast_t decoder;
- labcomm_handler_typecast_t handler;
+ struct labcomm_signature *signature;
+ labcomm_decoder_function decoder;
+ labcomm_handler_function handler;
labcomm_encoder_function encode;
void *context;
-} labcomm_sample_entry_t;
+};
#ifndef LABCOMM_ENCODER_LINEAR_SEARCH
-extern labcomm_signature_t labcomm_first_signature;
-extern labcomm_signature_t labcomm_last_signature;
+extern struct labcomm_signature labcomm_first_signature;
+extern struct labcomm_signature labcomm_last_signature;
#endif
-typedef struct labcomm_encoder_context {
+struct labcomm_encoder_context {
#ifdef LABCOMM_ENCODER_LINEAR_SEARCH
- labcomm_sample_entry_t *sample;
+ struct labcomm_sample_entry *sample;
int index;
#else
- labcomm_sample_entry_t *by_section;
+ struct labcomm_sample_entry *by_section;
#endif
-} labcomm_encoder_context_t;
+};
-typedef struct labcomm_decoder_context {
- labcomm_sample_entry_t *sample;
-} labcomm_decoder_context_t;
+struct labcomm_decoder_context {
+ struct labcomm_sample_entry *sample;
+};
void labcomm_register_error_handler_encoder(struct labcomm_encoder *encoder, labcomm_error_handler_callback callback)
{
@@ -109,7 +109,7 @@ void labcomm_decoder_register_new_datatype_handler(struct labcomm_decoder *d, la
d->on_new_datatype = on_new_datatype;
}
-int on_new_datatype(labcomm_decoder_t *d, labcomm_signature_t *sig)
+int on_new_datatype(struct labcomm_decoder *d, struct labcomm_signature *sig)
{
d->on_error(LABCOMM_ERROR_DEC_UNKNOWN_DATATYPE, 4, "%s(): unknown datatype '%s'\n", __FUNCTION__, sig->name);
return 0;
@@ -141,22 +141,22 @@ void on_error_fprintf(enum labcomm_error error_id, size_t nbr_va_args, ...)
}
-static labcomm_sample_entry_t *get_sample_by_signature_address(
- labcomm_sample_entry_t *head,
- labcomm_signature_t *signature)
+static struct labcomm_sample_entry *get_sample_by_signature_address(
+ struct labcomm_sample_entry *head,
+ struct labcomm_signature *signature)
{
- labcomm_sample_entry_t *p;
+ struct labcomm_sample_entry *p;
for (p = head ; p && p->signature != signature ; p = p->next) {
}
return p;
}
-static labcomm_sample_entry_t *get_sample_by_signature_value(
- labcomm_sample_entry_t *head,
- labcomm_signature_t *signature)
+static struct labcomm_sample_entry *get_sample_by_signature_value(
+ struct labcomm_sample_entry *head,
+ struct labcomm_signature *signature)
{
- labcomm_sample_entry_t *p;
+ struct labcomm_sample_entry *p;
for (p = head ; p ; p = p->next) {
if (p->signature->type == signature->type &&
p->signature->size == signature->size &&
@@ -169,11 +169,11 @@ static labcomm_sample_entry_t *get_sample_by_signature_value(
return p;
}
-static labcomm_sample_entry_t *get_sample_by_index(
- labcomm_sample_entry_t *head,
+static struct labcomm_sample_entry *get_sample_by_index(
+ struct labcomm_sample_entry *head,
int index)
{
- labcomm_sample_entry_t *p;
+ struct labcomm_sample_entry *p;
for (p = head ; p && p->index != index ; p = p->next) {
}
return p;
@@ -182,12 +182,12 @@ static labcomm_sample_entry_t *get_sample_by_index(
#ifdef LABCOMM_ENCODER_LINEAR_SEARCH
static int get_encoder_index_by_search(
- labcomm_encoder_t *e,
- labcomm_signature_t *s)
+ struct labcomm_encoder *e,
+ struct labcomm_signature *s)
{
int result = 0;
- labcomm_encoder_context_t *context = e->context;
- labcomm_sample_entry_t *sample = context->sample;
+ struct labcomm_encoder_context *context = e->context;
+ struct labcomm_sample_entry *sample = context->sample;
while (sample) {
if (sample->signature == s) { break; }
sample = sample->next;
@@ -201,8 +201,8 @@ static int get_encoder_index_by_search(
#else
static int get_encoder_index_by_section(
- labcomm_encoder_t *e,
- labcomm_signature_t *s)
+ struct labcomm_encoder *e,
+ struct labcomm_signature *s)
{
int result = -ENOENT;
if (&labcomm_first_signature <= s && s <= &labcomm_last_signature) {
@@ -214,8 +214,8 @@ static int get_encoder_index_by_section(
#endif
static int get_encoder_index(
- labcomm_encoder_t *e,
- labcomm_signature_t *s)
+ struct labcomm_encoder *e,
+ struct labcomm_signature *s)
{
#ifdef LABCOMM_ENCODER_LINEAR_SEARCH
return get_encoder_index_by_search(e, s);
@@ -225,7 +225,7 @@ static int get_encoder_index(
}
static void labcomm_encode_signature(struct labcomm_encoder *e,
- labcomm_signature_t *signature)
+ struct labcomm_signature *signature)
{
int i, index;
@@ -247,14 +247,14 @@ static void labcomm_encode_signature(struct labcomm_encoder *e,
#ifdef LABCOMM_ENCODER_LINEAR_SEARCH
static int encoder_add_signature_by_search(struct labcomm_encoder *e,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
labcomm_encoder_function encode)
{
int result;
- labcomm_encoder_context_t *context = e->context;
- labcomm_sample_entry_t *sample;
+ struct labcomm_encoder_context *context = e->context;
+ struct labcomm_sample_entry *sample;
- sample = (labcomm_sample_entry_t*)malloc(sizeof(labcomm_sample_entry_t));
+ sample = (struct labcomm_sample_entry *)malloc(sizeof(*sample));
if (sample == NULL) {
result = -ENOMEM;
} else {
@@ -272,14 +272,14 @@ static int encoder_add_signature_by_search(struct labcomm_encoder *e,
#ifndef LABCOMM_ENCODER_LINEAR_SEARCH
static int encoder_add_signature_by_section(struct labcomm_encoder *e,
- labcomm_signature_t *s,
+ struct labcomm_signature *s,
labcomm_encoder_function encode)
{
int result = -ENOENT;
if (&labcomm_first_signature <= s && s <= &labcomm_last_signature) {
/* Signature is in right linker section */
- labcomm_encoder_context_t *context = e->context;
+ struct labcomm_encoder_context *context = e->context;
int index = s - &labcomm_first_signature;
if (context->by_section == NULL) {
@@ -302,7 +302,7 @@ out:
#endif
static int encoder_add_signature(struct labcomm_encoder *e,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
labcomm_encoder_function encode)
{
int index = -ENOENT;
@@ -316,12 +316,12 @@ static int encoder_add_signature(struct labcomm_encoder *e,
}
/*
-static labcomm_sample_entry_t *encoder_get_sample_by_signature_address(
- labcomm_encoder_t *encoder,
- labcomm_signature_t *s)
+static struct labcomm_sample_entry *encoder_get_sample_by_signature_address(
+ struct labcomm_encoder *encoder,
+ struct labcomm_signature *s)
{
- labcomm_sample_entry_t *result = NULL;
- labcomm_encoder_context_t *context = encoder->context;
+ struct labcomm_sample_entry *result = NULL;
+ struct labcomm_encoder_context *context = encoder->context;
#ifndef LABCOMM_ENCODER_LINEAR_SEARCH
if (&labcomm_first_signature <= s && s <= &labcomm_last_signature) {
@@ -334,17 +334,17 @@ static labcomm_sample_entry_t *encoder_get_sample_by_signature_address(
}
*/
-labcomm_encoder_t *labcomm_encoder_new(
+struct labcomm_encoder *labcomm_encoder_new(
const struct labcomm_writer_action writer,
void *writer_context,
const struct labcomm_lock_action *lock,
void *lock_context)
{
- labcomm_encoder_t *result = malloc(sizeof(labcomm_encoder_t));
+ struct labcomm_encoder *result = malloc(sizeof(*result));
if (result) {
- labcomm_encoder_context_t *context;
+ struct labcomm_encoder_context *context;
- context = malloc(sizeof(labcomm_encoder_context_t));
+ context = malloc(sizeof(*context));
#ifdef LABCOMM_ENCODER_LINEAR_SEARCH
context->sample = NULL;
context->index = LABCOMM_USER;
@@ -369,8 +369,8 @@ labcomm_encoder_t *labcomm_encoder_new(
}
void labcomm_internal_encoder_register(
- labcomm_encoder_t *e,
- labcomm_signature_t *signature,
+ struct labcomm_encoder *e,
+ struct labcomm_signature *signature,
labcomm_encoder_function encode)
{
if (signature->type == LABCOMM_SAMPLE) {
@@ -394,8 +394,8 @@ void labcomm_internal_encoder_register(
}
int labcomm_internal_encode(
- labcomm_encoder_t *e,
- labcomm_signature_t *signature,
+ struct labcomm_encoder *e,
+ struct labcomm_signature *signature,
labcomm_encoder_function encode,
void *value)
{
@@ -415,14 +415,14 @@ no_end:
return result;
}
-void labcomm_encoder_free(labcomm_encoder_t* e)
+void labcomm_encoder_free(struct labcomm_encoder* e)
{
e->writer.action.free(&e->writer);
- labcomm_encoder_context_t *context = (labcomm_encoder_context_t *) e->context;
+ struct labcomm_encoder_context *context = (struct labcomm_encoder_context *) e->context;
#ifdef LABCOMM_ENCODER_LINEAR_SEARCH
- labcomm_sample_entry_t *entry = context->sample;
- labcomm_sample_entry_t *entry_next;
+ struct labcomm_sample_entry *entry = context->sample;
+ struct labcomm_sample_entry *entry_next;
while (entry != NULL) {
entry_next = entry->next;
free(entry);
@@ -453,7 +453,7 @@ int labcomm_encoder_ioctl(struct labcomm_encoder *encoder,
int labcomm_internal_encoder_ioctl(struct labcomm_encoder *encoder,
int action,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
va_list va)
{
int result = -ENOTSUP;
@@ -466,8 +466,8 @@ int labcomm_internal_encoder_ioctl(struct labcomm_encoder *encoder,
}
static void collect_flat_signature(
- labcomm_decoder_t *decoder,
- labcomm_encoder_t *signature_writer)
+ struct labcomm_decoder *decoder,
+ struct labcomm_encoder *signature_writer)
{
int type = labcomm_read_packed32(&decoder->reader);
if (type >= LABCOMM_USER) {
@@ -516,16 +516,16 @@ static void collect_flat_signature(
}
}
-labcomm_decoder_t *labcomm_decoder_new(
+struct labcomm_decoder *labcomm_decoder_new(
const struct labcomm_reader_action reader,
void *reader_context,
const struct labcomm_lock_action *lock,
void *lock_context)
{
- labcomm_decoder_t *result = malloc(sizeof(labcomm_decoder_t));
+ struct labcomm_decoder *result = malloc(sizeof(*result));
if (result) {
- labcomm_decoder_context_t *context =
- (labcomm_decoder_context_t*)malloc(sizeof(labcomm_decoder_context_t));
+ struct labcomm_decoder_context *context =
+ (struct labcomm_decoder_context *)malloc(sizeof(*context));
context->sample = 0;
result->context = context;
result->reader.data = 0;
@@ -545,18 +545,18 @@ labcomm_decoder_t *labcomm_decoder_new(
}
void labcomm_internal_decoder_register(
- labcomm_decoder_t *d,
- labcomm_signature_t *signature,
- labcomm_decoder_typecast_t type_decoder,
- labcomm_handler_typecast_t handler,
+ struct labcomm_decoder *d,
+ struct labcomm_signature *signature,
+ labcomm_decoder_function type_decoder,
+ labcomm_handler_function handler,
void *handler_context)
{
- labcomm_decoder_context_t *context = d->context;
- labcomm_sample_entry_t *sample;
+ struct labcomm_decoder_context *context = d->context;
+ struct labcomm_sample_entry *sample;
sample = get_sample_by_signature_address(context->sample,
signature);
if (!sample) {
- sample = (labcomm_sample_entry_t*)malloc(sizeof(labcomm_sample_entry_t));
+ sample = (struct labcomm_sample_entry *)malloc(sizeof(*sample));
sample->next = context->sample;
context->sample = sample;
sample->index = 0;
@@ -567,23 +567,23 @@ void labcomm_internal_decoder_register(
sample->context = handler_context;
}
-int labcomm_decoder_decode_one(labcomm_decoder_t *d)
+int labcomm_decoder_decode_one(struct labcomm_decoder *d)
{
int result;
do {
result = d->reader.action.start(&d->reader);
if (result > 0) {
- labcomm_decoder_context_t *context = d->context;
+ struct labcomm_decoder_context *context = d->context;
result = labcomm_read_packed32(&d->reader);
if (result == LABCOMM_TYPEDEF || result == LABCOMM_SAMPLE) {
/* TODO: should the labcomm_dynamic_buffer_writer be
a permanent part of labcomm_decoder? */
- labcomm_encoder_t *e = labcomm_encoder_new(
+ struct labcomm_encoder *e = labcomm_encoder_new(
labcomm_dynamic_buffer_writer, NULL, NULL, NULL);
- labcomm_signature_t signature;
- labcomm_sample_entry_t *entry = NULL;
+ struct labcomm_signature signature;
+ struct labcomm_sample_entry *entry = NULL;
int index, err;
index = labcomm_read_packed32(&d->reader); //int
@@ -624,7 +624,7 @@ int labcomm_decoder_decode_one(labcomm_decoder_t *d)
result = -ENOENT;
}
} else {
- labcomm_sample_entry_t *entry;
+ struct labcomm_sample_entry *entry;
entry = get_sample_by_index(context->sample, result);
if (!entry) {
@@ -644,18 +644,18 @@ int labcomm_decoder_decode_one(labcomm_decoder_t *d)
return result;
}
-void labcomm_decoder_run(labcomm_decoder_t *d)
+void labcomm_decoder_run(struct labcomm_decoder *d)
{
while (labcomm_decoder_decode_one(d) > 0) {
}
}
-void labcomm_decoder_free(labcomm_decoder_t* d)
+void labcomm_decoder_free(struct labcomm_decoder* d)
{
d->reader.action.free(&d->reader);
- labcomm_decoder_context_t *context = (labcomm_decoder_context_t *) d->context;
- labcomm_sample_entry_t *entry = context->sample;
- labcomm_sample_entry_t *entry_next;
+ struct labcomm_decoder_context *context = (struct labcomm_decoder_context *) d->context;
+ struct labcomm_sample_entry *entry = context->sample;
+ struct labcomm_sample_entry *entry_next;
while (entry != NULL) {
entry_next = entry->next;
@@ -685,7 +685,7 @@ int labcomm_decoder_ioctl(struct labcomm_decoder *decoder,
int labcomm_internal_decoder_ioctl(struct labcomm_decoder *decoder,
int action,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
va_list va)
{
int result = -ENOTSUP;
diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h
index c3d8a46530d87fb70af0b5819f41e23156a26c28..97eaa4a813136ae9c7bde788519b4957df333c0d 100644
--- a/lib/c/labcomm.h
+++ b/lib/c/labcomm.h
@@ -11,14 +11,14 @@ struct labcomm_decoder;
/*
* Signature entry
*/
-typedef struct labcomm_signature {
+struct labcomm_signature {
int type;
char *name;
int (*encoded_size)(struct labcomm_signature *, void *); // void * == encoded_sample *
int size;
unsigned char *signature;
int cached_encoded_size; // -1 if not initialized or type is variable size
-} labcomm_signature_t;
+};
/*
* Error handling.
@@ -71,7 +71,7 @@ const char *labcomm_error_get_str(enum labcomm_error error_id);
typedef int (*labcomm_handle_new_datatype_callback)(
struct labcomm_decoder *decoder,
- labcomm_signature_t *sig);
+ struct labcomm_signature *sig);
void labcomm_decoder_register_new_datatype_handler(struct labcomm_decoder *d,
labcomm_handle_new_datatype_callback on_new_datatype);
@@ -101,10 +101,10 @@ struct labcomm_reader_action {
int (*start)(struct labcomm_reader *r);
int (*end)(struct labcomm_reader *r);
int (*fill)(struct labcomm_reader *r);
- int (*ioctl)(struct labcomm_reader *r, int, labcomm_signature_t *, va_list);
+ int (*ioctl)(struct labcomm_reader *r, int, struct labcomm_signature *, va_list);
};
-typedef struct labcomm_reader {
+struct labcomm_reader {
void *context;
unsigned char *data;
int data_size;
@@ -113,7 +113,7 @@ typedef struct labcomm_reader {
int error;
struct labcomm_reader_action action;
labcomm_error_handler_callback on_error;
-} labcomm_reader_t;
+};
struct labcomm_decoder *labcomm_decoder_new(
const struct labcomm_reader_action reader,
@@ -142,15 +142,16 @@ struct labcomm_writer_action {
int (*free)(struct labcomm_writer *w);
int (*start)(struct labcomm_writer *w,
struct labcomm_encoder *encoder,
- int index,
- labcomm_signature_t *signature,
+ int index, struct labcomm_signature *signature,
void *value);
int (*end)(struct labcomm_writer *w);
int (*flush)(struct labcomm_writer *w);
- int (*ioctl)(struct labcomm_writer *w, int, labcomm_signature_t *, va_list);
+ int (*ioctl)(struct labcomm_writer *w,
+ int index, struct labcomm_signature *,
+ va_list);
};
-typedef struct labcomm_writer {
+struct labcomm_writer {
void *context;
unsigned char *data;
int data_size;
@@ -159,7 +160,7 @@ typedef struct labcomm_writer {
int error;
struct labcomm_writer_action action;
labcomm_error_handler_callback on_error;
-} labcomm_writer_t;
+};
struct labcomm_encoder *labcomm_encoder_new(
const struct labcomm_writer_action writer,
diff --git a/lib/c/labcomm_dynamic_buffer_writer.c b/lib/c/labcomm_dynamic_buffer_writer.c
index b03fae0906bbcef5a7ea6d30c46d22e96eae6888..b58a711b726afcf08e096bb693881f88b178dfac 100644
--- a/lib/c/labcomm_dynamic_buffer_writer.c
+++ b/lib/c/labcomm_dynamic_buffer_writer.c
@@ -31,7 +31,7 @@ static int dyn_free(struct labcomm_writer *w)
static int dyn_start(struct labcomm_writer *w,
struct labcomm_encoder *encoder,
int index,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
void *value)
{
void *tmp;
@@ -74,7 +74,7 @@ static int dyn_flush(struct labcomm_writer *w)
static int dyn_ioctl(struct labcomm_writer *w,
int action,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
va_list arg)
{
int result = -ENOTSUP;
diff --git a/lib/c/labcomm_fd_writer.c b/lib/c/labcomm_fd_writer.c
index 3c678691e419462c82e78f613af5e1d89d0a4dee..ce3d8bdf5bf7ebab8ab03fe06003cd5e95632197 100644
--- a/lib/c/labcomm_fd_writer.c
+++ b/lib/c/labcomm_fd_writer.c
@@ -43,7 +43,7 @@ static int fd_free(struct labcomm_writer *w)
static int fd_start(struct labcomm_writer *w,
struct labcomm_encoder *encoder,
int index,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
void *value)
{
w->pos = 0;
diff --git a/lib/c/labcomm_ioctl.h b/lib/c/labcomm_ioctl.h
index 04dff0fe7e42c9cb4d6c8f0b5d67bf0ed47377ba..984cd09eff41b70f6592ac8bfe809ed091f8c1b3 100644
--- a/lib/c/labcomm_ioctl.h
+++ b/lib/c/labcomm_ioctl.h
@@ -2,7 +2,7 @@
struct labcomm_ioctl_register_signature {
int index;
- labcomm_signature_t *signature;
+ struct labcomm_signature *signature;
};
#define LABCOMM_IOCTL_REGISTER_SIGNATURE 0x0001
diff --git a/lib/c/labcomm_private.h b/lib/c/labcomm_private.h
index ec7af91c1f2beda61f8c5363a98498211519a045..a1de8a8b1652589e42b2467d429b3043d371b8bd 100644
--- a/lib/c/labcomm_private.h
+++ b/lib/c/labcomm_private.h
@@ -42,49 +42,49 @@
*
*/
#define LABCOMM_DECLARE_SIGNATURE(name) \
- labcomm_signature_t name __attribute__((section("labcomm")))
+ struct labcomm_signature name __attribute__((section("labcomm")))
/*
* Semi private decoder declarations
*/
-typedef void (*labcomm_handler_typecast_t)(void *, void *);
+typedef void (*labcomm_handler_function)(void *value, void *context);
-typedef void (*labcomm_decoder_typecast_t)(
- struct labcomm_decoder *,
- labcomm_handler_typecast_t,
- void *);
+typedef void (*labcomm_decoder_function)(
+ struct labcomm_decoder *d,
+ labcomm_handler_function handler,
+ void *context);
-typedef struct labcomm_decoder {
+struct labcomm_decoder {
void *context;
- labcomm_reader_t reader;
+ struct labcomm_reader reader;
struct {
void *context;
const struct labcomm_lock_action *action;
} lock;
labcomm_error_handler_callback on_error;
labcomm_handle_new_datatype_callback on_new_datatype;
-} labcomm_decoder_t;
+};
/*
* Non typesafe registration function to be called from
* generated labcomm_decoder_register_* functions.
*/
void labcomm_internal_decoder_register(
- labcomm_decoder_t *,
- labcomm_signature_t *,
- labcomm_decoder_typecast_t,
- labcomm_handler_typecast_t,
+ struct labcomm_decoder *d,
+ struct labcomm_signature *s,
+ labcomm_decoder_function decoder,
+ labcomm_handler_function handler,
void *context);
int labcomm_internal_decoder_ioctl(struct labcomm_decoder *decoder,
int ioctl_action,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
va_list args);
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define LABCOMM_DECODE(name, type) \
- static inline type labcomm_read_##name(labcomm_reader_t *r) { \
+ static inline type labcomm_read_##name(struct labcomm_reader *r) { \
type result; int i; \
for (i = sizeof(type) - 1 ; i >= 0 ; i--) { \
if (r->pos >= r->count) { \
@@ -95,14 +95,14 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *decoder,
} \
return result; \
} \
- static inline type labcomm_decode_##name(labcomm_decoder_t *d) { \
+ static inline type labcomm_decode_##name(struct labcomm_decoder *d) { \
return labcomm_read_##name(&d->reader); \
}
#else
#define LABCOMM_DECODE(name, type) \
- static inline type labcomm_read_##name(labcomm_reader_t *r) { \
+ static inline type labcomm_read_##name(struct labcomm_reader *r) { \
type result; int i; \
for (i = 0 ; i < sizeof(type) ; i++) { \
if (r->pos >= r->count) { \
@@ -113,7 +113,7 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *decoder,
} \
return result; \
} \
- static inline type labcomm_decode_##name(labcomm_decoder_t *d) { \
+ static inline type labcomm_decode_##name(struct labcomm_decoder *d) { \
return labcomm_read_##name(&d->reader); \
}
@@ -127,7 +127,7 @@ LABCOMM_DECODE(long, long long)
LABCOMM_DECODE(float, float)
LABCOMM_DECODE(double, double)
-static inline unsigned int labcomm_read_packed32(labcomm_reader_t *r)
+static inline unsigned int labcomm_read_packed32(struct labcomm_reader *r)
{
unsigned int result = 0;
@@ -147,12 +147,12 @@ static inline unsigned int labcomm_read_packed32(labcomm_reader_t *r)
return result;
}
-static inline unsigned int labcomm_decode_packed32(labcomm_decoder_t *d)
+static inline unsigned int labcomm_decode_packed32(struct labcomm_decoder *d)
{
return labcomm_read_packed32(&d->reader);
}
-static inline char *labcomm_read_string(labcomm_reader_t *r)
+static inline char *labcomm_read_string(struct labcomm_reader *r)
{
char *result;
int length, i;
@@ -170,7 +170,7 @@ static inline char *labcomm_read_string(labcomm_reader_t *r)
return result;
}
-static inline char *labcomm_decode_string(labcomm_decoder_t *d)
+static inline char *labcomm_decode_string(struct labcomm_decoder *d)
{
return labcomm_read_string(&d->reader);
}
@@ -182,36 +182,36 @@ typedef int (*labcomm_encoder_function)(
struct labcomm_encoder *,
void *value);
-typedef struct labcomm_encoder {
+struct labcomm_encoder {
void *context;
- labcomm_writer_t writer;
+ struct labcomm_writer writer;
struct {
void *context;
const struct labcomm_lock_action *action;
} lock;
labcomm_error_handler_callback on_error;
-} labcomm_encoder_t;
+};
void labcomm_internal_encoder_register(
- labcomm_encoder_t *encoder,
- labcomm_signature_t *signature,
+ struct labcomm_encoder *encoder,
+ struct labcomm_signature *signature,
labcomm_encoder_function encode);
int labcomm_internal_encode(
- labcomm_encoder_t *encoder,
- labcomm_signature_t *signature,
+ struct labcomm_encoder *encoder,
+ struct labcomm_signature *signature,
labcomm_encoder_function encode,
void *value);
int labcomm_internal_encoder_ioctl(struct labcomm_encoder *encoder,
int ioctl_action,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
va_list args);
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define LABCOMM_ENCODE(name, type) \
- static inline int labcomm_write_##name(labcomm_writer_t *w, type data) { \
+ static inline int labcomm_write_##name(struct labcomm_writer *w, type data) { \
int i; \
for (i = sizeof(type) - 1 ; i >= 0 ; i--) { \
if (w->pos >= w->count) { /*buffer is full*/ \
@@ -224,14 +224,14 @@ int labcomm_internal_encoder_ioctl(struct labcomm_encoder *encoder,
} \
return 0; \
} \
- static inline int labcomm_encode_##name(labcomm_encoder_t *e, type data) { \
+ static inline int labcomm_encode_##name(struct labcomm_encoder *e, type data) { \
return labcomm_write_##name(&e->writer, data); \
}
#else
#define LABCOMM_ENCODE(name, type) \
- static inline int labcomm_write_##name(labcomm_writer_t *w, type data) { \
+ static inline int labcomm_write_##name(struct labcomm_writer *w, type data) { \
int i; \
for (i = 0 ; i < sizeof(type) ; i++) { \
if (w->pos >= w->count) { \
@@ -244,7 +244,7 @@ int labcomm_internal_encoder_ioctl(struct labcomm_encoder *encoder,
} \
return 0; \
} \
- static inline int labcomm_encode_##name(labcomm_encoder_t *e, type data) { \
+ static inline int labcomm_encode_##name(struct labcomm_encoder *e, type data) { \
return labcomm_write_##name(&e->writer, data); \
}
@@ -258,7 +258,7 @@ LABCOMM_ENCODE(long, long long)
LABCOMM_ENCODE(float, float)
LABCOMM_ENCODE(double, double)
-static inline int labcomm_write_packed32(labcomm_writer_t *w,
+static inline int labcomm_write_packed32(struct labcomm_writer *w,
unsigned int data)
{
unsigned char tmp[5];
@@ -279,14 +279,14 @@ static inline int labcomm_write_packed32(labcomm_writer_t *w,
}
-static inline int labcomm_encode_packed32(labcomm_encoder_t *e,
+static inline int labcomm_encode_packed32(struct labcomm_encoder *e,
unsigned int data)
{
return labcomm_write_packed32(&e->writer, data);
}
-static inline int labcomm_write_string(labcomm_writer_t *w, char *s)
+static inline int labcomm_write_string(struct labcomm_writer *w, char *s)
{
int length, i, err;
@@ -305,8 +305,8 @@ static inline int labcomm_write_string(labcomm_writer_t *w, char *s)
return 0;
}
-static inline int labcomm_encode_string(labcomm_encoder_t *e,
- char *s)
+static inline int labcomm_encode_string(struct labcomm_encoder *e,
+ char *s)
{
return labcomm_write_string(&e->writer, s);
}
diff --git a/lib/c/test/test_labcomm_basic_type_encoding.c b/lib/c/test/test_labcomm_basic_type_encoding.c
index cf6a1519e5724838ef1f328e3e29321f722d4a7c..b074ab0a5da11586c33e62f41bb7377e60e5f57c 100644
--- a/lib/c/test/test_labcomm_basic_type_encoding.c
+++ b/lib/c/test/test_labcomm_basic_type_encoding.c
@@ -6,7 +6,7 @@
static int line;
static unsigned char buffer[128];
-static labcomm_encoder_t encoder = {
+static struct labcomm_encoder encoder = {
.context = NULL,
.writer = {
.context = NULL,
@@ -22,7 +22,7 @@ static labcomm_encoder_t encoder = {
.on_error = NULL,
};
-static labcomm_decoder_t decoder = {
+static struct labcomm_decoder decoder = {
.context = NULL,
.reader = {
.context = NULL,
diff --git a/lib/c/test/test_labcomm_generated_encoding.c b/lib/c/test/test_labcomm_generated_encoding.c
index 7a86a8d0759b7ab5d29c9bb6ca2f6407cf7ccb07..ba05d82e1266e46e2400427ee59ba0f05b9eb5a6 100644
--- a/lib/c/test/test_labcomm_generated_encoding.c
+++ b/lib/c/test/test_labcomm_generated_encoding.c
@@ -28,7 +28,7 @@ static int buf_writer_free(struct labcomm_writer *w)
static int buf_writer_start(struct labcomm_writer *w,
struct labcomm_encoder *encoder,
int index,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
void *value)
{
return 0;
@@ -50,7 +50,7 @@ static int buf_writer_flush(struct labcomm_writer *w)
static int buf_writer_ioctl(
struct labcomm_writer *w,
int action,
- labcomm_signature_t *signature,
+ struct labcomm_signature *signature,
va_list arg)
{
int result = -ENOTSUP;
@@ -108,7 +108,7 @@ const struct labcomm_writer_action buffer_writer = {
.ioctl = buf_writer_ioctl
};
-void dump_encoder(labcomm_encoder_t *encoder)
+void dump_encoder(struct labcomm_encoder *encoder)
{
int i;
@@ -132,7 +132,7 @@ int main(void)
generated_encoding_V V;
generated_encoding_B B = 1;
- labcomm_encoder_t *encoder = labcomm_encoder_new(buffer_writer, buffer,
+ struct labcomm_encoder *encoder = labcomm_encoder_new(buffer_writer, buffer,
NULL, NULL);
labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);