Merge branch 'master' into camille
This commit is contained in:
commit
61cd1209ff
BIN
.cmds.c.swp
BIN
.cmds.c.swp
Binary file not shown.
6
cmds.c
6
cmds.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 14:17:26 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/17 13:06:35 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 13:09:13 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -101,10 +101,8 @@ static int ft_cmds_fill(t_list **cmds, t_list **env, const char *line)
|
||||
return (0);
|
||||
}
|
||||
|
||||
t_list **ft_parse_cmds(char *line, t_list **env)
|
||||
t_list **ft_parse_cmds(char *line, t_list **env, int infile, int outfile)
|
||||
{
|
||||
int infile;
|
||||
int outfile;
|
||||
t_list **cmds;
|
||||
|
||||
cmds = malloc(sizeof(t_list *));
|
||||
|
33
env.c
33
env.c
@ -6,7 +6,7 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
|
||||
/* Updated: 2023/02/16 16:24:21 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 13:05:29 by erey-bet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -205,7 +205,8 @@ int set_value_by_key(char *key, char *value, t_list **head)
|
||||
|
||||
int create_value_by_key(char *key, char *value, t_list **head)
|
||||
{
|
||||
t_env *content;
|
||||
t_env *content;
|
||||
|
||||
if (set_value_by_key(key, value, head) == 0)
|
||||
return (0);
|
||||
content = ft_calloc(1, sizeof(t_env));
|
||||
@ -217,6 +218,25 @@ int create_value_by_key(char *key, char *value, t_list **head)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char **env_to_strs(t_list **head)
|
||||
{
|
||||
t_list *current;
|
||||
t_env *content;
|
||||
char **env;
|
||||
int i;
|
||||
|
||||
current = *head;
|
||||
env = ft_calloc(ft_lstsize(*head), sizeof(char *));
|
||||
i = 0;
|
||||
while (current->content)
|
||||
{
|
||||
content = current->content;
|
||||
env[i++] = ft_strmerger(3, content->key, "=", content->value);
|
||||
current = current->next;
|
||||
}
|
||||
return (env);
|
||||
}
|
||||
|
||||
t_list **init_env(char **env)
|
||||
{
|
||||
t_list **head;
|
||||
@ -241,3 +261,12 @@ t_list **init_env(char **env)
|
||||
}
|
||||
return (head);
|
||||
}
|
||||
|
||||
/*int main(int argc, char *argv[], char **env)
|
||||
{
|
||||
t_list **new;
|
||||
|
||||
new = init_env(env);
|
||||
ft_printf("%S", env_to_strs(new));
|
||||
return (0);
|
||||
}*/
|
||||
|
3
infile.c
3
infile.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 17:52:10 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/16 17:52:29 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 13:19:09 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -33,6 +33,7 @@ static int ft_infile_is_valid(const char *line)
|
||||
if (tab[i][0] == '<')
|
||||
{
|
||||
ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]);
|
||||
ft_freer_tab_ultimate(1, tab);
|
||||
return (0);
|
||||
}
|
||||
ft_freer_tab_ultimate(1, tab);
|
||||
|
4
main.c
4
main.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/17 13:05:54 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 13:13:19 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -45,6 +45,7 @@ int main(int ac, char **av, char **env)
|
||||
ft_lstclear(data.env, env_del);
|
||||
free(data.env);
|
||||
free(line);
|
||||
return (1);
|
||||
}
|
||||
infile = ft_infile(line);
|
||||
if (infile == -2)
|
||||
@ -53,6 +54,7 @@ int main(int ac, char **av, char **env)
|
||||
ft_lstclear(data.env, env_del);
|
||||
free(data.env);
|
||||
free(line);
|
||||
return (1);
|
||||
}
|
||||
cmds = ft_parse_cmds(line, data.env, infile, outfile);
|
||||
if (cmds == NULL)
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 18:01:07 by cchauvet #+# #+# */
|
||||
/* Updated: 2023/02/16 17:53:28 by cchauvet ### ########.fr */
|
||||
/* Updated: 2023/02/17 13:19:46 by cchauvet ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -32,6 +32,7 @@ static int ft_outfile_is_valid(const char *line)
|
||||
if (tab[i][0] == '>')
|
||||
{
|
||||
ft_eprintf("minishell: %s: must be followed by an infile\n", tab[i]);
|
||||
ft_freer_tab_ultimate(1, tab);
|
||||
return (0);
|
||||
}
|
||||
ft_freer_tab_ultimate(1, tab);
|
||||
|
@ -71,7 +71,8 @@ static int ft_special_char_dub(const char *str)
|
||||
}
|
||||
i = i + y;
|
||||
}
|
||||
i++;
|
||||
else
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user