-int print_event(struct format *fmt_write, struct ctf_text_stream_pos *sout,
- struct format *fmt_read, struct ctf_file_stream *sin)
-{
- struct ctf_stream *stream_class = sin->stream;
- struct ctf_event *event_class;
- uint64_t id = 0;
- int len_index;
-
- /* Read and print event header */
- if (stream_class->event_header) {
- fmt_read->struct_read(&sin->pos.parent, stream_class->event_header);
-
- /* lookup event id */
- len_index = struct_declaration_lookup_field_index(td->packet_header->declaration,
- g_quark_from_static_string("id"));
- if (len_index >= 0) {
- struct definition_integer *defint;
- struct field *field;
-
- field = struct_definition_get_field_from_index(stream_class->event_header, len_index);
- assert(field->definition->declaration->id == CTF_TYPE_INTEGER);
- defint = container_of(field->definition, struct definition_integer, p);
- assert(defint->declaration->signedness == FALSE);
- id = defint->value._unsigned; /* set id */
- }
-
- fmt_write->struct_write(&sout->parent, stream_class->event_header);
- }
-
- /* Read and print stream-declared event context */
- if (stream_class->event_context) {
- fmt_read->struct_read(&sin->pos.parent, stream_class->event_context);
- fmt_write->struct_write(&sout->parent, stream_class->event_context);
- }
-
- if (id >= stream_class->events_by_id->len) {
- fprintf(stdout, "[error] Event id %" PRIu64 " is outside range.\n", id);
- return -EINVAL;
- }
- event_class = g_ptr_array_index(stream_class->events_by_id, id);
- if (!event_class) {
- fprintf(stdout, "[error] Event id %" PRIu64 " is unknown.\n", id);
- return -EINVAL;
- }
-
- /* Read and print event-declared event context */
- if (event_class->context) {
- fmt_read->struct_read(&sin->pos.parent, event_class->context);
- fmt_write->struct_write(&sout->parent, event_class->context);
- }
-
- /* Read and print event payload */
- if (event_class->fields) {
- fmt_read->struct_read(&sin->pos.parent, event_class->fields);
- fmt_write->struct_write(&sout->parent, event_class->fields);
- }
-
- return 0;
-}
-
-static
-int print_stream(struct format *fmt_write, struct ctf_text_stream_pos *sout,
- struct format *fmt_read, struct ctf_file_stream *sin)