diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/node.c | 13 | ||||
-rw-r--r-- | misc/node.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/misc/node.c b/misc/node.c index b7bf06d9c1..f5fb8da0e9 100644 --- a/misc/node.c +++ b/misc/node.c @@ -81,3 +81,16 @@ void node_map_add_flag(struct mpv_node *dst, const char *key, bool v) { node_map_add(dst, key, MPV_FORMAT_FLAG)->u.flag = v; } + +mpv_node *node_map_get(mpv_node *src, const char *key) +{ + if (src->format != MPV_FORMAT_NODE_MAP) + return NULL; + + for (int i = 0; i < src->u.list->num; i++) { + if (strcmp(key, src->u.list->keys[i]) == 0) + return &src->u.list->values[i]; + } + + return NULL; +} diff --git a/misc/node.h b/misc/node.h index a1bdab0ae1..5d8100da41 100644 --- a/misc/node.h +++ b/misc/node.h @@ -10,5 +10,6 @@ void node_map_add_string(struct mpv_node *dst, const char *key, const char *val) void node_map_add_int64(struct mpv_node *dst, const char *key, int64_t v); void node_map_add_double(struct mpv_node *dst, const char *key, double v); void node_map_add_flag(struct mpv_node *dst, const char *key, bool v); +mpv_node *node_map_get(mpv_node *src, const char *key); #endif |