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
+18 -15
View File
@@ -175,7 +175,7 @@ void ffDestroyOSOptions(FFOSOptions* options)
}
#ifdef FF_HAVE_JSONC
bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module)
bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module)
{
if (strcasecmp(type, FF_OS_MODULE_NAME) != 0)
return false;
@@ -183,23 +183,26 @@ bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data
FFOSOptions __attribute__((__cleanup__(ffDestroyOSOptions))) options;
ffInitOSOptions(&options);
FF_JSON_OBJECT_OBJECT_FOREACH(data, module, key, val)
if (module)
{
if (strcasecmp(key, "type") == 0)
continue;
if (ffJsonConfigParseModuleArgs(data, key, val, &options.moduleArgs))
continue;
#if defined(__linux__) || defined(__FreeBSD__)
if (strcasecmp(key, "file") == 0)
{
ffStrbufSetS(&options.file, data->ffjson_object_get_string(val));
json_object_object_foreach(module, key, val)
{
if (strcasecmp(key, "type") == 0)
continue;
}
#endif
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
if (ffJsonConfigParseModuleArgs(key, val, &options.moduleArgs))
continue;
#if defined(__linux__) || defined(__FreeBSD__)
if (strcasecmp(key, "file") == 0)
{
ffStrbufSetS(&options.file, json_object_get_string(val));
continue;
}
#endif
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &options.moduleArgs, "Unknown JSON key %s", key);
}
}
ffPrintOS(instance, &options);
+2 -2
View File
@@ -9,6 +9,6 @@ bool ffParseOSCommandOptions(FFOSOptions* options, const char* key, const char*
void ffDestroyOSOptions(FFOSOptions* options);
#ifdef FF_HAVE_JSONC
#include "common/config.h"
bool ffParseOSJsonObject(FFinstance* instance, const char* type, JSONCData* data, json_object* module);
#include "common/jsonconfig.h"
bool ffParseOSJsonObject(FFinstance* instance, const char* type, json_object* module);
#endif