diff --git a/Makefile.build b/Makefile.build index 2989dec293f4810e3699e1ed16fda46804dfb59b..823d5af3f240461c01f294d8907cfee38a496ac4 100644 --- a/Makefile.build +++ b/Makefile.build @@ -55,6 +55,7 @@ lib/kernel_SRC += lib/kernel/console.c # printf(), putchar(). # User process code. userprog_SRC = userprog/process.c # Process loading. +userprog_SRC += userprog/parse_arguments.c # Parses arguments from command line string. userprog_SRC += userprog/populate_stack.c # Populates stack with program arguments. userprog_SRC += userprog/pagedir.c # Page directories. userprog_SRC += userprog/exception.c # User exception handler. diff --git a/userprog/argument_parsing.h b/userprog/argument_parsing.h index 78be27f44035bdf14e2f6f9dbb867978bd527a99..78f4e0eca38b95a4c16e3963d9944105bc1906ef 100644 --- a/userprog/argument_parsing.h +++ b/userprog/argument_parsing.h @@ -1,6 +1,15 @@ #ifndef USERPROG_ARGUMENT_PARSING_H #define USERPROG_ARGUMENT_PARSING_H +/* + * Given a string containing the command invoking the program `command_line` + * and a pointer to an array of C strings (pointer to `char* argv[]`), parse + * `command_line` into individual arguments, populate `argv` with these and + * return the number of arguments that were parsed (this is the value that can + * be used for `argc`). + */ +int parse_arguments(const char* command_line, char***argv); + /* * Given stack pointer `esp`, argument count `argc` and arguments array `argv`, * Populates the stack pointed to by the stack pointer with the given arguments. diff --git a/userprog/parse_arguments.c b/userprog/parse_arguments.c new file mode 100644 index 0000000000000000000000000000000000000000..aeaefd0778156808a54f8c2b1da7b1197886efbc --- /dev/null +++ b/userprog/parse_arguments.c @@ -0,0 +1,6 @@ +#include "userprog/argument_parsing.h" + + +int parse_arguments(const char* command_line, char***argv) { + #warning "Implement me" +}