-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_puts.c
59 lines (52 loc) · 946 Bytes
/
my_puts.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
** my_puts.c for minish2 in /home/sebastien/travaux/minishell2
**
** Made by chapui_s
** Login <chapui_s@epitech.eu>
**
** Started on Sun Feb 9 17:48:16 2014 chapui_s
** Last update Sat Mar 8 17:37:37 2014 chapui_s
*/
#include <stdlib.h>
#include <unistd.h>
#include "minish.h"
void *puterror_null(char *str)
{
while (str && *str)
write(2, str++, 1);
return (NULL);
}
int puterror(char *str)
{
while (str && *str)
write(2, str++, 1);
return (-1);
}
int my_putstr(char *str)
{
while (str && *str)
write(fd_tty, str++, 1);
return (0);
}
void my_tputs(char *str)
{
if (str == NULL)
{
puterror("error: problem with tgetstr\n");
exit(EXIT_FAILURE);
}
while (str && *str)
write(fd_tty, str++, 1);
}
void my_tputs2(int n1, int n2, int n3)
{
char tab[4];
int i;
i = 0;
tab[0] = n1;
tab[1] = n2;
tab[2] = n3;
tab[3] = 0;
while (tab[i])
write(fd_tty, &(tab[i++]), 1);
}