44#include "modules/bios/bios.h"
55#include "util/stringUtils.h"
66
7- #define FF_BIOS_NUM_FORMAT_ARGS 4
7+ #define FF_BIOS_NUM_FORMAT_ARGS 5
88
99void ffPrintBios (FFBiosOptions * options )
1010{
@@ -13,9 +13,12 @@ void ffPrintBios(FFBiosOptions* options)
1313 ffStrbufInit (& bios .release );
1414 ffStrbufInit (& bios .vendor );
1515 ffStrbufInit (& bios .version );
16+ ffStrbufInit (& bios .type );
1617
1718 const char * error = ffDetectBios (& bios );
1819
20+ FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate ();
21+
1922 if (error )
2023 {
2124 ffPrintError (FF_BIOS_MODULE_NAME , 0 , & options -> moduleArgs , "%s" , error );
@@ -28,21 +31,40 @@ void ffPrintBios(FFBiosOptions* options)
2831 goto exit ;
2932 }
3033
34+ if (options -> moduleArgs .key .length == 0 )
35+ {
36+ if (bios .type .length == 0 )
37+ ffStrbufSetStatic (& bios .type , "Unknown" );
38+ else if (ffStrbufIgnCaseEqualS (& bios .type , "BIOS" ))
39+ ffStrbufSetStatic (& bios .type , "Legacy" );
40+
41+ ffStrbufSetF (& key , FF_BIOS_MODULE_NAME " (%s)" , bios .type .chars );
42+ }
43+ else
44+ {
45+ ffStrbufClear (& key );
46+ ffParseFormatString (& key , & options -> moduleArgs .key , 3 , (FFformatarg []){
47+ {FF_FORMAT_ARG_TYPE_STRBUF , & bios .type },
48+ });
49+ }
50+
3151 if (options -> moduleArgs .outputFormat .length == 0 )
3252 {
33- ffPrintLogoAndKey (FF_BIOS_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT );
53+ ffPrintLogoAndKey (key . chars , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT );
3454 ffStrbufWriteTo (& bios .version , stdout );
3555 if (bios .release .length )
36- printf (" (%s)" , bios .release .chars );
37- putchar ('\n' );
56+ printf (" (%s)\n" , bios .release .chars );
57+ else
58+ putchar ('\n' );
3859 }
3960 else
4061 {
41- ffPrintFormat (FF_BIOS_MODULE_NAME , 0 , & options -> moduleArgs , FF_BIOS_NUM_FORMAT_ARGS , (FFformatarg []) {
62+ ffPrintFormat (key . chars , 0 , & options -> moduleArgs , FF_BIOS_NUM_FORMAT_ARGS , (FFformatarg []) {
4263 {FF_FORMAT_ARG_TYPE_STRBUF , & bios .date },
4364 {FF_FORMAT_ARG_TYPE_STRBUF , & bios .release },
4465 {FF_FORMAT_ARG_TYPE_STRBUF , & bios .vendor },
4566 {FF_FORMAT_ARG_TYPE_STRBUF , & bios .version },
67+ {FF_FORMAT_ARG_TYPE_STRBUF , & bios .type },
4668 });
4769 }
4870
@@ -51,6 +73,7 @@ void ffPrintBios(FFBiosOptions* options)
5173 ffStrbufDestroy (& bios .release );
5274 ffStrbufDestroy (& bios .vendor );
5375 ffStrbufDestroy (& bios .version );
76+ ffStrbufDestroy (& bios .type );
5477}
5578
5679bool ffParseBiosCommandOptions (FFBiosOptions * options , const char * key , const char * value )
@@ -95,6 +118,7 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
95118 ffStrbufInit (& bios .release );
96119 ffStrbufInit (& bios .vendor );
97120 ffStrbufInit (& bios .version );
121+ ffStrbufInit (& bios .type );
98122
99123 const char * error = ffDetectBios (& bios );
100124
@@ -115,12 +139,14 @@ void ffGenerateBiosJsonResult(FF_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut
115139 yyjson_mut_obj_add_strbuf (doc , obj , "release" , & bios .release );
116140 yyjson_mut_obj_add_strbuf (doc , obj , "vendor" , & bios .vendor );
117141 yyjson_mut_obj_add_strbuf (doc , obj , "version" , & bios .version );
142+ yyjson_mut_obj_add_strbuf (doc , obj , "type" , & bios .type );
118143
119144exit :
120145 ffStrbufDestroy (& bios .date );
121146 ffStrbufDestroy (& bios .release );
122147 ffStrbufDestroy (& bios .vendor );
123148 ffStrbufDestroy (& bios .version );
149+ ffStrbufDestroy (& bios .type );
124150}
125151
126152void ffPrintBiosHelpFormat (void )
@@ -129,7 +155,8 @@ void ffPrintBiosHelpFormat(void)
129155 "bios date" ,
130156 "bios release" ,
131157 "bios vendor" ,
132- "bios version"
158+ "bios version" ,
159+ "firmware type" ,
133160 });
134161}
135162
0 commit comments