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.
29 lines
624 B
C
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);
|
|
}
|