Strip a flag from argv, returning true if found. */
| 738 | |
| 739 | /* Strip a flag from argv, returning true if found. */ |
| 740 | static bool cli_strip_flag(int *argc, char **argv, const char *flag) { |
| 741 | for (int i = 0; i < *argc; i++) { |
| 742 | if (strcmp(argv[i], flag) != 0) { |
| 743 | continue; |
| 744 | } |
| 745 | for (int j = i; j < *argc - SKIP_ONE; j++) { |
| 746 | argv[j] = argv[j + SKIP_ONE]; |
| 747 | } |
| 748 | (*argc)--; |
| 749 | return true; |
| 750 | } |
| 751 | return false; |
| 752 | } |
| 753 | |
| 754 | /* Strip a flag AND its following value from argv, returning the value (a pointer |
| 755 | * into the original argv strings, valid for the process lifetime) or NULL if the |