X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=types%2Fstring.c;h=5bbba98c8c047c7cb574126b97191a6b5d23f9de;hp=bff569db93bb11118b0904d48fcc5f1454623863;hb=54d1c81f52d1f8ac081a4b06996cc69db9294ce6;hpb=98b6832656447ab0f8024f9086aa67625e391ac7 diff --git a/types/string.c b/types/string.c index bff569db..5bbba98c 100644 --- a/types/string.c +++ b/types/string.c @@ -16,22 +16,31 @@ * * 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 static -struct definition *_string_definition_new(struct declaration *declaration, +struct bt_definition *_string_definition_new(struct bt_declaration *declaration, struct definition_scope *parent_scope, GQuark field_name, int index, const char *root_name); static -void _string_definition_free(struct definition *definition); +void _string_definition_free(struct bt_definition *definition); static -void _string_declaration_free(struct declaration *declaration) +void _string_declaration_free(struct bt_declaration *declaration) { struct declaration_string *string_declaration = container_of(declaration, struct declaration_string, p); @@ -39,7 +48,7 @@ void _string_declaration_free(struct declaration *declaration) } struct declaration_string * - string_declaration_new(enum ctf_string_encoding encoding) + bt_string_declaration_new(enum ctf_string_encoding encoding) { struct declaration_string *string_declaration; @@ -55,8 +64,8 @@ struct declaration_string * } static -struct definition * - _string_definition_new(struct declaration *declaration, +struct bt_definition * + _string_definition_new(struct bt_declaration *declaration, struct definition_scope *parent_scope, GQuark field_name, int index, const char *root_name) @@ -67,7 +76,7 @@ struct definition * int ret; string = g_new(struct definition_string, 1); - declaration_ref(&string_declaration->p); + bt_declaration_ref(&string_declaration->p); string->p.declaration = declaration; string->declaration = string_declaration; string->p.ref = 1; @@ -77,30 +86,41 @@ struct definition * */ string->p.index = root_name ? INT_MAX : index; string->p.name = field_name; - string->p.path = new_definition_path(parent_scope, field_name, + string->p.path = bt_new_definition_path(parent_scope, field_name, root_name); string->p.scope = NULL; string->value = NULL; string->len = 0; string->alloc_len = 0; - ret = register_field_definition(field_name, &string->p, + ret = bt_register_field_definition(field_name, &string->p, parent_scope); assert(!ret); return &string->p; } static -void _string_definition_free(struct definition *definition) +void _string_definition_free(struct bt_definition *definition) { struct definition_string *string = container_of(definition, struct definition_string, p); - declaration_unref(string->p.declaration); + bt_declaration_unref(string->p.declaration); g_free(string->value); g_free(string); } -char *get_string(struct definition *field) +enum ctf_string_encoding bt_get_string_encoding(const struct bt_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 *bt_get_string(const struct bt_definition *field) { struct definition_string *string_definition = container_of(field, struct definition_string, p);