-
Notifications
You must be signed in to change notification settings - Fork 0
/
ents.c
57 lines (50 loc) · 1.51 KB
/
ents.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ents.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dmoureu- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/07 16:28:40 by dmoureu- #+# #+# */
/* Updated: 2016/02/07 19:08:46 by dmoureu- ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
t_ent *newent(char *name, struct stat *filestat)
{
t_ent *ent;
ent = (t_ent *)malloc(sizeof(t_ent));
ent->name = ft_strdup(name);
ent->mtime = filestat->st_mtimespec.tv_sec;
ent->next = NULL;
return (ent);
}
t_ent *addent(t_ent **lstent, t_ent *ent)
{
t_ent *beginlst;
t_ent *current;
beginlst = *lstent;
current = beginlst;
if (!*lstent)
beginlst = ent;
else
{
while (current->next)
current = current->next;
current->next = ent;
}
return (beginlst);
}
int entlen(t_ent *ent)
{
int length;
t_ent *ment;
ment = ent;
length = 0;
while (ment)
{
length++;
ment = ment->next;
}
return (length);
}