Rev 640 | Rev 788 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 640 | Rev 668 | ||
---|---|---|---|
Line 469... | Line 469... | ||
469 | { |
469 | { |
470 | index_t start = 0, end = 0; |
470 | index_t start = 0, end = 0; |
471 | cmd_info_t *cmd = NULL; |
471 | cmd_info_t *cmd = NULL; |
472 | link_t *cur; |
472 | link_t *cur; |
473 | int i; |
473 | int i; |
- | 474 | int error = 0; |
|
474 | 475 | ||
475 | if (!parse_argument(cmdline, len, &start, &end)) { |
476 | if (!parse_argument(cmdline, len, &start, &end)) { |
476 | /* Command line did not contain alphanumeric word. */ |
477 | /* Command line did not contain alphanumeric word. */ |
477 | return NULL; |
478 | return NULL; |
478 | } |
479 | } |
Line 518... | Line 519... | ||
518 | printf("Too few arguments.\n"); |
519 | printf("Too few arguments.\n"); |
519 | spinlock_unlock(&cmd->lock); |
520 | spinlock_unlock(&cmd->lock); |
520 | return NULL; |
521 | return NULL; |
521 | } |
522 | } |
522 | 523 | ||
- | 524 | error = 0; |
|
523 | switch (cmd->argv[i].type) { |
525 | switch (cmd->argv[i].type) { |
524 | case ARG_TYPE_STRING: |
526 | case ARG_TYPE_STRING: |
525 | buf = cmd->argv[i].buffer; |
527 | buf = cmd->argv[i].buffer; |
526 | strncpy(buf, (const char *) &cmdline[start], min((end - start) + 2, cmd->argv[i].len)); |
528 | strncpy(buf, (const char *) &cmdline[start], min((end - start) + 2, cmd->argv[i].len)); |
527 | buf[min((end - start) + 1, cmd->argv[i].len - 1)] = '\0'; |
529 | buf[min((end - start) + 1, cmd->argv[i].len - 1)] = '\0'; |
528 | break; |
530 | break; |
529 | case ARG_TYPE_INT: |
531 | case ARG_TYPE_INT: |
530 | if (parse_int_arg(cmdline+start, end-start+1, |
532 | if (parse_int_arg(cmdline+start, end-start+1, |
531 | &cmd->argv[i].intval)) |
533 | &cmd->argv[i].intval)) |
532 | return NULL; |
534 | error = 1; |
533 | break; |
535 | break; |
534 | case ARG_TYPE_VAR: |
536 | case ARG_TYPE_VAR: |
535 | if (start != end && cmdline[start] == '"' && cmdline[end] == '"') { |
537 | if (start != end && cmdline[start] == '"' && cmdline[end] == '"') { |
536 | buf = cmd->argv[i].buffer; |
538 | buf = cmd->argv[i].buffer; |
537 | strncpy(buf, (const char *) &cmdline[start+1], |
539 | strncpy(buf, (const char *) &cmdline[start+1], |
Line 542... | Line 544... | ||
542 | } else if (!parse_int_arg(cmdline+start, end-start+1, |
544 | } else if (!parse_int_arg(cmdline+start, end-start+1, |
543 | &cmd->argv[i].intval)) |
545 | &cmd->argv[i].intval)) |
544 | cmd->argv[i].vartype = ARG_TYPE_INT; |
546 | cmd->argv[i].vartype = ARG_TYPE_INT; |
545 | else { |
547 | else { |
546 | printf("Unrecognized variable argument.\n"); |
548 | printf("Unrecognized variable argument.\n"); |
547 | return NULL; |
549 | error = 1; |
548 | } |
550 | } |
549 | break; |
551 | break; |
550 | case ARG_TYPE_INVALID: |
552 | case ARG_TYPE_INVALID: |
551 | default: |
553 | default: |
552 | printf("invalid argument type\n"); |
554 | printf("invalid argument type\n"); |
553 | return NULL; |
555 | error = 1; |
554 | break; |
556 | break; |
555 | } |
557 | } |
556 | } |
558 | } |
557 | 559 | ||
- | 560 | if (error) { |
|
- | 561 | spinlock_unlock(&cmd->lock); |
|
- | 562 | return NULL; |
|
- | 563 | } |
|
- | 564 | ||
558 | start = end + 1; |
565 | start = end + 1; |
559 | if (parse_argument(cmdline, len, &start, &end)) { |
566 | if (parse_argument(cmdline, len, &start, &end)) { |
560 | printf("Too many arguments.\n"); |
567 | printf("Too many arguments.\n"); |
561 | spinlock_unlock(&cmd->lock); |
568 | spinlock_unlock(&cmd->lock); |
562 | return NULL; |
569 | return NULL; |