Commit 720b1c8b authored by komask's avatar komask
Browse files

headers norm

parent 80f92279
......@@ -7,6 +7,8 @@ SRC_DIR += src/builtins/
SRC += main.c
SRC += signal_handling.c
SRC += free_utils.c
SRC += var_utils.c
SRC += check_syntax.c
SRC += parsing_handler.c
......@@ -28,7 +30,6 @@ SRC += ft_export.c
SRC += export_print.c
SRC += export_in_env.c
SRC += ft_unset.c
SRC += var_utils.c
SRC += ft_env.c
SRC += ft_exit.c
......
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* builtins.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:42:53 by mvidal-a #+# #+# */
/* Updated: 2021/02/11 16:46:44 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BUILTINS_H
# define BUILTINS_H
......@@ -5,7 +17,7 @@
# include "error.h"
# define ECHO_OPTIONS "n"
# define ECHO_N_OPTION 0b00000001
# define ECHO_N_OPTION 0x01
# define ENTIRE_STR -1
......@@ -25,9 +37,9 @@ int ft_exit(char **args, t_xe *xe);
** utils
*/
t_byte shift_options(char ***args, char *op_chars);
int print_export(char **env, char **exported);
int ft_env_export(char *var, t_xe *xe, ssize_t equalsign_pos);
int check_var_name(char *var, ssize_t name_len);
t_byte shift_options(char ***args, char *op_chars);
int print_export(char **env, char **exported);
int ft_env_export(char *var, t_xe *xe, ssize_t equalsign_pos);
int check_var_name(char *var, ssize_t name_len);
#endif
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:52:06 by mvidal-a #+# #+# */
/* Updated: 2021/02/11 16:52:07 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ERROR_H
# define ERROR_H
#include <string.h>
# include <string.h>
#include "minishell.h"
# include "minishell.h"
enum e_retcode
{
......@@ -39,8 +51,8 @@ enum e_retcode
EMPTY_CMD,
};
int clean_and_exit(int ret, t_xe *xe);
int ft_error(int ret, t_xe *xe);
int error_and_exit(enum e_retcode ret, t_xe *xe);
int clean_and_exit(int ret, t_xe *xe);
int ft_error(int ret, t_xe *xe);
int error_and_exit(enum e_retcode ret, t_xe *xe);
#endif
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* execution.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:49:21 by mvidal-a #+# #+# */
/* Updated: 2021/02/11 16:55:00 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef EXECUTION_H
# define EXECUTION_H
#include <sys/types.h> // waitpid, opendir
#include <sys/wait.h> // waitpid
#include <fcntl.h> // open
#include <dirent.h> // readdir, opendir
# include <sys/types.h>
# include <sys/wait.h>
# include <fcntl.h>
# include <dirent.h>
# include "minishell.h"
# include "error.h"
......@@ -25,6 +37,8 @@ enum e_cmd_code
typedef int (*t_exec)(char **args, t_xe *xe);
int handle_execution(t_xe *xe, int fd_in, int proc);
/*
** main function
*/
......
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:52:23 by mvidal-a #+# #+# */
/* Updated: 2021/02/11 16:57:03 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
......@@ -16,7 +28,6 @@
# include "libft.h"
/*
** **********************************
** ** GENERAL DEFINES **
......@@ -29,8 +40,6 @@
# define TRUE 1
# define FALSE 0
# define _XOPEN_SOURCE // qu'est-ce?
# define FT_PS1 "$ "
# define SHLVL_STR "SHLVL"
......@@ -51,7 +60,7 @@
** **********************************
*/
enum e_redir_op
enum e_redir_op
{
NO_REDIR,
FILEIN,
......@@ -60,7 +69,7 @@ enum e_redir_op
AMBIG
};
typedef struct s_command
typedef struct s_command
{
char **args;
char **redir_paths;
......@@ -68,9 +77,9 @@ typedef struct s_command
t_byte pipe_flag;
t_byte var_flag;
uint8_t pad[6];
} t_command;
} t_command;
typedef struct s_xe
typedef struct s_xe
{
pid_t gpid;
int backup_stdin;
......@@ -81,8 +90,7 @@ typedef struct s_xe
char **exported;
char flags;
uint8_t pad[7];
} t_xe;
} t_xe;
/*
** **********************************
......@@ -90,19 +98,23 @@ typedef struct s_xe
** **********************************
*/
void signal_handler(void);
/*
** signals
*/
void signal_handler(void);
int handle_execution(t_xe *xe, int fd_in, int proc);
/*
** env management
*/
int env_replace_var(char *var_name, char *value, t_xe *xe);
int env_replace_var(char *var_name, char *value, t_xe *xe);
/*
** free utils
*/
void print_tokens(t_list *tokens); // temp
void free_token(void *content);
void free_command(void *content);
void free_commands(t_list **commands);
void free_command(void *content);
void free_commands(t_list **commands);
#endif
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:48:07 by mvidal-a #+# #+# */
/* Updated: 2021/02/11 16:49:11 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PARSING_H
# define PARSING_H
# include "minishell.h"
# include "error.h"
# define BUF_SIZE 4096
# define BUF_SIZE 4096
# define S_EMPTY 0x001
# define S_BACKSL 0x002
......
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 16:57:40 by mvidal-a #+# #+# */
/* Updated: 2021/02/11 16:57:42 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void free_command(void *content)
{
t_command *command;
command = (t_command *)content;
free_str_array(command->args);
free_str_array(command->redir_paths);
free(command->redir_types);
free(command);
}
void free_commands(t_list **commands)
{
ft_lstclear(commands, free_command);
}
......@@ -6,7 +6,7 @@
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/01 11:25:30 by mvidal-a #+# #+# */
/* Updated: 2021/02/01 11:25:30 by mvidal-a ### ########.fr */
/* Updated: 2021/02/11 16:57:24 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
......@@ -62,19 +62,3 @@ int add_to_buf(t_state_machine *machine, char c)
machine->len++;
return (SUCCESS);
}
void free_command(void *content)
{
t_command *command;
command = (t_command *)content;
free_str_array(command->args);
free_str_array(command->redir_paths);
free(command->redir_types);
free(command);
}
void free_commands(t_list **commands)
{
ft_lstclear(commands, free_command);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment