20
20
*/
21
21
22
22
#include <stdio.h>
23
+ #include <string.h>
23
24
#include <strings.h>
24
25
#include <stdlib.h>
25
26
#include <getopt.h>
@@ -171,6 +172,10 @@ static const struct string_keyword opt_string_keyword[] = {
171
172
{ "processor-frequency" , 4 , 0x16 }, /* dmi_processor_frequency() */
172
173
};
173
174
175
+ /* This is a template, 3rd field is set at runtime. */
176
+ static struct string_keyword opt_oem_string_keyword =
177
+ { NULL , 11 , 0x00 };
178
+
174
179
static void print_opt_string_list (void )
175
180
{
176
181
unsigned int i ;
@@ -206,6 +211,34 @@ static int parse_opt_string(const char *arg)
206
211
return -1 ;
207
212
}
208
213
214
+ static int parse_opt_oem_string (const char * arg )
215
+ {
216
+ unsigned long val ;
217
+ char * next ;
218
+
219
+ if (opt .string )
220
+ {
221
+ fprintf (stderr , "Only one string can be specified\n" );
222
+ return -1 ;
223
+ }
224
+
225
+ /* Return the number of OEM strings */
226
+ if (strcmp (arg , "count" ) == 0 )
227
+ goto done ;
228
+
229
+ val = strtoul (arg , & next , 10 );
230
+ if (next == arg || val == 0x00 || val > 0xff )
231
+ {
232
+ fprintf (stderr , "Invalid OEM string number: %s\n" , arg );
233
+ return -1 ;
234
+ }
235
+
236
+ opt_oem_string_keyword .offset = val ;
237
+ done :
238
+ opt .string = & opt_oem_string_keyword ;
239
+ return 0 ;
240
+ }
241
+
209
242
210
243
/*
211
244
* Command line options handling
@@ -225,6 +258,7 @@ int parse_command_line(int argc, char * const argv[])
225
258
{ "dump" , no_argument , NULL , 'u' },
226
259
{ "dump-bin" , required_argument , NULL , 'B' },
227
260
{ "from-dump" , required_argument , NULL , 'F' },
261
+ { "oem-string" , required_argument , NULL , 'O' },
228
262
{ "no-sysfs" , no_argument , NULL , 'S' },
229
263
{ "version" , no_argument , NULL , 'V' },
230
264
{ NULL , 0 , NULL , 0 }
@@ -255,6 +289,11 @@ int parse_command_line(int argc, char * const argv[])
255
289
return -1 ;
256
290
opt .flags |= FLAG_QUIET ;
257
291
break ;
292
+ case 'O' :
293
+ if (parse_opt_oem_string (optarg ) < 0 )
294
+ return -1 ;
295
+ opt .flags |= FLAG_QUIET ;
296
+ break ;
258
297
case 't' :
259
298
opt .type = parse_opt_type (opt .type , optarg );
260
299
if (opt .type == NULL )
@@ -315,6 +354,7 @@ void print_help(void)
315
354
" --dump-bin FILE Dump the DMI data to a binary file\n"
316
355
" --from-dump FILE Read the DMI data from a binary file\n"
317
356
" --no-sysfs Do not attempt to read DMI data from sysfs files\n"
357
+ " --oem-string N Only display the value of the given OEM string\n"
318
358
" -V, --version Display the version and exit\n" ;
319
359
320
360
printf ("%s" , help );
0 commit comments