This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neco/src/util.h
Matthias Schiffer bcef77a7fb
Switch to a JSON-based config format
We can get rid of a lot of code by ditching out INI format parser. We also
remove the support for "subtype" and "generator" templates for now; rather
than implementing this in NeCo itself, templates could be implemented as
a Lua DSL later.
2019-05-31 18:42:01 +02:00

29 lines
624 B
C

#pragma once
#include <json-c/json.h>
#define NODE_NAME(c) (*(char **)&(c)->node.key)
static inline struct json_object * neco_json_get_value(
struct json_object *obj,
const char *key,
enum json_type type
) {
struct json_object *value;
if (!json_object_object_get_ex(obj, key, &value))
return NULL;
if (!json_object_is_type(value, type))
return NULL;
return value;
}
static inline const char * neco_json_get_string(struct json_object *obj, const char *key) {
struct json_object *value = neco_json_get_value(obj, key, json_type_string);
if (!value)
return NULL;
return json_object_get_string(value);
}