From c97a0699cffb4070d2e49cdab7bda6a185140b71 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Sat, 22 Feb 2025 22:45:53 +0100 Subject: splitting the argument into the source and detination --- main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.c b/main.c index 14c8861..63b1e3d 100644 --- a/main.c +++ b/main.c @@ -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); -- cgit v1.2.3-70-g09d2