diff options
Diffstat (limited to '')
| -rw-r--r-- | src/shell.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/shell.c b/src/shell.c index 5fb18bc..2cb3719 100644 --- a/src/shell.c +++ b/src/shell.c | |||
| @@ -32,8 +32,10 @@ void | |||
| 32 | exec_args(int c, char **v) | 32 | exec_args(int c, char **v) |
| 33 | { | 33 | { |
| 34 | int i; | 34 | int i; |
| 35 | char line[MAXLINELEN]; | ||
| 35 | Command *cmd = NULL; | 36 | Command *cmd = NULL; |
| 36 | CommandArgs *args; | 37 | CommandArgs *args; |
| 38 | Alg *scramble; | ||
| 37 | 39 | ||
| 38 | for (i = 0; i < NCOMMANDS; i++) | 40 | for (i = 0; i < NCOMMANDS; i++) |
| 39 | if (commands[i] != NULL && !strcmp(v[0], commands[i]->name)) | 41 | if (commands[i] != NULL && !strcmp(v[0], commands[i]->name)) |
| @@ -50,7 +52,27 @@ exec_args(int c, char **v) | |||
| 50 | return; | 52 | return; |
| 51 | } | 53 | } |
| 52 | 54 | ||
| 53 | cmd->exec(args); | 55 | if (args->scrstdin) { |
| 56 | while (true) { | ||
| 57 | if (fgets(line, MAXLINELEN, stdin) == NULL) { | ||
| 58 | clearerr(stdin); | ||
| 59 | break; | ||
| 60 | } | ||
| 61 | |||
| 62 | scramble = new_alg(line); | ||
| 63 | |||
| 64 | printf(">>> Line: %s", line); | ||
| 65 | |||
| 66 | if (scramble != NULL && scramble->len > 0) { | ||
| 67 | args->scramble = scramble; | ||
| 68 | cmd->exec(args); | ||
| 69 | free_alg(scramble); | ||
| 70 | args->scramble = NULL; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } else { | ||
| 74 | cmd->exec(args); | ||
| 75 | } | ||
| 54 | free_args(args); | 76 | free_args(args); |
| 55 | } | 77 | } |
| 56 | 78 | ||
