+static
+void write_event_header(struct ctf_stream_pos *pos, char *line,
+ char **tline, size_t len, size_t *tlen,
+ uint64_t *ts)
+{
+ unsigned long sec, usec;
+ int ret;
+
+ if (!s_timestamp)
+ return;
+
+ /* Only need to be executed on first pass (dummy) */
+ if (pos->dummy) {
+ /* Extract time from input line */
+ ret = sscanf(line, "[%lu.%lu] ", &sec, &usec);
+ if (ret == 2) {
+ *tline = strchr(line, ']');
+ assert(*tline);
+ (*tline)++;
+ if ((*tline)[0] == ' ') {
+ (*tline)++;
+ }
+ *tlen = len + line - *tline;
+ *ts = (uint64_t) sec * USEC_PER_SEC + (uint64_t) usec;
+ }
+ }
+ /* timestamp */
+ ctf_align_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+ if (!pos->dummy)
+ *(uint64_t *) ctf_get_pos_addr(pos) = *ts;
+ ctf_move_pos(pos, sizeof(uint64_t) * CHAR_BIT);
+}
+