예제 #1
0
파일: trace.c 프로젝트: brianrob/babeltrace
const char *
bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace,
		int index)
{
	const char *ret = NULL;

	if (!trace) {
		goto end;
	}

	ret = bt_ctf_attributes_get_field_name(trace->environment, index);

end:
	return ret;
}
예제 #2
0
BT_HIDDEN
const char *
bt_ctf_event_class_get_attribute_name(
		struct bt_ctf_event_class *event_class, int index)
{
	const char *ret;

	if (!event_class) {
		ret = NULL;
		goto end;
	}

	ret = bt_ctf_attributes_get_field_name(event_class->attributes, index);

end:
	return ret;
}
예제 #3
0
파일: trace.c 프로젝트: brianrob/babeltrace
static
void append_env_metadata(struct bt_ctf_trace *trace,
		struct metadata_context *context)
{
	int i;
	int env_size;

	env_size = bt_ctf_attributes_get_count(trace->environment);

	if (env_size <= 0) {
		return;
	}

	g_string_append(context->string, "env {\n");

	for (i = 0; i < env_size; ++i) {
		struct bt_value *env_field_value_obj = NULL;
		const char *entry_name;

		entry_name = bt_ctf_attributes_get_field_name(
			trace->environment, i);
		env_field_value_obj = bt_ctf_attributes_get_field_value(
			trace->environment, i);

		if (!entry_name || !env_field_value_obj) {
			goto loop_next;
		}

		switch (bt_value_get_type(env_field_value_obj)) {
		case BT_VALUE_TYPE_INTEGER:
		{
			int ret;
			int64_t int_value;

			ret = bt_value_integer_get(env_field_value_obj,
				&int_value);

			if (ret) {
				goto loop_next;
			}

			g_string_append_printf(context->string,
				"\t%s = %" PRId64 ";\n", entry_name,
				int_value);
			break;
		}
		case BT_VALUE_TYPE_STRING:
		{
			int ret;
			const char *str_value;
			char *escaped_str = NULL;

			ret = bt_value_string_get(env_field_value_obj,
				&str_value);

			if (ret) {
				goto loop_next;
			}

			escaped_str = g_strescape(str_value, NULL);

			if (!escaped_str) {
				goto loop_next;
			}

			g_string_append_printf(context->string,
				"\t%s = \"%s\";\n", entry_name, escaped_str);
			free(escaped_str);
			break;
		}

		default:
			goto loop_next;
		}

loop_next:
		BT_PUT(env_field_value_obj);
	}

	g_string_append(context->string, "};\n\n");
}