Strip a flag from argv, returning true if found. */
| 568 | |
| 569 | /* Strip a flag from argv, returning true if found. */ |
| 570 | static bool cli_strip_flag(int *argc, char **argv, const char *flag) { |
| 571 | for (int i = 0; i < *argc; i++) { |
| 572 | if (strcmp(argv[i], flag) != 0) { |
| 573 | continue; |
| 574 | } |
| 575 | for (int j = i; j < *argc - SKIP_ONE; j++) { |
| 576 | argv[j] = argv[j + SKIP_ONE]; |
| 577 | } |
| 578 | (*argc)--; |
| 579 | return true; |
| 580 | } |
| 581 | return false; |
| 582 | } |
| 583 | |
| 584 | /* Strip a flag AND its following value from argv, returning the value (a pointer |
| 585 | * into the original argv strings, valid for the process lifetime) or NULL if the |