- nr_fields = bt_ctf_field_type_structure_get_field_count(struct_type);
- for (i = 0; i < nr_fields; i++) {
- const char *field_name;
-
- field = bt_ctf_field_structure_get_field_by_index(
- packet_context, i);
- if (!field) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- goto error;
- }
- if (bt_ctf_field_type_structure_get_field_by_index(struct_type,
- &field_name, &field_type, i) < 0) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- goto error;
- }
-
- if (bt_ctf_field_type_get_type_id(field_type) != BT_CTF_FIELD_TYPE_ID_INTEGER) {
- fprintf(err, "[error] Unexpected packet context field type\n");
- goto error;
- }
-
- ret = ctf_copy_packet_context_field(err, field, field_name,
- writer_packet_context, writer_packet_context_type);
- BT_PUT(field_type);
- BT_PUT(field);
- if (ret != BT_COMPONENT_STATUS_OK) {
- fprintf(err, "[error] %s in %s:%d\n", __func__,
- __FILE__, __LINE__);
- goto error;
- }
- }
-