static void sml_value_entry_write_( void * p, sml_buffer *buf) {
	sml_value_entry * entry = p;

	sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 2);
	sml_value_write(entry->value, buf);
	sml_signature_write(entry->value_signature, buf);
}
示例#2
0
void sml_proc_par_value_write(sml_proc_par_value *value, sml_buffer *buf) {
	if (value == 0) {
		sml_buf_optional_write(buf);
		return;
	}

	sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 2);
	sml_u8_write(value->tag, buf);

	switch (*(value->tag)) {
		case SML_PROC_PAR_VALUE_TAG_VALUE:
			sml_value_write(value->data.value, buf);
			break;
		case SML_PROC_PAR_VALUE_TAG_PERIOD_ENTRY:
			sml_period_entry_write(value->data.period_entry, buf);
			break;
		case SML_PROC_PAR_VALUE_TAG_TUPEL_ENTRY:
			sml_tupel_entry_write(value->data.tupel_entry, buf);
			break;
		case SML_PROC_PAR_VALUE_TAG_TIME:
			sml_time_write(value->data.time, buf);
			break;
		default:
			printf("error: unknown tag in %s\n", __FUNCTION__);
	}
}
示例#3
0
TEST(sml_value, write_boolean) {
	sml_value *v = sml_value_init();
	v->type = SML_TYPE_BOOLEAN;
	v->data.boolean = sml_boolean_init(SML_BOOLEAN_FALSE);

	sml_value_write(v, buf);
	expected_buf(buf, "4200", 2);
}
示例#4
0
TEST(sml_value, write_octet_string) {
	sml_value *v = sml_value_init();
	v->type = SML_TYPE_OCTET_STRING;
	v->data.bytes = sml_octet_string_init((unsigned char *)"Hallo", 5);

	sml_value_write(v, buf);
	expected_buf(buf, "0648616C6C6F", 6);
}
示例#5
0
TEST(sml_value, write_integer16) {
	sml_value *v = sml_value_init();
	v->type = SML_TYPE_INTEGER | SML_TYPE_NUMBER_16;
	v->data.int16 = sml_i16_init(-5);

	sml_value_write(v, buf);
	expected_buf(buf, "53FFFB", 3);
}
示例#6
0
TEST(sml_value, write_unsigned32) {
	sml_value *v = sml_value_init();
	v->type = SML_TYPE_UNSIGNED | SML_TYPE_NUMBER_32;
	v->data.uint32 = sml_u32_init(42);

	sml_value_write(v, buf);
	expected_buf(buf, "650000002A", 5);
}
示例#7
0
void sml_period_entry_write(sml_period_entry *period, sml_buffer *buf) {
	if (period == 0) {
		sml_buf_optional_write(buf);
		return;
	}

	sml_buf_set_type_and_length(buf, SML_TYPE_LIST, 5);

	sml_octet_string_write(period->obj_name, buf);
	sml_unit_write(period->unit, buf);
	sml_i8_write(period->scaler, buf);
	sml_value_write(period->value, buf);
	sml_octet_string_write(period->value_signature, buf);
}
示例#8
0
TEST(sml_value, write_optional) {
	sml_value_write(0, buf);
	expected_buf(buf, "01", 1);
}