summaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-12 14:48:24 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:34 +0200
commit1157f07c5b8b97112f9a6bde695aff8072a88fb2 (patch)
tree03cb53ab5789bca871228cef6698f97d87b92ac4 /misc
parent4fd3ad8d63aabeb1dc2448d650bb942d24163f54 (diff)
downloadmpv-1157f07c5b8b97112f9a6bde695aff8072a88fb2.tar.bz2
mpv-1157f07c5b8b97112f9a6bde695aff8072a88fb2.tar.xz
node: move a mpv_node helper from ipc.c to shared code
This particular one is needed in a following commit.
Diffstat (limited to 'misc')
-rw-r--r--misc/node.c13
-rw-r--r--misc/node.h1
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