static void * sml_prof_obj_period_entry_parse_(sml_buffer *buf) {
	sml_prof_obj_period_entry *entry = sml_prof_obj_period_entry_init();

	if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
		buf->error = 1;
		goto error;
	}

	if (sml_buf_get_next_length(buf) != 4) {
		buf->error = 1;
		goto error;
	}


	entry->val_time = sml_time_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;
	entry->status = sml_u64_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;
	entry->value_list = sml_sequence_parse(buf, sml_value_entry_parse_, sml_value_entry_free_);
	if (sml_buf_has_errors(buf)) goto error;
	entry->period_signature = sml_signature_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;

	return entry;

error:
	buf->error = 1;
	sml_prof_obj_period_entry_free(entry);
	return 0;
}
sml_get_profile_pack_response *sml_get_profile_pack_response_parse(sml_buffer *buf){
	sml_get_profile_pack_response *msg = sml_get_profile_pack_response_init();

	if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
		buf->error = 1;
		goto error;
	}

	if (sml_buf_get_next_length(buf) != 8) {
		buf->error = 1;
		goto error;
	}

	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, sml_prof_obj_header_entry_parse_, sml_prof_obj_header_entry_free_);
	if (sml_buf_has_errors(buf)) goto error;

	msg->period_list = sml_sequence_parse(buf, sml_prof_obj_period_entry_parse_, 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;
}
Exemplo n.º 3
0
sml_proc_par_value *sml_proc_par_value_parse(sml_buffer *buf) {
	if (sml_buf_optional_is_skipped(buf)) {
		return 0;
	}

	sml_proc_par_value *ppv = sml_proc_par_value_init();

	if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
		buf->error = 1;
		goto error;
	}

	if (sml_buf_get_next_length(buf) != 2) {
		buf->error = 1;
		goto error;
	}

	ppv->tag = sml_u8_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;

	switch (*(ppv->tag)) {
		case SML_PROC_PAR_VALUE_TAG_VALUE:
			ppv->data.value = sml_value_parse(buf);
			break;
		case SML_PROC_PAR_VALUE_TAG_PERIOD_ENTRY:
			ppv->data.period_entry = sml_period_entry_parse(buf);
			break;
		case SML_PROC_PAR_VALUE_TAG_TUPEL_ENTRY:
			ppv->data.tupel_entry = sml_tupel_entry_parse(buf);
			break;
		case SML_PROC_PAR_VALUE_TAG_TIME:
			ppv->data.time = sml_time_parse(buf);
			break;
		default:
			buf->error = 1;
			goto error;
	}

	return ppv;

error:
	sml_proc_par_value_free(ppv);
	return 0;
}
Exemplo n.º 4
0
sml_open_response *sml_open_response_parse(sml_buffer *buf) {
	sml_open_response *msg = sml_open_response_init();

	if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
		buf->error = 1;
		goto error;
	}

	if (sml_buf_get_next_length(buf) != 6) {
		buf->error = 1;
		goto error;
	}

	msg->codepage = sml_octet_string_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;

	msg->client_id = sml_octet_string_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;

	msg->req_file_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->ref_time = sml_time_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;

	msg->sml_version = sml_u8_parse(buf);
	if (sml_buf_has_errors(buf)) goto error;

	return msg;
error:
	sml_open_response_free(msg);
	return 0;
}
Exemplo n.º 5
0
sml_tupel_entry *sml_tupel_entry_parse(sml_buffer *buf) {
	if (sml_buf_optional_is_skipped(buf)) {
		return 0;
	}

	sml_tupel_entry *tupel = sml_tupel_entry_init();

	if (sml_buf_get_next_type(buf) != SML_TYPE_LIST) {
		buf->error = 1;
		goto error;
	}

	if (sml_buf_get_next_length(buf) != 23) {
		buf->error = 1;
		goto error;
	}

	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;

error:
	sml_tupel_entry_free(tupel);
	return 0;
}