36 return m ? m->
count : 0;
48 i = prev - m->
elems + 1;
52 for (; i < m->
count; i++) {
55 for (j = 0; s[j] == key[j] && key[j]; j++)
74 char *oldval =
NULL, *copy_key =
NULL, *copy_value =
NULL;
77 copy_key = (
void *)key;
81 copy_value = (
void *)value;
86 if (!m || (key && !copy_key) || (value && !copy_value))
112 size_t len = strlen(oldval) + strlen(copy_value) + 1;
134 if (m && !m->
count) {
147 snprintf(valuestr,
sizeof(valuestr),
"%"PRId64, value);
153 const char *key_val_sep,
const char *pairs_sep,
160 if (key && *key && strspn(*buf, key_val_sep)) {
165 if (key && *key && val && *val)
177 const char *key_val_sep,
const char *pairs_sep,
222 const char key_val_sep,
const char pairs_sep)
227 char special_chars[] = {pairs_sep, key_val_sep,
'\0'};
229 if (!buffer || pairs_sep ==
'\0' || key_val_sep ==
'\0' || pairs_sep == key_val_sep ||
230 pairs_sep ==
'\\' || key_val_sep ==
'\\')
235 return *buffer ? 0 :
AVERROR(ENOMEM);
258 static void test_separators(
const AVDictionary *m,
const char pair,
const char val)
261 char pairs[] = {pair ,
'\0'};
262 char vals[] = {
val,
'\0'};
268 printf(
"%s\n", buffer);
282 printf(
"Testing av_dict_get_string() and av_dict_parse_string()\n");
284 printf(
"%s\n", buffer);
293 test_separators(dict,
',',
'=');
299 test_separators(dict,
'"',
'=');
300 test_separators(dict,
'\'',
'=');
301 test_separators(dict,
',',
'"');
302 test_separators(dict,
',',
'\'');
303 test_separators(dict,
'\'',
'"');
304 test_separators(dict,
'"',
'\'');
307 printf(
"\nTesting av_dict_set()\n");
320 printf(
"%s %s\n", e->
key, e->
value);
328 printf(
"'%s' '%s'\n", e->
key, e->
value);
333 printf(
"\nTesting av_dict_set_int()\n");
344 printf(
"%s %s\n", e->
key, e->
value);
348 printf(
"\nTesting av_dict_set() with existing AVDictionaryEntry.key as key\n");
353 printf(
"%s\n", e->
value);
356 printf(
"%s\n", e->
value);
const char const char void * val
memory handling functions
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
#define AV_BPRINT_SIZE_UNLIMITED
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
common internal API header
AVDictionaryEntry * elems
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
GLsizei GLboolean const GLfloat * value
#define AV_DICT_APPEND
If the entry already exists, append to it.
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
char * av_strdup(const char *s)
Duplicate the string s.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
Escape the content in src and append it to dstbuf.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
int main(int argc, char **argv)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int parse_key_value_pair(AVDictionary **pm, const char **buf, const char *key_val_sep, const char *pairs_sep, int flags)