42_minishell/minishell.h
2023-02-28 13:16:10 +01:00

105 lines
3.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
/* Updated: 2023/02/28 13:14:57 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
# include "libftx/libftx.h"
# include "utils/utils.h"
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
# include <sys/wait.h>
# include <stdio.h>
# include <unistd.h>
# include <limits.h>
# include <string.h>
# include <readline/readline.h>
# include <readline/history.h>
# define DEBUG 0
typedef struct s_data
{
t_list **env;
int exit_code;
char *exit_code_str;
} t_data;
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(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);
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(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_data *data, const char *str);
char **env_to_strs(t_list **head);
/* Environnement */
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);
int create_value_by_key_dup(char *key, char *value, t_list **head);
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);
int delete_by_key(char *key, t_list **head);
int possible_key(char *key);
/* Echo */
int echo(int fd, char **strs);
/* PWD */
int pwd(int fd);
char *get_pwd(int fd);
/* Env */
int print_env(t_list **env, int fd);
/* Export */
int export(t_list **env, char **args, int fd);
/* CD */
int move_folder(char **args, int fd);
/* Unset */
int unset(t_list **env, char **args, int fd);
/* Exit */
int ft_exit(char **args, int fd);
typedef struct s_cmd
{
int fd_in;
int fd_out;
char *executable;
char **args;
} t_cmd;
typedef struct s_env
{
char *key;
char *value;
} t_env;
#endif