JsonConfig: refactor to get rid of data-ffjson_*

This commit is contained in:
李通洲
2023-03-15 15:24:40 +08:00
parent 5f52c64d4d
commit dca9ce4b2d
37 changed files with 463 additions and 364 deletions
+13 -10
View File
@@ -61,7 +61,7 @@ void ffDestroySeparatorOptions(FFSeparatorOptions* options)
}
#ifdef FF_HAVE_JSONC
bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module)
bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module)
{
if (strcasecmp(type, FF_SEPARATOR_MODULE_NAME) != 0)
return false;
@@ -69,18 +69,21 @@ bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCDat
FFSeparatorOptions __attribute__((__cleanup__(ffDestroySeparatorOptions))) options;
ffInitSeparatorOptions(&options);
FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val)
if (module)
{
if (strcasecmp(key, "type") == 0)
continue;
if (strcasecmp(key, "string") == 0)
json_object_object_foreach(module, key, val)
{
ffStrbufSetS(&options.string, data->ffjson_object_get_string(val));
continue;
}
if (strcasecmp(key, "type") == 0)
continue;
ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
if (strcasecmp(key, "string") == 0)
{
ffStrbufSetS(&options.string, json_object_get_string(val));
continue;
}
ffPrintErrorString(instance, FF_SEPARATOR_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key);
}
}
ffPrintSeparator(instance, &options);
+2 -2
View File
@@ -9,6 +9,6 @@ bool ffParseSeparatorCommandOptions(FFSeparatorOptions* options, const char* key
void ffDestroySeparatorOptions(FFSeparatorOptions* options);
#ifdef FF_HAVE_JSONC
#include "common/config.h"
bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module);
#include "common/jsonconfig.h"
bool ffParseSeparatorJsonObject(FFinstance* instance, const char* type, json_object* module);
#endif