Skip to content

Commit

Permalink
Merge pull request #1 from mychibani/new
Browse files Browse the repository at this point in the history
New
  • Loading branch information
ychibani42 authored Oct 25, 2022
2 parents 33b70c1 + 7336b3d commit 360292e
Show file tree
Hide file tree
Showing 64 changed files with 3,174 additions and 421 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
<<<<<<< HEAD
"files.associations": {
"libft_structs.h": "c",
"minishell.h": "c",
Expand All @@ -19,4 +20,7 @@
"types.h": "c"
},
"C_Cpp.dimInactiveRegions": false
=======
"editor.insertSpaces": false
>>>>>>> 9923ad66d018a1acebba4d870492e7da51377107
}
74 changes: 49 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,55 @@
# +:+ +:+ +:+ #
# By: ychibani <ychibani@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/05/04 14:03:48 by jroux-fo #+# #+# #
# Updated: 2022/09/15 11:50:13by ychibani ### ########.fr #
# Created: 2022/05/04 14:03:48 by ychibani #+# #+# #
# Updated: 2022/10/25 19:49:19 by ychibani ### ########.fr #
# #
# **************************************************************************** #

SRCS_FILES = srcs/minishell/minishell.c \
srcs/init/init_structs.c \
srcs/init/env.c \
srcs/parser/parsing.c \
srcs/parser/synthax_checker.c \
srcs/token/tokenizer.c \
srcs/token/word_operator_fct.c \
srcs/token/tokenizer_utils_fct.c \
srcs/lexer/lexer.c \
srcs/lexer/lexer_utils.c \
srcs/utils/utils.c \
srcs/clean/cleaner_prog.c \
srcs/clean/clean_exit.c \
srcs/executor/signals/signal.c \
srcs/here_doc/here_doc.c \
srcs/here_doc/here_doc_utils.c \
srcs/expander/expander.c \
srcs/expander/expander2.c \
srcs/expander/dq_expander.c \
srcs/expander/heredoc_expand.c \
SRCS_FILES = srcs/minishell/minishell.c \
srcs/init/init_structs.c \
srcs/init/env.c \
srcs/parser/parsing.c \
srcs/parser/synthax_checker.c \
srcs/parser/synthax_checker_utils.c \
srcs/parser/clean_token.c \
srcs/parser/resplit_after_expand.c \
srcs/parser/remove_quotes.c \
srcs/parser/sequence_launcher.c \
srcs/token/tokenizer.c \
srcs/token/word_operator_fct.c \
srcs/token/tokenizer_utils_fct.c \
srcs/lexer/lexer.c \
srcs/lexer/lexer_utils.c \
srcs/utils/utils.c \
srcs/utils/test_utils.c \
srcs/clean/cleaner_prog.c \
srcs/clean/clean_exit.c \
srcs/executor/signals/signal.c \
srcs/here_doc/here_doc.c \
srcs/here_doc/here_doc_utils.c \
srcs/here_doc/here_doc_utils2.c \
srcs/expander/expander.c \
srcs/expander/expander2.c \
srcs/expander/expander3.c \
srcs/expander/expander4.c \
srcs/expander/heredoc_expand.c \
srcs/executor/builtin/echo/echo.c \
srcs/executor/builtin/env/env.c \
srcs/executor/builtin/env/env_utils.c \
srcs/executor/builtin/pwd/pwd.c \
srcs/executor/builtin/cd/cd.c \
srcs/executor/builtin/cd/cd_utils.c \
srcs/executor/builtin/export/export.c \
srcs/executor/builtin/export/export_utils.c \
srcs/executor/builtin/unset/unset.c \
srcs/executor/exec_prep/execution_preparation.c \
srcs/executor/exec_prep/handle_redirect.c \
srcs/executor/exec.c \
srcs/executor/launcher_fork.c \
srcs/executor/builtin/exit/exit.c \



NAME = minishell

Expand All @@ -43,14 +67,14 @@ LIBFT = libft/libft.a

CC = gcc

CFLAGS = -Wall -Werror -Wextra -g3
CFLAGS = -Wall -Werror -Wextra -fsanitize=address -g3

RM = rm -rf

_END=$'\e[0m
_BOLD=$'\e[1m
_UNDER=$'\e[4m
_REV=$'\e[7m:
_REV=$'\e[7m
_GREY=$'\e[30m
_RED=$'\e[0;31m
_GREEN=$'\e[32m
Expand Down Expand Up @@ -97,7 +121,7 @@ re: fclean
git:
git add .
git commit -m "$m"
git push origin master
git push

-include ${DEPS_FILES}

Expand Down
2 changes: 1 addition & 1 deletion includes/minishell.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ychibani <ychibani@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/06 17:40:51 by ychibani #+# #+# */
/* Updated: 2022/09/23 14:36:57 by ychibani ### ########.fr */
/* Updated: 2022/10/04 13:26:31 by ychibani ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
13 changes: 11 additions & 2 deletions includes/minishell_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ychibani <ychibani@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/18 17:06:56 by ychibani #+# #+# */
/* Updated: 2022/09/19 13:18:33 by ychibani ### ########.fr */
/* Updated: 2022/10/17 14:12:06 by ychibani ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -20,7 +20,8 @@ typedef enum e_type
REDIRECTION,
HERE_DOC,
INVALID,
NEW_LINE
NEW_LINE,
OPERATOR
} t_type;

typedef enum e_state
Expand All @@ -38,4 +39,12 @@ typedef enum e_token_pos
LAST
} t_token_pos;

typedef enum e_redir_type
{
HD,
GREAT,
LESS,
D_GREAT
} t_redir_type;

#endif
174 changes: 161 additions & 13 deletions includes/minishell_fonctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ychibani <ychibani@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/02 20:42:53 by ychibani #+# #+# */
/* Updated: 2022/10/03 14:23:14 by ychibani ### ########.fr */
/* Updated: 2022/10/25 19:47:58 by ychibani ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,9 +17,11 @@
** Init
*/

t_program_data *init_data_struct(t_program_data *data);
t_program_data *init_data_struct(t_program_data *data, char **env);
int change_directory(char *path);
t_user_input *init_user_input_struct(t_user_input *ui);
void __init_structs(t_program_data *data, t_user_input *ui);
void __init_structs(t_program_data *data,
t_user_input *ui, char **env);

/*
** Env
Expand All @@ -33,6 +35,118 @@ int get_env_size(char **env);
*/

int change_directory(char *path);
void ft_cd(t_user_input *ui);

/*
** Cd_utils
*/

t_env *ft_find_var(char *name, t_env **env);
int ft_cdhome(char *cd);
int ft_cdpwd(char *cd);

/*
** echo
*/

void ft_echo(t_user_input *ui);
char *remove_quote(char *str);
void ft_echo_pipe(char **cmd);
char *fill_print_echo_pipe(char **s);

/*
** env
*/

void ft_env(t_user_input *ui);
t_env *ft_init_env(char *var_to_split);
t_env **ft_split_env(char **env);
char **ft_collect_env(int *no_env, t_user_input *ui, char **env);

/*
** env_utils
*/

void __env_clear(t_env **lst, void (*del)(void*));
char *__strncpy(char *dst, const char *src, size_t dstsize);
t_env *__lst_env_new(char *name, char *value, int appear);
void __env_lstadd_back(t_env **alst, t_env *new);
int ft_size(char **str);

/*
** exit
*/

void ft_exit(t_user_input *ui);

/*
** export
*/

int great_redirection(t_cmd *cmd_list);
int less_redirection(t_cmd *cmd_list);
int dgreat_redirection(t_cmd *cmd_list);
int hd_redirection(t_cmd *cmd_list);

void ft_choose_export(t_user_input *ui);
void ft_export_arg(t_user_input *ui, char *var);
void ft_export_no_arg(t_user_input *ui);
void ft_make_export(t_env *search, char *to_set, t_user_input *ui);
void ft_changevar(t_env *env, char *var_to_split);

/*
** export_utils
*/

void ft_free(char **to_free, int i);
int ft_var_length(char *var);
int ft_valid_var(char *str);
void ft_concat_var(t_env *env, char *var_to_split);

/*
** pwd
*/

char *ft_getpwd(t_user_input *ui);
void ft_pwd(t_user_input *ui);

/*
** unset
*/

void ft_unset(t_user_input *ui);

/*
** pipex
*/

int ft_pipex(t_user_input *ui);
int _file_descriptors_duplicators(int _first, int _second);
int _close_file_descriptors(int _first, int _second);
int ft_execve(char *cmd, char **argvec, char **env);
void _clean_char_tab(char **tab);
void __clean_env(t_env **env);
int ft_is_pipe(t_lexer *lexer);
t_cmd *init_new_cmd(t_cmd *new);
void _error_prompt(char *str);
int __count_cmd(t_cmd *head);
char **get_path(char **envp);
t_cmd *ft_split_cmd(t_lexer **lexer, t_cmd *head);

/*
** children_work
*/


/*
** exec
*/

char *__get_name(int name);
int ft_cmd(t_user_input *ui);
char **ft_list_to_chr(t_env **env);
int ft_cmd_pipe(t_user_input *ui, char **cmd);


/*
** Tokenizer Utils
Expand All @@ -59,6 +173,7 @@ int get_word(char **token, char *str, int i);

int lexer(t_list *token, t_lexer **lexer);
t_lexer *synthax_checker(t_lexer **lexer, t_program_data *data);
t_lexer *synthax_error(t_lexer *lexer, t_program_data *data);

/*
** Parsing
Expand All @@ -71,11 +186,14 @@ int treat_usr_inputs(char *user_input,
** Heredoc
*/

int end_of_info(char *hd_content, int here_doc_fd,
t_lexer *lexer, int eof_type);
int eof_type(char *eof);
int wait_here_doc(pid_t pid, t_program_data *data);
void treat_eof(char *line, char *eof, t_program_data *data);
void init_child_hd(char *eof, t_lexer *travel,
t_program_data *data, t_lexer *save);
int __heredoc(t_user_input *ui, t_program_data *data);
int heredoc_join(char *adding_line, char **heredoc);
int get_usr_input(char **eof, t_program_data *data);
int read_from_stdin(char *eof, char **heredoc,
t_program_data *data);
Expand All @@ -97,26 +215,46 @@ void __signal(int sig);

char **__free_tab(char **tab);
void __lexer_clear(t_lexer **lst);
void __lexer_clear2(t_lexer **lst, void (*del)(void*));
void __clean_input(t_user_input *ui, char **inputs, char *line);
void destroy_env(t_program_data *data);
int __error_catcher(t_lexer **seq, t_program_data *data);
int __error_after_expand(t_lexer **seq);

/*
**
** Expand
*/

int sequence_launcher(t_lexer **seq, t_program_data *data);
int sequence_launcher(t_user_input *ui, t_program_data *data);
char *get_testing_wd(char *start_wd, int *offset);
int find_key(char *testing_wd, char *env_str,
t_program_data *data, int j);
t_program_data *data);
char *handle_quotes_in_env(char *str);
int get_value(char *testing_wd, char *env_str,
int get_value(char *testing_wd,
char **expanded_wd, char *key_value);
int __heredoc_expansion(char **token, t_program_data *data);
void update_token(char **token, char **new_token);
int parameter_expand(char *str, char **expanded_wd, t_program_data *data, int *offset);
int treat_final_rv(char **wd, int *offset, t_program_data *data);
char *get_key(char *str);
int is_valid_char(char c);
void update_token(char **token, char **new_token);
int parameter_expand(char *str, char **expanded_wd,
t_program_data *data, int *offset);
int treat_final_rv(char **wd, int *offset, t_program_data *data);
char *get_key(char *str);
int is_valid_char(char c);
int lexer_remove_quote(t_lexer *lexer);
int __expand_var(t_lexer *seq, t_program_data *data);
int __split_token_after_expand(t_lexer *travel);
int in_quote(char *s, char *to_find);
char **unquoted_char_split(char *s, char *charset);
int is_operator_valid(char *cmp);




/*
** Command
*/


t_cmd *create_cmd_list(t_lexer *lexer, t_program_data *data);

/*
** Exit
Expand All @@ -132,4 +270,14 @@ void print_data(t_program_data *data, t_user_input *ui);
void print_linked_list(t_list *list);
void print_lexer_list(t_lexer *lexer);

int __execute_sequence(t_cmd *save, t_program_data *data);


/*
** REDIRECT
*/



void cmd_list_free(t_cmd **cmd_list_free);
#endif
Loading

0 comments on commit 360292e

Please sign in to comment.