added command parse func to main
parent
0ebcdc3ad5
commit
635fb539a3
24
main.c
24
main.c
|
@ -1,3 +1,26 @@
|
|||
void
|
||||
parse_command(char *input) {
|
||||
static char com[COM_BUF_SIZE];
|
||||
memcpy(com, input, COM_BUF_SIZE);
|
||||
static char *starts[128];
|
||||
memset(starts, 0, sizeof(starts));
|
||||
int next_start = 0;
|
||||
com[COM_BUF_SIZE - 1] = ' ';
|
||||
for (int i = 0; i < COM_BUF_SIZE; i++) {
|
||||
for (; com[i] == ' ' && i < COM_BUF_SIZE; i++);
|
||||
if (i >= COM_BUF_SIZE) break;
|
||||
starts[next_start] = com + i;
|
||||
for(; i < COM_BUF_SIZE && com[i] != ' '; i++)
|
||||
;
|
||||
com[i] = '\0';
|
||||
next_start++;
|
||||
}
|
||||
|
||||
for (int i = 0; starts[i] != NULL; i++) {
|
||||
puts(starts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
static char buf[COM_BUF_SIZE];
|
||||
|
@ -19,3 +42,4 @@ main(int argc, char **argv) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue