uint64_t id = 0;
int ret;
+ ctf_pos_get_event(pos);
+
if (pos->offset == EOF)
return EOF;
+ assert(pos->offset < pos->content_size);
/* Read event header */
if (stream->stream_event_header) {
assert(off >= 0);
pos->offset = 0;
} else {
+ read_next_packet:
switch (whence) {
case SEEK_CUR:
+ if (pos->offset == EOF)
+ return;
/* The reader will expect us to skip padding */
assert(pos->offset + offset == pos->content_size);
++pos->cur_index;
file_stream->parent.timestamp = index->timestamp_begin;
pos->content_size = index->content_size;
pos->packet_size = index->packet_size;
- if (index->data_offset <= index->content_size) {
+ if (index->data_offset < index->content_size) {
pos->offset = 0; /* will read headers */
+ } else if (index->data_offset == index->content_size) {
+ /* empty packet */
+ pos->offset = index->data_offset;
+ offset = 0;
+ goto read_next_packet;
} else {
pos->offset = EOF;
return;
toread -= readlen;
if (!toread) {
ret = 0; /* continue reading next packet */
- break;
+ goto read_padding;
}
}
return ret;
+
+read_padding:
+ toread = (header.packet_size - header.content_size) / CHAR_BIT;
+ ret = fseek(in, toread, SEEK_CUR);
+ if (ret < 0) {
+ fprintf(stdout, "[warning] Missing padding at end of file\n");
+ ret = 0;
+ }
+ return ret;
}
static