diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-10 11:43:05 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-10 11:43:05 +0200 |
| commit | cccd4692fab390d0c4fbab3fcae7f4aa55ca9f1a (patch) | |
| tree | 935f8aa5b19c780bdd7dbd7581dd067bad7b1eeb /src/eval/redir.c | |
| parent | 5b681182824ae45b5a27d1503de32fa2760c5800 (diff) | |
| download | minishell-cccd4692fab390d0c4fbab3fcae7f4aa55ca9f1a.tar.gz minishell-cccd4692fab390d0c4fbab3fcae7f4aa55ca9f1a.tar.bz2 minishell-cccd4692fab390d0c4fbab3fcae7f4aa55ca9f1a.zip | |
Added comment to preprocess, redir, setup, signal, eval_cmd and utils
Diffstat (limited to 'src/eval/redir.c')
| -rw-r--r-- | src/eval/redir.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/eval/redir.c b/src/eval/redir.c index 9d88b29..8c154d5 100644 --- a/src/eval/redir.c +++ b/src/eval/redir.c @@ -6,12 +6,21 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/15 11:05:34 by charles #+# #+# */ -/* Updated: 2020/10/09 14:38:16 by cacharle ### ########.fr */ +/* Updated: 2020/10/10 11:40:16 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "eval.h" +/* +** \brief Open a file and close the previous opened file +** if there was one already setup +** \param filename File to open +** \param fd File descriptor to set or replace +** \param oflag Flag passed to the open function +** \return 0 on success, the error status code otherwise +*/ + static int st_open_replace(char *filename, int *fd, int oflag) { if (fd == NULL) @@ -31,6 +40,15 @@ static int st_open_replace(char *filename, int *fd, int oflag) return (0); } +/* +** \brief Call st_open_replace with different argument +** according to the redirection type +** \param filename Name of the file to open +** \param fds Input/output file descriptors +** \param tag Token tag of the redirection +** \return Whatever st_open_replace returns +*/ + static int st_open_replace_dispatch(char *filename, int fds[2], enum e_tok tag) { int *fd; @@ -64,6 +82,16 @@ static int st_tok_lsts_destroy_ret( return (ret); } +/* +** \brief Extract redirections from tokens +** \param redirs List of token of redirection, in the format +** redir token -> n sticked string token -> redir token -> ... +** \param env Environement need for interpolation of redirection filename +** \param fds Input/output file descriptor to setup +** \return 0 on success, +** the command evaluation error status code otherwise +*/ + int redir_extract(t_tok_lst **redirs, t_env env, int fds[2]) { t_tok_lst *after; |
