blob: 49693203976b43f215494ac03c9264b678e33f9d (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* b_export_mute.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <stdlib.h>
#include <stdint.h>
#include "b_export.h"
#include "b_export_next.h"
#include "d_enum.h"
#include "f_fail.h"
#include "s_destroy.h"
#include "s_line.h"
#include "s_lvars.h"
#include "s_struct.h"
#include "u_utils.h"
#include "u_vars.h"
uint8_t
b_export_mute(char *args[],
t_msh *msh)
{
/* TODO: norme */
char **ptr;
char *varval;
char fmt[4096];
t_bool next;
uint8_t r;
if (args[0] == NULL)
return (0);
r = 0;
ptr = args;
while (*ptr != NULL)
{
next = FALSE;
if (check_valid_identifier(*ptr) == FALSE)
{
next = TRUE;
r = 1;
}
if (next == FALSE && check_equals(*ptr) == FALSE)
{
next = TRUE;
ft_sprintf(fmt, "$%s", *ptr);
varval = u_get_cstm_vr(fmt, msh);
if (varval != NULL)
{
ft_sprintf(fmt, "%s=%s", *ptr, varval);
b_add_to_env_from_globals(*ptr, fmt, msh);
ft_memdel((void*)&varval);
}
}
else if (next == FALSE && check_equals(*ptr) == TRUE)
{
b_export_with_equals(*ptr, msh);
}
ptr++;
}
/* TODO: finish export */
return (r);
}
|