aboutsummaryrefslogtreecommitdiff
path: root/src/error.c
diff options
context:
space:
mode:
authorDominik Kaiser2025-01-15 16:36:45 +0100
committerDominik Kaiser2025-01-15 16:36:45 +0100
commit64a413a49ed7979aad9a1eede5ba25c267884839 (patch)
tree355b20c5b8dea4046b502ffd8e758a475ffb41de /src/error.c
parent48912782078b2b3f59413db2539bf6fa6e56b2f8 (diff)
downloadminishell-64a413a49ed7979aad9a1eede5ba25c267884839.tar.gz
minishell-64a413a49ed7979aad9a1eede5ba25c267884839.zip
Outsource error function
Diffstat (limited to 'src/error.c')
-rw-r--r--src/error.c23
1 files changed, 23 insertions, 0 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);
+}