Skip to content
Snippets Groups Projects
Verified Commit 76fb9ae7 authored by ja3-saxby's avatar ja3-saxby
Browse files

Remove debugging code

parent 79d1b7f2
No related branches found
No related tags found
1 merge request!4Implement parse_arguments()
......@@ -5,19 +5,16 @@
int parse_arguments(const char* command_line, char**argv) {
printf("parse_arguments(command_line) = '%s'\n", command_line);
int argc = 0;
// the state pointer required by strtok_r() for use between calls
char* state_pointer;
// first call to strtok_r() is the only one where string to parse is passed
argv[0] = strtok_r(command_line, " ", &state_pointer);
printf("parse_arguments(): argv[0] = '%s'\n", argv[0]);
argc++;
// now, parse token-by-token for any additional arguments
char* token = strtok_r(NULL, " ", &state_pointer);
while (token != NULL) {
argv[argc] = token;
printf("parse_arguments(): argv[%d] = '%s'\n", argc, argv[argc]);
argc++;
token = strtok_r(NULL, " ", &state_pointer);
}
......
......@@ -234,16 +234,11 @@ load (const char *command, void (**eip) (void), void **esp)
// extract arguments (including file name)
// NOTE: decide how many arguments we want --is 255 the standard number?
char* argv[255];
printf("load(command) = '%s'\n", command);
// copy the command string so we have a separate copy to manipulate
// generous length limit based on 255 arguments that are 15 chars long each
char command_copy[255];
strlcpy(command_copy, command, 255);
printf("load(): command_copy = '%s'\n", command_copy);
int argc = parse_arguments(command_copy, argv);
for (int i = 0; i < argc; i++) {
printf("load(): argv[%d] = '%s'\n", i, argv[i]);
}
char* file_name = argv[0]; // file name is always argument 0
/* Allocate and activate page directory. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment