+
+ for (i = 0; i < env_size; ++i) {
+ struct bt_object *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_object_get_type(env_field_value_obj)) {
+ case BT_OBJECT_TYPE_INTEGER:
+ {
+ int ret;
+ int64_t int_value;
+
+ ret = bt_object_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_OBJECT_TYPE_STRING:
+ {
+ int ret;
+ const char *str_value;
+ char *escaped_str = NULL;
+
+ ret = bt_object_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_OBJECT_PUT(env_field_value_obj);
+ }
+