예제 #1
0
파일: test.c 프로젝트: Hegen/libtrading
int fmsgcmp(struct fix_message *expected, struct fix_message *actual)
{
	int i;
	int ret = 1;
	struct fix_field *actual_field;
	struct fix_field *expected_field;

	if (expected->body_length && expected->body_length != actual->body_length)
		goto exit;

	if (expected->msg_seq_num && expected->msg_seq_num != actual->msg_seq_num)
		goto exit;

	if (fstrcmp(expected->sender_comp_id, actual->sender_comp_id))
		goto exit;

	if (fstrcmp(expected->target_comp_id, actual->target_comp_id))
		goto exit;

	if (fstrcmp(expected->begin_string, actual->begin_string))
		goto exit;

	if (fstrcmp(expected->msg_type, actual->msg_type))
		goto exit;

	for (i = 0; i < expected->nr_fields; i++) {
		expected_field = &expected->fields[i];
		actual_field = fix_get_field(actual, expected_field->tag);

		if (!actual_field)
			goto exit;

		switch (expected_field->type) {
			case FIX_TYPE_STRING:
				if (fstrcmp(expected_field->string_value, actual_field->string_value))
					goto exit;
				break;
			case FIX_TYPE_FLOAT:
				if (expected_field->float_value != actual_field->float_value)
					goto exit;
				break;
			case FIX_TYPE_CHAR:
				if (fstrcasecmp(&expected_field->char_value, &actual_field->char_value))
					goto exit;
				break;
			case FIX_TYPE_CHECKSUM:
			case FIX_TYPE_INT:
				if (expected_field->int_value != actual_field->int_value)
					goto exit;
				break;
			default:
				break;
		}
	}

	return 0;

exit:
	return ret;
}
예제 #2
0
int64_t fix_get_int(struct fix_message *self, int tag, int64_t _default_)
{
    struct fix_field *field = fix_get_field(self, tag);
    return field ? field->int_value : _default_;
}
예제 #3
0
char fix_get_char(struct fix_message *self, int tag, char _default_)
{
    struct fix_field *field = fix_get_field(self, tag);
    return field ? field->char_value : _default_;
}
예제 #4
0
double fix_get_float(struct fix_message *self, int tag, double _default_) {
    struct fix_field *field = fix_get_field(self, tag);
    return field ? field->float_value : _default_;
}