eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 0d7482e37955b9fd03863bc99c92a3eee6c0766d
parent 01ea05d65090d5a28678fd3e0b4883c20b204619
Author: James Prestwood <prestwoj@gmail.com>
Date:   Thu,  6 Jan 2022 11:50:05 -0800

json: add json_iter_get_container

This allows getting an iterator for a container nested inside
an array.

Diffstat:
Msrc/json.c | 14++++++++++++++
Msrc/json.h | 2++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/json.c b/src/json.c @@ -384,6 +384,20 @@ bool json_iter_get_null(struct json_iter *iter) return false; } +bool json_iter_get_container(struct json_iter *iter, + struct json_iter *container) +{ + struct json_contents *c = iter->contents; + jsmntok_t *t = c->tokens + iter->current; + + if (t->type != JSMN_OBJECT && t->type != JSMN_ARRAY) + return false; + + iter_recurse(iter, t, container); + + return true; +} + enum json_type json_iter_get_type(struct json_iter *iter) { struct json_contents *c = iter->contents; diff --git a/src/json.h b/src/json.h @@ -93,6 +93,8 @@ bool json_iter_get_int(struct json_iter *iter, int *i); bool json_iter_get_uint(struct json_iter *iter, unsigned int *i); bool json_iter_get_boolean(struct json_iter *iter, bool *b); bool json_iter_get_null(struct json_iter *iter); +bool json_iter_get_container(struct json_iter *iter, + struct json_iter *container); enum json_type json_iter_get_type(struct json_iter *iter); bool json_iter_next(struct json_iter *iter);