Create argument parsing interface
Here's the header file I am proposing for the argument-parsing interface:
#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.
* TODO: clarify what, if anything, `esp` stands for and rename it to something
* clearer if possible.
*/
void populate_stack(void* esp, int argc, char** argv);
#endif /* userprog/argument_parsing.h */
If this interface is accepted, then we will need to implement the functions prototyped in this header and then add a small additional bit of code in userprog/process.c
to tie it all together. This latter part should be quite straightforward and we can follow the sample implementation provided at https://blackboard.uwe.ac.uk/webapps/blackboard/execute/content/file?cmd=view&content_id=_7203569_1&course_id=_323032_1 for a guide on structure.
Edited by ja3-saxby