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;
|
buffer[i] = 0;
|
||||||
readline(128, buffer);
|
readline(128, buffer);
|
||||||
|
|
||||||
char* argv[32];
|
char* rest = split_on_first(' ', buffer);
|
||||||
int argc = string_split(' ', buffer, argv);
|
|
||||||
|
|
||||||
|
|
||||||
if (strcmp(argv[0], "help", 4)) {
|
if (strcmp(buffer, "help", 4)) {
|
||||||
printf(
|
printf(
|
||||||
"XnoeOS 32 Bit Mode Help.\n"
|
"XnoeOS 32 Bit Mode Help.\n"
|
||||||
"------------------------\n"
|
"------------------------\n"
|
||||||
@ -37,15 +36,16 @@ int main() {
|
|||||||
": Shows this message\n"
|
": Shows this message\n"
|
||||||
"- clear\n"
|
"- clear\n"
|
||||||
": Clears the screen\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();
|
clear_screen();
|
||||||
set_curpos(0, 0);
|
set_curpos(0, 0);
|
||||||
} else if (strcmp(argv[0], "echo", 4)) {
|
} else if (strcmp(buffer, "echo", 4)) {
|
||||||
int index = 0;
|
printf("%s\n", rest);
|
||||||
while (++index <= argc)
|
} else {
|
||||||
printf("%s ", argv[index]);
|
printf("Bad Command or filename!\n");
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
14
strings.c
14
strings.c
@ -10,6 +10,20 @@ bool strcmp(char* a, char* b, int max) {
|
|||||||
return true;
|
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 string_split(char delimeter, char* string, char** pointer_array) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int last_split_index = 0;
|
int last_split_index = 0;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
bool strcmp(char* a, char* b, int max);
|
bool strcmp(char* a, char* b, int max);
|
||||||
|
char* split_on_first(char delimeter, char* string);
|
||||||
int string_split(char delimeter, char* string, char** pointer_array);
|
int string_split(char delimeter, char* string, char** pointer_array);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user