return ret;
}
+int bt_ctf_get_int_signedness(const struct definition *field)
+{
+ int ret;
+
+ if (field && bt_ctf_field_type(field) == CTF_TYPE_INTEGER) {
+ ret = get_int_signedness(field);
+ } else {
+ ret = -1;
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
+int bt_ctf_get_int_base(const struct definition *field)
+{
+ int ret;
+
+ if (field && bt_ctf_field_type(field) == CTF_TYPE_INTEGER) {
+ ret = get_int_base(field);
+ } else {
+ ret = -1;
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
+int bt_ctf_get_int_byte_order(const struct definition *field)
+{
+ int ret;
+
+ if (field && bt_ctf_field_type(field) == CTF_TYPE_INTEGER) {
+ ret = get_int_byte_order(field);
+ } else {
+ ret = -1;
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
+enum ctf_string_encoding bt_ctf_get_encoding(const struct definition *field)
+{
+ enum ctf_string_encoding ret = 0;
+
+ if (!field)
+ goto end;
+
+ if (bt_ctf_field_type(field) == CTF_TYPE_INTEGER)
+ ret = get_int_encoding(field);
+ else if (bt_ctf_field_type(field) == CTF_TYPE_STRING)
+ ret = get_string_encoding(field);
+ else
+ goto error;
+
+end:
+ return ret;
+
+error:
+ bt_ctf_field_set_error(-EINVAL);
+ return -1;
+}
+
+int bt_ctf_get_array_len(const struct definition *field)
+{
+ int ret;
+
+ if (field && bt_ctf_field_type(field) == CTF_TYPE_ARRAY) {
+ ret = get_array_len(field);
+ } else {
+ ret = -1;
+ bt_ctf_field_set_error(-EINVAL);
+ }
+
+ return ret;
+}
+
uint64_t bt_ctf_get_uint64(const struct definition *field)
{
unsigned int ret = 0;
NR_CTF_TYPES,
};
+/*
+ * the supported CTF string encodings
+ */
+enum ctf_string_encoding {
+ CTF_STRING_NONE = 0,
+ CTF_STRING_UTF8,
+ CTF_STRING_ASCII,
+ CTF_STRING_UNKNOWN,
+};
+
/*
* the structure to manipulate events
*/
*/
enum ctf_type_id bt_ctf_field_type(const struct definition *def);
+/*
+ * bt_ctf_get_int_signedness: return the signedness of an integer
+ *
+ * return 0 if unsigned
+ * return 1 if signed
+ * return -1 on error
+ */
+int bt_ctf_get_int_signedness(const struct definition *field);
+
+/*
+ * bt_ctf_get_int_base: return the base of an int or a negative value on error
+ */
+int bt_ctf_get_int_base(const struct definition *field);
+
+/*
+ * bt_ctf_get_int_byte_order: return the byte order of an int or a negative
+ * value on error
+ */
+int bt_ctf_get_int_byte_order(const struct definition *field);
+
+/*
+ * bt_ctf_get_encoding: return the encoding of an int or a string.
+ * return a negative value on error
+ */
+enum ctf_string_encoding bt_ctf_get_encoding(const struct definition *field);
+
+/*
+ * bt_ctf_get_array_len: return the len of an array or a negative
+ * value on error
+ */
+int bt_ctf_get_array_len(const struct definition *field);
+
/*
* Field access functions
*
return call(pos, definition);
}
-enum ctf_string_encoding {
- CTF_STRING_NONE = 0,
- CTF_STRING_UTF8,
- CTF_STRING_ASCII,
- CTF_STRING_UNKNOWN,
-};
-
/*
* Because we address in bits, bitfields end up being exactly the same as
* integers, except that their read/write functions must be able to deal with
struct ctf_clock *clock);
uint64_t get_unsigned_int(const struct definition *field);
int64_t get_signed_int(const struct definition *field);
+int get_int_signedness(const struct definition *field);
+int get_int_byte_order(const struct definition *field);
+int get_int_base(const struct definition *field);
+enum ctf_string_encoding get_int_encoding(const struct definition *field);
/*
* mantissa_len is the length of the number of bytes represented by the mantissa
struct declaration_string *
string_declaration_new(enum ctf_string_encoding encoding);
char *get_string(const struct definition *field);
+enum ctf_string_encoding get_string_encoding(const struct definition *field);
struct declaration_struct *
struct_declaration_new(struct declaration_scope *parent_scope,
struct definition *array_index(struct definition_array *array, uint64_t i);
int array_rw(struct stream_pos *pos, struct definition *definition);
GString *get_char_array(const struct definition *field);
+int get_array_len(const struct definition *field);
/*
* int_declaration and elem_declaration passed as parameter now belong
return g_ptr_array_index(array->elems, i);
}
+int get_array_len(const struct definition *field)
+{
+ struct definition_array *array_definition;
+ struct declaration_array *array_declaration;
+
+ array_definition = container_of(field, struct definition_array, p);
+ array_declaration = array_definition->declaration;
+
+ return array_declaration->len;
+}
+
GString *get_char_array(const struct definition *field)
{
struct definition_array *array_definition;
g_free(integer);
}
+enum ctf_string_encoding get_int_encoding(const struct definition *field)
+{
+ struct definition_integer *integer_definition;
+ const struct declaration_integer *integer_declaration;
+
+ integer_definition = container_of(field, struct definition_integer, p);
+ integer_declaration = integer_definition->declaration;
+
+ return integer_declaration->encoding;
+}
+
+int get_int_base(const struct definition *field)
+{
+ struct definition_integer *integer_definition;
+ const struct declaration_integer *integer_declaration;
+
+ integer_definition = container_of(field, struct definition_integer, p);
+ integer_declaration = integer_definition->declaration;
+
+ return integer_declaration->base;
+}
+
+int get_int_byte_order(const struct definition *field)
+{
+ struct definition_integer *integer_definition;
+ const struct declaration_integer *integer_declaration;
+
+ integer_definition = container_of(field, struct definition_integer, p);
+ integer_declaration = integer_definition->declaration;
+
+ return integer_declaration->byte_order;
+}
+
+int get_int_signedness(const struct definition *field)
+{
+ struct definition_integer *integer_definition;
+ const struct declaration_integer *integer_declaration;
+
+ integer_definition = container_of(field, struct definition_integer, p);
+ integer_declaration = integer_definition->declaration;
+
+ return integer_declaration->signedness;
+}
+
uint64_t get_unsigned_int(const struct definition *field)
{
struct definition_integer *integer_definition;
g_free(string);
}
+enum ctf_string_encoding get_string_encoding(const struct definition *field)
+{
+ struct definition_string *string_definition;
+ const struct declaration_string *string_declaration;
+
+ string_definition = container_of(field, struct definition_string, p);
+ string_declaration = string_definition->declaration;
+
+ return string_declaration->encoding;
+}
+
char *get_string(const struct definition *field)
{
struct definition_string *string_definition =