diff --git a/lib/c/2006/labcomm2006.c b/lib/c/2006/labcomm2006.c index ff09b636127ffd0746165b98db2b453d975bad96..badfe4765fe3bd6e3e802c070caa35f0eaf64b16 100644 --- a/lib/c/2006/labcomm2006.c +++ b/lib/c/2006/labcomm2006.c @@ -138,9 +138,9 @@ int labcomm2006_writer_ioctl(struct labcomm2006_writer *w, static const char *labcomm2006_error_string[] = { -#define LABCOMM_ERROR(name, description) description , +#define LABCOMM2006_ERROR(name, description) description , #include "labcomm2006_error.h" -#undef LABCOMM_ERROR +#undef LABCOMM2006_ERROR }; static const int labcomm2006_error_string_count = (sizeof(labcomm2006_error_string) / sizeof(labcomm2006_error_string[0])); @@ -242,7 +242,7 @@ static int local_index = LABCOMM_USER; void labcomm2006_set_local_index(struct labcomm2006_signature *signature) { if (signature->index != 0) { - labcomm2006_error_fatal_global(LABCOMM_ERROR_SIGNATURE_ALREADY_SET, + labcomm2006_error_fatal_global(LABCOMM2006_ERROR_SIGNATURE_ALREADY_SET, "Signature already set: %s", signature->name); } signature->index = local_index; @@ -252,7 +252,7 @@ void labcomm2006_set_local_index(struct labcomm2006_signature *signature) int labcomm2006_get_local_index(const struct labcomm2006_signature *signature) { if (signature->index == 0) { - labcomm2006_error_fatal_global(LABCOMM_ERROR_SIGNATURE_NOT_SET, + labcomm2006_error_fatal_global(LABCOMM2006_ERROR_SIGNATURE_NOT_SET, "Signature not set: %s", signature->name); } return signature->index; diff --git a/lib/c/2006/labcomm2006_decoder.c b/lib/c/2006/labcomm2006_decoder.c index 885f67edbaad8328fbca09adba30d84683a66e19..2ae181d624dbfff1df9e927c6f4cd6766ff2a437 100644 --- a/lib/c/2006/labcomm2006_decoder.c +++ b/lib/c/2006/labcomm2006_decoder.c @@ -91,7 +91,7 @@ static int collect_flat_signature( result = decoder->reader->error; if (result < 0) { goto out; } if (type >= LABCOMM_USER) { - decoder->on_error(LABCOMM_ERROR_UNIMPLEMENTED_FUNC, 3, + decoder->on_error(LABCOMM2006_ERROR_UNIMPLEMENTED_FUNC, 3, "Implement %s ... (1) for type 0x%x\n", __FUNCTION__, type); } else { labcomm2006_write_packed32(writer, type); @@ -132,7 +132,7 @@ static int collect_flat_signature( } break; default: { result = -ENOSYS; - decoder->on_error(LABCOMM_ERROR_UNIMPLEMENTED_FUNC, 3, + decoder->on_error(LABCOMM2006_ERROR_UNIMPLEMENTED_FUNC, 3, "Implement %s (2) for type 0x%x...\n", __FUNCTION__, type); } break; } @@ -250,7 +250,7 @@ static int decode_typedef_or_sample(struct labcomm2006_decoder *d, int kind) d->on_new_datatype(d, &signature); result = -ENOENT; } else if (entry->index && entry->index != remote_index) { - d->on_error(LABCOMM_ERROR_DEC_INDEX_MISMATCH, 5, + d->on_error(LABCOMM2006_ERROR_DEC_INDEX_MISMATCH, 5, "%s(): index mismatch '%s' (id=0x%x != 0x%x)\n", __FUNCTION__, signature.name, entry->index, remote_index); result = -ENOENT; diff --git a/lib/c/2006/labcomm2006_error.h b/lib/c/2006/labcomm2006_error.h index 9c257b991b1d4bfc887a52effb5c241191c4fe7c..526545ec918cda988567ba8b59e582437a5d63a4 100644 --- a/lib/c/2006/labcomm2006_error.h +++ b/lib/c/2006/labcomm2006_error.h @@ -23,9 +23,9 @@ #define __LABCOMM2006_ERROR_H__ enum labcomm2006_error { -#define LABCOMM_ERROR(name, description) name , +#define LABCOMM2006_ERROR(name, description) name , #include "labcomm2006_error.h" -#undef LABCOMM_ERROR +#undef LABCOMM2006_ERROR }; struct labcomm2006_error_handler; @@ -41,28 +41,28 @@ void labcomm2006_error_fatal_global(enum labcomm2006_error error, #endif -#ifdef LABCOMM_ERROR +#ifdef LABCOMM2006_ERROR -LABCOMM_ERROR(LABCOMM_ERROR_SIGNATURE_ALREADY_SET, - "Signature has already been set") -LABCOMM_ERROR(LABCOMM_ERROR_SIGNATURE_NOT_SET, - "Signature has not been set") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_SIGNATURE_ALREADY_SET, + "Signature has already been set") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_SIGNATURE_NOT_SET, + "Signature has not been set") -LABCOMM_ERROR(LABCOMM_ERROR_ENC_NO_REG_SIGNATURE, - "Encoder has no registration for this signature") -LABCOMM_ERROR(LABCOMM_ERROR_ENC_BUF_FULL, - "The labcomm buffer is full") -LABCOMM_ERROR(LABCOMM_ERROR_DEC_UNKNOWN_DATATYPE, - "Decoder: Unknown datatype") -LABCOMM_ERROR(LABCOMM_ERROR_DEC_INDEX_MISMATCH, - "Decoder: index mismatch") -LABCOMM_ERROR(LABCOMM_ERROR_DEC_TYPE_NOT_FOUND, - "Decoder: type not found") -LABCOMM_ERROR(LABCOMM_ERROR_UNIMPLEMENTED_FUNC, - "This function is not yet implemented") -LABCOMM_ERROR(LABCOMM_ERROR_MEMORY, - "Could not allocate memory") -LABCOMM_ERROR(LABCOMM_ERROR_USER_DEF, - "User defined error") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_ENC_NO_REG_SIGNATURE, + "Encoder has no registration for this signature") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_ENC_BUF_FULL, + "The labcomm buffer is full") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_DEC_UNKNOWN_DATATYPE, + "Decoder: Unknown datatype") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_DEC_INDEX_MISMATCH, + "Decoder: index mismatch") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_DEC_TYPE_NOT_FOUND, + "Decoder: type not found") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_UNIMPLEMENTED_FUNC, + "This function is not yet implemented") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_MEMORY, + "Could not allocate memory") +LABCOMM2006_ERROR(LABCOMM2006_ERROR_USER_DEF, + "User defined error") #endif diff --git a/lib/c/2006/labcomm2006_private.h b/lib/c/2006/labcomm2006_private.h index efa095fdfffd049e67f1402e2d36267431aa2e82..c3bd51d5e817231f4d35bfa4c743dd94fb2ffe70 100644 --- a/lib/c/2006/labcomm2006_private.h +++ b/lib/c/2006/labcomm2006_private.h @@ -241,7 +241,7 @@ static inline char *labcomm2006_read_string(struct labcomm2006_reader *r) length = labcomm2006_read_packed32(r); result = labcomm2006_memory_alloc(r->memory, 1, length + 1); if (!result) { - labcomm2006_on_error_fprintf(LABCOMM_ERROR_MEMORY, 4, "%d byte at %s:%d", + labcomm2006_on_error_fprintf(LABCOMM2006_ERROR_MEMORY, 4, "%d byte at %s:%d", length+1, __FUNCTION__, __LINE__); return NULL; } diff --git a/lib/c/2014/labcomm2014.c b/lib/c/2014/labcomm2014.c index 41d6f1ae921f60d801751b992ea10629d4c180f3..c2285e8fd5f5590140ea14c026b787fbd2ae7a61 100644 --- a/lib/c/2014/labcomm2014.c +++ b/lib/c/2014/labcomm2014.c @@ -138,9 +138,9 @@ int labcomm2014_writer_ioctl(struct labcomm2014_writer *w, static const char *labcomm2014_error_string[] = { -#define LABCOMM_ERROR(name, description) description , +#define LABCOMM2014_ERROR(name, description) description , #include "labcomm2014_error.h" -#undef LABCOMM_ERROR +#undef LABCOMM2014_ERROR }; static const int labcomm2014_error_string_count = (sizeof(labcomm2014_error_string) / sizeof(labcomm2014_error_string[0])); @@ -241,7 +241,7 @@ static int local_index = LABCOMM_USER; void labcomm2014_set_local_index(struct labcomm2014_signature *signature) { if (signature->index != 0) { - labcomm2014_error_fatal_global(LABCOMM_ERROR_SIGNATURE_ALREADY_SET, + labcomm2014_error_fatal_global(LABCOMM2014_ERROR_SIGNATURE_ALREADY_SET, "Signature already set: %s\n", signature->name); } signature->index = local_index; @@ -251,7 +251,7 @@ void labcomm2014_set_local_index(struct labcomm2014_signature *signature) int labcomm2014_get_local_index(const struct labcomm2014_signature *signature) { if (signature->index == 0) { - labcomm2014_error_fatal_global(LABCOMM_ERROR_SIGNATURE_NOT_SET, + labcomm2014_error_fatal_global(LABCOMM2014_ERROR_SIGNATURE_NOT_SET, "Signature not set: %s\n", signature->name); } return signature->index; diff --git a/lib/c/2014/labcomm2014_encoder.c b/lib/c/2014/labcomm2014_encoder.c index 864ff3f03f0a079b63be2de47ed3e527e80d627f..cbd38c88cf18ecc9ba427d1be61e718d7ea48ac7 100644 --- a/lib/c/2014/labcomm2014_encoder.c +++ b/lib/c/2014/labcomm2014_encoder.c @@ -87,7 +87,7 @@ struct labcomm2014_encoder *labcomm2014_encoder_new( struct labcomm2014_memory *memory, struct labcomm2014_scheduler *scheduler) { - return internal_encoder_new(writer,error,memory,scheduler,TRUE); + return internal_encoder_new(writer,error,memory,scheduler,LABCOMM2014_TRUE); } void labcomm2014_encoder_free(struct labcomm2014_encoder* e) { @@ -310,7 +310,7 @@ static int calc_sig_encoded_size(struct labcomm2014_encoder *e, const struct labcomm2014_signature *sig) { int result=0; - map_signature(sig_size, &result, sig, FALSE); + map_signature(sig_size, &result, sig, LABCOMM2014_FALSE); return result; } @@ -344,7 +344,7 @@ static int internal_reg_type( labcomm2014_write_packed32(e->writer, index); labcomm2014_write_string(e->writer, signature->name); labcomm2014_write_packed32(e->writer, sig_size); - do_write_signature(e, signature, FALSE); + do_write_signature(e, signature, LABCOMM2014_FALSE); labcomm2014_writer_end(e->writer, e->writer->action_context); result = e->writer->error; @@ -359,7 +359,7 @@ int labcomm2014_internal_encoder_type_register( const struct labcomm2014_signature *signature) { #ifndef LABCOMM_WITHOUT_TYPE_DEFS - return internal_reg_type(e, signature, FALSE); + return internal_reg_type(e, signature, LABCOMM2014_FALSE); #else return 0; #endif diff --git a/lib/c/2014/labcomm2014_error.h b/lib/c/2014/labcomm2014_error.h index 0b06ec2708d50643dbdc9d9fcf50b920668b0241..9162e63acb7795e0b054833ac98d60765dc95e94 100644 --- a/lib/c/2014/labcomm2014_error.h +++ b/lib/c/2014/labcomm2014_error.h @@ -23,9 +23,9 @@ #define __LABCOMM2014_ERROR_H___ enum labcomm2014_error { -#define LABCOMM_ERROR(name, description) name , +#define LABCOMM2014_ERROR(name, description) name , #include "labcomm2014_error.h" -#undef LABCOMM_ERROR +#undef LABCOMM2014_ERROR }; struct labcomm2014_error_handler; @@ -41,30 +41,30 @@ void labcomm2014_error_fatal_global(enum labcomm2014_error error, #endif -#ifdef LABCOMM_ERROR +#ifdef LABCOMM2014_ERROR -LABCOMM_ERROR(LABCOMM_ERROR_SIGNATURE_ALREADY_SET, - "Signature has already been set") -LABCOMM_ERROR(LABCOMM_ERROR_SIGNATURE_NOT_SET, - "Signature has not been set") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_SIGNATURE_ALREADY_SET, + "Signature has already been set") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_SIGNATURE_NOT_SET, + "Signature has not been set") -LABCOMM_ERROR(LABCOMM_ERROR_ENC_NO_REG_SIGNATURE, - "Encoder has no registration for this signature") -LABCOMM_ERROR(LABCOMM_ERROR_ENC_BUF_FULL, - "The labcomm2014 buffer is full") -LABCOMM_ERROR(LABCOMM_ERROR_DEC_UNKNOWN_DATATYPE, - "Decoder: Unknown datatype") -LABCOMM_ERROR(LABCOMM_ERROR_DEC_INDEX_MISMATCH, - "Decoder: index mismatch") -LABCOMM_ERROR(LABCOMM_ERROR_DEC_TYPE_NOT_FOUND, - "Decoder: type not found") -LABCOMM_ERROR(LABCOMM_ERROR_UNIMPLEMENTED_FUNC, - "This function is not yet implemented") -LABCOMM_ERROR(LABCOMM_ERROR_MEMORY, - "Could not allocate memory") -LABCOMM_ERROR(LABCOMM_ERROR_USER_DEF, - "User defined error") -LABCOMM_ERROR(LABCOMM_ERROR_BAD_WRITER, - "Decoder: writer_ioctl() failed") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_ENC_NO_REG_SIGNATURE, + "Encoder has no registration for this signature") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_ENC_BUF_FULL, + "The labcomm2014 buffer is full") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_DEC_UNKNOWN_DATATYPE, + "Decoder: Unknown datatype") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_DEC_INDEX_MISMATCH, + "Decoder: index mismatch") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_DEC_TYPE_NOT_FOUND, + "Decoder: type not found") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_UNIMPLEMENTED_FUNC, + "This function is not yet implemented") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_MEMORY, + "Could not allocate memory") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_USER_DEF, + "User defined error") +LABCOMM2014_ERROR(LABCOMM2014_ERROR_BAD_WRITER, + "Decoder: writer_ioctl() failed") #endif diff --git a/lib/c/2014/labcomm2014_private.h b/lib/c/2014/labcomm2014_private.h index 42615c151e1951aaacaa1db20dc2e174de6d5ba1..03060722be6d6ae17d5addb0d18abb6d7d95d531 100644 --- a/lib/c/2014/labcomm2014_private.h +++ b/lib/c/2014/labcomm2014_private.h @@ -281,7 +281,7 @@ static inline char *labcomm2014_read_string(struct labcomm2014_reader *r) length = labcomm2014_read_packed32(r); result = labcomm2014_memory_alloc(r->memory, 1, length + 1); if (!result) { - labcomm20142014_on_error_fprintf(LABCOMM_ERROR_MEMORY, 4, "%d byte at %s:%d", + labcomm20142014_on_error_fprintf(LABCOMM2014_ERROR_MEMORY, 4, "%d byte at %s:%d", length+1, __FUNCTION__, __LINE__); return NULL; } diff --git a/lib/c/2014/labcomm2014_type_signature.c b/lib/c/2014/labcomm2014_type_signature.c index abc95a35a9ebeb2eba4c7a2ba71f8a3fd938072d..dce1836199fd47e30bf53f8f4766dd81cf3c7b43 100644 --- a/lib/c/2014/labcomm2014_type_signature.c +++ b/lib/c/2014/labcomm2014_type_signature.c @@ -30,7 +30,7 @@ static labcomm2014_bool sig_dump_checked(struct labcomm2014_signature_data *sign /* buf (out) : byte array to write signature into len (in/out): input: buf size, out: signature length - return TRUE if aborted due to overrun + return LABCOMM2014_TRUE if aborted due to overrun */ labcomm2014_bool labcomm2014_signature_dump(struct labcomm2014_signature_data *signature, char *buf, int *len) @@ -62,7 +62,7 @@ static labcomm2014_bool sig_dump_checked(struct labcomm2014_signature_data *sign buf += inner_len; } else { //printf("neither data nor ref, bailing out.\n"); - return TRUE; + return LABCOMM2014_TRUE; } p+=1; } @@ -70,7 +70,7 @@ static labcomm2014_bool sig_dump_checked(struct labcomm2014_signature_data *sign } /* compare signature (flattened, if needed) to other - return TRUE if equal + return LABCOMM2014_TRUE if equal */ labcomm2014_bool labcomm2014_signature_cmp( struct labcomm2014_signature_data *s1, struct labcomm2014_signature_data *s2) @@ -84,7 +84,7 @@ labcomm2014_bool labcomm2014_signature_cmp( struct labcomm2014_signature_data *s labcomm2014_bool res2 = labcomm2014_signature_dump(s2, buf2, &len2); if(res1 || res2) { printf("WARNING: OVERRUN\n"); - return FALSE; + return LABCOMM2014_FALSE; } else { return(len1 == len2 && memcmp(buf1, buf2, len1)==0); } diff --git a/lib/c/2014/labcomm2014_type_signature.h b/lib/c/2014/labcomm2014_type_signature.h index 1d776404ba173f2e98a5bc286753a42176a0276a..7c21b95b3435f14f81784a2d6f7fc0f5c926cb7d 100644 --- a/lib/c/2014/labcomm2014_type_signature.h +++ b/lib/c/2014/labcomm2014_type_signature.h @@ -4,8 +4,8 @@ //XXX move to common.h #ifndef labcomm2014_bool #define labcomm2014_bool char -#define TRUE 1 -#define FALSE 0 +#define LABCOMM2014_TRUE 1 +#define LABCOMM2014_FALSE 0 #endif /* @@ -112,7 +112,7 @@ int labcomm2014_decoder_register_labcomm2014_type_binding( void labcomm2014_signature_print(struct labcomm2014_signature_data *signature); /* compare signatures (flattened, if needed) to other -* return TRUE if equal +* return LABCOMM2014_TRUE if equal */ labcomm2014_bool labcomm2014_signature_cmp( struct labcomm2014_signature_data *s2, struct labcomm2014_signature_data *s1); @@ -121,7 +121,7 @@ labcomm2014_bool labcomm2014_signature_cmp( struct labcomm2014_signature_data *s * buf (out) : byte array to write signature into * len (in/out): input: buf size, out: signature length * - * return TRUE if aborted due to overrun + * return LABCOMM2014_TRUE if aborted due to overrun */ labcomm2014_bool labcomm2014_signature_dump(struct labcomm2014_signature_data *signature, char *buf, int *len);