Skip to content
Snippets Groups Projects

Create argument parsing interface

Merged ja3-saxby requested to merge josh/argument-passing-interface into feature/argument-parsing
1 unresolved thread

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

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
21 21 static thread_func start_process NO_RETURN;
22 22 static bool load (const char *cmdline, void (**eip) (void), void **esp);
23 23
24 /* Starts a new thread running a user program loaded from
25 FILENAME. The new thread may be scheduled (and may even exit)
24 /* Starts a new thread running a user program loaded by parsing
25 COMMAND. The new thread may be scheduled (and may even exit)
26 26 before process_execute() returns. Returns the new process's
27 27 thread id, or TID_ERROR if the thread cannot be created. */
28 28 tid_t
29 process_execute (const char *file_name)
29 process_execute (const char *command)
30 30 {
31 31 char *fn_copy;
  • ja3-saxby added 1 commit

    added 1 commit

    • b0a505f1 - Rename fn_copy to command_copy following feedback

    Compare with previous version

  • merged

  • a2-stratford mentioned in commit a217c45b

    mentioned in commit a217c45b

  • a2-stratford mentioned in commit 28d20c32

    mentioned in commit 28d20c32

  • Please register or sign in to reply
    Loading