The current behavior when searching for a specific parameter is to exit with an error when the first unexpected parameter is found. The function argv_find() will search for a specific parameter, ignoring all other parameters. Consumers for the function will be added in a later patch. Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> --- lib/argv.h | 1 + lib/argv.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/argv.h b/lib/argv.h index 2104dd42748d..efc390ae4fae 100644 --- a/lib/argv.h +++ b/lib/argv.h @@ -8,3 +8,4 @@ extern void __setup_args(void); extern void setup_args_progname(const char *args); extern void setup_env(char *env, int size); +extern int argv_find(const char *needle, int argc, char **argv); diff --git a/lib/argv.c b/lib/argv.c index f0e183a8f02f..6e4593997e0b 100644 --- a/lib/argv.c +++ b/lib/argv.c @@ -144,3 +144,14 @@ void setup_env(char *env, int size) *env++ = '\0'; } } + +int argv_find(const char *needle, int argc, char **argv) +{ + int i; + + for (i = 0; i < argc; i++) + if (strcmp(argv[i], needle) == 0) + return i; + + return -1; +} -- 2.17.0 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm