Modules: return bool to indicate whether the detection is succeeded

This commit is contained in:
李通洲
2025-08-18 13:38:30 +08:00
parent a9aaa36b2c
commit 3b5e9c74d6
147 changed files with 869 additions and 538 deletions
+9 -2
View File
@@ -6,8 +6,9 @@
#define FF_INITSYSTEM_DISPLAY_NAME "Init System"
void ffPrintInitSystem(FFInitSystemOptions* options)
bool ffPrintInitSystem(FFInitSystemOptions* options)
{
bool success = false;
FFInitSystemResult result = {
.name = ffStrbufCreate(),
.exe = ffStrbufCreate(),
@@ -41,11 +42,14 @@ void ffPrintInitSystem(FFInitSystemOptions* options)
FF_FORMAT_ARG(result.pid, "pid"),
}));
}
success = true;
exit:
ffStrbufDestroy(&result.name);
ffStrbufDestroy(&result.exe);
ffStrbufDestroy(&result.version);
return success;
}
void ffParseInitSystemJsonObject(FFInitSystemOptions* options, yyjson_val* module)
@@ -66,8 +70,9 @@ void ffGenerateInitSystemJsonConfig(FFInitSystemOptions* options, yyjson_mut_doc
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
}
void ffGenerateInitSystemJsonResult(FF_MAYBE_UNUSED FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
bool ffGenerateInitSystemJsonResult(FF_MAYBE_UNUSED FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
{
bool success = false;
FFInitSystemResult result = {
.name = ffStrbufCreate(),
.exe = ffStrbufCreate(),
@@ -88,11 +93,13 @@ void ffGenerateInitSystemJsonResult(FF_MAYBE_UNUSED FFInitSystemOptions* options
yyjson_mut_obj_add_strbuf(doc, obj, "exe", &result.exe);
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result.version);
yyjson_mut_obj_add_uint(doc, obj, "pid", result.pid);
success = true;
exit:
ffStrbufDestroy(&result.name);
ffStrbufDestroy(&result.exe);
ffStrbufDestroy(&result.version);
return success;
}
void ffInitInitSystemOptions(FFInitSystemOptions* options)
+1 -1
View File
@@ -4,7 +4,7 @@
#define FF_INITSYSTEM_MODULE_NAME "InitSystem"
void ffPrintInitSystem(FFInitSystemOptions* options);
bool ffPrintInitSystem(FFInitSystemOptions* options);
void ffInitInitSystemOptions(FFInitSystemOptions* options);
void ffDestroyInitSystemOptions(FFInitSystemOptions* options);