Processes: JSON format support

This commit is contained in:
李通洲
2023-09-08 15:47:37 +08:00
parent 826aa2e46d
commit aff4a57092
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -33,7 +33,7 @@ void ffPrintProcesses(FFProcessesOptions* options)
void ffInitProcessesOptions(FFProcessesOptions* options)
{
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_PROCESSES_MODULE_NAME, ffParseProcessesCommandOptions, ffParseProcessesJsonObject, ffPrintProcesses, NULL);
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_PROCESSES_MODULE_NAME, ffParseProcessesCommandOptions, ffParseProcessesJsonObject, ffPrintProcesses, ffGenerateProcessesJson);
ffOptionInitModuleArg(&options->moduleArgs);
}
@@ -68,3 +68,17 @@ void ffParseProcessesJsonObject(FFProcessesOptions* options, yyjson_val* module)
ffPrintError(FF_PROCESSES_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
void ffGenerateProcessesJson(FF_MAYBE_UNUSED FFProcessesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
uint32_t result;
const char* error = ffDetectProcesses(&result);
if(error)
{
yyjson_mut_obj_add_str(doc, module, "error", error);
return;
}
yyjson_mut_obj_add_uint(doc, module, "result", result);
}
+1
View File
@@ -9,3 +9,4 @@ void ffInitProcessesOptions(FFProcessesOptions* options);
bool ffParseProcessesCommandOptions(FFProcessesOptions* options, const char* key, const char* value);
void ffDestroyProcessesOptions(FFProcessesOptions* options);
void ffParseProcessesJsonObject(FFProcessesOptions* options, yyjson_val* module);
void ffGenerateProcessesJson(FFProcessesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module);