| 1 | #ifndef _BABELTRACE_FORMAT_H |
| 2 | #define _BABELTRACE_FORMAT_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace |
| 6 | * |
| 7 | * Trace Format Header |
| 8 | * |
| 9 | * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 10 | * |
| 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | * of this software and associated documentation files (the "Software"), to deal |
| 13 | * in the Software without restriction, including without limitation the rights |
| 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | * copies of the Software, and to permit persons to whom the Software is |
| 16 | * furnished to do so, subject to the following conditions: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice shall be included in |
| 19 | * all copies or substantial portions of the Software. |
| 20 | */ |
| 21 | |
| 22 | #include <babeltrace/types.h> |
| 23 | #include <stdint.h> |
| 24 | #include <stdio.h> |
| 25 | #include <glib.h> |
| 26 | |
| 27 | struct trace_descriptor; |
| 28 | |
| 29 | struct format { |
| 30 | GQuark name; |
| 31 | |
| 32 | uint64_t (*uint_read)(struct stream_pos *pos, |
| 33 | const struct declaration_integer *integer_declaration); |
| 34 | int64_t (*int_read)(struct stream_pos *pos, |
| 35 | const struct declaration_integer *integer_declaration); |
| 36 | void (*uint_write)(struct stream_pos *pos, |
| 37 | const struct declaration_integer *integer_declaration, |
| 38 | uint64_t v); |
| 39 | void (*int_write)(struct stream_pos *pos, |
| 40 | const struct declaration_integer *integer_declaration, |
| 41 | int64_t v); |
| 42 | |
| 43 | void (*float_copy)(struct stream_pos *destp, |
| 44 | struct stream_pos *srcp, |
| 45 | const struct declaration_float *float_declaration); |
| 46 | double (*double_read)(struct stream_pos *pos, |
| 47 | const struct declaration_float *float_declaration); |
| 48 | void (*double_write)(struct stream_pos *pos, |
| 49 | const struct declaration_float *float_declaration, |
| 50 | double v); |
| 51 | |
| 52 | void (*string_copy)(struct stream_pos *dest, struct stream_pos *src, |
| 53 | const struct declaration_string *string_declaration); |
| 54 | void (*string_read)(char **dest, struct stream_pos *src, |
| 55 | const struct declaration_string *string_declaration); |
| 56 | void (*string_write)(struct stream_pos *dest, const char *src, |
| 57 | const struct declaration_string *string_declaration); |
| 58 | void (*string_free_temp)(char *string); |
| 59 | |
| 60 | /* |
| 61 | * enum_read returns a GArray of GQuark. Must be released with |
| 62 | * g_array_unref(). |
| 63 | */ |
| 64 | GArray *(*enum_read)(struct stream_pos *pos, |
| 65 | const struct declaration_enum *src); |
| 66 | void (*enum_write)(struct stream_pos *pos, |
| 67 | const struct declaration_enum *dest, |
| 68 | GQuark q); |
| 69 | void (*struct_begin)(struct stream_pos *pos, |
| 70 | const struct declaration_struct *struct_declaration); |
| 71 | void (*struct_end)(struct stream_pos *pos, |
| 72 | const struct declaration_struct *struct_declaration); |
| 73 | void (*variant_begin)(struct stream_pos *pos, |
| 74 | const struct declaration_variant *variant_declaration); |
| 75 | void (*variant_end)(struct stream_pos *pos, |
| 76 | const struct declaration_variant *variant_declaration); |
| 77 | void (*array_begin)(struct stream_pos *pos, |
| 78 | const struct declaration_array *array_declaration); |
| 79 | void (*array_end)(struct stream_pos *pos, |
| 80 | const struct declaration_array *array_declaration); |
| 81 | void (*sequence_begin)(struct stream_pos *pos, |
| 82 | const struct declaration_sequence *sequence_declaration); |
| 83 | void (*sequence_end)(struct stream_pos *pos, |
| 84 | const struct declaration_sequence *sequence_declaration); |
| 85 | struct trace_descriptor *(*open_trace)(const char *path, int flags); |
| 86 | void (*close_trace)(struct trace_descriptor *descriptor); |
| 87 | }; |
| 88 | |
| 89 | struct format *bt_lookup_format(GQuark qname); |
| 90 | void bt_fprintf_format_list(FILE *fp); |
| 91 | int bt_register_format(struct format *format); |
| 92 | |
| 93 | /* TBD: format unregistration */ |
| 94 | |
| 95 | #endif /* _BABELTRACE_FORMAT_H */ |