-
Notifications
You must be signed in to change notification settings - Fork 0
/
args.c
62 lines (55 loc) · 1.54 KB
/
args.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* t_arg.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dmoureu- <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/27 17:44:23 by dmoureu- #+# #+# */
/* Updated: 2016/02/10 18:46:13 by dmoureu- ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
t_arg *newarg(char *str)
{
t_arg *arg;
arg = (t_arg*)malloc(sizeof(t_arg));
arg->path = ft_strdup(str);
arg->deny = 0;
arg->mtime = 0;
arg->empty = 1;
arg->ent = NULL;
arg->read = 0;
arg->sub = NULL;
arg->next = NULL;
return (arg);
}
t_arg *addarg(t_arg **lstarg, t_arg *arg)
{
t_arg *beginlst;
t_arg *current;
beginlst = *lstarg;
current = beginlst;
if (!*lstarg)
beginlst = arg;
else
{
while (current->next)
current = current->next;
current->next = arg;
}
return (beginlst);
}
int arglen(t_arg *arg)
{
int length;
t_arg *marg;
marg = arg;
length = 0;
while (marg)
{
length++;
marg = marg->next;
}
return (length);
}