* @brief Helper routine to parse a single arg and return its mask * * Parse all the - options to create a mask (or a serial speed in the * case of -S). If the arg doesn't start with '-' assume it's an env * variable and set that instead. */
| 125 | * variable and set that instead. |
| 126 | */ |
| 127 | int |
| 128 | boot_parse_arg(char *v) |
| 129 | { |
| 130 | char *n; |
| 131 | int howto; |
| 132 | |
| 133 | #if 0 |
| 134 | /* Need to see if this is better or worse than the meat of the #else */ |
| 135 | static const char howto_switches[] = "aCdrgDmphsv"; |
| 136 | static int howto_masks[] = { |
| 137 | RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE, |
| 138 | RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE |
| 139 | }; |
| 140 | |
| 141 | opts = strchr(kargs, '-'); |
| 142 | while (opts != NULL) { |
| 143 | while (*(++opts) != '\0') { |
| 144 | sw = strchr(howto_switches, *opts); |
| 145 | if (sw == NULL) |
| 146 | break; |
| 147 | howto |= howto_masks[sw - howto_switches]; |
| 148 | } |
| 149 | opts = strchr(opts, '-'); |
| 150 | } |
| 151 | #else |
| 152 | howto = 0; |
| 153 | if (*v == '-') { |
| 154 | while (*v != '\0') { |
| 155 | v++; |
| 156 | switch (*v) { |
| 157 | case 'a': howto |= RB_ASKNAME; break; |
| 158 | case 'C': howto |= RB_CDROM; break; |
| 159 | case 'd': howto |= RB_KDB; break; |
| 160 | case 'D': howto |= RB_MULTIPLE; break; |
| 161 | case 'm': howto |= RB_MUTE; break; |
| 162 | case 'g': howto |= RB_GDB; break; |
| 163 | case 'h': howto |= RB_SERIAL; break; |
| 164 | case 'p': howto |= RB_PAUSE; break; |
| 165 | case 'P': howto |= RB_PROBE; break; |
| 166 | case 'r': howto |= RB_DFLTROOT; break; |
| 167 | case 's': howto |= RB_SINGLE; break; |
| 168 | case 'S': SETENV("comconsole_speed", v + 1); v += strlen(v); break; |
| 169 | case 'v': howto |= RB_VERBOSE; break; |
| 170 | } |
| 171 | } |
| 172 | } else { |
| 173 | n = strsep(&v, "="); |
| 174 | if (v == NULL) |
| 175 | SETENV(n, "1"); |
| 176 | else |
| 177 | SETENV(n, v); |
| 178 | } |
| 179 | #endif |
| 180 | return (howto); |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * @brief breakup the command line into args, and pass to boot_parse_arg |
no test coverage detected