-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_pstderr4.c
35 lines (32 loc) · 1.4 KB
/
ft_pstderr4.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_pstderr4.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abenamar <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/10 17:43:54 by abenamar #+# #+# */
/* Updated: 2023/09/15 10:51:02 by abenamar ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int ft_pstderr4(char *s1, char *s2, char *s3, char *s4)
{
char *str;
int n;
str = ft_strdup("minishell: ");
if (s1)
str = ft_strjoin_and_free(str, ft_strdup(s1));
if (s2)
str = ft_strjoin_and_free(str, ft_strdup(s2));
if (s3)
str = ft_strjoin_and_free(str, ft_strdup(s3));
if (s4)
str = ft_strjoin_and_free(str, ft_strdup(s4));
str = ft_strjoin_and_free(str, ft_strdup("\n"));
n = ft_strlen(str);
if (write(STDERR_FILENO, str, n * sizeof(char)) == -1)
return (-1);
free(str);
return (n);
}