core: rebuild of parsing and the execution
This commit is contained in:
25
data/data.c
Normal file
25
data/data.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "./data_private.h"
|
||||
|
||||
int *ft_get_exit_code(void)
|
||||
{
|
||||
static int exit_code = 0;
|
||||
|
||||
return (&exit_code);
|
||||
}
|
||||
|
||||
int ft_gen_exit_code(t_data *data)
|
||||
{
|
||||
char *str;
|
||||
|
||||
if (data->exit_code_str != NULL)
|
||||
free(data->exit_code_str);
|
||||
str = ft_itoa(data->exit_code);
|
||||
if (str == NULL)
|
||||
{
|
||||
ft_printf("minishell: malloc failed");
|
||||
return (1);
|
||||
}
|
||||
data->exit_code_str = str;
|
||||
return (0);
|
||||
}
|
||||
|
16
data/data.h
Normal file
16
data/data.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef DATA_H
|
||||
# define DATA_H
|
||||
# include "../libftx/libft/list.h"
|
||||
|
||||
typedef struct s_data
|
||||
{
|
||||
t_list **env;
|
||||
t_list **cmds;
|
||||
int exit_code;
|
||||
char *exit_code_str;
|
||||
} t_data;
|
||||
|
||||
int *ft_get_exit_code();
|
||||
int ft_gen_exit_code(t_data *data);
|
||||
|
||||
#endif
|
6
data/data_private.h
Normal file
6
data/data_private.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef DATA_PRIVATE_H
|
||||
# define DATA_PRIVATE_H
|
||||
# include "../libftx/libftx.h"
|
||||
# include "./data.h"
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user