-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
62 lines (54 loc) · 1.63 KB
/
utils.c
File metadata and controls
62 lines (54 loc) · 1.63 KB
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
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lmenigau <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/18 03:27:42 by lmenigau #+# #+# */
/* Updated: 2017/04/13 01:57:12 by lmenigau ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void put_str_buff(t_buff *buff, char *str, size_t len)
{
size_t i;
i = 0;
while (i < len)
{
buff->buff[buff->count % BUFF_SIZE] = str[i];
buff->count++;
if (buff->count % BUFF_SIZE == 0)
write(1, buff->buff, BUFF_SIZE);
i++;
}
}
int put_wstr_buff(t_buff *buff, wchar_t *str, size_t len)
{
size_t i;
i = 0;
while (str[i] != '\0' && i < len)
{
if (check_utf8(buff, str[i]) == -1)
return (-1);
i++;
}
return (0);
}
void write_to_buff(t_buff *buffer, char c)
{
buffer->buff[buffer->count % BUFF_SIZE] = c;
buffer->count++;
if ((buffer->count % BUFF_SIZE) == 0)
write(1, buffer->buff, BUFF_SIZE);
}
size_t ft_strchri(const char *str, int c)
{
size_t i;
i = 0;
while (str[i] && str[i] != c)
{
i++;
}
return (i);
}