Rev 3268 | Rev 3275 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3268 | Rev 3269 | ||
---|---|---|---|
Line 61... | Line 61... | ||
61 | int tok_input(cliuser_t *usr) |
61 | int tok_input(cliuser_t *usr) |
62 | { |
62 | { |
63 | char *cmd[WORD_MAX]; |
63 | char *cmd[WORD_MAX]; |
64 | int n = 0, i = 0; |
64 | int n = 0, i = 0; |
65 | int rc = 0; |
65 | int rc = 0; |
66 | char *tmp = (char *) NULL; |
66 | char *tmp; |
67 | 67 | ||
68 | if (NULL == usr->line) { |
68 | if (NULL == usr->line) |
69 | rc = CL_EFAIL; |
69 | return CL_EFAIL; |
70 | goto finit; |
- | |
71 | } |
- | |
72 | 70 | ||
73 | tmp = cli_strdup(usr->line); |
71 | tmp = cli_strdup(usr->line); |
74 | - | ||
- | 72 | cli_verbose("Tok: tmp = %s", tmp); |
|
75 | /* Break up what the user typed, space delimited */ |
73 | /* Break up what the user typed, space delimited */ |
76 | cmd[n] = cli_strtok(tmp, " "); |
74 | cmd[n] = cli_strtok(tmp, " "); |
77 | while (cmd[n] && n < WORD_MAX) { |
75 | while (cmd[n] && n < WORD_MAX) { |
78 | cmd[++n] = cli_strtok(NULL, " "); |
76 | cmd[++n] = cli_strtok(NULL, " "); |
79 | } |
77 | } |
80 | 78 | ||
- | 79 | for (n = 0; cmd[n] != NULL; n++) |
|
- | 80 | cli_verbose("arg[%d] => `%s'", n, cmd[n]); |
|
- | 81 | ||
81 | /* We have rubbish */ |
82 | /* We have rubbish */ |
82 | if (NULL == cmd[0]) { |
83 | if (NULL == cmd[0]) { |
83 | rc = CL_ENOENT; |
84 | rc = CL_ENOENT; |
84 | goto finit; |
85 | goto finit; |
85 | } |
86 | } |
Line 111... | Line 112... | ||
111 | rc = try_exec(cmd[0], cmd); |
112 | rc = try_exec(cmd[0], cmd); |
112 | goto finit; |
113 | goto finit; |
113 | } |
114 | } |
114 | 115 | ||
115 | finit: |
116 | finit: |
- | 117 | /* Why is free complaining about these ? |
|
116 | if (NULL != usr->line) { |
118 | if (NULL != usr->line) { |
117 | free(usr->line); |
119 | free(usr->line); |
118 | usr->line = (char *) NULL; |
120 | usr->line = (char *) NULL; |
119 | } |
121 | } |
120 | if (NULL != tmp) |
122 | if (NULL != tmp) |
121 | free(tmp); |
123 | free(tmp); |
122 | 124 | */ |
|
123 | return rc; |
125 | return rc; |
124 | } |
126 | } |
125 | 127 | ||
126 | #ifdef HELENOS |
128 | #ifdef HELENOS |
127 | /* Borrowed from Jiri Svoboda's 'cli' uspace app */ |
129 | /* Borrowed from Jiri Svoboda's 'cli' uspace app */ |