-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils3.c
More file actions
74 lines (69 loc) · 1.95 KB
/
utils3.c
File metadata and controls
74 lines (69 loc) · 1.95 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
63
64
65
66
67
68
69
70
71
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edamar <edamar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 18:10:41 by edamar #+# #+# */
/* Updated: 2023/12/28 10:45:53 by edamar ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include <stdlib.h>
void expand_utils2(t_shell **shell, char *back, t_list *lex,
char *before)
{
if (!lex->content)
{
free(back);
free(before);
malloc_error(4, shell);
}
}
void expand_utils3(t_shell **shell, char *before, char *new_value,
t_list *lex)
{
if (!new_value)
{
free(before);
malloc_error(4, shell);
}
free(lex->content);
lex->content = ft_strjoin(before, new_value);
free(new_value);
}
void expand_utils4(t_shell **shell, char *before, char *new_value,
t_list *lex)
{
if (!lex->content)
{
free(before);
free(new_value);
malloc_error(4, shell);
}
}
void export_utils(t_shell **shell, char **key, char **value,
char *text)
{
if (ft_strchr(text, '=') != 0)
{
*key = ft_substr(text, 0, ft_strchrindex(text, '='));
if (!(*key))
malloc_error(5, shell);
*value = ft_substr(text, ft_strchrindex(text, '=') + 1, (ft_strlen(text)
- 1));
if (!(*value))
{
free(key);
malloc_error(5, shell);
}
}
else
{
*key = ft_substr(text, 0, ft_strlen(text));
if (!(*key))
malloc_error(5, shell);
*value = NULL;
}
}