MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / parse_key_value_pair

Function parse_key_value_pair

libavutil/opt.c:1787–1819  ·  view source on GitHub ↗

* Store the value in the field in ctx that is named like key. * ctx must be an AVClass context, storing is done using AVOptions. * * @param buf the string to parse, buf will be updated to point at the * separator just after the parsed key/value pair * @param key_val_sep a 0-terminated list of characters used to * separate key from value * @param pairs_sep a 0-terminated list of characters u

Source from the content-addressed store, hash-verified

1785 * cannot be set
1786 */
1787static int parse_key_value_pair(void *ctx, const char **buf,
1788 const char *key_val_sep, const char *pairs_sep)
1789{
1790 char *key = av_get_token(buf, key_val_sep);
1791 char *val;
1792 int ret;
1793
1794 if (!key)
1795 return AVERROR(ENOMEM);
1796
1797 if (*key && strspn(*buf, key_val_sep)) {
1798 (*buf)++;
1799 val = av_get_token(buf, pairs_sep);
1800 if (!val) {
1801 av_freep(&key);
1802 return AVERROR(ENOMEM);
1803 }
1804 } else {
1805 av_log(ctx, AV_LOG_ERROR, "Missing key or no key/value separator found after key '%s'\n", key);
1806 av_free(key);
1807 return AVERROR(EINVAL);
1808 }
1809
1810 av_log(ctx, AV_LOG_DEBUG, "Setting entry with key '%s' to value '%s'\n", key, val);
1811
1812 ret = av_opt_set(ctx, key, val, AV_OPT_SEARCH_CHILDREN);
1813 if (ret == AVERROR_OPTION_NOT_FOUND)
1814 av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key);
1815
1816 av_free(key);
1817 av_free(val);
1818 return ret;
1819}
1820
1821int av_set_options_string(void *ctx, const char *opts,
1822 const char *key_val_sep, const char *pairs_sep)

Callers 1

av_set_options_stringFunction · 0.70

Calls 5

av_get_tokenFunction · 0.85
av_freepFunction · 0.85
av_logFunction · 0.85
av_opt_setFunction · 0.85
av_freeFunction · 0.70

Tested by

no test coverage detected