Strip a flag from argv, returning true if found. */
| 695 | |
| 696 | /* Strip a flag from argv, returning true if found. */ |
| 697 | static bool cli_strip_flag(int *argc, char **argv, const char *flag) { |
| 698 | for (int i = 0; i < *argc; i++) { |
| 699 | if (strcmp(argv[i], flag) != 0) { |
| 700 | continue; |
| 701 | } |
| 702 | for (int j = i; j < *argc - SKIP_ONE; j++) { |
| 703 | argv[j] = argv[j + SKIP_ONE]; |
| 704 | } |
| 705 | (*argc)--; |
| 706 | return true; |
| 707 | } |
| 708 | return false; |
| 709 | } |
| 710 | |
| 711 | /* Strip a flag AND its following value from argv, returning the value (a pointer |
| 712 | * into the original argv strings, valid for the process lifetime) or NULL if the |