Rev 2572 | Rev 3194 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2572 | Rev 3193 | ||
---|---|---|---|
Line 167... | Line 167... | ||
167 | str[i] = str[i - 1]; |
167 | str[i] = str[i - 1]; |
168 | str[pos] = ch; |
168 | str[pos] = ch; |
169 | } |
169 | } |
170 | 170 | ||
171 | /** Try to find a command beginning with prefix */ |
171 | /** Try to find a command beginning with prefix */ |
172 | static const char * cmdtab_search_one(const char *name,link_t **startpos) |
172 | static const char *cmdtab_search_one(const char *name,link_t **startpos) |
173 | { |
173 | { |
174 | size_t namelen = strlen(name); |
174 | size_t namelen = strlen(name); |
175 | const char *curname; |
175 | const char *curname; |
176 | 176 | ||
177 | spinlock_lock(&cmd_lock); |
177 | spinlock_lock(&cmd_lock); |
Line 201... | Line 201... | ||
201 | * @param name - string to match, changed to hint on exit |
201 | * @param name - string to match, changed to hint on exit |
202 | * @return number of found matches |
202 | * @return number of found matches |
203 | */ |
203 | */ |
204 | static int cmdtab_compl(char *name) |
204 | static int cmdtab_compl(char *name) |
205 | { |
205 | { |
206 | static char output[MAX_SYMBOL_NAME+1]; |
206 | static char output[MAX_SYMBOL_NAME + 1]; |
207 | link_t *startpos = NULL; |
207 | link_t *startpos = NULL; |
208 | const char *foundtxt; |
208 | const char *foundtxt; |
209 | int found = 0; |
209 | int found = 0; |
210 | int i; |
210 | int i; |
211 | 211 | ||
212 | output[0] = '\0'; |
212 | output[0] = '\0'; |
213 | while ((foundtxt = cmdtab_search_one(name, &startpos))) { |
213 | while ((foundtxt = cmdtab_search_one(name, &startpos))) { |
214 | startpos = startpos->next; |
214 | startpos = startpos->next; |
215 | if (!found) |
215 | if (!found) |
216 | strncpy(output, foundtxt, strlen(foundtxt)+1); |
216 | strncpy(output, foundtxt, strlen(foundtxt) + 1); |
217 | else { |
217 | else { |
218 | for (i = 0; output[i] && foundtxt[i] && |
218 | for (i = 0; output[i] && foundtxt[i] && |
219 | output[i] == foundtxt[i]; i++) |
219 | output[i] == foundtxt[i]; i++) |
220 | ; |
220 | ; |
221 | output[i] = '\0'; |
221 | output[i] = '\0'; |
Line 238... | Line 238... | ||
238 | strncpy(name, output, MAX_SYMBOL_NAME); |
238 | strncpy(name, output, MAX_SYMBOL_NAME); |
239 | return found; |
239 | return found; |
240 | 240 | ||
241 | } |
241 | } |
242 | 242 | ||
- | 243 | //char *clever_readline(const char *prompt, chardev_t *input); |
|
243 | static char * clever_readline(const char *prompt, chardev_t *input) |
244 | static char *clever_readline(const char *prompt, chardev_t *input) |
244 | { |
245 | { |
245 | static int histposition = 0; |
246 | static int histposition = 0; |
246 | 247 | ||
247 | static char tmp[MAX_CMDLINE+1]; |
248 | static char tmp[MAX_CMDLINE + 1]; |
248 | int curlen = 0, position = 0; |
249 | int curlen = 0, position = 0; |
249 | char *current = history[histposition]; |
250 | char *current = history[histposition]; |
250 | int i; |
251 | int i; |
251 | char mod; /* Command Modifier */ |
252 | char mod; /* Command Modifier */ |
252 | char c; |
253 | char c; |
Line 255... | Line 256... | ||
255 | while (1) { |
256 | while (1) { |
256 | c = _getc(input); |
257 | c = _getc(input); |
257 | if (c == '\n') { |
258 | if (c == '\n') { |
258 | putchar(c); |
259 | putchar(c); |
259 | break; |
260 | break; |
- | 261 | } |
|
260 | } if (c == '\b') { /* Backspace */ |
262 | if (c == '\b') { /* Backspace */ |
261 | if (position == 0) |
263 | if (position == 0) |
262 | continue; |
264 | continue; |
263 | for (i = position; i < curlen; i++) |
265 | for (i = position; i < curlen; i++) |
264 | current[i - 1] = current[i]; |
266 | current[i - 1] = current[i]; |
265 | curlen--; |
267 | curlen--; |
Line 541... | Line 543... | ||
541 | switch (cmd->argv[i].type) { |
543 | switch (cmd->argv[i].type) { |
542 | case ARG_TYPE_STRING: |
544 | case ARG_TYPE_STRING: |
543 | buf = (char *) cmd->argv[i].buffer; |
545 | buf = (char *) cmd->argv[i].buffer; |
544 | strncpy(buf, (const char *) &cmdline[start], |
546 | strncpy(buf, (const char *) &cmdline[start], |
545 | min((end - start) + 2, cmd->argv[i].len)); |
547 | min((end - start) + 2, cmd->argv[i].len)); |
546 | buf[min((end - start) + 1, cmd->argv[i].len - 1)] = '\0'; |
548 | buf[min((end - start) + 1, cmd->argv[i].len - 1)] = |
- | 549 | '\0'; |
|
547 | break; |
550 | break; |
548 | case ARG_TYPE_INT: |
551 | case ARG_TYPE_INT: |
549 | if (parse_int_arg(cmdline + start, end - start + 1, |
552 | if (parse_int_arg(cmdline + start, end - start + 1, |
550 | &cmd->argv[i].intval)) |
553 | &cmd->argv[i].intval)) |
551 | error = 1; |
554 | error = 1; |
Line 558... | Line 561... | ||
558 | min((end-start), cmd->argv[i].len)); |
561 | min((end-start), cmd->argv[i].len)); |
559 | buf[min((end - start), cmd->argv[i].len - 1)] = |
562 | buf[min((end - start), cmd->argv[i].len - 1)] = |
560 | '\0'; |
563 | '\0'; |
561 | cmd->argv[i].intval = (unative_t) buf; |
564 | cmd->argv[i].intval = (unative_t) buf; |
562 | cmd->argv[i].vartype = ARG_TYPE_STRING; |
565 | cmd->argv[i].vartype = ARG_TYPE_STRING; |
563 | } else if (!parse_int_arg(cmdline + start, end - start + 1, |
566 | } else if (!parse_int_arg(cmdline + start, |
564 | &cmd->argv[i].intval)) { |
567 | end - start + 1, &cmd->argv[i].intval)) { |
565 | cmd->argv[i].vartype = ARG_TYPE_INT; |
568 | cmd->argv[i].vartype = ARG_TYPE_INT; |
566 | } else { |
569 | } else { |
567 | printf("Unrecognized variable argument.\n"); |
570 | printf("Unrecognized variable argument.\n"); |
568 | error = 1; |
571 | error = 1; |
569 | } |
572 | } |