Changeset 659e9473 in mainline


Ignore:
Timestamp:
2011-06-11T16:03:44Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6939edb
Parents:
f65b5fe9
Message:

Refactor logic for running a bdsh command out of tok_input

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/input.c

    rf65b5fe9 r659e9473  
    5656static tinput_t *tinput;
    5757
     58static int run_command(char **, cliuser_t *);
     59
    5860/* Tokenizes input from console, sees if the first word is a built-in, if so
    5961 * invokes the built-in entry point (a[0]) passing all arguments in a[] to
     
    6264{
    6365        char *cmd[WORD_MAX];
    64         int n = 0, i = 0;
     66        int n = 0;
    6567        int rc = 0;
    6668        char *tmp;
     
    7678        }
    7779
    78         /* We have rubbish */
    79         if (NULL == cmd[0]) {
    80                 rc = CL_ENOENT;
    81                 goto finit;
    82         }
     80        rc = run_command(cmd, usr);
    8381
    84         /* Its a builtin command ? */
    85         if ((i = (is_builtin(cmd[0]))) > -1) {
    86                 rc = run_builtin(i, cmd, usr);
    87                 goto finit;
    88         /* Its a module ? */
    89         } else if ((i = (is_module(cmd[0]))) > -1) {
    90                 rc = run_module(i, cmd);
    91                 goto finit;
    92         }
    93 
    94         /* See what try_exec thinks of it */
    95         rc = try_exec(cmd[0], cmd);
    96 
    97 finit:
    9882        if (NULL != usr->line) {
    9983                free(usr->line);
     
    10488
    10589        return rc;
     90}
     91
     92int run_command(char **cmd, cliuser_t *usr)
     93{
     94        int id = 0;
     95       
     96        /* We have rubbish */
     97        if (NULL == cmd[0]) {
     98                return CL_ENOENT;
     99        }
     100       
     101        /* Is it a builtin command ? */
     102        if ((id = (is_builtin(cmd[0]))) > -1) {
     103                return run_builtin(id, cmd, usr);
     104        }
     105       
     106        /* Is it a module ? */
     107        if ((id = (is_module(cmd[0]))) > -1) {
     108                return run_module(id, cmd);
     109        }
     110
     111        /* See what try_exec thinks of it */
     112        return try_exec(cmd[0], cmd);
    106113}
    107114
Note: See TracChangeset for help on using the changeset viewer.