-
Notifications
You must be signed in to change notification settings - Fork 0
/
aff_c.c
37 lines (32 loc) · 1.37 KB
/
aff_c.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aff_c.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wtrembla <wtrembla@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/26 18:12:14 by wtrembla #+# #+# */
/* Updated: 2014/03/04 16:36:36 by wtrembla ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int aff_c(int c)
{
int fd;
if ((fd = open(ttyname(0), O_WRONLY)) == -1)
ft_error("aff_c: error opening new interface");
write(fd, &c, 1);
if (close(fd) == -1)
ft_error("aff_c: error closing new interface");
return (0);
}
int aff_str(char *str)
{
int fd;
if ((fd = open(ttyname(0), O_WRONLY)) == -1)
ft_error("aff_str: error opening new interface");
ft_putstr_fd(str, fd);
if (close(fd) == -1)
ft_error("aff_str: error closing new interface");
return (0);
}