BT_HIDDEN struct bt_ctf_field *bt_ctf_event_get_payload_by_index( struct bt_ctf_event *event, int index) { struct bt_ctf_field *field = NULL; if (!event || index < 0) { goto end; } field = bt_ctf_field_structure_get_field_by_index(event->fields_payload, index); end: return field; }
BT_HIDDEN enum bt_component_status update_packet_context_field(FILE *err, struct bt_ctf_packet *writer_packet, const char *name, int64_t value) { enum bt_component_status ret; struct bt_ctf_field *packet_context = NULL, *writer_packet_context = NULL; struct bt_ctf_field_type *struct_type = NULL, *field_type = NULL; struct bt_ctf_field *field = NULL, *writer_field = NULL; int nr_fields, i, int_ret; packet_context = bt_ctf_packet_get_context(writer_packet); if (!packet_context) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } struct_type = bt_ctf_field_get_type(packet_context); if (!struct_type) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } writer_packet_context = bt_ctf_packet_get_context(writer_packet); if (!writer_packet_context) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } 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(struct_type, &field_name, &field_type, i) < 0) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } if (strcmp(field_name, name)) { BT_PUT(field_type); BT_PUT(field); continue; } 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; } writer_field = bt_ctf_field_structure_get_field(writer_packet_context, field_name); if (!writer_field) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } int_ret = bt_ctf_field_unsigned_integer_set_value(writer_field, value); if (int_ret < 0) { fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__); goto error; } BT_PUT(writer_field); BT_PUT(field_type); BT_PUT(field); } ret = BT_COMPONENT_STATUS_OK; goto end; error: bt_put(writer_field); bt_put(field_type); bt_put(field); ret = BT_COMPONENT_STATUS_ERROR; end: bt_put(struct_type); bt_put(packet_context); return ret; }