X-Git-Url: http://git.lttng.org/?p=lttngtop.git;a=blobdiff_plain;f=lib%2Fbabeltrace%2Fctf-text%2Ftypes.h;fp=lib%2Fbabeltrace%2Fctf-text%2Ftypes.h;h=7b4b7171e733176b54536816e0a9ee1f8b06423b;hp=0000000000000000000000000000000000000000;hb=b1acd2b342a35dc6c5a8036fb0280321203e89b7;hpb=a18dc7c24b4ac751c46a96198aebcbb1dcd4cdd6 diff --git a/lib/babeltrace/ctf-text/types.h b/lib/babeltrace/ctf-text/types.h new file mode 100644 index 0000000..7b4b717 --- /dev/null +++ b/lib/babeltrace/ctf-text/types.h @@ -0,0 +1,97 @@ +#ifndef _BABELTRACE_CTF_TEXT_TYPES_H +#define _BABELTRACE_CTF_TEXT_TYPES_H + +/* + * Common Trace Format (Text Output) + * + * Type header + * + * Copyright 2010 - Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Inherit from both struct bt_stream_pos and struct bt_trace_descriptor. + */ +struct ctf_text_stream_pos { + struct bt_stream_pos parent; + struct bt_trace_descriptor trace_descriptor; + FILE *fp; /* File pointer. NULL if unset. */ + int depth; + int dummy; /* disable output */ + int print_names; /* print field names */ + int field_nr; + uint64_t last_real_timestamp; /* to print delta */ + uint64_t last_cycles_timestamp; /* to print delta */ + GString *string; /* Current string */ +}; + +static inline +struct ctf_text_stream_pos *ctf_text_pos(struct bt_stream_pos *pos) +{ + return container_of(pos, struct ctf_text_stream_pos, parent); +} + +/* + * Write only is supported for now. + */ +BT_HIDDEN +int ctf_text_integer_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_float_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_string_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_enum_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_struct_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_variant_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_array_write(struct bt_stream_pos *pos, struct bt_definition *definition); +BT_HIDDEN +int ctf_text_sequence_write(struct bt_stream_pos *pos, struct bt_definition *definition); + +static inline +void print_pos_tabs(struct ctf_text_stream_pos *pos) +{ + int i; + + for (i = 0; i < pos->depth; i++) + fprintf(pos->fp, "\t"); +} + +/* + * Check if the field must be printed. + */ +BT_HIDDEN +int print_field(struct bt_definition *definition); + +#endif /* _BABELTRACE_CTF_TEXT_TYPES_H */