Kernel: add JSON format support

This commit is contained in:
李通洲
2023-09-05 16:09:46 +08:00
parent dfbfb88a45
commit 39b21f95b7
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -32,7 +32,7 @@ void ffPrintKernel(FFKernelOptions* options)
void ffInitKernelOptions(FFKernelOptions* options)
{
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_KERNEL_MODULE_NAME, ffParseKernelCommandOptions, ffParseKernelJsonObject, ffPrintKernel, NULL);
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_KERNEL_MODULE_NAME, ffParseKernelCommandOptions, ffParseKernelJsonObject, ffPrintKernel, ffGenerateKernelJson);
ffOptionInitModuleArg(&options->moduleArgs);
}
@@ -67,3 +67,12 @@ void ffParseKernelJsonObject(FFKernelOptions* options, yyjson_val* module)
ffPrintError(FF_KERNEL_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
void ffGenerateKernelJson(FF_MAYBE_UNUSED FFKernelOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
yyjson_mut_obj_add_strbuf(doc, obj, "architecture", &instance.state.platform.systemArchitecture);
yyjson_mut_obj_add_strbuf(doc, obj, "name", &instance.state.platform.systemName);
yyjson_mut_obj_add_strbuf(doc, obj, "release", &instance.state.platform.systemRelease);
yyjson_mut_obj_add_strbuf(doc, obj, "version", &instance.state.platform.systemVersion);
}