MCPcopy Create free account
hub / github.com/coreboot/coreboot / main

Function main

util/cbfstool/elogtool.c:370–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370int main(int argc, char **argv)
371{
372 char *filename = NULL;
373 enum elogtool_flag flags = 0;
374 struct buffer buf;
375 unsigned int i;
376 int argflag;
377 int ret;
378
379 if (argc < 2) {
380 usage(argv[0]);
381 return ELOGTOOL_EXIT_BAD_ARGS;
382 }
383
384 while (1) {
385 int option_index;
386 argflag = getopt_long(argc, argv, "Uhf:", long_options, &option_index);
387 if (argflag == -1)
388 break;
389
390 switch (argflag) {
391 case 'h':
392 case '?':
393 usage(argv[0]);
394 return ELOGTOOL_EXIT_SUCCESS;
395
396 case 'f':
397 if (!optarg) {
398 usage(argv[0]);
399 return ELOGTOOL_EXIT_BAD_ARGS;
400 }
401
402 filename = optarg;
403 break;
404 case 'U':
405 flags |= ELOGTOOL_FLAG_UTC;
406 break;
407
408 default:
409 break;
410 }
411 }
412
413 /* At least one command must be available. */
414 if (optind >= argc) {
415 usage(argv[0]);
416 return ELOGTOOL_EXIT_BAD_ARGS;
417 }
418
419 /* Returned buffer must be freed. */
420 ret = elog_read(&buf, filename);
421 if (ret)
422 return ret;
423
424 for (i = 0; i < ARRAY_SIZE(cmds); i++) {
425 if (!strcmp(cmds[i].name, argv[optind])) {
426 /* For commands that parse their own arguments. */
427 cmd_argv = &argv[optind+1];

Callers

nothing calls this directly

Calls 6

getopt_longFunction · 0.85
elog_readFunction · 0.85
elog_writeFunction · 0.85
buffer_deleteFunction · 0.85
usageFunction · 0.70
strcmpFunction · 0.50

Tested by

no test coverage detected