JsonConfig: prepare for module weather and public ip

This commit is contained in:
李通洲
2023-08-18 13:28:07 +08:00
parent 55b9e274b6
commit 77e0d9dba1
6 changed files with 63 additions and 14 deletions
+8 -4
View File
@@ -564,7 +564,7 @@ static bool parseJsoncFile(const char* path)
{
if (error.code != YYJSON_READ_ERROR_FILE_OPEN)
{
fprintf(stderr, "ERROR: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg);
fprintf(stderr, "Error: failed to parse JSON config file `%s` at pos %zu: %s\n", path, error.pos, error.msg);
exit(477);
}
return false;
@@ -1256,7 +1256,11 @@ int main(int argc, const char** argv)
}
}
if(data.structure.length > 0 || !instance.state.configDoc)
const bool useJsonConfig = data.structure.length == 0 && instance.state.configDoc;
if(useJsonConfig)
ffPrintJsonConfig(true);
else
{
//If we don't have a custom structure, use the default one
if(data.structure.length == 0)
@@ -1281,9 +1285,9 @@ int main(int argc, const char** argv)
if (!instance.config.noBuffer) fflush(stdout);
#endif
if (data.structure.length == 0 && instance.state.configDoc)
if (useJsonConfig)
{
ffPrintJsonConfig();
ffPrintJsonConfig(false);
}
else
{