From b16d4b834d95d5cc0757d09e74fe6042e55f5440 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 10 Sep 2020 15:08:28 +0200 Subject: Added better error handling in eval --- include/error.h | 24 +++++++++++++++--------- include/eval.h | 10 +++++----- include/minishell.h | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/error.h b/include/error.h index 941f1b2..2326d1a 100644 --- a/include/error.h +++ b/include/error.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/08/27 20:34:25 by charles #+# #+# */ -/* Updated: 2020/08/27 20:38:52 by charles ### ########.fr */ +/* Updated: 2020/09/10 14:48:42 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,17 +20,23 @@ ** error.c */ -typedef enum +enum { - ERR_FATAL = -1, - ERR_NONE = 0, - ERR_AMBIGUOUS_REDIR = 1, - ERR_OPEN = 1, - ERR_CMD_NOT_FOUND = 127, - ERR_SYNTAX = 2, -} t_err; + ERR_NONE = 1024, + ERR_FATAL, + ERR_SYNTAX, + ERR_OPEN, + ERR_AMBIGUOUS_REDIR, + ERR_CMD_NOT_FOUND, + ERR_IS_DIRECTORY, + ERR_ERRNO, +}; + +typedef int t_err; void errorf(const char *format, ...); void verrorf(const char *format, va_list ap); +void error_set_status(int status); +int error_get_status(int status); #endif diff --git a/include/eval.h b/include/eval.h index a23b249..7139f34 100644 --- a/include/eval.h +++ b/include/eval.h @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:30 by charles #+# #+# */ -/* Updated: 2020/09/09 17:27:21 by charles ### ########.fr */ +/* Updated: 2020/09/10 14:14:56 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,9 +39,9 @@ typedef struct t_builtin_entry *builtin; } t_fork_param_cmd; -# define MS_NO_FD -2 -# define FDS_WRITE 1 -# define FDS_READ 0 +# define FD_NONE -2 +# define FD_WRITE 1 +# define FD_READ 0 extern pid_t g_child_pid; @@ -64,7 +64,7 @@ t_ftlst *split_token(t_ftlst **lst, enum e_tok); ** redir.c */ -bool redir_extract(t_tok_lst **redirs, t_env env, int fds[2]); +int redir_extract(t_tok_lst **redirs, t_env env, int fds[2]); /* ** exec.c diff --git a/include/minishell.h b/include/minishell.h index 085f082..7e755a3 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -51,7 +51,7 @@ typedef t_ftht* t_path; typedef t_ftvec* t_env; -extern int g_last_status_code; +extern int g_last_status; extern char *g_basename; /* -- cgit