diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-02-22 22:45:53 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-02-22 22:45:53 +0100 |
| commit | c97a0699cffb4070d2e49cdab7bda6a185140b71 (patch) | |
| tree | b2fa3c0292a7ae8876e310c35e2d05b94b1fa025 | |
| parent | 054e9d7393bac2f51be121308f5f3916ad9ab875 (diff) | |
splitting the argument into the source and detination
| -rw-r--r-- | main.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -88,6 +88,21 @@ struct command split_command(char *input) { return user_command; } +struct split_arg split_argument(struct command argument) { + struct split_arg new_argument = {}; + + char *source = strtok(argument.arg, " "); + char *destination = strtok(NULL, " "); + + if (source != NULL) { + new_argument.source = source; + } + if (destination != NULL) { + new_argument.destination = destination; + } + return new_argument; +} + void exec_command(char *input) { const struct command user_command = split_command(input); |
