| 1 | /* |
| 2 | * The MIT License (MIT) |
| 3 | * |
| 4 | * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com> |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | /* Type */ |
| 26 | struct bt_ctf_field_type; |
| 27 | |
| 28 | /* Common enumerations */ |
| 29 | enum bt_ctf_scope { |
| 30 | BT_CTF_SCOPE_UNKNOWN = -1, |
| 31 | BT_CTF_SCOPE_TRACE_PACKET_HEADER = 1, |
| 32 | BT_CTF_SCOPE_STREAM_PACKET_CONTEXT = 2, |
| 33 | BT_CTF_SCOPE_STREAM_EVENT_HEADER = 3, |
| 34 | BT_CTF_SCOPE_STREAM_EVENT_CONTEXT = 4, |
| 35 | BT_CTF_SCOPE_EVENT_CONTEXT = 5, |
| 36 | BT_CTF_SCOPE_EVENT_PAYLOAD = 6, |
| 37 | BT_CTF_SCOPE_ENV = 0, |
| 38 | BT_CTF_SCOPE_EVENT_FIELDS = 6, |
| 39 | }; |
| 40 | |
| 41 | enum bt_ctf_field_type_id { |
| 42 | BT_CTF_FIELD_TYPE_ID_UNKNOWN = CTF_TYPE_UNKNOWN, |
| 43 | BT_CTF_FIELD_TYPE_ID_INTEGER = CTF_TYPE_INTEGER, |
| 44 | BT_CTF_FIELD_TYPE_ID_FLOAT = CTF_TYPE_FLOAT, |
| 45 | BT_CTF_FIELD_TYPE_ID_ENUM = CTF_TYPE_ENUM, |
| 46 | BT_CTF_FIELD_TYPE_ID_STRING = CTF_TYPE_STRING, |
| 47 | BT_CTF_FIELD_TYPE_ID_STRUCT = CTF_TYPE_STRUCT, |
| 48 | BT_CTF_FIELD_TYPE_ID_ARRAY = CTF_TYPE_ARRAY, |
| 49 | BT_CTF_FIELD_TYPE_ID_SEQUENCE = CTF_TYPE_SEQUENCE, |
| 50 | BT_CTF_FIELD_TYPE_ID_VARIANT = CTF_TYPE_VARIANT, |
| 51 | BT_CTF_NR_TYPE_IDS = NR_CTF_TYPES, |
| 52 | }; |
| 53 | |
| 54 | enum bt_ctf_byte_order { |
| 55 | BT_CTF_BYTE_ORDER_UNKNOWN = -1, |
| 56 | BT_CTF_BYTE_ORDER_NATIVE = 0, |
| 57 | BT_CTF_BYTE_ORDER_UNSPECIFIED, |
| 58 | BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, |
| 59 | BT_CTF_BYTE_ORDER_BIG_ENDIAN, |
| 60 | BT_CTF_BYTE_ORDER_NETWORK, |
| 61 | }; |
| 62 | |
| 63 | enum bt_ctf_string_encoding { |
| 64 | BT_CTF_STRING_ENCODING_UNKNOWN = CTF_STRING_UNKNOWN, |
| 65 | BT_CTF_STRING_ENCODING_NONE = CTF_STRING_NONE, |
| 66 | BT_CTF_STRING_ENCODING_UTF8 = CTF_STRING_UTF8, |
| 67 | BT_CTF_STRING_ENCODING_ASCII = CTF_STRING_ASCII, |
| 68 | }; |
| 69 | |
| 70 | /* Common functions */ |
| 71 | enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id( |
| 72 | struct bt_ctf_field_type *field_type); |
| 73 | int bt_ctf_field_type_get_alignment( |
| 74 | struct bt_ctf_field_type *field_type); |
| 75 | int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *field_type, |
| 76 | unsigned int alignment); |
| 77 | enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order( |
| 78 | struct bt_ctf_field_type *field_type); |
| 79 | int bt_ctf_field_type_set_byte_order( |
| 80 | struct bt_ctf_field_type *field_type, |
| 81 | enum bt_ctf_byte_order byte_order); |
| 82 | int bt_ctf_field_type_compare(struct bt_ctf_field_type *field_type_a, |
| 83 | struct bt_ctf_field_type *field_type_b); |
| 84 | struct bt_ctf_field_type *bt_ctf_field_type_copy( |
| 85 | struct bt_ctf_field_type *field_type); |
| 86 | |
| 87 | /* Integer field type base enumeration */ |
| 88 | enum bt_ctf_integer_base { |
| 89 | BT_CTF_INTEGER_BASE_UNKNOWN = -1, |
| 90 | BT_CTF_INTEGER_BASE_BINARY = 2, |
| 91 | BT_CTF_INTEGER_BASE_OCTAL = 8, |
| 92 | BT_CTF_INTEGER_BASE_DECIMAL = 10, |
| 93 | BT_CTF_INTEGER_BASE_HEXADECIMAL = 16, |
| 94 | }; |
| 95 | |
| 96 | /* Integer field type functions */ |
| 97 | struct bt_ctf_field_type *bt_ctf_field_type_integer_create( |
| 98 | unsigned int size); |
| 99 | int bt_ctf_field_type_integer_get_size( |
| 100 | struct bt_ctf_field_type *int_field_type); |
| 101 | int bt_ctf_field_type_integer_set_size( |
| 102 | struct bt_ctf_field_type *int_field_type, unsigned int size); |
| 103 | int bt_ctf_field_type_integer_is_signed( |
| 104 | struct bt_ctf_field_type *int_field_type); |
| 105 | int bt_ctf_field_type_integer_set_is_signed( |
| 106 | struct bt_ctf_field_type *int_field_type, int is_signed); |
| 107 | enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base( |
| 108 | struct bt_ctf_field_type *int_field_type); |
| 109 | int bt_ctf_field_type_integer_set_base( |
| 110 | struct bt_ctf_field_type *int_field_type, |
| 111 | enum bt_ctf_integer_base base); |
| 112 | enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding( |
| 113 | struct bt_ctf_field_type *int_field_type); |
| 114 | int bt_ctf_field_type_integer_set_encoding( |
| 115 | struct bt_ctf_field_type *int_field_type, |
| 116 | enum bt_ctf_string_encoding encoding); |
| 117 | struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class( |
| 118 | struct bt_ctf_field_type *int_field_type); |
| 119 | int bt_ctf_field_type_integer_set_mapped_clock_class( |
| 120 | struct bt_ctf_field_type *int_field_type, |
| 121 | struct bt_ctf_clock_class *clock_class); |
| 122 | |
| 123 | /* Floating point number field type functions */ |
| 124 | struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void); |
| 125 | int bt_ctf_field_type_floating_point_get_exponent_digits( |
| 126 | struct bt_ctf_field_type *float_field_type); |
| 127 | int bt_ctf_field_type_floating_point_set_exponent_digits( |
| 128 | struct bt_ctf_field_type *float_field_type, |
| 129 | unsigned int exponent_size); |
| 130 | int bt_ctf_field_type_floating_point_get_mantissa_digits( |
| 131 | struct bt_ctf_field_type *float_field_type); |
| 132 | int bt_ctf_field_type_floating_point_set_mantissa_digits( |
| 133 | struct bt_ctf_field_type *float_field_type, |
| 134 | unsigned int mantissa_sign_size); |
| 135 | |
| 136 | /* Enumeration field type functions */ |
| 137 | struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create( |
| 138 | struct bt_ctf_field_type *int_field_type); |
| 139 | struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type( |
| 140 | struct bt_ctf_field_type *enum_field_type); |
| 141 | int64_t bt_ctf_field_type_enumeration_get_mapping_count( |
| 142 | struct bt_ctf_field_type *enum_field_type); |
| 143 | int bt_ctf_field_type_enumeration_get_mapping_signed( |
| 144 | struct bt_ctf_field_type *enum_field_type, int index, |
| 145 | const char **BTOUTSTR, int64_t *OUTPUT, int64_t *OUTPUT); |
| 146 | int bt_ctf_field_type_enumeration_get_mapping_unsigned( |
| 147 | struct bt_ctf_field_type *enum_field_type, int index, |
| 148 | const char **BTOUTSTR, uint64_t *OUTPUT, |
| 149 | uint64_t *OUTPUT); |
| 150 | int bt_ctf_field_type_enumeration_add_mapping_signed( |
| 151 | struct bt_ctf_field_type *enum_field_type, const char *name, |
| 152 | int64_t range_begin, int64_t range_end); |
| 153 | int bt_ctf_field_type_enumeration_add_mapping_unsigned( |
| 154 | struct bt_ctf_field_type *enum_field_type, const char *name, |
| 155 | uint64_t range_begin, uint64_t range_end); |
| 156 | struct bt_ctf_field_type_enumeration_mapping_iterator * |
| 157 | bt_ctf_field_type_enumeration_find_mappings_by_name( |
| 158 | struct bt_ctf_field_type *enum_field_type, |
| 159 | const char *name); |
| 160 | struct bt_ctf_field_type_enumeration_mapping_iterator * |
| 161 | bt_ctf_field_type_enumeration_find_mappings_by_signed_value( |
| 162 | struct bt_ctf_field_type *enum_field_type, |
| 163 | int64_t value); |
| 164 | struct bt_ctf_field_type_enumeration_mapping_iterator * |
| 165 | bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value( |
| 166 | struct bt_ctf_field_type *enum_field_type, |
| 167 | uint64_t value); |
| 168 | |
| 169 | /* Enumeration field type mapping iterator functions */ |
| 170 | int bt_ctf_field_type_enumeration_mapping_iterator_get_signed( |
| 171 | struct bt_ctf_field_type_enumeration_mapping_iterator *iter, |
| 172 | const char **BTOUTSTR, int64_t *OUTPUT, int64_t *OUTPUT); |
| 173 | int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned( |
| 174 | struct bt_ctf_field_type_enumeration_mapping_iterator *iter, |
| 175 | const char **BTOUTSTR, uint64_t *OUTPUT, uint64_t *OUTPUT); |
| 176 | int bt_ctf_field_type_enumeration_mapping_iterator_next( |
| 177 | struct bt_ctf_field_type_enumeration_mapping_iterator *iter); |
| 178 | |
| 179 | /* String field type functions */ |
| 180 | struct bt_ctf_field_type *bt_ctf_field_type_string_create(void); |
| 181 | enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding( |
| 182 | struct bt_ctf_field_type *string_field_type); |
| 183 | int bt_ctf_field_type_string_set_encoding( |
| 184 | struct bt_ctf_field_type *string_field_type, |
| 185 | enum bt_ctf_string_encoding encoding); |
| 186 | |
| 187 | /* Structure field type functions */ |
| 188 | struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void); |
| 189 | int64_t bt_ctf_field_type_structure_get_field_count( |
| 190 | struct bt_ctf_field_type *struct_field_type); |
| 191 | int bt_ctf_field_type_structure_get_field_by_index( |
| 192 | struct bt_ctf_field_type *struct_field_type, |
| 193 | const char **BTOUTSTR, struct bt_ctf_field_type **BTOUTFT, |
| 194 | uint64_t index); |
| 195 | struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name( |
| 196 | struct bt_ctf_field_type *struct_field_type, |
| 197 | const char *field_name); |
| 198 | int bt_ctf_field_type_structure_add_field( |
| 199 | struct bt_ctf_field_type *struct_field_type, |
| 200 | struct bt_ctf_field_type *field_type, |
| 201 | const char *field_name); |
| 202 | |
| 203 | /* Array field type functions */ |
| 204 | struct bt_ctf_field_type *bt_ctf_field_type_array_create( |
| 205 | struct bt_ctf_field_type *element_field_type, |
| 206 | unsigned int length); |
| 207 | struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type( |
| 208 | struct bt_ctf_field_type *array_field_type); |
| 209 | int64_t bt_ctf_field_type_array_get_length( |
| 210 | struct bt_ctf_field_type *array_field_type); |
| 211 | |
| 212 | /* Sequence field type functions */ |
| 213 | struct bt_ctf_field_type *bt_ctf_field_type_sequence_create( |
| 214 | struct bt_ctf_field_type *element_field_type, |
| 215 | const char *length_name); |
| 216 | struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type( |
| 217 | struct bt_ctf_field_type *sequence_field_type); |
| 218 | const char *bt_ctf_field_type_sequence_get_length_field_name( |
| 219 | struct bt_ctf_field_type *sequence_field_type); |
| 220 | struct bt_ctf_field_path *bt_ctf_field_type_sequence_get_length_field_path( |
| 221 | struct bt_ctf_field_type *sequence_field_type); |
| 222 | |
| 223 | /* Variant field type functions */ |
| 224 | struct bt_ctf_field_type *bt_ctf_field_type_variant_create( |
| 225 | struct bt_ctf_field_type *tag_field_type, |
| 226 | const char *tag_name); |
| 227 | struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type( |
| 228 | struct bt_ctf_field_type *variant_field_type); |
| 229 | const char *bt_ctf_field_type_variant_get_tag_name( |
| 230 | struct bt_ctf_field_type *variant_field_type); |
| 231 | int bt_ctf_field_type_variant_set_tag_name( |
| 232 | struct bt_ctf_field_type *variant_field_type, |
| 233 | const char *tag_name); |
| 234 | struct bt_ctf_field_path *bt_ctf_field_type_variant_get_tag_field_path( |
| 235 | struct bt_ctf_field_type *variant_field_type); |
| 236 | int64_t bt_ctf_field_type_variant_get_field_count( |
| 237 | struct bt_ctf_field_type *variant_field_type); |
| 238 | int bt_ctf_field_type_variant_get_field_by_index( |
| 239 | struct bt_ctf_field_type *variant_field_type, |
| 240 | const char **BTOUTSTR, |
| 241 | struct bt_ctf_field_type **BTOUTFT, uint64_t index); |
| 242 | struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name( |
| 243 | struct bt_ctf_field_type *variant_field_type, |
| 244 | const char *field_name); |
| 245 | int bt_ctf_field_type_variant_add_field( |
| 246 | struct bt_ctf_field_type *variant_field_type, |
| 247 | struct bt_ctf_field_type *field_type, |
| 248 | const char *field_name); |