blob: be4d94de21f09177e81fc3d1bb0878045950ecb1 (
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
72
73
74
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_b_export.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 "ft_b_env.h"
#include "ft_f_fail.h"
#include "ft_s_struct.h"
#include "ft_u_utils.h"
static int8_t
ft_check_valid_identifier(const char *arg)
{
char *ptr;
ptr = (char*)arg;
if (ft_isalpha(ptr[0]))
{
return (1);
}
return (0);
}
static int8_t
ft_check_equals(const char *arg)
{
char *ptr;
ptr = (char*)arg;
while (*ptr)
{
if (*ptr == '=')
return (1);
ptr++;
}
return (0);
}
uint8_t
ft_b_export(char *args[],
t_msh *msh)
{
char **ptr;
const uint64_t argc = ft_get_argc((const char**)args);
int8_t next;
if (argc == 0)
{
return (ft_b_env(NULL, msh));
}
ptr = args;
while (*ptr)
{
next = 0;
if (!ft_check_valid_identifier(*ptr))
{
ft_fail_identifier("export", *ptr);
}
ft_check_equals(*ptr);
ptr++;
}
/* TODO: finish export */
return (0);
}
|