-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
90 lines (79 loc) · 1.96 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mtacnet <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/18 11:09:24 by mtacnet #+# #+# */
/* Updated: 2017/08/29 14:34:56 by mtacnet ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int verif_list(t_elem **lst, char *tab_arg)
{
int i;
int len;
t_elem *head;
i = 0;
len = 0;
head = (*lst);
while ((*lst) != NULL)
{
i = -1;
while ((*lst)->content[++i])
if ((*lst)->content[i] == '=')
len = i;
if (ft_strncmp((*lst)->content, tab_arg, len) == 0)
{
ft_strdel(&(*lst)->content);
(*lst)->content = ft_strdup(tab_arg);
(*lst) = head;
return (1);
}
(*lst) = (*lst)->next;
}
(*lst) = head;
return (0);
}
void view_list(t_elem **lst)
{
t_elem *head;
head = (*lst);
while ((*lst) != NULL)
{
ft_putendl((*lst)->content);
(*lst) = (*lst)->next;
}
(*lst) = head;
}
int verif_line(char *line)
{
int i;
i = 0;
if (line == NULL && !line[0])
return (1);
return (0);
}
void modif_line(char **line)
{
int i;
i = 0;
while (line[0][i])
{
if (line[0][i] == '\t')
line[0][i] = 040;
i++;
}
}
void cpy_lst(t_elem **lst_dest, t_elem **lst_src)
{
t_elem *head;
head = (*lst_src);
while ((*lst_src) != NULL)
{
push_elem(lst_dest, (*lst_src)->content);
(*lst_src) = (*lst_src)->next;
}
(*lst_src) = head;
}