please ;-;

This commit is contained in:
Jonathan Turner 2023-11-29 08:06:18 -05:00
parent 83cf16d15a
commit ac1eef983f
2 changed files with 34 additions and 4 deletions

View File

@ -45,11 +45,22 @@ void user_input(char *input) {
} else if (strncmp(input, "ADD", 3) == 0) { } else if (strncmp(input, "ADD", 3) == 0) {
// Parse the base register value from the user input // Parse the base register value from the user input
char base_str[16]; char base_str[16];
kprint("Enter base register value: ");
kread(base_str);
u32 base = atoi(base_str);
umem_head = add_node(umem_head, base, 0x100, true, global_id++); // Get input from your input source (you need to implement this)
get_input(base_str);
// Check if the input matches the expected message
if (strcmp(base_str, "Enter base register value: ") == 0) {
// Input matches, proceed to read the value
get_input(base_str); // Assuming get_input reads the actual value
u32 base = digit_conver(base_str);
umem_head = add_node(umem_head, base, 0x100, true, global_id++);
} else {
// Input doesn't match the expected message
kprint("Invalid input format.\n");
// Handle the error or prompt the user again
}
} else if (strcmp(input, "LIST") == 0) { } else if (strcmp(input, "LIST") == 0) {
kprint("***** FORWARD ****\n"); kprint("***** FORWARD ****\n");
print_list( umem_head, true); print_list( umem_head, true);
@ -113,3 +124,20 @@ void user_input(char *input) {
} }
kprint("> "); kprint("> ");
} }
int digconver(const char *str) {
int result = 0;
int i = 0;
while (str[i] != '\0') {
if (str[i] >= '0' && str[i] <= '9') {
result = result * 10 + (str[i] - '0');
} else {
kprint("Error - Provided input is not a valid number.\n");
return 0;
}
i++;
}
return result;
}

View File

@ -11,4 +11,6 @@
void user_input(char *input); void user_input(char *input);
int digit_conver(const char *str);
#endif #endif