Added single split function, added error message to kernel32
This commit is contained in:
parent
290794b885
commit
c803f4a38e
18
kernel32.c
18
kernel32.c
@ -25,11 +25,10 @@ int main() {
|
||||
buffer[i] = 0;
|
||||
readline(128, buffer);
|
||||
|
||||
char* argv[32];
|
||||
int argc = string_split(' ', buffer, argv);
|
||||
char* rest = split_on_first(' ', buffer);
|
||||
|
||||
|
||||
if (strcmp(argv[0], "help", 4)) {
|
||||
if (strcmp(buffer, "help", 4)) {
|
||||
printf(
|
||||
"XnoeOS 32 Bit Mode Help.\n"
|
||||
"------------------------\n"
|
||||
@ -37,15 +36,16 @@ int main() {
|
||||
": Shows this message\n"
|
||||
"- clear\n"
|
||||
": Clears the screen\n"
|
||||
" - echo\n"
|
||||
": Repeats the text written afterwards\n"
|
||||
);
|
||||
} else if (strcmp(argv[0], "clear", 5)) {
|
||||
} else if (strcmp(buffer, "clear", 5)) {
|
||||
clear_screen();
|
||||
set_curpos(0, 0);
|
||||
} else if (strcmp(argv[0], "echo", 4)) {
|
||||
int index = 0;
|
||||
while (++index <= argc)
|
||||
printf("%s ", argv[index]);
|
||||
printf("\n");
|
||||
} else if (strcmp(buffer, "echo", 4)) {
|
||||
printf("%s\n", rest);
|
||||
} else {
|
||||
printf("Bad Command or filename!\n");
|
||||
}
|
||||
}
|
||||
}
|
14
strings.c
14
strings.c
@ -10,6 +10,20 @@ bool strcmp(char* a, char* b, int max) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char* split_on_first(char delimeter, char* string) {
|
||||
int index = 0;
|
||||
char current;
|
||||
|
||||
while (current = string[index++]) {
|
||||
if (current == delimeter) {
|
||||
string[index-1] = 0;
|
||||
return string+index;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int string_split(char delimeter, char* string, char** pointer_array) {
|
||||
int index = 0;
|
||||
int last_split_index = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user