norm: splitted functions in main into appropriate file

Moved lstdelenvelem & env2lst to ms_env.c
Normed out files
This commit is contained in:
Tanguy MAZE
2019-09-20 12:06:44 +02:00
parent 852248636f
commit cf62dae53b
124 changed files with 4850 additions and 30 deletions

View File

@@ -6,45 +6,29 @@
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/19 17:08:46 by tmaze #+# #+# */
/* Updated: 2019/09/19 17:59:58 by tmaze ### ########.fr */
/* Updated: 2019/09/20 11:58:04 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void lstdelenvelem(void *content, size_t size)
void put_env(t_list *env)
{
size = 0;
ft_strdel(&(((char**)content)[1]));
ft_strdel(&(((char**)content)[0]));
ft_memdel(&content);
}
t_list *it;
t_list *env2lst(char** env)
{
t_list *ret;
t_list *new;
int i;
i = 0;
ret = NULL;
while (env[i])
it = env;
while (it)
{
if ((new = (t_list*)ft_memalloc(sizeof(t_list))) == NULL
|| (new->content = ft_strsplit(env[i], '=')) == NULL
|| ft_lstaddend(&ret, new) == NULL)
{
ft_lstdel(&ret, &lstdelenvelem);
return (NULL);
}
i++;
ft_printf("%s=", ((char**)it->content)[0]);
if (((char**)it->content)[1])
ft_printf("%s", ((char**)it->content)[1]);
ft_putchar('\n');
it = it->next;
}
return (ret);
}
int main(void)
{
extern char **environ;
t_list *env;
char *cmd;
@@ -59,9 +43,11 @@ int main(void)
if (ft_getline(&cmd) >= 0)
{
ft_printf("%s\n", cmd);
if (ft_strequ(cmd, "env"))
put_env(env);
}
ft_strdel(&cmd);
break;
break ;
}
ft_lstdel(&env, &lstdelenvelem);
return (0);