Strip a flag from argv, returning true if found. */
| 239 | |
| 240 | /* Strip a flag from argv, returning true if found. */ |
| 241 | static bool cli_strip_flag(int *argc, char **argv, const char *flag) { |
| 242 | for (int i = 0; i < *argc; i++) { |
| 243 | if (strcmp(argv[i], flag) != 0) { |
| 244 | continue; |
| 245 | } |
| 246 | for (int j = i; j < *argc - SKIP_ONE; j++) { |
| 247 | argv[j] = argv[j + SKIP_ONE]; |
| 248 | } |
| 249 | (*argc)--; |
| 250 | return true; |
| 251 | } |
| 252 | return false; |
| 253 | } |
| 254 | |
| 255 | /* Strip a flag AND its following value from argv, returning the value (a pointer |
| 256 | * into the original argv strings, valid for the process lifetime) or NULL if the |