-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.c
More file actions
49 lines (40 loc) · 1.19 KB
/
input.c
File metadata and controls
49 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* input.c
*
* (C) 2000 Jordan DeLong
*/
#include <string.h>
#include "kosh.h"
#include "builtin.h"
/* read command line, try to execute builtin commands, otherwise externals (this coming soon) */
void input_oneloop(void) {
int argc;
char *argv[20]; /* limit to 20 args (should be plenty) */
char *str;
char buff[256];
/* Wait for a line of input */
conio_printf("$ ");
if (conio_input_getline(-1, buff, 255) < 0) {
kosh_exit = 1;
return;
}
str = buff;
/* we don't care if the user just hit enter */
if (buff[0] == '\0')
return;
/* seperate the string into args */
for (argc = 0; argc < 20;) {
if ((argv[argc] = strsep(&str, " \t\n")) == NULL)
break;
if (*argv[argc] != '\0')
argc++;
}
/* try to run the command as a builtin */
if (!kosh_builtin_command(argc, argv)) {
/* makeabspath(buff, argv[0], NAME_MAX); */
/* the builtin failed so we try an external */
/* if (process->load_and_exec(buff, argc, argv))
conio_printf("kosh: %s: command not found\n", buff); */
conio_printf("Sorry, OS mode not available yet\n");
}
}