2014-06-13 02:34:57 +02:00
|
|
|
#include "bind_config.h"
|
|
|
|
|
|
|
|
#include <platform.h>
|
|
|
|
#include <kernel/types.h>
|
|
|
|
#include <kernel/jsonconf.h>
|
2014-06-13 17:04:06 +02:00
|
|
|
#include <util/log.h>
|
2014-06-13 02:34:57 +02:00
|
|
|
#include <cJSON.h>
|
2014-06-13 22:02:03 +02:00
|
|
|
#include <string.h>
|
2014-06-13 02:34:57 +02:00
|
|
|
|
2014-06-13 22:02:03 +02:00
|
|
|
int config_parse(const char *json)
|
2014-06-13 02:34:57 +02:00
|
|
|
{
|
|
|
|
cJSON * conf = cJSON_Parse(json);
|
|
|
|
if (conf) {
|
|
|
|
json_config(conf);
|
|
|
|
cJSON_Delete(conf);
|
2014-06-13 22:02:03 +02:00
|
|
|
return 0;
|
2014-06-13 17:04:06 +02:00
|
|
|
} else {
|
2014-06-13 22:02:03 +02:00
|
|
|
int line;
|
|
|
|
char buffer[10];
|
|
|
|
const char *xp = json, *lp, *ep = cJSON_GetErrorPtr();
|
|
|
|
for (line=0;xp && xp<ep;++line) {
|
|
|
|
lp = xp;
|
|
|
|
xp = strchr(xp, '\n');
|
|
|
|
}
|
|
|
|
xp = (ep > json + 10) ? ep - 10 : json;
|
|
|
|
strncpy(buffer, xp, sizeof(buffer));
|
|
|
|
buffer[9] = 0;
|
|
|
|
log_error("json parse error in line %d, position %d, near `%s`\n", line, ep-lp, buffer);
|
|
|
|
return 1;
|
2014-06-13 02:34:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-13 22:02:03 +02:00
|
|
|
int config_read(const char *filename)
|
2014-06-13 02:34:57 +02:00
|
|
|
{
|
2014-06-13 22:02:03 +02:00
|
|
|
return 1;
|
2014-06-13 02:34:57 +02:00
|
|
|
}
|
2014-06-13 22:02:03 +02:00
|
|
|
|