Rev 4263 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4263 | Rev 4327 | ||
|---|---|---|---|
| Line 59... | Line 59... | ||
| 59 | char *tmp; |
59 | char *tmp; |
| 60 | 60 | ||
| 61 | if (NULL == usr->line) |
61 | if (NULL == usr->line) |
| 62 | return CL_EFAIL; |
62 | return CL_EFAIL; |
| 63 | 63 | ||
| 64 | tmp = strdup(usr->line); |
64 | tmp = str_dup(usr->line); |
| 65 | 65 | ||
| 66 | cmd[n] = strtok(tmp, " "); |
66 | cmd[n] = strtok(tmp, " "); |
| 67 | while (cmd[n] && n < WORD_MAX) { |
67 | while (cmd[n] && n < WORD_MAX) { |
| 68 | cmd[++n] = strtok(NULL, " "); |
68 | cmd[++n] = strtok(NULL, " "); |
| 69 | } |
69 | } |
| Line 144... | Line 144... | ||
| 144 | * Implement something like editline() / readline(), if even |
144 | * Implement something like editline() / readline(), if even |
| 145 | * just for command history and making arrows work. */ |
145 | * just for command history and making arrows work. */ |
| 146 | void get_input(cliuser_t *usr) |
146 | void get_input(cliuser_t *usr) |
| 147 | { |
147 | { |
| 148 | char line[INPUT_MAX]; |
148 | char line[INPUT_MAX]; |
| 149 | size_t len = 0; |
- | |
| 150 | 149 | ||
| 151 | console_set_style(STYLE_EMPHASIS); |
150 | console_set_style(STYLE_EMPHASIS); |
| 152 | printf("%s", usr->prompt); |
151 | printf("%s", usr->prompt); |
| 153 | console_set_style(STYLE_NORMAL); |
152 | console_set_style(STYLE_NORMAL); |
| 154 | 153 | ||
| 155 | read_line(line, INPUT_MAX); |
154 | read_line(line, INPUT_MAX); |
| 156 | len = strlen(line); |
- | |
| 157 | /* Make sure we don't have rubbish or a C/R happy user */ |
155 | /* Make sure we don't have rubbish or a C/R happy user */ |
| 158 | if (len == 0 || line[0] == '\n') |
156 | if (str_cmp(line, "") == 0 || str_cmp(line, "\n") == 0) |
| 159 | return; |
157 | return; |
| 160 | usr->line = strdup(line); |
158 | usr->line = str_dup(line); |
| 161 | 159 | ||
| 162 | return; |
160 | return; |
| 163 | } |
161 | } |
| 164 | 162 | ||