From 781de171bdccc10d25841e45e8d5d5a3375f30f5 Mon Sep 17 00:00:00 2001 From: Juri Glass Date: Thu, 16 Jun 2011 17:02:53 +0200 Subject: [PATCH] renamed number parsing functions --- sml/include/sml/sml_number.h | 18 +++++++++--------- sml/src/sml_list.c | 4 ++-- sml/src/sml_message.c | 8 ++++---- sml/src/sml_number.c | 2 +- sml/src/sml_open_request.c | 2 +- sml/src/sml_open_response.c | 2 +- sml/src/sml_status.c | 8 ++++---- sml/src/sml_time.c | 4 ++-- sml/src/sml_value.c | 16 ++++++++-------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sml/include/sml/sml_number.h b/sml/include/sml/sml_number.h index 2a3a0c3..e6970cf 100644 --- a/sml/include/sml/sml_number.h +++ b/sml/include/sml/sml_number.h @@ -30,16 +30,16 @@ extern "C" { // Parses a number. Identified by type (SML_TYPE_INTEGER or SML_TYPE_UNSIGNED) // and maximal number of bytes (SML_TYPE_NUMBER_8, SML_TYPE_NUMBER_16, // SML_TYPE_NUMBER_32, SML_TYPE_NUMBER_64) -u64 mc_sml_parse_number(sml_buffer *buf, unsigned char type, int max_size); +u64 sml_number_parse(sml_buffer *buf, unsigned char type, int max_size); -#define mc_sml_parse_u8(buf) (u8) mc_sml_parse_number(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_8) -#define mc_sml_parse_u16(buf) (u16) mc_sml_parse_number(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_16) -#define mc_sml_parse_u32(buf) (u32) mc_sml_parse_number(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_32) -#define mc_sml_parse_u64(buf) (u64) mc_sml_parse_number(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_64) -#define mc_sml_parse_i8(buf) (i8) mc_sml_parse_number(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_8) -#define mc_sml_parse_i16(buf) (i16) mc_sml_parse_number(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_16) -#define mc_sml_parse_i32(buf) (i32) mc_sml_parse_number(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_32) -#define mc_sml_parse_i64(buf) (i64) mc_sml_parse_number(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_64) +#define sml_u8_parse(buf) (u8) sml_number_parse(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_8) +#define sml_u16_parse(buf) (u16) sml_number_parse(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_16) +#define sml_u32_parse(buf) (u32) sml_number_parse(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_32) +#define sml_u64_parse(buf) (u64) sml_number_parse(buf, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_64) +#define sml_i8_parse(buf) (i8) sml_number_parse(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_8) +#define sml_i16_parse(buf) (i16) sml_number_parse(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_16) +#define sml_i32_parse(buf) (i32) sml_number_parse(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_32) +#define sml_i64_parse(buf) (i64) sml_number_parse(buf, SML_TYPE_INTEGER, SML_TYPE_NUMBER_64) void sml_number_write(unsigned char type, int size, u64 value, sml_buffer *buf); diff --git a/sml/src/sml_list.c b/sml/src/sml_list.c index f39f093..214f37b 100644 --- a/sml/src/sml_list.c +++ b/sml/src/sml_list.c @@ -78,10 +78,10 @@ sml_list *sml_list_parse(sml_buffer *buf) { cur->val_time = SML_SKIP_OPTIONAL sml_time_parse(buf); if (sml_buf_has_errors(buf)) goto error; - cur->unit = SML_SKIP_OPTIONAL mc_sml_parse_u8(buf); + cur->unit = SML_SKIP_OPTIONAL sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; - cur->scaler = SML_SKIP_OPTIONAL mc_sml_parse_i8(buf); + cur->scaler = SML_SKIP_OPTIONAL sml_i8_parse(buf); if (sml_buf_has_errors(buf)) goto error; cur->value = SML_SKIP_OPTIONAL sml_value_parse(buf); diff --git a/sml/src/sml_message.c b/sml/src/sml_message.c index 1231c84..4fa43d5 100644 --- a/sml/src/sml_message.c +++ b/sml/src/sml_message.c @@ -55,16 +55,16 @@ sml_message *sml_message_parse(sml_buffer *buf) { msg->transaction_id = sml_octet_string_parse(buf); if (sml_buf_has_errors(buf)) goto error; - msg->group_id = mc_sml_parse_u8(buf); + msg->group_id = sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; - msg->abort_on_error = mc_sml_parse_u8(buf); + msg->abort_on_error = sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; msg->message_body = sml_message_body_parse(buf); if (sml_buf_has_errors(buf)) goto error; - msg->crc = mc_sml_parse_u16(buf); + msg->crc = sml_u16_parse(buf); if (sml_buf_has_errors(buf)) goto error; if (sml_buf_get_current_byte(buf) == SML_MESSAGE_END) { @@ -130,7 +130,7 @@ sml_message_body *sml_message_body_parse(sml_buffer *buf) { goto error; } - msg_body->tag = mc_sml_parse_u16(buf); + msg_body->tag = sml_u16_parse(buf); if (sml_buf_has_errors(buf)) goto error; switch (msg_body->tag) { diff --git a/sml/src/sml_number.c b/sml/src/sml_number.c index 0a50983..61d2bd2 100644 --- a/sml/src/sml_number.c +++ b/sml/src/sml_number.c @@ -21,7 +21,7 @@ #include #include -u64 mc_sml_parse_number(sml_buffer *buf, unsigned char type, int max_size) { +u64 sml_number_parse(sml_buffer *buf, unsigned char type, int max_size) { int l, i; u64 n = 0; diff --git a/sml/src/sml_open_request.c b/sml/src/sml_open_request.c index a538506..4c6f5c7 100644 --- a/sml/src/sml_open_request.c +++ b/sml/src/sml_open_request.c @@ -100,7 +100,7 @@ sml_open_request *sml_open_request_parse(sml_buffer *buf) { msg->password = SML_SKIP_OPTIONAL sml_octet_string_parse(buf); if (sml_buf_has_errors(buf)) goto error; - msg->sml_version = SML_SKIP_OPTIONAL mc_sml_parse_u8(buf); + msg->sml_version = SML_SKIP_OPTIONAL sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; return msg; diff --git a/sml/src/sml_open_response.c b/sml/src/sml_open_response.c index be3d869..b3cca11 100644 --- a/sml/src/sml_open_response.c +++ b/sml/src/sml_open_response.c @@ -50,7 +50,7 @@ sml_open_response *sml_open_response_parse(sml_buffer *buf) { msg->ref_time = SML_SKIP_OPTIONAL sml_time_parse(buf); if (sml_buf_has_errors(buf)) goto error; - msg->sml_version = SML_SKIP_OPTIONAL mc_sml_parse_u8(buf); + msg->sml_version = SML_SKIP_OPTIONAL sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; return msg; diff --git a/sml/src/sml_status.c b/sml/src/sml_status.c index 7e653c3..5ddf406 100644 --- a/sml/src/sml_status.c +++ b/sml/src/sml_status.c @@ -29,20 +29,20 @@ sml_status *sml_status_parse(sml_buffer *buf) { case SML_TYPE_UNSIGNED: switch (byte & SML_LENGTH_FIELD) { case SML_TYPE_NUMBER_8: - state->status8 = mc_sml_parse_u8(buf); + state->status8 = sml_u8_parse(buf); break; case SML_TYPE_NUMBER_16: - state->status16 = mc_sml_parse_u16(buf); + state->status16 = sml_u16_parse(buf); break; case SML_TYPE_NUMBER_16 + 1: case SML_TYPE_NUMBER_32: - state->status32 = mc_sml_parse_u32(buf); + state->status32 = sml_u32_parse(buf); break; case SML_TYPE_NUMBER_32 + 1: case SML_TYPE_NUMBER_32 + 2: case SML_TYPE_NUMBER_32 + 3: case SML_TYPE_NUMBER_64: - state->status64 = mc_sml_parse_u64(buf); + state->status64 = sml_u64_parse(buf); break; default: buf->error = 1; diff --git a/sml/src/sml_time.c b/sml/src/sml_time.c index 7a934ac..20dbe57 100644 --- a/sml/src/sml_time.c +++ b/sml/src/sml_time.c @@ -35,10 +35,10 @@ sml_time *sml_time_parse(sml_buffer *buf) { goto error; } - tme->tag = mc_sml_parse_u8(buf); + tme->tag = sml_u8_parse(buf); if (sml_buf_has_errors(buf)) goto error; - tme->data = mc_sml_parse_u32(buf); + tme->data = sml_u32_parse(buf); if (sml_buf_has_errors(buf)) goto error; return tme; diff --git a/sml/src/sml_value.c b/sml/src/sml_value.c index a549e19..bf2e757 100644 --- a/sml/src/sml_value.c +++ b/sml/src/sml_value.c @@ -35,23 +35,23 @@ sml_value *sml_value_parse(sml_buffer *buf) { case SML_TYPE_UNSIGNED: switch (byte & SML_LENGTH_FIELD) { case SML_TYPE_NUMBER_8: - value->data.uint8 = mc_sml_parse_u8(buf); + value->data.uint8 = sml_u8_parse(buf); value->type |= SML_TYPE_NUMBER_8; break; case SML_TYPE_NUMBER_16: - value->data.uint16 = mc_sml_parse_u16(buf); + value->data.uint16 = sml_u16_parse(buf); value->type |= SML_TYPE_NUMBER_16; break; case SML_TYPE_NUMBER_16 + 1: case SML_TYPE_NUMBER_32: - value->data.uint32 = mc_sml_parse_u32(buf); + value->data.uint32 = sml_u32_parse(buf); value->type |= SML_TYPE_NUMBER_32; break; case SML_TYPE_NUMBER_32 + 1: case SML_TYPE_NUMBER_32 + 2: case SML_TYPE_NUMBER_32 + 3: case SML_TYPE_NUMBER_64: - value->data.uint64 = mc_sml_parse_u64(buf); + value->data.uint64 = sml_u64_parse(buf); value->type |= SML_TYPE_NUMBER_64; break; default: @@ -67,23 +67,23 @@ sml_value *sml_value_parse(sml_buffer *buf) { // TODO: check if same problem exists for other SML_TYPEs too switch ((byte & SML_LENGTH_FIELD)-1) { case SML_TYPE_NUMBER_8: - value->data.int8 = mc_sml_parse_i8(buf); + value->data.int8 = sml_i8_parse(buf); value->type |= SML_TYPE_NUMBER_8; break; case SML_TYPE_NUMBER_16: - value->data.int16 = mc_sml_parse_i16(buf); + value->data.int16 = sml_i16_parse(buf); value->type |= SML_TYPE_NUMBER_16; break; case SML_TYPE_NUMBER_16 + 1: case SML_TYPE_NUMBER_32: - value->data.int32 = mc_sml_parse_i32(buf); + value->data.int32 = sml_i32_parse(buf); value->type |= SML_TYPE_NUMBER_32; break; case SML_TYPE_NUMBER_32 + 1: case SML_TYPE_NUMBER_32 + 2: case SML_TYPE_NUMBER_32 + 3: case SML_TYPE_NUMBER_64: - value->data.int64 = mc_sml_parse_i64(buf); + value->data.int64 = sml_i64_parse(buf); value->type |= SML_TYPE_NUMBER_64; break; default: