core: exit_code work ?

This commit is contained in:
Camille Chauvet 2023-02-24 20:30:01 +01:00
parent fc82eefd7b
commit 370e5149d5
14 changed files with 421 additions and 97 deletions

BIN
.nfs00000000098c85ed00000111 Executable file

Binary file not shown.

4
cmd.c
View File

@ -25,7 +25,7 @@ void ft_cmddel(void *ptr)
free(content);
}
int ft_cmd_filler(t_list *element, char **args, t_list **env)
int ft_cmd_filler(t_data *data, t_list *element, char **args)
{
t_cmd *content;
char *temp;
@ -37,7 +37,7 @@ int ft_cmd_filler(t_list *element, char **args, t_list **env)
i = 0;
while (args[i] != NULL)
{
temp = ft_env_filler(env, args[i]);
temp = ft_env_filler(data, args[i]);
if (temp == NULL)
return (1);
free(args[i]);

8
cmds.c
View File

@ -73,7 +73,7 @@ static int ft_cmds_prep(t_list **cmds, const char *line, int infile, int outfile
return (0);
}
static int ft_cmds_fill(t_list **cmds, t_list **env, const char *line)
static int ft_cmds_fill(t_data *data, t_list **cmds, const char *line)
{
char **tab;
char **args;
@ -88,7 +88,7 @@ static int ft_cmds_fill(t_list **cmds, t_list **env, const char *line)
while (tab[i] != NULL)
{
args = ft_split_quoted(tab[i], ' ');
if (ft_cmd_filler(current, args, env) == 1)
if (ft_cmd_filler(data, current, args) == 1)
{
ft_lstclear(cmds, ft_cmddel);
ft_freer_tab_ultimate(2, args, tab);
@ -101,14 +101,14 @@ 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, int infile, int outfile)
t_list **ft_parse_cmds(t_data *data, char *line, int infile, int outfile)
{
t_list **cmds;
cmds = malloc(sizeof(t_list *));
if (ft_cmds_prep(cmds, line, infile, outfile) == 1)
return (NULL);
if (ft_cmds_fill(cmds, env, line) == 1)
if (ft_cmds_fill(data, cmds, line) == 1)
return (NULL);
return (cmds);
}

View File

@ -10,13 +10,32 @@
/* */
/* ************************************************************************** */
#include "libftx/libftx.h"
#include "minishell.h"
static char *ft_get_value(t_list **env, char *key)
int ft_gen_exit_code_var(t_data *data)
{
char *str;
str = ft_itoa(data->exit_code);
if (str == NULL)
{
ft_printf("minishell: malloc failed");
return (1);
}
data->exit_code_str = str;
return (0);
}
static char *ft_get_value(t_data *data, char *key)
{
char *value;
value = get_value_by_key(key, env);
if (key[0] == '\0')
return ("$");
if (ft_strcmp("?", key) == 0)
return (data->exit_code_str);
value = get_value_by_key(key, data->env);
if (value == NULL)
value = "";
return (value);
@ -42,6 +61,13 @@ static char *ft_get_key(char *str)
ft_eprintf("minishell: malloc failed\n");
return (key);
}
if (str[i] == '?')
{
key = ft_strdup("?");
if (key == NULL)
ft_eprintf("minishell: malloc failed\n");
return (key);
}
while (str[i] != '\0' && str[i] != '$' && str[i] != ' '
&& str[i] != '"')
i++;
@ -51,7 +77,7 @@ static char *ft_get_key(char *str)
return (key);
}
char *ft_env_filler(t_list **env, const char *str)
char *ft_env_filler(t_data *data, const char *str)
{
size_t i;
char *key;
@ -78,7 +104,7 @@ char *ft_env_filler(t_list **env, const char *str)
free(out);
return (NULL);
}
value = ft_get_value(env, key);
value = ft_get_value(data, key);
if (value == NULL)
{
free(key);

View File

@ -14,7 +14,7 @@
#include "minishell.h"
#include <unistd.h>
static char *ft_get_executable_path(char *executable_name, t_list **env)
static char *ft_get_executable_path(t_data *data, char *executable_name)
{
char *path;
char *temp;
@ -40,7 +40,7 @@ static char *ft_get_executable_path(char *executable_name, t_list **env)
}
else
{
tab = ft_split(get_value_by_key("PATH", env), ':');
tab = ft_split(get_value_by_key("PATH", data->env), ':');
if (tab == NULL)
return (NULL);
i = 0;
@ -64,13 +64,14 @@ static char *ft_get_executable_path(char *executable_name, t_list **env)
if (path == NULL)
{
ft_eprintf("%s: command not found\n", executable_name);
data->exit_code = 127;
}
ft_freer_tab_ultimate(1, tab);
}
return (path);
}
static int ft_excutor(t_cmd *cmd, t_list **env)
static int ft_executor(t_data *data, t_cmd *cmd)
{
int pid;
int return_value;
@ -83,7 +84,7 @@ static int ft_excutor(t_cmd *cmd, t_list **env)
return (1);
if (pid == 0)
{
tab = env_to_strs(env);
tab = env_to_strs(data->env);
if (tab == NULL)
return (1);
dup2(cmd->fd_out, 1);
@ -92,6 +93,7 @@ static int ft_excutor(t_cmd *cmd, t_list **env)
}
else
waitpid(pid, &return_value, 0);
data->exit_code = return_value;
return (return_value);
}
@ -123,7 +125,10 @@ static int ft_own_cmd(t_data *data, t_cmd *cmd)
}
}
if (return_code != -1)
{
cmd->executable = NULL;
data->exit_code = return_code;
}
return (return_code);
}
@ -131,8 +136,7 @@ int ft_cmds_executor(t_data *data, t_list **cmds)
{
t_cmd *content;
t_list *current;
char *return_value;
int cmd_return;
int exit_code;
int fds[2];
current = *cmds;
@ -149,28 +153,18 @@ int ft_cmds_executor(t_data *data, t_list **cmds)
content->fd_out = fds[1];
((t_cmd *) current->next->content)->fd_in = fds[0];
}
cmd_return = ft_own_cmd(data, content);
if (cmd_return == -1)
{
content->executable = ft_get_executable_path(
content->executable, data->env);
content->executable = ft_get_executable_path(data,
content->executable);
if (content->executable != NULL)
cmd_return = ft_excutor(content, data->env);
exit_code = ft_executor(data, content);
}
else if (cmd_return == -2)
return (-1);
data->exit_code = cmd_return;
return_value = ft_itoa(cmd_return);
if (return_value == NULL)
{
ft_eprintf("minishell: malloc failed\n");
if (ft_gen_exit_code_var(data))
return (1);
}
if (content->fd_in > 2)
close(content->fd_in);
if (content->fd_out > 2)
close(content->fd_out);
set_value_by_key("?", return_value, data->env);
current = current->next;
}
return (0);

View File

@ -96,12 +96,15 @@ static int ft_remove_infile(char *line)
return (0);
}
int ft_infile(char *line)
int ft_infile(t_data *data, char *line)
{
int fd;
if (ft_infile_is_valid(line) == 0)
{
data->exit_code = 2;
return (-2);
}
fd = ft_get_infile(line);
if (fd == -2)
return (-2);

79
main.c
View File

@ -40,70 +40,59 @@ static char *ft_get_user_input()
static int ft_minishell(t_data *data, char *line)
{
t_list **cmds;
int code;
char *line_clean;
int infile;
int outfile;
if (ft_syntatic_verif(line))
if (ft_syntatic_verif(data, line))
return (1);
line_clean = ft_normalizer(line);
if (line_clean == NULL)
return (1);
outfile = ft_outfile(line_clean);
outfile = ft_outfile(data, line_clean);
if (outfile == -2)
{
free(line_clean);
return (1);
}
infile = ft_infile(line_clean);
infile = ft_infile(data, line_clean);
if (infile == -2)
{
close(outfile);
if (outfile > 2)
close(outfile);
free(line_clean);
return (1);
}
cmds = ft_parse_cmds(line_clean, data->env, infile, outfile);
if (cmds == NULL)
if (ft_gen_exit_code_var(data))
{
close(outfile);
close(infile);
if (outfile > 2)
close(outfile);
if (infile > 2)
close(infile);
ft_lstclear(cmds, ft_cmddel);
free(cmds);
free(line_clean);
return (1);
}
code = ft_cmds_executor(data, cmds);
cmds = ft_parse_cmds(data, line_clean, infile, outfile);
if (cmds == NULL)
{
if (outfile > 2)
close(outfile);
if (infile > 2)
close(infile);
ft_lstclear(cmds, ft_cmddel);
free(cmds);
free(line_clean);
return (1);
}
ft_cmds_executor(data, cmds);
ft_lstclear(cmds, ft_cmddel);
free(cmds);
free(line_clean);
return (code);
}
#if DEBUG
int main(int ac, char **av, char **env)
{
t_data data;
if (ac == 1)
return (1);
data.env = init_env(env);
if (data.env == NULL)
return (1);
if (ft_minishell(data.env, av[1]) == 1)
{
ft_lstclear(data.env, env_del);
free(data.env);
return (1);
}
ft_lstclear(data.env, env_del);
free(data.env);
return (0);
}
#else
void ft_ctrlc(int num)
{
(void) num;
@ -140,23 +129,11 @@ int main(int ac, char **av, char **env)
(void) av;
signal(SIGINT, ft_ctrlc);
signal(SIGQUIT, ft_quit);
data.exit_code = 0;
data.env = init_env(env);
if (data.env == NULL)
return (1);
if (create_value_by_key_dup("", "$", data.env) == 1
|| create_value_by_key_dup("?", "0", data.env) == 1)
{
ft_lstclear(data.env, env_del);
free(data.env);
return (1);
}
line = ft_get_user_input();
if (line == NULL)
{
ft_lstclear(data.env, env_del);
free(data.env);
return (1);
}
while (line != NULL)
{
if (ft_minishell(&data, line) == -1)
@ -164,15 +141,9 @@ int main(int ac, char **av, char **env)
free(line);
line = ft_get_user_input();
if (line == NULL)
{
ft_lstclear(data.env, env_del);
free(data.env);
return (1);
}
break ;
}
ft_lstclear(data.env, env_del);
free(data.env);
return (data.exit_code);
}
#endif

View File

@ -30,15 +30,16 @@ typedef struct s_data
{
t_list **env;
int exit_code;
char *exit_code_str;
} t_data;
int ft_syntatic_verif(const char *str);
int ft_syntatic_verif(t_data *data, const char *str);
int ft_file_is_readable(const char *path);
int ft_file_is_writable(const char *path);
int ft_file_is_appendable(const char *path);
char *ft_get_file_path(const char *infile);
int ft_infile(char *line);
int ft_outfile(char *line);
int ft_infile(t_data *data, char *line);
int ft_outfile(t_data *data, char *line);
int ft_heredoc(char *stop);
int *ft_get_heredoc();
size_t ft_seglen_quoted(const char *str, char c);
@ -46,10 +47,11 @@ int ft_cmds_executor(t_data *data, t_list **cmds);
char **ft_split_quoted(const char *s, char c);
void ft_cmddel(void *content);
void env_del(void *content);
t_list **ft_parse_cmds(char *line, t_list **env, int infile, int outfile);
int ft_cmd_filler(t_list *current, char **args, t_list **env);
t_list **ft_parse_cmds(t_data *data, char *line, int infile, int outfile);
int ft_gen_exit_code_var(t_data *data);
int ft_cmd_filler(t_data *data, t_list *current, char **args);
char *ft_normalizer(char *str);
char *ft_env_filler(t_list **env, const char *str);
char *ft_env_filler(t_data *data, const char *str);
char **env_to_strs(t_list **head);
/* Environnement */
@ -95,8 +97,8 @@ typedef struct s_cmd
typedef struct s_env
{
void *key;
void *value;
char *key;
char *value;
} t_env;
#endif

1
minishell_tester Submodule

@ -0,0 +1 @@
Subproject commit 1c6111b2fd281937d38ebfa7e8d87b38baef0802

View File

@ -97,12 +97,15 @@ static int ft_remove_outfile(char *line)
return (0);
}
int ft_outfile(char *line)
int ft_outfile(t_data *data, char *line)
{
int fd;
if (ft_outfile_is_valid(line) == 0)
{
data->exit_code = 2;
return (-2);
}
fd = ft_get_outfile(line);
if (fd == -2)
return (-2);

View File

@ -36,6 +36,8 @@ static int ft_pipe_is_alone(const char *str)
{
while (str[i] == ' ')
i++;
while (ft_is_in_quote(str, i))
i++;
if (str[i] == '\0')
break ;
if (str[i] != '|')
@ -99,10 +101,15 @@ int ft_empty_verif(const char *str)
return (str[i] == '\0');
}
int ft_syntatic_verif(const char *str)
int ft_syntatic_verif(t_data *data, const char *str)
{
return (ft_quote_verif(str)
if (ft_quote_verif(str)
|| ft_empty_verif(str)
|| ft_pipe_is_alone(str)
|| ft_special_char_dub(str));
|| ft_special_char_dub(str))
{
data->exit_code = 2;
return (1);
}
return (0);
}

0
t Normal file
View File

290
tags Normal file
View File

@ -0,0 +1,290 @@
!_TAG_EXTRA_DESCRIPTION anonymous /Include tags for non-named objects like lambda/
!_TAG_EXTRA_DESCRIPTION fileScope /Include tags of file scope/
!_TAG_EXTRA_DESCRIPTION pseudo /Include pseudo tags/
!_TAG_EXTRA_DESCRIPTION subparser /Include tags generated by subparsers/
!_TAG_FIELD_DESCRIPTION epoch /the last modified time of the input file (only for F\/file kind tag)/
!_TAG_FIELD_DESCRIPTION file /File-restricted scoping/
!_TAG_FIELD_DESCRIPTION input /input file/
!_TAG_FIELD_DESCRIPTION name /tag name/
!_TAG_FIELD_DESCRIPTION pattern /pattern/
!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/
!_TAG_FIELD_DESCRIPTION!C++ name /aliased names/
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_KIND_DESCRIPTION!C d,macro /macro definitions/
!_TAG_KIND_DESCRIPTION!C e,enumerator /enumerators (values inside an enumeration)/
!_TAG_KIND_DESCRIPTION!C f,function /function definitions/
!_TAG_KIND_DESCRIPTION!C g,enum /enumeration names/
!_TAG_KIND_DESCRIPTION!C h,header /included header files/
!_TAG_KIND_DESCRIPTION!C m,member /struct, and union members/
!_TAG_KIND_DESCRIPTION!C s,struct /structure names/
!_TAG_KIND_DESCRIPTION!C t,typedef /typedefs/
!_TAG_KIND_DESCRIPTION!C u,union /union names/
!_TAG_KIND_DESCRIPTION!C v,variable /variable definitions/
!_TAG_KIND_DESCRIPTION!C++ c,class /classes/
!_TAG_KIND_DESCRIPTION!C++ d,macro /macro definitions/
!_TAG_KIND_DESCRIPTION!C++ e,enumerator /enumerators (values inside an enumeration)/
!_TAG_KIND_DESCRIPTION!C++ f,function /function definitions/
!_TAG_KIND_DESCRIPTION!C++ g,enum /enumeration names/
!_TAG_KIND_DESCRIPTION!C++ h,header /included header files/
!_TAG_KIND_DESCRIPTION!C++ m,member /class, struct, and union members/
!_TAG_KIND_DESCRIPTION!C++ n,namespace /namespaces/
!_TAG_KIND_DESCRIPTION!C++ s,struct /structure names/
!_TAG_KIND_DESCRIPTION!C++ t,typedef /typedefs/
!_TAG_KIND_DESCRIPTION!C++ u,union /union names/
!_TAG_KIND_DESCRIPTION!C++ v,variable /variable definitions/
!_TAG_KIND_DESCRIPTION!Markdown S,subsection /level 2 sections/
!_TAG_KIND_DESCRIPTION!Markdown T,l4subsection /level 4 sections/
!_TAG_KIND_DESCRIPTION!Markdown c,chapter /chapters/
!_TAG_KIND_DESCRIPTION!Markdown n,footnote /footnotes/
!_TAG_KIND_DESCRIPTION!Markdown s,section /sections/
!_TAG_KIND_DESCRIPTION!Markdown t,subsubsection /level 3 sections/
!_TAG_KIND_DESCRIPTION!Markdown u,l5subsection /level 5 sections/
!_TAG_KIND_DESCRIPTION!Sh a,alias /aliases/
!_TAG_KIND_DESCRIPTION!Sh f,function /functions/
!_TAG_KIND_DESCRIPTION!Sh h,heredoc /label for here document/
!_TAG_KIND_DESCRIPTION!Sh s,script /script files/
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_OUTPUT_VERSION 0.0 /current.age/
!_TAG_PARSER_VERSION!C 0.0 /current.age/
!_TAG_PARSER_VERSION!C++ 0.0 /current.age/
!_TAG_PARSER_VERSION!Markdown 0.0 /current.age/
!_TAG_PARSER_VERSION!Sh 0.0 /current.age/
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
!_TAG_PROC_CWD /nfs/homes/cchauvet/42/minishell/ //
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 6.0.0 //
!_TAG_ROLE_DESCRIPTION!C!header local /local header/
!_TAG_ROLE_DESCRIPTION!C!header system /system header/
!_TAG_ROLE_DESCRIPTION!C!macro undef /undefined/
!_TAG_ROLE_DESCRIPTION!C++!header local /local header/
!_TAG_ROLE_DESCRIPTION!C++!header system /system header/
!_TAG_ROLE_DESCRIPTION!C++!macro undef /undefined/
!_TAG_ROLE_DESCRIPTION!Sh!heredoc endmarker /end marker/
!_TAG_ROLE_DESCRIPTION!Sh!script loaded /loaded/
BUFFER_SIZE libftx/gnl/get_next_line.h /^# define BUFFER_SIZE /;" d
Bonus minishell_tester/README.md /^# Bonus $/;" c
DEBUG minishell.h /^# define DEBUG /;" d
EXTRA_H libftx/extra/extra.h /^# define EXTRA_H$/;" d
Extra tests minishell_tester/README.md /^# Extra tests$/;" c
FT_PRINTF_H libftx/printf/ft_printf.h /^# define FT_PRINTF_H$/;" d
GET_NEXT_LINE_H libftx/gnl/get_next_line.h /^# define GET_NEXT_LINE_H$/;" d
How to run minishell_tester/README.md /^# How to run $/;" c
Installation minishell_tester/README.md /^# Installation $/;" c
LIBFTX_H libftx/libftx.h /^# define LIBFTX_H$/;" d
LIBFT_H libftx/libft/libft.h /^# define LIBFT_H$/;" d
MINISHELL_H minishell.h /^# define MINISHELL_H$/;" d
Manual tests minishell_tester/README.md /^# Manual tests $/;" c
Separate tests minishell_tester/README.md /^# Separate tests$/;" c
UTILS_H utils/utils.h /^# define UTILS_H$/;" d
add_export builtins/export.c /^void add_export(t_list **env, char *args, int fd, int *err)$/;" f typeref:typename:void
add_sort env.c /^void add_sort(t_list **head, t_env *var)$/;" f typeref:typename:void
args minishell.h /^ char **args;$/;" m struct:s_cmd typeref:typename:char **
check_argument builtins/echo.c /^int check_argument(char *str, int *check)$/;" f typeref:typename:int
content libftx/libft/libft.h /^ void *content;$/;" m struct:s_list typeref:typename:void *
content libftx/libftx.h /^ void *content;$/;" m struct:s_list typeref:typename:void *
create_value_by_key env.c /^int create_value_by_key(char *key, char *value, t_list **head)$/;" f typeref:typename:int
create_value_by_key_dup env3.c /^int create_value_by_key_dup(char *key, char *value, t_list **env)$/;" f typeref:typename:int
delete_by_key env3.c /^int delete_by_key(char *key, t_list **head)$/;" f typeref:typename:int
echo builtins/echo.c /^int echo(int fd, char **strs)$/;" f typeref:typename:int
env minishell.h /^ t_list **env;$/;" m struct:s_data typeref:typename:t_list **
env_del env2.c /^void env_del(void *ptr)$/;" f typeref:typename:void
env_to_strs env2.c /^char **env_to_strs(t_list **head)$/;" f typeref:typename:char **
error builtins/exit.c /^static int error(int err, char *reason, char *problem, int fd)$/;" f typeref:typename:int file:
error builtins/export.c /^static int error(char *str, int fd)$/;" f typeref:typename:int file:
error builtins/unset.c /^int error(char *str, int fd)$/;" f typeref:typename:int
executable minishell.h /^ char *executable;$/;" m struct:s_cmd typeref:typename:char *
exit_code minishell.h /^ int exit_code;$/;" m struct:s_data typeref:typename:int
export builtins/export.c /^int export(t_list **env, char **args, int fd)$/;" f typeref:typename:int
fd_in minishell.h /^ int fd_in;$/;" m struct:s_cmd typeref:typename:int
fd_out minishell.h /^ int fd_out;$/;" m struct:s_cmd typeref:typename:int
ft_atoi libftx/libft/ft_atoi.c /^int ft_atoi(const char *nptr)$/;" f typeref:typename:int
ft_atoi_check utils/ft_atoi_check.c /^int ft_atoi_check(const char *nptr)$/;" f typeref:typename:int
ft_base_size libftx/extra/ft_ultoa_base.c /^static size_t ft_base_size(char *base)$/;" f typeref:typename:size_t file:
ft_base_size libftx/printf/ft_dprintul_base.c /^static size_t ft_base_size(char *base)$/;" f typeref:typename:size_t file:
ft_bzero libftx/libft/ft_bzero.c /^void ft_bzero(void *s, size_t n)$/;" f typeref:typename:void
ft_calloc libftx/libft/ft_calloc.c /^void *ft_calloc(size_t nmemb, size_t size)$/;" f typeref:typename:void *
ft_cancel libftx/libft/ft_split.c /^void *ft_cancel(void **tab, size_t len)$/;" f typeref:typename:void *
ft_change_exit_code utils/ft_change_exit_code.c /^int ft_change_exit_code(t_data *data, int new_value)$/;" f typeref:typename:int
ft_cmd_filler cmd.c /^int ft_cmd_filler(t_list *element, char **args, t_list **env)$/;" f typeref:typename:int
ft_cmddel cmd.c /^void ft_cmddel(void *ptr)$/;" f typeref:typename:void
ft_cmds_executor execution.c /^int ft_cmds_executor(t_data *data, t_list **cmds)$/;" f typeref:typename:int
ft_cmds_fill cmds.c /^static int ft_cmds_fill(t_list **cmds, t_list **env, const char *line)$/;" f typeref:typename:int file:
ft_cmds_init cmds.c /^static int ft_cmds_init(t_list **cmds, size_t len)$/;" f typeref:typename:int file:
ft_cmds_prep cmds.c /^static int ft_cmds_prep(t_list **cmds, const char *line, int infile, int outfile)$/;" f typeref:typename:int file:
ft_contain_only libftx/extra/ft_contain_only.c /^int ft_contain_only(char *str, char c)$/;" f typeref:typename:int
ft_contain_only_str libftx/extra/ft_contain_only.c /^int ft_contain_only_str(char *str, char *to_find)$/;" f typeref:typename:int
ft_ctrlc main.c /^void ft_ctrlc(int num)$/;" f typeref:typename:void
ft_dprint_upperx libftx/printf/ft_dprintX.c /^int ft_dprint_upperx(int fd, unsigned int n)$/;" f typeref:typename:int
ft_dprintarg libftx/printf/ft_dprintarg.c /^int ft_dprintarg(int fd, int arg, va_list args)$/;" f typeref:typename:int
ft_dprintf libftx/printf/ft_printf.c /^int ft_dprintf(int fd, const char *format, ...)$/;" f typeref:typename:int
ft_dprintflag libftx/printf/ft_dprintflag.c /^int ft_dprintflag(int fd, const char *flag, va_list va)$/;" f typeref:typename:int
ft_dprintl_base libftx/printf/ft_dprintl_base.c /^int ft_dprintl_base(int fd, long long int n, char *base)$/;" f typeref:typename:int
ft_dprintptr libftx/printf/ft_dprintptr.c /^int ft_dprintptr(int fd, void *ptr)$/;" f typeref:typename:int
ft_dprintseg libftx/printf/ft_vdprintf.c /^static int ft_dprintseg(int fd, const char *str)$/;" f typeref:typename:int file:
ft_dprintstrtab libftx/printf/ft_dprintstrtab.c /^int ft_dprintstrtab(int fd, char **tab)$/;" f typeref:typename:int
ft_dprintul libftx/printf/ft_dprintul.c /^int ft_dprintul(int fd, unsigned long long n)$/;" f typeref:typename:int
ft_dprintul_base libftx/printf/ft_dprintul_base.c /^int ft_dprintul_base(int fd, unsigned long long n, char *base)$/;" f typeref:typename:int
ft_dprintx libftx/printf/ft_dprintx.c /^int ft_dprintx(int fd, unsigned int n)$/;" f typeref:typename:int
ft_empty_verif syntatics.c /^int ft_empty_verif(const char *str)$/;" f typeref:typename:int
ft_env_filler env_fill.c /^char *ft_env_filler(t_list **env, const char *str)$/;" f typeref:typename:char *
ft_eprintf libftx/printf/ft_eprintf.c /^int ft_eprintf(const char *format, ...)$/;" f typeref:typename:int
ft_executor execution.c /^static int ft_executor(t_cmd *cmd, t_list **env)$/;" f typeref:typename:int file:
ft_exit builtins/exit.c /^int ft_exit(char **args, int fd)$/;" f typeref:typename:int
ft_file_is_appendable file.c /^int ft_file_is_appendable(const char *path)$/;" f typeref:typename:int
ft_file_is_executable file.c /^int ft_file_is_executable(const char *path)$/;" f typeref:typename:int
ft_file_is_readable file.c /^int ft_file_is_readable(const char *path)$/;" f typeref:typename:int
ft_file_is_writable file.c /^int ft_file_is_writable(const char *path)$/;" f typeref:typename:int
ft_freer_tab libftx/extra/ft_freer.c /^void ft_freer_tab(char **tab)$/;" f typeref:typename:void
ft_freer_tab_ultimate libftx/extra/ft_freer.c /^void ft_freer_tab_ultimate(size_t len, ...)$/;" f typeref:typename:void
ft_freer_ultimate libftx/extra/ft_freer.c /^void ft_freer_ultimate(size_t len, ...)$/;" f typeref:typename:void
ft_gen_exit_code_var env_fill.c /^int ft_gen_exit_code_var(t_data *data)$/;" f typeref:typename:int
ft_get_executable_path execution.c /^static char *ft_get_executable_path(char *executable_name, t_list **env)$/;" f typeref:typename:char * file:
ft_get_heredoc heredoc.c /^int *ft_get_heredoc()$/;" f typeref:typename:int *
ft_get_infile infile.c /^static int ft_get_infile(const char *line)$/;" f typeref:typename:int file:
ft_get_key env_fill.c /^static char *ft_get_key(char *str)$/;" f typeref:typename:char * file:
ft_get_outfile outfile.c /^static int ft_get_outfile(const char *line)$/;" f typeref:typename:int file:
ft_get_user_input main.c /^static char *ft_get_user_input()$/;" f typeref:typename:char * file:
ft_get_value env_fill.c /^static char *ft_get_value(t_list **env, char *key)$/;" f typeref:typename:char * file:
ft_getextra libftx/gnl/get_next_line.c /^char *ft_getextra(char *str)$/;" f typeref:typename:char *
ft_getline libftx/gnl/get_next_line.c /^char *ft_getline(int fd)$/;" f typeref:typename:char *
ft_getreturn libftx/gnl/get_next_line.c /^char *ft_getreturn(char *str)$/;" f typeref:typename:char *
ft_getstash libftx/gnl/get_next_line.c /^char *ft_getstash(int fd)$/;" f typeref:typename:char *
ft_heredoc heredoc.c /^int ft_heredoc(char *stop)$/;" f typeref:typename:int
ft_heredoc_creator heredoc.c /^int ft_heredoc_creator(char *stop, int fd)$/;" f typeref:typename:int
ft_infile infile.c /^int ft_infile(t_data *data, char *line)$/;" f typeref:typename:int
ft_infile_is_valid infile.c /^static int ft_infile_is_valid(const char *line)$/;" f typeref:typename:int file:
ft_is_in libftx/extra/ft_is_in.c /^int ft_is_in(char *str, char c)$/;" f typeref:typename:int
ft_is_in libftx/libft/ft_strtrim.c /^static int ft_is_in(const char c, const char *charset)$/;" f typeref:typename:int file:
ft_is_in_quote utils/ft_is_in_quote.c /^int ft_is_in_quote(const char *str, size_t n)$/;" f typeref:typename:int
ft_isalnum libftx/libft/ft_isalnum.c /^int ft_isalnum(int c)$/;" f typeref:typename:int
ft_isalpha libftx/libft/ft_isalpha.c /^int ft_isalpha(int c)$/;" f typeref:typename:int
ft_isarg libftx/printf/ft_isarg.c /^int ft_isarg(int c)$/;" f typeref:typename:int
ft_isascii libftx/libft/ft_isascii.c /^int ft_isascii(int c)$/;" f typeref:typename:int
ft_isdigit libftx/libft/ft_isdigit.c /^int ft_isdigit(int c)$/;" f typeref:typename:int
ft_isdigit libftx/printf/ft_isdigit.c /^int ft_isdigit(int c)$/;" f typeref:typename:int
ft_isdup libftx/extra/ft_ultoa_base.c /^static int ft_isdup(char *str)$/;" f typeref:typename:int file:
ft_isdup libftx/printf/ft_dprintul_base.c /^static int ft_isdup(char *str)$/;" f typeref:typename:int file:
ft_isprint libftx/libft/ft_isprint.c /^int ft_isprint(int c)$/;" f typeref:typename:int
ft_isspace utils/ft_atoi_check.c /^static int ft_isspace(char c)$/;" f typeref:typename:int file:
ft_itoa libftx/libft/ft_itoa.c /^char *ft_itoa(int n)$/;" f typeref:typename:char *
ft_lstadd_back libftx/libft/ft_lstadd_back.c /^void ft_lstadd_back(t_list **lst, t_list *new)$/;" f typeref:typename:void
ft_lstadd_front libftx/libft/ft_lstadd_front.c /^void ft_lstadd_front(t_list **lst, t_list *new)$/;" f typeref:typename:void
ft_lstclear libftx/libft/ft_lstclear.c /^void ft_lstclear(t_list **lst, void (*del)(void *))$/;" f typeref:typename:void
ft_lstdelone libftx/libft/ft_lstdelone.c /^void ft_lstdelone(t_list *lst, void (*del)(void *))$/;" f typeref:typename:void
ft_lstiter libftx/libft/ft_lstiter.c /^void ft_lstiter(t_list *lst, void (*f)(void *))$/;" f typeref:typename:void
ft_lstlast libftx/libft/ft_lstlast.c /^t_list *ft_lstlast(t_list *lst)$/;" f typeref:typename:t_list *
ft_lstmap libftx/libft/ft_lstmap.c /^t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))$/;" f typeref:typename:t_list *
ft_lstnew libftx/libft/ft_lstnew.c /^t_list *ft_lstnew(void *content)$/;" f typeref:typename:t_list *
ft_lstsize libftx/libft/ft_lstsize.c /^int ft_lstsize(t_list *lst)$/;" f typeref:typename:int
ft_memchr libftx/libft/ft_memchr.c /^void *ft_memchr(const void *s, int c, size_t n)$/;" f typeref:typename:void *
ft_memcmp libftx/libft/ft_memcmp.c /^int ft_memcmp(const void *s1, const void *s2, size_t n)$/;" f typeref:typename:int
ft_memcpy libftx/libft/ft_memcpy.c /^void *ft_memcpy(void *dest, const void *src, size_t n)$/;" f typeref:typename:void *
ft_memmove libftx/libft/ft_memmove.c /^void *ft_memmove(void *dest, const void *src, size_t n)$/;" f typeref:typename:void *
ft_memset libftx/libft/ft_memset.c /^void *ft_memset(void *s, int c, size_t n)$/;" f typeref:typename:void *
ft_minishell main.c /^static int ft_minishell(t_data *data, char *line)$/;" f typeref:typename:int file:
ft_nb_digit libftx/libft/ft_itoa.c /^static int ft_nb_digit(int n)$/;" f typeref:typename:int file:
ft_normalizer spacer.c /^char *ft_normalizer(char *str)$/;" f typeref:typename:char *
ft_outfile outfile.c /^int ft_outfile(t_data *data, char *line)$/;" f typeref:typename:int
ft_outfile_is_valid outfile.c /^static int ft_outfile_is_valid(const char *line)$/;" f typeref:typename:int file:
ft_own_cmd execution.c /^static int ft_own_cmd(t_data *data, t_cmd *cmd)$/;" f typeref:typename:int file:
ft_parse_cmds cmds.c /^t_list **ft_parse_cmds(t_data *data, char *line, int infile, int outfile)$/;" f typeref:typename:t_list **
ft_pipe_is_alone syntatics.c /^static int ft_pipe_is_alone(const char *str)$/;" f typeref:typename:int file:
ft_printf libftx/printf/ft_printf.c /^int ft_printf(const char *format, ...)$/;" f typeref:typename:int
ft_printn utils/ft_printn.c /^void ft_printn(const char *str, size_t n)$/;" f typeref:typename:void
ft_putchar_fd libftx/libft/ft_putchar_fd.c /^void ft_putchar_fd(char c, int fd)$/;" f typeref:typename:void
ft_putchar_fd_p libftx/printf/ft_putchar_fd.c /^int ft_putchar_fd_p(int fd, char c)$/;" f typeref:typename:int
ft_putendl_fd libftx/libft/ft_putendl_fd.c /^void ft_putendl_fd(char *s, int fd)$/;" f typeref:typename:void
ft_putnbr_fd libftx/libft/ft_putnbr_fd.c /^void ft_putnbr_fd(int n, int fd)$/;" f typeref:typename:void
ft_putstr_fd libftx/libft/ft_putstr_fd.c /^void ft_putstr_fd(char *s, int fd)$/;" f typeref:typename:void
ft_putstr_fd_p libftx/printf/ft_putstr_fd.c /^int ft_putstr_fd_p(int fd, char *str)$/;" f typeref:typename:int
ft_quit main.c /^void ft_quit(int num)$/;" f typeref:typename:void
ft_quote_remover utils/ft_quote_remover.c /^char *ft_quote_remover(char *str)$/;" f typeref:typename:char *
ft_quote_verif syntatics.c /^static int ft_quote_verif(const char *str)$/;" f typeref:typename:int file:
ft_random_generator libftx/extra/ft_random_generator.c /^size_t ft_random_generator(size_t start, size_t stop)$/;" f typeref:typename:size_t
ft_remove_infile infile.c /^static int ft_remove_infile(char *line)$/;" f typeref:typename:int file:
ft_remove_outfile outfile.c /^static int ft_remove_outfile(char *line)$/;" f typeref:typename:int file:
ft_seglen libftx/libft/ft_split.c /^static size_t ft_seglen(const char *s, char c)$/;" f typeref:typename:size_t file:
ft_seglen_quoted utils/ft_split_quoted.c /^size_t ft_seglen_quoted(const char *str, char c)$/;" f typeref:typename:size_t
ft_segsplitter libftx/libft/ft_split.c /^static char **ft_segsplitter(char **tab, size_t len, const char *s, char c)$/;" f typeref:typename:char ** file:
ft_segsplitter utils/ft_split_quoted.c /^static char **ft_segsplitter(char **tab, size_t len, const char *s, char c)$/;" f typeref:typename:char ** file:
ft_skipflag libftx/printf/ft_skipflag.c /^int ft_skipflag(const char *str)$/;" f typeref:typename:int
ft_space_simplifier spacer.c /^static void ft_space_simplifier(char *str)$/;" f typeref:typename:void file:
ft_spacer_after spacer.c /^static char *ft_spacer_after(const char *str)$/;" f typeref:typename:char * file:
ft_spacer_before spacer.c /^static char *ft_spacer_before(const char *str)$/;" f typeref:typename:char * file:
ft_special_char_dub syntatics.c /^static int ft_special_char_dub(const char *str)$/;" f typeref:typename:int file:
ft_split libftx/libft/ft_split.c /^char **ft_split(const char *s, char c)$/;" f typeref:typename:char **
ft_split_quoted utils/ft_split_quoted.c /^char **ft_split_quoted(const char *s, char c)$/;" f typeref:typename:char **
ft_str_is_empty utils/ft_str_is_empty.c /^int ft_str_is_empty(const char *str)$/;" f typeref:typename:int
ft_str_size libftx/extra/ft_ultoa_base.c /^static size_t ft_str_size(unsigned long long n, size_t base_size)$/;" f typeref:typename:size_t file:
ft_str_size libftx/printf/ft_dprintul_base.c /^static size_t ft_str_size(unsigned long long n, size_t base_size)$/;" f typeref:typename:size_t file:
ft_strchr libftx/libft/ft_strchr.c /^char *ft_strchr(const char *s, int c)$/;" f typeref:typename:char *
ft_strchri libftx/extra/ft_strchri.c /^ssize_t ft_strchri(char *str, char c)$/;" f typeref:typename:ssize_t
ft_strcmp libftx/extra/ft_strcmp.c /^int ft_strcmp(char *s1, char *s2)$/;" f typeref:typename:int
ft_strdup libftx/libft/ft_strdup.c /^char *ft_strdup(const char *s)$/;" f typeref:typename:char *
ft_strfjoin libftx/extra/ft_strfjoin.c /^char *ft_strfjoin(char *s1, char *s2)$/;" f typeref:typename:char *
ft_strgen libftx/extra/ft_strgen.c /^char *ft_strgen(char c, size_t len)$/;" f typeref:typename:char *
ft_striteri libftx/libft/ft_striteri.c /^void ft_striteri(char *s, void (*f)(unsigned int, char *))$/;" f typeref:typename:void
ft_strjoin libftx/libft/ft_strjoin.c /^char *ft_strjoin(const char *s1, const char *s2)$/;" f typeref:typename:char *
ft_strlcat libftx/libft/ft_strlcat.c /^size_t ft_strlcat(char *dest, const char *src, size_t size)$/;" f typeref:typename:size_t
ft_strlcpy libftx/libft/ft_strlcpy.c /^size_t ft_strlcpy(char *dst, const char *src, size_t size)$/;" f typeref:typename:size_t
ft_strlen libftx/libft/ft_strlen.c /^size_t ft_strlen(const char *s)$/;" f typeref:typename:size_t
ft_strlen libftx/printf/ft_strlen.c /^size_t ft_strlen(const char *s)$/;" f typeref:typename:size_t
ft_strmapi libftx/libft/ft_strmapi.c /^char *ft_strmapi(char const *s, char (*f)(unsigned int, char))$/;" f typeref:typename:char *
ft_strmerger libftx/extra/ft_strmerger.c /^char *ft_strmerger(size_t arg_len, ...)$/;" f typeref:typename:char *
ft_strnchr utils/ft_strnchr.c /^ssize_t ft_strnchr(const char *str, char c)$/;" f typeref:typename:ssize_t
ft_strncmp libftx/libft/ft_strncmp.c /^int ft_strncmp(const char *s1, const char *s2, size_t n)$/;" f typeref:typename:int
ft_strncpy utils/ft_strncpy.c /^size_t ft_strncpy(char *dst, const char *src, size_t n)$/;" f typeref:typename:size_t
ft_strndup libftx/extra/ft_strndup.c /^char *ft_strndup(const char *src, size_t n)$/;" f typeref:typename:char *
ft_strnstr libftx/libft/ft_strnstr.c /^char *ft_strnstr(const char *big, const char *little, size_t len)$/;" f typeref:typename:char *
ft_strrchr libftx/libft/ft_strrchr.c /^char *ft_strrchr(const char *s, int c)$/;" f typeref:typename:char *
ft_strreplace utils/ft_strreplace.c /^char *ft_strreplace(const char *str, const char *fill,$/;" f typeref:typename:char *
ft_strshift utils/ft_strshift.c /^void ft_strshift(char *str, int shift)$/;" f typeref:typename:void
ft_strtrim libftx/libft/ft_strtrim.c /^char *ft_strtrim(const char *s1, const char *set)$/;" f typeref:typename:char *
ft_substr libftx/libft/ft_substr.c /^char *ft_substr(char const *s, unsigned int start, size_t len)$/;" f typeref:typename:char *
ft_swap libftx/extra/ft_swap.c /^void ft_swap(void *a, void *b)$/;" f typeref:typename:void
ft_swap_char libftx/extra/ft_swap.c /^void ft_swap_char(char *a, char *b)$/;" f typeref:typename:void
ft_swap_int libftx/extra/ft_swap.c /^void ft_swap_int(int *a, int *b)$/;" f typeref:typename:void
ft_syntatic_verif syntatics.c /^int ft_syntatic_verif(t_data *data, const char *str)$/;" f typeref:typename:int
ft_tabrealloc libftx/extra/ft_tabrealloc.c /^char **ft_tabrealloc(char **tab, size_t current_size, size_t new_size)$/;" f typeref:typename:char **
ft_tolower libftx/libft/ft_tolower.c /^int ft_tolower(int c)$/;" f typeref:typename:int
ft_toupper libftx/libft/ft_toupper.c /^int ft_toupper(int c)$/;" f typeref:typename:int
ft_ultoa_base libftx/extra/ft_ultoa_base.c /^char *ft_ultoa_base(unsigned long long n, char *base)$/;" f typeref:typename:char *
ft_vdprintf libftx/printf/ft_vdprintf.c /^int ft_vdprintf(int fd, const char *format, va_list va)$/;" f typeref:typename:int
get_index env2.c /^int get_index(char *s, char c)$/;" f typeref:typename:int
get_key env3.c /^char *get_key(char *str)$/;" f typeref:typename:char *
get_next_line libftx/gnl/get_next_line.c /^char *get_next_line(int fd)$/;" f typeref:typename:char *
get_pwd builtins/pwd.c /^char *get_pwd(int fd)$/;" f typeref:typename:char *
get_value env3.c /^char *get_value(char *str)$/;" f typeref:typename:char *
get_value_by_key env.c /^char *get_value_by_key(char *key, t_list **head)$/;" f typeref:typename:char *
init_env env.c /^t_list **init_env(char **env)$/;" f typeref:typename:t_list **
is_space builtins/echo.c /^int is_space(char c)$/;" f typeref:typename:int
key minishell.h /^ char *key;$/;" m struct:s_env typeref:typename:char *
main main.c /^int main(int ac, char **av, char **env)$/;" f typeref:typename:int
main minishell_tester/test_files/loop.c /^int main(int argc, char const *argv[])$/;" f typeref:typename:int
move_folder builtins/cd.c /^int move_folder(char *path, int fd)$/;" f typeref:typename:int
next libftx/libft/libft.h /^ struct s_list *next;$/;" m struct:s_list typeref:struct:s_list *
next libftx/libftx.h /^ struct s_list *next;$/;" m struct:s_list typeref:struct:s_list *
possible_key env3.c /^int possible_key(char *key)$/;" f typeref:typename:int
print_env builtins/env.c /^int print_env(t_list **env, int fd)$/;" f typeref:typename:int
print_export builtins/export.c /^void print_export(t_list **env, int fd)$/;" f typeref:typename:void
pwd builtins/pwd.c /^int pwd(int fd)$/;" f typeref:typename:int
s_cmd minishell.h /^typedef struct s_cmd$/;" s
s_data minishell.h /^typedef struct s_data$/;" s
s_env minishell.h /^typedef struct s_env$/;" s
s_list libftx/libft/libft.h /^typedef struct s_list$/;" s
s_list libftx/libftx.h /^typedef struct s_list$/;" s
set_value_by_key env.c /^int set_value_by_key(char *key, char *value, t_list **head)$/;" f typeref:typename:int
swap_env env2.c /^void swap_env(void **a, void **b)$/;" f typeref:typename:void
swap_env_3 env2.c /^void swap_env_3(void **a, void **b, void **c)$/;" f typeref:typename:void
t_cmd minishell.h /^} t_cmd;$/;" t typeref:struct:s_cmd
t_data minishell.h /^} t_data;$/;" t typeref:struct:s_data
t_env minishell.h /^} t_env;$/;" t typeref:struct:s_env
t_list libftx/libft/libft.h /^} t_list;$/;" t typeref:struct:s_list
t_list libftx/libftx.h /^} t_list;$/;" t typeref:struct:s_list
unset builtins/unset.c /^int unset(t_list **env, char **args, int fd)$/;" f typeref:typename:int
value minishell.h /^ char *value;$/;" m struct:s_env typeref:typename:char *

View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_change_exit_code.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/24 19:04:04 by cchauvet #+# #+# */
/* Updated: 2023/02/24 19:05:57 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "../minishell.h"
int ft_change_exit_code(t_data *data, int new_value)
{
char *exit_code_str;
data->exit_code = new_value;
exit_code_str = ft_itoa(new_value);
if (exit_code_str == NULL)
{
ft_eprintf("minishell: malloc failed\n");
return (1);
}
return (0);
}