src/libFLAC/stream_decoder.c : Fix buffer read overflow.
[platform/upstream/flac.git] / src / plugin_common / tags.h
1 /* plugin_common - Routines common to several plugins
2  * Copyright (C) 2002-2009  Josh Coalson
3  * Copyright (C) 2011-2013  Xiph.Org Foundation
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19
20 #ifndef FLAC__PLUGIN_COMMON__TAGS_H
21 #define FLAC__PLUGIN_COMMON__TAGS_H
22
23 #include "FLAC/format.h"
24
25 FLAC__bool FLAC_plugin__tags_get(const char *filename, FLAC__StreamMetadata **tags);
26 FLAC__bool FLAC_plugin__tags_set(const char *filename, const FLAC__StreamMetadata *tags);
27
28 /*
29  * Deletes the tags object and sets '*tags' to NULL.
30  */
31 void FLAC_plugin__tags_destroy(FLAC__StreamMetadata **tags);
32
33 /*
34  * Gets the value (in UTF-8) of the first tag with the given name (NULL if no
35  * such tag exists).
36  */
37 const char *FLAC_plugin__tags_get_tag_utf8(const FLAC__StreamMetadata *tags, const char *name);
38
39 /*
40  * Gets the value (in UCS-2) of the first tag with the given name (NULL if no
41  * such tag exists).
42  *
43  * NOTE: the returned string is malloc()ed and must be free()d by the caller.
44  */
45 FLAC__uint16 *FLAC_plugin__tags_get_tag_ucs2(const FLAC__StreamMetadata *tags, const char *name);
46
47 /*
48  * Removes all tags with the given 'name'.  Returns the number of tags removed,
49  * or -1 on memory allocation error.
50  */
51 int FLAC_plugin__tags_delete_tag(FLAC__StreamMetadata *tags, const char *name);
52
53 /*
54  * Removes all tags.  Returns the number of tags removed, or -1 on memory
55  * allocation error.
56  */
57 int FLAC_plugin__tags_delete_all(FLAC__StreamMetadata *tags);
58
59 /*
60  * Adds a "name=value" tag to the tags.  'value' must be in UTF-8.  If
61  * 'separator' is non-NULL and 'tags' already contains a tag for 'name', the
62  * first such tag's value is appended with separator, then value.
63  */
64 FLAC__bool FLAC_plugin__tags_add_tag_utf8(FLAC__StreamMetadata *tags, const char *name, const char *value, const char *separator);
65
66 /*
67  * Adds a "name=value" tag to the tags.  'value' must be in UCS-2.  If 'tags'
68  * already contains a tag or tags for 'name', then they will be replaced
69  * according to 'replace_all': if 'replace_all' is false, only the first such
70  * tag will be replaced; if true, all matching tags will be replaced by the one
71  * new tag. 
72  */
73 FLAC__bool FLAC_plugin__tags_set_tag_ucs2(FLAC__StreamMetadata *tags, const char *name, const FLAC__uint16 *value, FLAC__bool replace_all);
74
75 #endif