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

Function parse_assignment

util/nvramtool/cli/nvramtool.c:695–718  ·  view source on GitHub ↗

* parse_assignment * * Parse the string 'arg' (which supposedly represents an assignment) into a * NAME and a VALUE. If 'arg' does not conform to the proper assignment * syntax, exit with a usage message. Otherwise, on return, 'arg' is broken * into substrings representing NAME and VALUE, and *name and *value are set * to point to these two substrings. ************************************

Source from the content-addressed store, hash-verified

693 * to point to these two substrings.
694 ****************************************************************************/
695static void parse_assignment(char arg[], const char **name, const char **value)
696{
697 static const size_t N_MATCHES = 4;
698 regmatch_t match[N_MATCHES];
699 regex_t assignment;
700
701 compile_reg_expr(REG_EXTENDED | REG_NEWLINE, assignment_regex, &assignment);
702
703 /* Does 'arg' conform to proper assignment syntax? If not, exit with a
704 * usage message.
705 */
706 if (regexec(&assignment, arg, N_MATCHES, match, 0))
707 usage(stderr);
708
709 /* Ok, we found a valid assignment. Break it into two strings
710 * representing NAME and VALUE.
711 */
712 arg[match[1].rm_eo] = '\0';
713 arg[match[2].rm_eo] = '\0';
714 *name = &arg[match[1].rm_so];
715 *value = &arg[match[2].rm_so];
716
717 regfree(&assignment);
718}
719
720/****************************************************************************
721 * list_cmos_entry

Callers 1

op_cmos_set_one_paramFunction · 0.85

Calls 4

regexecFunction · 0.85
regfreeFunction · 0.85
compile_reg_exprFunction · 0.50
usageFunction · 0.50

Tested by

no test coverage detected