-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
63 lines (56 loc) · 1.51 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ctreton <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/05 10:12:08 by ctreton #+# #+# */
/* Updated: 2014/01/10 20:34:10 by ctreton ### ########.fr */
/* */
/* ************************************************************************** */
#include "select.h"
int count_max(t_elem *e)
{
int max;
int col;
max = 0;
col = e->x;
while (e->prev && (e->prev)->x == col)
e = e->prev;
while (e && e->x == col)
{
if ((int)ft_strlen(e->value) > max)
max = (int)ft_strlen(e->value);
e = e->next;
}
return (max + 1);
}
int ft_tputs(int c)
{
static int fd;
if (fd == 0)
fd = init_fd(fd);
ft_putchar_fd(c, fd);
return (1);
}
int calc_x(int l, int c, t_elem *e)
{
int x;
int tmp;
x = 0;
while (e->prev)
e = e->prev;
while (c > 0)
{
x = e->pos_x + count_max(e);
tmp = 0;
while (tmp < l)
{
e = e->next;
tmp++;
}
c--;
}
return (x);
}