+
+struct bt_definition *bt_lookup_definition(const struct bt_definition *definition,
+ const char *field_name)
+{
+ struct definition_scope *scope = get_definition_scope(definition);
+
+ if (!scope)
+ return NULL;
+
+ return lookup_field_definition_scope(g_quark_from_string(field_name),
+ scope);
+}
+
+struct definition_integer *bt_lookup_integer(const struct bt_definition *definition,
+ const char *field_name,
+ int signedness)
+{
+ struct bt_definition *lookup;
+ struct definition_integer *lookup_integer;
+
+ lookup = bt_lookup_definition(definition, field_name);
+ if (!lookup)
+ return NULL;
+ if (lookup->declaration->id != CTF_TYPE_INTEGER)
+ return NULL;
+ lookup_integer = container_of(lookup, struct definition_integer, p);
+ if (lookup_integer->declaration->signedness != signedness)
+ return NULL;
+ return lookup_integer;
+}
+
+struct definition_enum *bt_lookup_enum(const struct bt_definition *definition,
+ const char *field_name,
+ int signedness)
+{
+ struct bt_definition *lookup;
+ struct definition_enum *lookup_enum;
+
+ lookup = bt_lookup_definition(definition, field_name);
+ if (!lookup)
+ return NULL;
+ if (lookup->declaration->id != CTF_TYPE_ENUM)
+ return NULL;
+ lookup_enum = container_of(lookup, struct definition_enum, p);
+ if (lookup_enum->integer->declaration->signedness != signedness)
+ return NULL;
+ return lookup_enum;
+}
+
+struct bt_definition *bt_lookup_variant(const struct bt_definition *definition,
+ const char *field_name)
+{
+ struct bt_definition *lookup;
+ struct definition_variant *bt_lookup_variant;
+
+ lookup = bt_lookup_definition(definition, field_name);
+ if (!lookup)
+ return NULL;
+ if (lookup->declaration->id != CTF_TYPE_VARIANT)
+ return NULL;
+ bt_lookup_variant = container_of(lookup, struct definition_variant, p);
+ lookup = bt_variant_get_current_field(bt_lookup_variant);
+ assert(lookup);
+ return lookup;
+}