unified code style, added error checks

This commit is contained in:
Juri Glass 2011-09-29 18:33:13 +02:00
parent e85407a2bc
commit 10eff9a51a
12 changed files with 82 additions and 4 deletions

View file

@ -35,8 +35,6 @@ typedef struct {
octet_string *username; // optional
octet_string *password; // optional
octet_string *list_name; // optional
} sml_get_list_request;
sml_get_list_request* sml_get_list_request_init();

View file

@ -27,7 +27,6 @@
extern "C" {
#endif
typedef struct {
octet_string *server_id; // optional
octet_string *username; // optional

View file

@ -41,10 +41,13 @@ sml_attention_response *sml_attention_response_parse(sml_buffer *buf){
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->attention_number = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->attention_message = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->attention_details = sml_tree_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -55,12 +55,16 @@ sml_get_list_request *sml_get_list_request_parse(sml_buffer *buf) {
msg->client_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->username = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->password = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->list_name = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -41,16 +41,22 @@ sml_get_list_response *sml_get_list_response_parse(sml_buffer *buf) {
msg->client_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->list_name = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->act_sensor_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->val_list = sml_list_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->list_signature = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->act_gateway_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -43,12 +43,16 @@ sml_get_proc_parameter_request *sml_get_proc_parameter_request_parse(sml_buffer
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->username = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->password = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree_path = sml_tree_path_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->attribute = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -40,8 +40,10 @@ sml_get_proc_parameter_response *sml_get_proc_parameter_response_parse(sml_buffe
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree_path = sml_tree_path_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree = sml_tree_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -42,20 +42,28 @@ sml_get_profile_list_response *sml_get_profile_list_response_parse(sml_buffer *b
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->act_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->reg_period = sml_u32_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree_path = sml_tree_path_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->val_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->status = sml_u64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->period_list = sml_sequence_parse(buf, (void *) &sml_period_entry_parse, (void (*)(void *)) &sml_period_entry_free);
if (sml_buf_has_errors(buf)) goto error;
msg->rawdata = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->period_signature = sml_signature_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -75,16 +75,22 @@ sml_get_profile_pack_request *sml_get_profile_pack_request_parse(sml_buffer *buf
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->username = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->password = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->with_rawdata = sml_boolean_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->begin_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->end_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree_path = sml_tree_path_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -42,17 +42,33 @@ sml_get_profile_pack_response *sml_get_profile_pack_response_parse(sml_buffer *b
}
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->act_time = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->reg_period = sml_u32_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree_path = sml_tree_path_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->header_list = sml_sequence_parse(buf, (void *) &sml_prof_obj_header_entry_parse, (void (*)(void *)) &sml_prof_obj_header_entry_free);
if (sml_buf_has_errors(buf)) goto error;
msg->period_list = sml_sequence_parse(buf, (void *) &sml_prof_obj_period_entry_parse, (void (*)(void *)) &sml_prof_obj_period_entry_free);
if (sml_buf_has_errors(buf)) goto error;
msg->rawdata = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->profile_signature = sml_signature_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
return msg;
error:
buf->error = 1;
sml_get_profile_pack_response_free(msg);
return 0;
}

View file

@ -40,12 +40,16 @@ sml_set_proc_parameter_request *sml_set_proc_parameter_request_parse(sml_buffer
msg->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->username = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->password = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree_path = sml_tree_path_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
msg->parameter_tree = sml_tree_parse(buf);
if (sml_buf_has_errors(buf)) goto error;

View file

@ -123,7 +123,10 @@ sml_tree *sml_tree_parse(sml_buffer *buf){
}
tree->parameter_name = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tree->parameter_value = sml_proc_par_value_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
if (!sml_buf_optional_is_skipped(buf)) {
if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
@ -334,37 +337,58 @@ sml_tupel_entry *sml_tupel_entry_parse(sml_buffer *buf) {
}
tupel->server_id = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->sec_index = sml_time_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->status = sml_u64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->unit_pA = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->scaler_pA = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->value_pA = sml_i64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->unit_R1 = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->scaler_R1 = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->value_R1 = sml_i64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->unit_R4 = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->scaler_R4 = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->value_R4 = sml_i64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->signature_pA_R1_R4 = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->unit_mA = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->scaler_mA = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->value_mA = sml_i64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->unit_R2 = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->scaler_R2 = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->value_R2 = sml_i64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->unit_R3 = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->scaler_R3 = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->value_R3 = sml_i64_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
tupel->signature_mA_R2_R3 = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
return tupel;
@ -483,12 +507,16 @@ sml_period_entry *sml_period_entry_parse(sml_buffer *buf) {
period->obj_name = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
period->unit = sml_unit_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
period->scaler = sml_i8_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
period->value = sml_value_parse(buf);
if (sml_buf_has_errors(buf)) goto error;
period->value_signature = sml_octet_string_parse(buf);
if (sml_buf_has_errors(buf)) goto error;