diff options
Diffstat (limited to 'i3bar/src/mode.c')
-rw-r--r-- | i3bar/src/mode.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/i3bar/src/mode.c b/i3bar/src/mode.c index 13d02110..aea43ab4 100644 --- a/i3bar/src/mode.c +++ b/i3bar/src/mode.c @@ -16,7 +16,6 @@ /* A datatype to pass through the callbacks to save the state */ struct mode_json_params { - char *json; char *cur_key; char *name; bool pango_markup; @@ -96,26 +95,17 @@ static yajl_callbacks mode_callbacks = { }; /* - * Start parsing the received JSON string + * Parse the received JSON string * */ -void parse_mode_json(char *json) { - /* FIXME: Fasciliate stream processing, i.e. allow starting to interpret - * JSON in chunks */ +void parse_mode_json(const unsigned char *json, size_t size) { struct mode_json_params params; - mode binding; - params.cur_key = NULL; - params.json = json; params.mode = &binding; - yajl_handle handle; - yajl_status state; - - handle = yajl_alloc(&mode_callbacks, NULL, (void *)¶ms); - - state = yajl_parse(handle, (const unsigned char *)json, strlen(json)); + yajl_handle handle = yajl_alloc(&mode_callbacks, NULL, (void *)¶ms); + yajl_status state = yajl_parse(handle, json, size); /* FIXME: Proper error handling for JSON parsing */ switch (state) { |