-
Notifications
You must be signed in to change notification settings - Fork 2
/
minishell_utils.c
43 lines (37 loc) · 1.39 KB
/
minishell_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkong <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/22 21:36:06 by jkong #+# #+# */
/* Updated: 2022/06/24 21:00:35 by jkong ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include "safe_io.h"
#include "string_buffer.h"
#include <errno.h>
#include <string.h>
static void _print_err_v(const char *format, va_list *ap)
{
t_str_buf *buf;
char *str;
buf = str_append_format_v(NULL, format, ap);
str = str_dispose(buf);
puterr_safe(str);
free(str);
}
void print_err(const char *format, ...)
{
va_list ap;
va_start(ap, format);
_print_err_v(format, &ap);
va_end(ap);
}
void exit_fail(const char *s)
{
print_err("%s: %s\n", s, strerror(errno));
exit(EXIT_FAILURE);
}