no compile time warnings

This commit is contained in:
Juri Glass 2011-07-11 13:46:35 +02:00
parent b1d3536ba8
commit 5d2118345b
15 changed files with 62 additions and 79 deletions

View file

@ -38,7 +38,7 @@ typedef struct {
sml_time *begin_time; // optional
sml_time *end_time; // optional
sml_tree_path *parameter_tree_path;
// sml_object_list * object_list; // optional sml_object_list not implemented yet
void *object_list; // sml_object_list * object_list; // optional sml_object_list not implemented yet
sml_tree *das_details; // optional
} sml_get_profile_pack_request;

View file

@ -36,8 +36,8 @@ typedef struct sml_list_entry {
octet_string *obj_name;
sml_status *status; // optional
sml_time *val_time; // optional
sml_unit unit; // optional
i8 scaler; // optional
sml_unit *unit; // optional
i8 *scaler; // optional
sml_value *value;
sml_signature *value_signature; // optional

View file

@ -55,16 +55,16 @@ extern "C" {
typedef struct {
u16 tag;
u16 *tag;
void *data;
} sml_message_body;
typedef struct {
octet_string *transaction_id;
u8 group_id;
u8 abort_on_error;
u8 *group_id;
u8 *abort_on_error;
sml_message_body *message_body;
u16 crc;
u16 *crc;
/* end of message */
} sml_message;

View file

@ -34,7 +34,7 @@ void *sml_number_init(u64 number, unsigned char type, int size);
// SML_TYPE_NUMBER_32, SML_TYPE_NUMBER_64)
void *sml_number_parse(sml_buffer *buf, unsigned char type, int max_size);
void sml_number_write(unsigned char type, int size, u64 value, sml_buffer *buf);
//void sml_number_write(unsigned char type, int size, u64 value, sml_buffer *buf);
void sml_number_write_new(void *np, unsigned char type, int size, sml_buffer *buf);
#define sml_u8_init(n) (u8 *) sml_number_init(n, SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_8)

View file

@ -35,7 +35,7 @@ typedef struct {
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
u8 sml_version; // optional
u8 *sml_version; // optional
} sml_open_request;
//sml_open_request *sml_open_request_init();

View file

@ -35,7 +35,7 @@ typedef struct {
octet_string *req_file_id;
octet_string *server_id;
sml_time *ref_time; // optional
u8 sml_version; // optional
u8 *sml_version; // optional
} sml_open_response;
sml_open_response *sml_open_response_parse(sml_buffer *buf);

View file

@ -27,10 +27,10 @@ extern "C" {
typedef union {
u8 status8;
u16 status16;
u32 status32;
u64 status64;
u8 *status8;
u16 *status16;
u32 *status32;
u64 *status64;
} sml_status;
sml_status *sml_status_parse(sml_buffer *buf);

View file

@ -28,8 +28,8 @@ extern "C" {
typedef struct {
u8 tag;
u32 data;
u8 *tag;
u32 *data;
} sml_time;
// Parses a time, updates the buffer accordingly, memory must be free'd elsewhere.

View file

@ -37,7 +37,7 @@ extern "C" {
// TODO
typedef struct {
u8 tag;
u8 *tag;
union {
sml_value *value;
// sml_period_entry

View file

@ -34,14 +34,14 @@ typedef struct {
union {
sml_boolean boolean;
octet_string *bytes; // can has zero length
i8 int8;
i16 int16;
i32 int32;
i64 int64;
u8 uint8;
u16 uint16;
u32 uint32;
u64 uint64;
i8 *int8;
i16 *int16;
i32 *int32;
i64 *int64;
u8 *uint8;
u16 *uint16;
u32 *uint32;
u64 *uint64;
} data;
} sml_value;

View file

@ -33,41 +33,19 @@ sml_get_profile_pack_request *sml_get_profile_pack_request_init(){
}
void sml_get_profile_pack_request_write(sml_get_profile_pack_request *msg, sml_buffer *buf) {
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 9);
// server_id
if (msg->server_id != NULL) {
sml_octet_string_write(msg->server_id,buf);
} else sml_buf_optional_write(buf);
// username
if (msg->username != NULL) {
sml_octet_string_write(msg->username,buf);
} else sml_buf_optional_write(buf);
// password
if (msg->password != NULL) {
sml_octet_string_write(msg->password,buf);
} else sml_buf_optional_write(buf);
// with_rawdata
if (msg->with_rawdata != NULL) {
printf("TODO: %s - comparision is not valid", __FUNCTION__);
sml_boolean_write(msg->with_rawdata,buf);
} else sml_buf_optional_write(buf); // with_rawdata
// begin_time
if (msg->begin_time != NULL){
sml_time_write(msg->begin_time, buf);
} else sml_buf_optional_write(buf); // begin_time
sml_buf_optional_write(buf); // end_time
// parameter_tree_path is not optional
sml_tree_path_write(msg->parameter_tree_path, buf);
sml_buf_optional_write(buf); // object_list
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 9);
sml_octet_string_write(msg->server_id, buf);
sml_octet_string_write(msg->username, buf);
sml_octet_string_write(msg->password, buf);
sml_boolean_write(msg->with_rawdata, buf);
sml_time_write(msg->begin_time, buf);
sml_time_write(msg->end_time, buf);
sml_tree_path_write(msg->parameter_tree_path, buf);
printf("TODO: %s - some struct members aren't written", __FUNCTION__);
sml_buf_optional_write(buf); // object_list
sml_buf_optional_write(buf); // das_details
printf("request_write");
}

View file

@ -96,13 +96,12 @@ void sml_message_write(sml_message *msg, sml_buffer *buf) {
int msg_start = buf->cursor;
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 6);
sml_octet_string_write(msg->transaction_id, buf);
sml_number_write(SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_8, (u64) msg->group_id, buf);
sml_number_write(SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_8, (u64) msg->abort_on_error, buf);
sml_u8_write(msg->group_id, buf);
sml_u8_write(msg->abort_on_error, buf);
sml_message_body_write(msg->message_body, buf);
msg->crc = sml_crc16_calculate(&(buf->buffer[msg_start]), buf->cursor - msg_start);
sml_number_write(SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_16, (u64) msg->crc, buf);
msg->crc = sml_u16_init(sml_crc16_calculate(&(buf->buffer[msg_start]), buf->cursor - msg_start));
sml_u16_write(msg->crc, buf);
// end of message
buf->buffer[buf->cursor] = 0x0;
@ -128,7 +127,7 @@ sml_message_body *sml_message_body_parse(sml_buffer *buf) {
msg_body->tag = sml_u16_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
switch (msg_body->tag) {
switch (*(msg_body->tag)) {
case SML_MESSAGE_OPEN_REQUEST:
msg_body->data = sml_open_request_parse(buf);
break;
@ -151,7 +150,7 @@ sml_message_body *sml_message_body_parse(sml_buffer *buf) {
msg_body->data = sml_attention_response_parse(buf);
break;
default:
printf("error: message type %04X not yet implemented\n", msg_body->tag);
printf("error: message type %04X not yet implemented\n", *(msg_body->tag));
break;
}
@ -165,16 +164,16 @@ error:
sml_message_body *sml_message_body_init(u16 tag, void *data) {
sml_message_body *message_body = (sml_message_body *) malloc(sizeof(sml_message_body));
memset(message_body, 0, sizeof(sml_message_body));
message_body->tag = tag;
message_body->tag = sml_u16_init(tag);
message_body->data = data;
return message_body;
}
void sml_message_body_write(sml_message_body *message_body, sml_buffer *buf) {
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 2);
sml_number_write(SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_16, (u64) message_body->tag, buf);
sml_u16_write(message_body->tag, buf);
switch (message_body->tag) {
switch (*(message_body->tag)) {
case SML_MESSAGE_OPEN_REQUEST:
sml_open_request_write((sml_open_request *) message_body->data, buf);
break;
@ -194,14 +193,14 @@ void sml_message_body_write(sml_message_body *message_body, sml_buffer *buf) {
sml_get_profile_pack_request_write((sml_get_profile_pack_request *)message_body->data, buf);
break;
default:
printf("error: message type %04X not yet implemented\n", message_body->tag);
printf("error: message type %04X not yet implemented\n", *(message_body->tag));
break;
}
}
void sml_message_body_free(sml_message_body *message_body) {
if (message_body) {
switch (message_body->tag) {
switch (*(message_body->tag)) {
case SML_MESSAGE_OPEN_REQUEST:
sml_open_request_free((sml_open_request *) message_body->data);
break;
@ -224,7 +223,7 @@ void sml_message_body_free(sml_message_body *message_body) {
sml_get_list_response_free((sml_get_list_response *) message_body->data);
break;
default:
printf("NYI: %s for message type %04X\n", __FUNCTION__, message_body->tag);
printf("NYI: %s for message type %04X\n", __FUNCTION__, *(message_body->tag));
break;
}

View file

@ -78,6 +78,7 @@ void *sml_number_parse(sml_buffer *buf, unsigned char type, int max_size) {
return np;
}
/*
void sml_number_write(unsigned char type, int size, u64 value, sml_buffer *buf) {
sml_buf_set_type_and_length(buf, type, size);
int i;
@ -90,6 +91,7 @@ void sml_number_write(unsigned char type, int size, u64 value, sml_buffer *buf)
}
buf->cursor += size;
}
*/
void sml_number_write_new(void *np, unsigned char type, int size, sml_buffer *buf) {
if (np == 0) {

View file

@ -48,9 +48,13 @@ error:
return 0;
}
void sml_time_write(sml_time *time, sml_buffer *buf){
printf("NYI: %s (writing optional flag instead)\n", __FUNCTION__);
sml_buf_optional_write(buf);
void sml_time_write(sml_time *time, sml_buffer *buf) {
if (time == 0) {
sml_buf_optional_write(buf);
return;
}
printf("NYI: %s (writing optional flag instead)\n", __FUNCTION__);
sml_buf_optional_write(buf);
}
void sml_time_free(sml_time *time) {

View file

@ -77,9 +77,9 @@ sml_proc_par_value *sml_proc_par_value_init(u8 tag, void *data) {
sml_proc_par_value *value = (sml_proc_par_value *) malloc(sizeof(sml_proc_par_value));
memset(value, 0, sizeof(sml_proc_par_value));
value->tag = tag;
value->tag = sml_u8_init(tag);
switch (tag) {
switch (*(value->tag)) {
case SML_PROC_PAR_VALUE_TAG_VALUE:
value->data.value = (sml_value*)data;
break;
@ -104,9 +104,9 @@ sml_proc_par_value *sml_proc_par_value_init(u8 tag, void *data) {
void sml_proc_par_value_write(sml_proc_par_value *value, sml_buffer *buf) {
sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 2);
sml_number_write(SML_TYPE_UNSIGNED, SML_TYPE_NUMBER_8, (u64) value->tag, buf);
sml_u8_write(value->tag, buf);
switch (value->tag) {
switch (*(value->tag)) {
case SML_PROC_PAR_VALUE_TAG_VALUE:
sml_value_write(value->data.value, buf);
break;