2023-02-14 11:11:39 -05:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* minishell.h :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
|
2023-02-21 09:07:14 -05:00
|
|
|
/* Updated: 2023/02/21 15:05:50 by cchauvet ### ########.fr */
|
2023-02-14 11:11:39 -05:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2023-02-14 01:21:24 -05:00
|
|
|
#ifndef MINISHELL_H
|
|
|
|
# define MINISHELL_H
|
2023-01-31 09:02:23 -05:00
|
|
|
# include "libftx/libftx.h"
|
2023-02-01 11:28:38 -05:00
|
|
|
# include "utils/utils.h"
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# include <fcntl.h>
|
2023-02-14 01:21:24 -05:00
|
|
|
# include <sys/wait.h>
|
|
|
|
# include <stdio.h>
|
2023-02-21 08:52:58 -05:00
|
|
|
# include <unistd.h>
|
|
|
|
# include <limits.h>
|
2023-02-14 01:21:24 -05:00
|
|
|
# include <readline/readline.h>
|
|
|
|
# include <readline/history.h>
|
2023-02-17 13:05:33 -05:00
|
|
|
# define DEBUG 0
|
2023-02-17 12:23:17 -05:00
|
|
|
|
2023-02-06 14:41:10 -05:00
|
|
|
int ft_syntatic_verif(const char *str);
|
|
|
|
int ft_file_is_readable(const char *path);
|
2023-02-15 14:52:27 -05:00
|
|
|
int ft_file_is_writable(const char *path);
|
|
|
|
int ft_file_is_appendable(const char *path);
|
2023-02-06 14:41:10 -05:00
|
|
|
char *ft_get_file_path(const char *infile);
|
|
|
|
int ft_infile(char *line);
|
|
|
|
int ft_outfile(char *line);
|
|
|
|
int ft_heredoc(char *stop);
|
|
|
|
size_t ft_seglen_quoted(const char *str, char c);
|
2023-02-16 12:28:10 -05:00
|
|
|
int ft_cmds_executor(t_list **cmds, t_list **env);
|
2023-02-06 14:41:10 -05:00
|
|
|
char **ft_split_quoted(const char *s, char c);
|
2023-02-15 14:52:27 -05:00
|
|
|
void ft_cmddel(void *content);
|
2023-02-14 11:11:39 -05:00
|
|
|
void env_del(void *content);
|
2023-02-17 07:07:10 -05:00
|
|
|
t_list **ft_parse_cmds(char *line, t_list **env, int infile, int outfile);
|
2023-02-16 12:28:10 -05:00
|
|
|
int ft_cmd_filler(t_list *current, char **args, t_list **env);
|
2023-02-15 14:52:27 -05:00
|
|
|
char *ft_normalizer(char *str);
|
2023-02-16 12:28:10 -05:00
|
|
|
char *ft_env_filler(t_list **env, const char *str);
|
2023-02-17 07:27:40 -05:00
|
|
|
char **env_to_strs(t_list **head);
|
2023-01-31 08:40:15 -05:00
|
|
|
|
2023-02-17 10:54:58 -05:00
|
|
|
/* Environnement */
|
2023-02-17 12:24:24 -05:00
|
|
|
t_list **init_env(char **env);
|
|
|
|
char **env_to_strs(t_list **head);
|
|
|
|
int create_value_by_key(char *key, char *value, t_list **head);
|
2023-02-21 08:36:20 -05:00
|
|
|
int create_value_by_key_dup(char *key, char *value, t_list **head);
|
2023-02-17 12:24:24 -05:00
|
|
|
int set_value_by_key(char *key, char *value, t_list **head);
|
|
|
|
char *get_value_by_key(char *key, t_list **head);
|
|
|
|
int get_index(char *s, char c);
|
|
|
|
void swap_env_3(void **a, void **b, void **c);
|
|
|
|
void swap_env(void **a, void **b);
|
|
|
|
void env_del(void *ptr);
|
|
|
|
char **env_to_strs(t_list **head);
|
|
|
|
char *get_value(char *str);
|
|
|
|
char *get_key(char *str);
|
2023-02-17 10:54:58 -05:00
|
|
|
|
|
|
|
/* Echo */
|
2023-02-21 09:07:14 -05:00
|
|
|
int echo(int fd, char **args);
|
2023-02-17 10:54:58 -05:00
|
|
|
/* PWD */
|
2023-02-21 08:45:43 -05:00
|
|
|
int pwd(int fd);
|
|
|
|
char *get_pwd(int fd);
|
2023-02-21 07:14:58 -05:00
|
|
|
/* ENV */
|
2023-02-21 07:21:20 -05:00
|
|
|
int print_env(t_list **head, int fd);
|
2023-02-21 07:14:58 -05:00
|
|
|
/* EXPORT */
|
2023-02-21 07:21:20 -05:00
|
|
|
int print_export(t_list **head, int fd);
|
2023-02-21 07:14:58 -05:00
|
|
|
/* CD */
|
2023-02-21 07:22:50 -05:00
|
|
|
int move_folder(char *path, int fd);
|
2023-02-21 07:21:20 -05:00
|
|
|
/* UNSET */
|
2023-02-21 07:22:50 -05:00
|
|
|
int unset(t_list **env, char **args, int fd);
|
2023-02-17 10:54:58 -05:00
|
|
|
|
2023-02-06 14:41:10 -05:00
|
|
|
typedef struct s_cmd
|
2023-01-31 08:40:15 -05:00
|
|
|
{
|
2023-02-14 01:21:24 -05:00
|
|
|
int fd_in;
|
|
|
|
int fd_out;
|
2023-02-06 14:41:10 -05:00
|
|
|
char *executable;
|
2023-02-09 12:47:05 -05:00
|
|
|
char **args;
|
2023-02-14 01:21:24 -05:00
|
|
|
} t_cmd;
|
|
|
|
|
|
|
|
typedef struct s_data
|
|
|
|
{
|
|
|
|
t_list **env;
|
2023-02-14 07:38:40 -05:00
|
|
|
int heredoc;
|
2023-02-14 01:21:24 -05:00
|
|
|
} t_data;
|
2023-01-31 09:02:23 -05:00
|
|
|
|
2023-02-16 09:13:55 -05:00
|
|
|
typedef struct s_env
|
|
|
|
{
|
|
|
|
void *key;
|
|
|
|
void *value;
|
|
|
|
} t_env;
|
|
|
|
|
2023-01-31 09:02:23 -05:00
|
|
|
#endif
|