aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/error.c23
-rw-r--r--src/get_cmd_path.c6
2 files changed, 26 insertions, 3 deletions
diff --git a/src/error.c b/src/error.c
new file mode 100644
index 0000000..628200d
--- /dev/null
+++ b/src/error.c
@@ -0,0 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* error.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2025/01/15 16:35:53 by dkaiser #+# #+# */
+/* Updated: 2025/01/15 16:36:18 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "minishell.h"
+#include <errno.h>
+
+void *error(int err_code, char *err_text, int exit_code, int *ret_code)
+{
+ errno = err_code;
+ perror(err_text);
+ if (ret_code != NULL)
+ *ret_code = exit_code;
+ return (NULL);
+}
diff --git a/src/get_cmd_path.c b/src/get_cmd_path.c
index fb45730..11100bc 100644
--- a/src/get_cmd_path.c
+++ b/src/get_cmd_path.c
@@ -6,7 +6,7 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/17 19:19:59 by chuhlig #+# #+# */
-/* Updated: 2025/01/15 16:32:30 by dkaiser ### ########.fr */
+/* Updated: 2025/01/15 16:34:56 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,7 +21,7 @@
static char *get_simple_cmd_path(char *cmd, int *return_code);
static char *get_absolute_cmd_path(char *cmd, t_env *env, int *return_code);
static char *find_in_path(char *cmd, t_env *env, int *return_code);
-static char *error(int err_code, char *err_text, int exit_code, int *ret_code);
+static void *error(int err_code, char *err_text, int exit_code, int *ret_code);
char **get_split_path(t_env *env);
static int is_directory(char *path);
@@ -111,7 +111,7 @@ static char *get_simple_cmd_path(char *cmd, int *return_code)
return (result);
}
-static char *error(int err_code, char *err_text, int exit_code, int *ret_code)
+static void *error(int err_code, char *err_text, int exit_code, int *ret_code)
{
errno = err_code;
perror(err_text);