| 291 | } |
| 292 | |
| 293 | int Debugger::ParseArgs(char *aArgs, char **aArgV, int &aArgCount, char *&aTransactionId) |
| 294 | { |
| 295 | aArgCount = 0; |
| 296 | |
| 297 | while (*aArgs) |
| 298 | { |
| 299 | if (aArgCount == MAX_DBGP_ARGS) |
| 300 | return DEBUGGER_E_PARSE_ERROR; |
| 301 | |
| 302 | if (*aArgs != '-') |
| 303 | return DEBUGGER_E_PARSE_ERROR; |
| 304 | ++aArgs; |
| 305 | |
| 306 | char arg_char = *aArgs; |
| 307 | if (!arg_char) |
| 308 | return DEBUGGER_E_PARSE_ERROR; |
| 309 | |
| 310 | if (aArgs[1] == ' ' && aArgs[2] != '-') |
| 311 | { |
| 312 | // Move the arg letter onto the space. |
| 313 | *++aArgs = arg_char; |
| 314 | } |
| 315 | // Store a pointer to the arg letter, followed immediately by its value. |
| 316 | aArgV[aArgCount++] = aArgs; |
| 317 | |
| 318 | if (arg_char == 'i') |
| 319 | { |
| 320 | // Handle transaction_id here to simplify many other sections. |
| 321 | aTransactionId = aArgs + 1; |
| 322 | --aArgCount; |
| 323 | } |
| 324 | |
| 325 | if (arg_char == '-') // -- base64-encoded-data |
| 326 | break; |
| 327 | |
| 328 | char *next_arg; |
| 329 | if (aArgs[1] == '"') |
| 330 | { |
| 331 | char *arg_end; |
| 332 | for (arg_end = aArgs + 1, next_arg = aArgs + 2; *next_arg != '"'; ++arg_end, ++next_arg) |
| 333 | { |
| 334 | if (*next_arg == '\\') |
| 335 | ++next_arg; // Currently only \\ and \" are supported; i.e. mark next char as literal. |
| 336 | if (!*next_arg) |
| 337 | return DEBUGGER_E_PARSE_ERROR; |
| 338 | // Copy the value to eliminate the quotes and escape sequences. |
| 339 | *arg_end = *next_arg; |
| 340 | } |
| 341 | *arg_end = '\0'; // Terminate this arg. |
| 342 | ++next_arg; |
| 343 | if (!*next_arg) |
| 344 | break; |
| 345 | if (strncmp(next_arg, " -", 2)) |
| 346 | return DEBUGGER_E_PARSE_ERROR; |
| 347 | } |
| 348 | else |
| 349 | { |
| 350 | // Find where this arg's value ends and the next arg begins. |
nothing calls this directly
no outgoing calls
no test coverage detected