diff --git a/srcs/cd.c b/srcs/cd.c index 705e2f0..80e9711 100755 --- a/srcs/cd.c +++ b/srcs/cd.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/16 21:02:54 by marde-vr #+# #+# */ -/* Updated: 2024/04/02 00:43:31 by tomoron ### ########.fr */ +/* Updated: 2024/04/18 17:56:04 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ int cd(t_token *args) if (args->next && args->next->next) { - ft_printf_fd(2, "minishell: cd: too many arguments\n"); + fprintf(stderr, "minishell: cd: too many arguments\n"); g_return_code = 1; return (1); } diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index 455ed42..473394f 100755 --- a/srcs/exec_bonus.c +++ b/srcs/exec_bonus.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ -/* Updated: 2024/04/17 18:29:30 by tomoron ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -77,7 +77,7 @@ int exec(t_msh *msh, char **cmd_args, int i, int cmd_count) perror("minishell: pipe"); ft_exit(msh, 1); } - ft_printf_fd(2, "pipe: msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]); + fprintf(stderr, "pipe: msh->fds[%d][0]: %d, msh->fds[%d][1]: %d\n", i, msh->fds[i][0], i, msh->fds[i][1]); } pid = fork(); if (pid == -1) @@ -161,7 +161,7 @@ void exec_commands(t_msh *msh) while (i < cmd_count) { get_redirections(msh, msh->cmds); - ft_printf_fd(2, "command: %s, in_type: %d, out_type: %d\n", msh->cmds->value, msh->in_type, msh->out_type); + fprintf(stderr, "command: %s, in_type: %d, out_type: %d\n", msh->cmds->value, msh->in_type, msh->out_type); exec_command(msh, i, cmd_count); free(msh->fds[i]); i++; diff --git a/srcs/here_doc.c b/srcs/here_doc.c index 9750580..45c54d8 100755 --- a/srcs/here_doc.c +++ b/srcs/here_doc.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/24 17:44:32 by marde-vr #+# #+# */ -/* Updated: 2024/04/13 12:58:01 by tomoron ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,8 +24,8 @@ void get_here_doc_input(t_msh *msh, char *eof) line = readline("> "); if (!line) { - ft_printf_fd(2, "\nminishell: warning: here-document delimited by"); - ft_printf_fd(2, " end-of-file, wanted %s", eof); + fprintf(stderr, "\nminishell: warning: here-document delimited by"); + fprintf(stderr, " end-of-file, wanted %s", eof); break ; } if (line && !ft_strncmp(line, eof, ft_strlen(eof))) diff --git a/srcs/input_redirections.c b/srcs/input_redirections.c index 65d8e64..478c080 100755 --- a/srcs/input_redirections.c +++ b/srcs/input_redirections.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:15:27 by marde-vr #+# #+# */ -/* Updated: 2024/04/18 17:22:28 by marde-vr ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,15 +16,15 @@ void redirect_input(t_msh *msh, int i) { if (msh->in_type != PIPE) { - ft_printf_fd(2, "redirecting input\n"); + fprintf(stderr, "redirecting input\n"); if (dup2(msh->in_fd, 0) < 0) ft_exit(msh, 1); close(msh->in_fd); } else { - ft_printf_fd(2, "redirecting pipe input\n"); - ft_printf_fd(2, "input of cmd %d: 0 -> %d\n", i, msh->fds[i - 1][0]); + fprintf(stderr, "redirecting pipe input\n"); + fprintf(stderr, "input of cmd %d: 0 -> %d\n", i, msh->fds[i - 1][0]); if (dup2(msh->fds[i - 1][0], 0) < 0) { perror("dup2"); //debug @@ -50,7 +50,7 @@ void open_input_file(t_msh *msh, t_cmd **cur_token) free_token(filename); if (msh->in_fd == -1 && !g_return_code) { - ft_printf_fd(2, "minishell: %s: ", (*cur_token)->next->value); + fprintf(stderr, "minishell: %s: ", (*cur_token)->next->value); perror(""); g_return_code = 1; } diff --git a/srcs/is_fd_open.c b/srcs/is_fd_open.c index aafb107..86b2070 100644 --- a/srcs/is_fd_open.c +++ b/srcs/is_fd_open.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 17:31:53 by marde-vr #+# #+# */ -/* Updated: 2024/03/05 17:35:39 by marde-vr ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,9 +16,9 @@ int is_fd_open(int fd) { if (fcntl(fd, F_GETFL) == -1) { - ft_printf_fd(2, "%d:closed\n", fd); + fprintf(stderr, "%d:closed\n", fd); return (0); } - ft_printf_fd(2, "%d:open\n", fd); + fprintf(stderr, "%d:open\n", fd); return (1); } diff --git a/srcs/output_redirections.c b/srcs/output_redirections.c index 7eef492..5baf346 100755 --- a/srcs/output_redirections.c +++ b/srcs/output_redirections.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 19:10:52 by marde-vr #+# #+# */ -/* Updated: 2024/04/18 17:23:18 by marde-vr ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,18 +17,18 @@ void redirect_output(t_msh *msh, int i) { if (msh->out_type != PIPE) { - ft_printf_fd(2, "redirecting output\n"); + fprintf(stderr, "redirecting output\n"); if (dup2(msh->out_fd, 1) < 0) ft_exit(msh, 1); } else { - ft_printf_fd(2, "redirecting pipe output\n"); + fprintf(stderr, "redirecting pipe output\n"); //sleep(1); if (dup2(msh->fds[i][1], 1) < 0) { perror("dup2"); - ft_printf_fd(2, "exiting\n"); + fprintf(stderr, "exiting\n"); //ft_exit(msh, 1); } } @@ -68,11 +68,11 @@ void get_out_type(t_msh *msh, t_cmd *cmds) cur_cmd = cur_cmd->next; while (cur_cmd && cur_cmd->next && !is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE) { - ft_printf_fd(2, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type); + fprintf(stderr, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type); cur_cmd = cur_cmd->next; } if (cur_cmd) - ft_printf_fd(2, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type); + fprintf(stderr, "%s: %d\n", cur_cmd->value, cur_cmd->cmd_type); if (cur_cmd->cmd_type == CMD || cur_cmd->cmd_type == PAREN) msh->out_type = 0; else if(cur_cmd && is_output_type(cur_cmd) && !is_operand_type(cur_cmd) && cur_cmd->cmd_type != PIPE) diff --git a/srcs/parsing_bonus.c b/srcs/parsing_bonus.c index 769943d..81d1455 100755 --- a/srcs/parsing_bonus.c +++ b/srcs/parsing_bonus.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/27 14:40:44 by tomoron #+# #+# */ -/* Updated: 2024/04/03 15:00:00 by tomoron ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -130,14 +130,14 @@ void print_syntax_error_bonus(t_cmd *cmd) { if (cmd->cmd_type == CMD || cmd->cmd_type == PAREN) return ; - ft_printf_fd(2, "minishell : syntax error near unexpected token `"); + fprintf(stderr, "minishell : syntax error near unexpected token `"); if (cmd->cmd_type == AND) - ft_printf_fd(2, "&&"); + fprintf(stderr, "&&"); if (cmd->cmd_type == OR) - ft_printf_fd(2, "||"); + fprintf(stderr, "||"); if (cmd->cmd_type == PIPE) - ft_printf_fd(2, "|"); - ft_printf_fd(2, "'\n"); + fprintf(stderr, "|"); + fprintf(stderr, "'\n"); } int check_tokens_syntax(t_cmd *cmd, t_cmd *last) diff --git a/srcs/path.c b/srcs/path.c index 014da01..9f9275b 100755 --- a/srcs/path.c +++ b/srcs/path.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */ -/* Updated: 2024/04/03 15:46:04 by tomoron ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -90,7 +90,7 @@ void get_cmd_path(t_msh *msh) get_path(msh, &found); if (!found) { - ft_printf_fd(2, "%s: command not found\n", msh->tokens->value); + fprintf(stderr, "%s: command not found\n", msh->tokens->value); free(msh->tokens->value); msh->tokens->value = 0; g_return_code = 127; diff --git a/srcs/pipe.c b/srcs/pipe.c index 98c42ee..1e8cf4b 100755 --- a/srcs/pipe.c +++ b/srcs/pipe.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */ -/* Updated: 2024/04/18 17:37:19 by marde-vr ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,23 +18,23 @@ void close_pipe_fds(t_msh *msh, int i) { if (msh->fds[i - 1][0] > 2) { - ft_printf_fd(2, "closing fd %d in child\n", msh->fds[i-1][0]); + fprintf(stderr, "closing fd %d in child\n", msh->fds[i-1][0]); close(msh->fds[i - 1][0]); } if (msh->fds[i - 1][1] > 2) { - ft_printf_fd(2, "closing fd %d in child\n", msh->fds[i-1][1]); + fprintf(stderr, "closing fd %d in child\n", msh->fds[i-1][1]); close(msh->fds[i - 1][1]); } } if (msh->fds[i][0] > 2) { - ft_printf_fd(2, "closing fd %d in child\n", msh->fds[i][0]); + fprintf(stderr, "closing fd %d in child\n", msh->fds[i][0]); close(msh->fds[i][0]); } if (msh->fds[i][1] > 2) { - ft_printf_fd(2, "closing fd %d in child\n", msh->fds[i][1]); + fprintf(stderr, "closing fd %d in child\n", msh->fds[i][1]); close(msh->fds[i][1]); } } @@ -55,7 +55,7 @@ void execute_command(t_msh *msh, char **cmd_args) env = env_to_char_tab(msh->env); if(env) { - ft_printf_fd(2, "execveing %s\n", msh->tokens->value); + fprintf(stderr, "execveing %s\n", msh->tokens->value); execve(msh->tokens->value, cmd_args, env); } ft_free_str_arr(env); @@ -71,7 +71,7 @@ void child(t_msh *msh, char **cmd_args, int i) if (msh->out_type == PIPE || msh->out_type == RED_O || msh->out_type == RED_O_APP) redirect_output(msh, i); - ft_printf_fd(2, "closing fds\n"); + fprintf(stderr, "closing fds\n"); close_pipe_fds(msh, i); execute_command(msh, cmd_args); close(0); @@ -89,12 +89,12 @@ void parent(t_msh *msh, int i, int cmd_count) { if (msh->fds[i - 1][0] > 2) { - ft_printf_fd(2, "closing fd %d in parent\n", msh->fds[i - 1][0]); + fprintf(stderr, "closing fd %d in parent\n", msh->fds[i - 1][0]); close(msh->fds[i - 1][0]); } if (msh->fds[i - 1][1] > 2) { - ft_printf_fd(2, "closing fd %d in parent\n", msh->fds[i - 1][1]); + fprintf(stderr, "closing fd %d in parent\n", msh->fds[i - 1][1]); close(msh->fds[i - 1][1]); } } @@ -102,23 +102,23 @@ void parent(t_msh *msh, int i, int cmd_count) { if (msh->fds[i][0] > 2) { - ft_printf_fd(2, "closing fd %d in parent\n", msh->fds[i][0]); + fprintf(stderr, "closing fd %d in parent\n", msh->fds[i][0]); close(msh->fds[i][0]); } if (msh->fds[i][1] > 2) { - ft_printf_fd(2, "closing fd %d in parent\n", msh->fds[i][1]); + fprintf(stderr, "closing fd %d in parent\n", msh->fds[i][1]); close(msh->fds[i][1]); } } if (msh->in_fd > 2) { - ft_printf_fd(2, "closing in_fd %d in parent\n", msh->in_fd); + fprintf(stderr, "closing in_fd %d in parent\n", msh->in_fd); close(msh->in_fd); } if (msh->out_fd > 2) { - ft_printf_fd(2, "closing in_fd %d in parent\n", msh->out_fd); + fprintf(stderr, "closing in_fd %d in parent\n", msh->out_fd); close(msh->out_fd); } } diff --git a/srcs/signal_handler.c b/srcs/signal_handler.c index a976d86..ae4c065 100755 --- a/srcs/signal_handler.c +++ b/srcs/signal_handler.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */ -/* Updated: 2024/04/14 11:41:06 by marde-vr ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -60,7 +60,7 @@ int set_echoctl(int value) //ft_printf("echoctl value : %d\n",value); if (tcgetattr(1, &t_p)) { - ft_printf_fd(2, "minishell: an error occured while getting the local fl\ + fprintf(stderr, "minishell: an error occured while getting the local fl\ ags\n"); return (1); } @@ -73,7 +73,7 @@ ags\n"); t_p.c_lflag = t_p.c_lflag & (~ECHOCTL); if (tcsetattr(1, TCSANOW, &t_p)) { - ft_printf_fd(2, "minishell: an error occured while setting the local fl\ + fprintf(stderr, "minishell: an error occured while setting the local fl\ ags\n"); return (1); } diff --git a/srcs/utils.c b/srcs/utils.c index 0d87989..0220fc1 100755 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */ -/* Updated: 2024/04/14 11:29:02 by marde-vr ### ########.fr */ +/* Updated: 2024/04/18 17:56:05 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -68,7 +68,7 @@ int file_access(t_msh *msh, int *found) if (fd != -1) { close(fd); - ft_printf_fd(2, "minishell: %s: Is a directory\n", msh->tokens->value); + fprintf(stderr, "minishell: %s: Is a directory\n", msh->tokens->value); g_return_code = 126; return (0); } @@ -76,7 +76,7 @@ int file_access(t_msh *msh, int *found) *found = 1; else { - ft_printf_fd(2, "minishell: %s: ", msh->tokens->value); + fprintf(stderr, "minishell: %s: ", msh->tokens->value); perror(""); g_return_code = 127; if (access(msh->tokens->value, F_OK) != -1)