diff options
| author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 18:55:07 +0200 | 
|---|---|---|
| committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-27 18:55:07 +0200 | 
| commit | 487a66394061f2d14a2fa421302966b5442d643f (patch) | |
| tree | 34237d4e9cb85f94bcefd46f399d2224dff3f6b3 | |
| parent | Correct shell prompt (diff) | |
| download | 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.gz 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.bz2 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.xz 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.tar.zst 42-minishell-487a66394061f2d14a2fa421302966b5442d643f.zip | |
I couldn't see shit
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | src/b_builtins.h | 25 | ||||
| -rw-r--r-- | src/b_cd.c (renamed from src/ft_b_cd.c) | 36 | ||||
| -rw-r--r-- | src/b_cd.h (renamed from src/ft_m_loop.h) | 11 | ||||
| -rw-r--r-- | src/b_echo.c (renamed from src/ft_b_echo.c) | 20 | ||||
| -rw-r--r-- | src/b_echo.h (renamed from src/ft_b_cd.h) | 11 | ||||
| -rw-r--r-- | src/b_env.c (renamed from src/ft_b_env.c) | 11 | ||||
| -rw-r--r-- | src/b_env.h (renamed from src/ft_b_pwd.h) | 11 | ||||
| -rw-r--r-- | src/b_exit.c (renamed from src/ft_b_exit.c) | 18 | ||||
| -rw-r--r-- | src/b_exit.h | 24 | ||||
| -rw-r--r-- | src/b_export.c (renamed from src/ft_b_export.c) | 27 | ||||
| -rw-r--r-- | src/b_export.h (renamed from src/ft_b_export.h) | 10 | ||||
| -rw-r--r-- | src/b_pwd.c (renamed from src/ft_b_pwd.c) | 6 | ||||
| -rw-r--r-- | src/b_pwd.h (renamed from src/ft_b_env.h) | 11 | ||||
| -rw-r--r-- | src/b_type.c (renamed from src/ft_b_type.c) | 34 | ||||
| -rw-r--r-- | src/b_type.h (renamed from src/ft_b_echo.h) | 11 | ||||
| -rw-r--r-- | src/b_unset.c (renamed from src/ft_b_unset.c) | 7 | ||||
| -rw-r--r-- | src/b_unset.h | 23 | ||||
| -rw-r--r-- | src/d_define.h (renamed from src/ft_d_define.h) | 8 | ||||
| -rw-r--r-- | src/d_enum.h (renamed from src/ft_d_enum.h) | 6 | ||||
| -rw-r--r-- | src/e_builtins.c (renamed from src/ft_e_builtins.c) | 30 | ||||
| -rw-r--r-- | src/e_builtins.h (renamed from src/ft_e_builtins.h) | 11 | ||||
| -rw-r--r-- | src/e_externs.c (renamed from src/ft_e_externs.c) | 30 | ||||
| -rw-r--r-- | src/e_externs.h (renamed from src/ft_e_externs.h) | 10 | ||||
| -rw-r--r-- | src/e_externs_next.c (renamed from src/ft_e_externs_next.c) | 34 | ||||
| -rw-r--r-- | src/e_externs_next.h (renamed from src/ft_e_externs_next.h) | 12 | ||||
| -rw-r--r-- | src/e_externs_pipes.c (renamed from src/ft_e_externs_pipes.c) | 42 | ||||
| -rw-r--r-- | src/e_externs_pipes.h | 20 | ||||
| -rw-r--r-- | src/e_lcom.c (renamed from src/ft_e_lcom.c) | 24 | ||||
| -rw-r--r-- | src/e_lcom.h (renamed from src/ft_u_utils.h) | 9 | ||||
| -rw-r--r-- | src/e_pipes.c (renamed from src/ft_e_pipes.c) | 22 | ||||
| -rw-r--r-- | src/e_pipes.h (renamed from src/ft_m_funptr.h) | 10 | ||||
| -rw-r--r-- | src/f_chdir.c (renamed from src/ft_f_chdir.c) | 6 | ||||
| -rw-r--r-- | src/f_chdir.h (renamed from src/ft_f_chdir.h) | 10 | ||||
| -rw-r--r-- | src/f_errno.c (renamed from src/ft_f_errno.c) | 6 | ||||
| -rw-r--r-- | src/f_errno.h (renamed from src/ft_m_redirs.h) | 10 | ||||
| -rw-r--r-- | src/f_fail.c (renamed from src/ft_f_fail.c) | 20 | ||||
| -rw-r--r-- | src/f_fail.h (renamed from src/ft_f_fail.h) | 22 | ||||
| -rw-r--r-- | src/f_redir.c (renamed from src/ft_f_redir.c) | 12 | ||||
| -rw-r--r-- | src/f_redir.h (renamed from src/ft_p_line.h) | 10 | ||||
| -rw-r--r-- | src/ft_b_builtins.h | 25 | ||||
| -rw-r--r-- | src/ft_b_type.h | 22 | ||||
| -rw-r--r-- | src/ft_b_unset.h | 22 | ||||
| -rw-r--r-- | src/ft_e_externs_pipes.h | 20 | ||||
| -rw-r--r-- | src/ft_m_prompt.h | 20 | ||||
| -rw-r--r-- | src/ft_p_lcom_next.h | 25 | ||||
| -rw-r--r-- | src/ft_s_lcom.h | 23 | ||||
| -rw-r--r-- | src/ft_u_vars.h | 21 | ||||
| -rw-r--r-- | src/m_argv.c (renamed from src/ft_m_argv.c) | 16 | ||||
| -rw-r--r-- | src/m_argv.h (renamed from src/ft_m_argv.h) | 10 | ||||
| -rw-r--r-- | src/m_comm.c (renamed from src/ft_m_comm.c) | 20 | ||||
| -rw-r--r-- | src/m_comm.h | 23 | ||||
| -rw-r--r-- | src/m_funptr.c (renamed from src/ft_m_funptr.c) | 32 | ||||
| -rw-r--r-- | src/m_funptr.h (renamed from src/ft_s_destroy.h) | 10 | ||||
| -rw-r--r-- | src/m_loop.c (renamed from src/ft_m_loop.c) | 38 | ||||
| -rw-r--r-- | src/m_loop.h (renamed from src/ft_b_exit.h) | 12 | ||||
| -rw-r--r-- | src/m_minishell.c (renamed from src/minishell.c) | 19 | ||||
| -rw-r--r-- | src/m_minishell.h (renamed from src/minishell.h) | 6 | ||||
| -rw-r--r-- | src/m_prompt.c (renamed from src/ft_m_prompt.c) | 10 | ||||
| -rw-r--r-- | src/m_prompt.h | 20 | ||||
| -rw-r--r-- | src/m_redirs.c (renamed from src/ft_m_redirs.c) | 18 | ||||
| -rw-r--r-- | src/m_redirs.h (renamed from src/ft_e_pipes.h) | 11 | ||||
| -rw-r--r-- | src/p_lcom.c (renamed from src/ft_p_lcom.c) | 36 | ||||
| -rw-r--r-- | src/p_lcom.h (renamed from src/ft_p_lcom.h) | 12 | ||||
| -rw-r--r-- | src/p_lcom_next.c (renamed from src/ft_p_lcom_next.c) | 16 | ||||
| -rw-r--r-- | src/p_lcom_next.h (renamed from src/ft_m_comm.h) | 14 | ||||
| -rw-r--r-- | src/p_line.c (renamed from src/ft_p_line.c) | 22 | ||||
| -rw-r--r-- | src/p_line.h (renamed from src/ft_f_redir.h) | 10 | ||||
| -rw-r--r-- | src/s_destroy.c (renamed from src/ft_s_destroy.c) | 10 | ||||
| -rw-r--r-- | src/s_destroy.h | 20 | ||||
| -rw-r--r-- | src/s_init.c (renamed from src/ft_s_init.c) | 20 | ||||
| -rw-r--r-- | src/s_init.h (renamed from src/ft_s_init.h) | 11 | ||||
| -rw-r--r-- | src/s_lcom.c (renamed from src/ft_s_lcom.c) | 28 | ||||
| -rw-r--r-- | src/s_lcom.h | 23 | ||||
| -rw-r--r-- | src/s_lpipes.c (renamed from src/ft_s_lpipes.c) | 28 | ||||
| -rw-r--r-- | src/s_lpipes.h (renamed from src/ft_s_lpipes.h) | 18 | ||||
| -rw-r--r-- | src/s_lvars.c (renamed from src/ft_s_lvars.c) | 14 | ||||
| -rw-r--r-- | src/s_lvars.h (renamed from src/ft_s_lvars.h) | 18 | ||||
| -rw-r--r-- | src/s_struct.h (renamed from src/ft_s_struct.h) | 8 | ||||
| -rw-r--r-- | src/u_utils.c (renamed from src/ft_u_utils.c) | 4 | ||||
| -rw-r--r-- | src/u_utils.h (renamed from src/ft_e_lcom.h) | 9 | ||||
| -rw-r--r-- | src/u_vars.c (renamed from src/ft_u_vars.c) | 62 | ||||
| -rw-r--r-- | src/u_vars.h (renamed from src/ft_f_errno.h) | 10 | 
83 files changed, 748 insertions, 736 deletions
| @@ -36,6 +36,7 @@ SRCS_NAME		+= m_argv  SRCS_NAME		+= m_comm  SRCS_NAME		+= m_funptr  SRCS_NAME		+= m_loop +SRCS_NAME		+= m_minishell  SRCS_NAME		+= m_prompt  SRCS_NAME		+= m_redirs  SRCS_NAME		+= s_destroy @@ -49,17 +50,14 @@ SRCS_NAME		+= p_lcom_next  SRCS_NAME		+= u_utils  SRCS_NAME		+= u_vars  #------------------------------------------------------------------------------# -SRCS			 = $(addprefix ${SRCS_DIR}, $(addprefix ft_, \ -	$(addsuffix .c, ${SRCS_NAME}))) -SRCS			+= ${SRCS_DIR}minishell.c +SRCS			 = $(addprefix ${SRCS_DIR}, $(addsuffix .c, ${SRCS_NAME}))  #------------------------------------------------------------------------------#  INCS_NAME		 = b_builtins  INCS_NAME		+= d_enum  INCS_NAME		+= d_define  INCS_NAME		+= s_struct  #------------------------------------------------------------------------------# -INCS			 = $(addprefix ${SRCS_DIR}, $(addprefix ft_, \ -	$(addsuffix .h, ${INCS_NAME}))) +INCS			 = $(addprefix ${SRCS_DIR}, $(addsuffix .h, ${INCS_NAME}))  INCS			+= $(patsubst %.c,%.h,${SRCS})  #------------------------------------------------------------------------------#  OBJS			 = $(patsubst ${SRCS_DIR}%.c,${OBJS_DIR}%.o,${SRCS}) diff --git a/src/b_builtins.h b/src/b_builtins.h new file mode 100644 index 0000000..f7e7e99 --- /dev/null +++ b/src/b_builtins.h @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   b_builtins.h                                       :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef B_BUILTINS_H +#define B_BUILTINS_H + +#include "b_cd.h" +#include "b_echo.h" +#include "b_env.h" +#include "b_exit.h" +#include "b_export.h" +#include "b_pwd.h" +#include "b_type.h" +#include "b_unset.h" + +#endif diff --git a/src/ft_b_cd.c b/src/b_cd.c index fbd0282..bcc8475 100644 --- a/src/ft_b_cd.c +++ b/src/b_cd.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_cd.c                                          :+:      :+:    :+:   */ +/*   b_cd.c                                             :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,55 +14,55 @@  #include <stdint.h>  #include <unistd.h> -#include "ft_f_fail.h" -#include "ft_s_destroy.h" -#include "ft_s_struct.h" -#include "ft_u_utils.h" -#include "ft_u_vars.h" +#include "f_fail.h" +#include "s_destroy.h" +#include "s_struct.h" +#include "u_utils.h" +#include "u_vars.h"  static void -	ft_set_path(char **path, +	set_path(char **path,  				char *args[],  				t_msh *msh)  {  	if (!(*path = ft_strdup(*args)))  	{ -		ft_s_destroy(msh); -		ft_fail_alloc(msh); +		s_destroy(msh); +		fail_alloc(msh);  	}  	if (!ft_strncmp("~/", *path, 2) || !ft_strncmp("~", *path, 2))  	{  		if (!(*path = ft_strsubst(*path, -			"~", ft_subst_var_value("$HOME", msh)))) +			"~", subst_var_value("$HOME", msh))))  		{ -			ft_s_destroy(msh); -			ft_fail_alloc(msh); +			s_destroy(msh); +			fail_alloc(msh);  		}  	}  }  uint8_t -	ft_b_cd(char *args[], +	b_cd(char *args[],  			t_msh *msh)  { -	const uint64_t	argc = ft_get_argc((const char**)args); +	const uint64_t	argc = get_argc((const char**)args);  	char			*path;  	if (argc >= 2)  	{ -		ft_fail_too_many_args("cd", msh); +		fail_too_many_args("cd", msh);  		return (1);  	}  	else if (argc == 0)  	{ -		if (!(path = ft_subst_var_value("$HOME", msh))) +		if (!(path = subst_var_value("$HOME", msh)))  			return (1);  	}  	else -		ft_set_path(&path, args, msh); +		set_path(&path, args, msh);  	if (chdir(path) != 0)  	{ -		ft_fail_chd("cd", path, msh); +		fail_chd("cd", path, msh);  		ft_memdel((void*)&path);  		return (1);  	} diff --git a/src/ft_m_loop.h b/src/b_cd.h index 4dd1873..629cf32 100644 --- a/src/ft_m_loop.h +++ b/src/b_cd.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_loop.h                                        :+:      :+:    :+:   */ +/*   b_cd.h                                             :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_M_LOOP -#define FT_M_LOOP +#ifndef B_CD_H +#define B_CD_H  #include <stdint.h> -#include "ft_s_struct.h" +#include "s_struct.h" -uint8_t	ft_m_loop(t_msh *msh); +uint8_t	b_cd(char *args[], +			t_msh *msh);  #endif diff --git a/src/ft_b_echo.c b/src/b_echo.c index de5431f..a02dad5 100644 --- a/src/ft_b_echo.c +++ b/src/b_echo.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_echo.c                                        :+:      :+:    :+:   */ +/*   b_echo.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,15 +15,15 @@  #include <stdio.h>  #include <stdlib.h> -#include "ft_s_struct.h" -#include "ft_u_utils.h" +#include "s_struct.h" +#include "u_utils.h"  /* TODO: echo "quoted text", echo 'quoted text', done*/  /* echo kill\nbackslash\nbut\nnot\nn, echo "quoted\nnew\nlines", done */  /* full buffer */  void -	ft_e_put(char *str, +	e_put(char *str,  			uint8_t op)  {  	size_t i; @@ -39,7 +39,7 @@ void  }  char -	*ft_e_initb(char *ptr[], +	*e_initb(char *ptr[],                      char *str)  {      size_t    len; @@ -58,7 +58,7 @@ char  /***********************************************/  /* void                                        */ -/*     ft_e_fill(char *ptr[], char **str)      */ +/*     e_fill(char *ptr[], char **str)         */  /* {                                           */  /*     char *bs;                               */  /*                                             */ @@ -70,7 +70,7 @@ char  /*     }                                       */  /*     else if ((bs = ft_strrchr(*str, '\\'))) */  /*     {                                       */ -/*         ft_e_put(*str, 0);                  */ +/*         e_put(*str, 0);                     */  /*     }                                       */  /*     else                                    */  /*         ft_printf("%s", *str);              */ @@ -78,10 +78,10 @@ char  /***********************************************/  uint8_t -	ft_b_echo(char *args[], +	b_echo(char *args[],  			t_msh *msh)  { -	const uint64_t	argc = ft_get_argc((const char **)args); +	const uint64_t	argc = get_argc((const char **)args);  	char			**ptr;  	char			*str;  	int8_t			nopt; @@ -90,7 +90,7 @@ uint8_t  	ptr = args;  	nopt = 0;      str = NULL; -    str = ft_e_initb(ptr, str); +    str = e_initb(ptr, str);  	if (argc >= 1)  	{  		if (ft_strncmp(ptr[0], "-n", 2) == 0) diff --git a/src/ft_b_cd.h b/src/b_echo.h index e789cc0..3481480 100644 --- a/src/ft_b_cd.h +++ b/src/b_echo.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_cd.h                                          :+:      :+:    :+:   */ +/*   b_echo.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_B_CD_H -#define FT_B_CD_H +#ifndef B_ECHO_H +#define B_ECHO_H  #include <stdint.h> -#include "ft_s_struct.h" -uint8_t	ft_b_cd(char *args[], +#include "s_struct.h" + +uint8_t	b_echo(char *args[],  				t_msh *msh);  #endif diff --git a/src/ft_b_env.c b/src/b_env.c index 14d05a2..08adaf5 100644 --- a/src/ft_b_env.c +++ b/src/b_env.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_env.c                                         :+:      :+:    :+:   */ +/*   b_env.c                                            :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -12,18 +12,19 @@  #include <libft.h>  #include <stdint.h> -#include "ft_f_fail.h" -#include "ft_s_struct.h" + +#include "f_fail.h" +#include "s_struct.h"  uint8_t -	ft_b_env(char *args[], +	b_env(char *args[],  			t_msh *msh)  {  	char	**ptr;  	if (args && args[0])  	{ -		ft_fail_no_options("env", msh); +		fail_no_options("env", msh);  		return (127);  	}  	ptr = msh->envp; diff --git a/src/ft_b_pwd.h b/src/b_env.h index 653c9e4..bd338ae 100644 --- a/src/ft_b_pwd.h +++ b/src/b_env.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_pwd.h                                         :+:      :+:    :+:   */ +/*   b_env.h                                            :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_B_PWD_H -#define FT_B_PWD_H +#ifndef B_ENV_H +#define B_ENV_H  #include <stdint.h> -#include "ft_s_struct.h" -uint8_t	ft_b_pwd(char *args[], +#include "s_struct.h" + +uint8_t	b_env(char *args[],  				t_msh *msh);  #endif diff --git a/src/ft_b_exit.c b/src/b_exit.c index 7a7e5e8..75f16bf 100644 --- a/src/ft_b_exit.c +++ b/src/b_exit.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_exit.c                                        :+:      :+:    :+:   */ +/*   b_exit.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,22 +15,22 @@  #include <stdint.h>  #include <unistd.h> -#include "ft_f_fail.h" -#include "ft_s_lcom.h" -#include "ft_s_destroy.h" -#include "ft_s_struct.h" -#include "ft_u_utils.h" +#include "f_fail.h" +#include "s_lcom.h" +#include "s_destroy.h" +#include "s_struct.h" +#include "u_utils.h"  uint8_t -	ft_b_exit(char *args[], +	b_exit(char *args[],  			t_msh *msh)  {  	uint8_t			ret; -	const uint64_t	argc = ft_get_argc((const char**)args); +	const uint64_t	argc = get_argc((const char**)args);  	if (argc > 1)  	{ -		ft_fail_too_many_args("exit", msh); +		fail_too_many_args("exit", msh);  		return (1);  	}  	if (argc == 1) diff --git a/src/b_exit.h b/src/b_exit.h new file mode 100644 index 0000000..d437e6a --- /dev/null +++ b/src/b_exit.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   b_exit.h                                           :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef B_EXIT_H +#define B_EXIT_H + +#include <stdint.h> + +#include "s_struct.h" + +uint8_t +	b_exit(char *args[], +			t_msh *msh); + +#endif diff --git a/src/ft_b_export.c b/src/b_export.c index fa2de45..5e7ee14 100644 --- a/src/ft_b_export.c +++ b/src/b_export.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_export.c                                      :+:      :+:    :+:   */ +/*   b_export.c                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,13 +13,14 @@  #include <libft.h>  #include <stdlib.h>  #include <stdint.h> -#include "ft_b_env.h" -#include "ft_f_fail.h" -#include "ft_s_struct.h" -#include "ft_u_utils.h" + +#include "b_env.h" +#include "f_fail.h" +#include "s_struct.h" +#include "u_utils.h"  static int8_t -	ft_check_valid_identifier(const char *arg) +	check_valid_identifier(const char *arg)  {  	char	*ptr; @@ -32,7 +33,7 @@ static int8_t  }  static int8_t -	ft_check_equals(const char *arg) +	check_equals(const char *arg)  {  	char	*ptr; @@ -47,30 +48,30 @@ static int8_t  }  uint8_t -	ft_b_export(char *args[], +	b_export(char *args[],  			 	t_msh *msh)  { -	const uint64_t	argc = ft_get_argc((const char**)args); +	const uint64_t	argc = get_argc((const char**)args);  	char			**ptr;  	int8_t			next;  	uint8_t			r;  	if (argc == 0)  	{ -		return (ft_b_env(NULL, msh)); +		return (b_env(NULL, msh));  	}  	ptr = args;  	r = 0;  	while (*ptr)  	{  		next = 0; -		if (!ft_check_valid_identifier(*ptr)) +		if (!check_valid_identifier(*ptr))  		{ -			ft_fail_identifier("export", *ptr, msh); +			fail_identifier("export", *ptr, msh);  			next = 1;  			r = 1;  		} -		if (next == 0 && !ft_check_equals(*ptr)) +		if (next == 0 && !check_equals(*ptr))  			next = 1;  		ptr++;  	} diff --git a/src/ft_b_export.h b/src/b_export.h index 3a28562..037f9d8 100644 --- a/src/ft_b_export.h +++ b/src/b_export.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_export.h                                      :+:      :+:    :+:   */ +/*   b_export.h                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,11 +10,13 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_B_EXPORT_H -#define FT_B_EXPORT_H +#ifndef B_EXPORT_H +#define B_EXPORT_H + +#include "s_struct.h"  uint8_t -	ft_b_export(char *args[], +	b_export(char *args[],  			 	t_msh *msh);  #endif diff --git a/src/ft_b_pwd.c b/src/b_pwd.c index d47600f..78ef128 100644 --- a/src/ft_b_pwd.c +++ b/src/b_pwd.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_pwd.c                                         :+:      :+:    :+:   */ +/*   b_pwd.c                                            :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,10 +13,10 @@  #include <libft.h>  #include <stdint.h> -#include "ft_s_struct.h" +#include "s_struct.h"  uint8_t -	ft_b_pwd(char *args[], +	b_pwd(char *args[],  			t_msh *msh)  {  	(void)args; diff --git a/src/ft_b_env.h b/src/b_pwd.h index 192c5d9..e165284 100644 --- a/src/ft_b_env.h +++ b/src/b_pwd.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_env.h                                         :+:      :+:    :+:   */ +/*   b_pwd.h                                            :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_B_ENV_H -#define FT_B_ENV_H +#ifndef B_PWD_H +#define B_PWD_H  #include <stdint.h> -#include "ft_s_struct.h" -uint8_t	ft_b_env(char *args[], +#include "s_struct.h" + +uint8_t	b_pwd(char *args[],  				t_msh *msh);  #endif diff --git a/src/ft_b_type.c b/src/b_type.c index 4338b32..ccaca43 100644 --- a/src/ft_b_type.c +++ b/src/b_type.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_type.c                                        :+:      :+:    :+:   */ +/*   b_type.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,14 +16,14 @@  #include <fcntl.h>  #include <unistd.h> -#include "ft_f_fail.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" -#include "ft_e_externs_next.h" -#include "ft_u_utils.h" +#include "f_fail.h" +#include "s_lcom.h" +#include "s_struct.h" +#include "e_externs_next.h" +#include "u_utils.h"  static int8_t -	ft_absolute_path_exists(char com[]) +	absolute_path_exists(char com[])  {  	int32_t	fd;  	DIR		*dir; @@ -42,7 +42,7 @@ static int8_t  }  static char -	*ft_type_get_path(char com[], +	*type_get_path(char com[],  					t_msh *msh)  {  	char	**envpath; @@ -52,34 +52,34 @@ static char  	fullpath = NULL;  	if (ft_ischarset("/.", com[0]))  	{ -		if (ft_absolute_path_exists(com)) +		if (absolute_path_exists(com))  		{  			if (!(fullpath = ft_strdup(com)))  			{ -				ft_lcom_clear(&msh->curr); -				ft_fail_alloc(msh); +				lcom_clear(&msh->curr); +				fail_alloc(msh);  			}  			return (fullpath);  		}  		return (NULL);  	} -	else if ((envpath = ft_get_env_path(msh)) != NULL) +	else if ((envpath = get_env_path(msh)) != NULL)  	{ -		fullpath = ft_search_in_path(com, envpath, msh); +		fullpath = search_in_path(com, envpath, msh);  		ft_delwords(envpath);  	}  	return (fullpath);  }  static uint8_t -	ft_chk_nonbuilt(char **ptr, +	chk_nonbuilt(char **ptr,  					t_msh *msh)  {  	char	*fullpath;  	int32_t	ret;  	ret = 0; -	fullpath = ft_type_get_path(*ptr, msh); +	fullpath = type_get_path(*ptr, msh);  	if (fullpath)  		ft_printf("%s is %s\n", *ptr, fullpath);  	else @@ -92,7 +92,7 @@ static uint8_t  }  uint8_t -	ft_b_type(char *args[], +	b_type(char *args[],  			t_msh *msh)  {  	char	**ptr; @@ -112,7 +112,7 @@ uint8_t  			ft_printf("%s is a shell builtin\n", *ptr);  		else  		{ -			ret = ft_chk_nonbuilt(ptr, msh); +			ret = chk_nonbuilt(ptr, msh);  		}  		ptr++;  	} diff --git a/src/ft_b_echo.h b/src/b_type.h index 7fd7463..5828e8d 100644 --- a/src/ft_b_echo.h +++ b/src/b_type.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_echo.h                                        :+:      :+:    :+:   */ +/*   b_type.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_B_ECHO_H -#define FT_B_ECHO_H +#ifndef B_TYPE_H +#define B_TYPE_H  #include <stdint.h> -#include "ft_s_struct.h" -uint8_t	ft_b_echo(char *args[], +#include "s_struct.h" + +uint8_t	b_type(char *args[],  				t_msh *msh);  #endif diff --git a/src/ft_b_unset.c b/src/b_unset.c index a382aca..92db749 100644 --- a/src/ft_b_unset.c +++ b/src/b_unset.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_unset.c                                       :+:      :+:    :+:   */ +/*   b_unset.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -11,10 +11,11 @@  /* ************************************************************************** */  #include <stdint.h> -#include "ft_s_struct.h" + +#include "s_struct.h"  uint8_t -	ft_b_unset(char *args[], +	b_unset(char *args[],  			t_msh *msh)  {  	(void)args; diff --git a/src/b_unset.h b/src/b_unset.h new file mode 100644 index 0000000..24e17f7 --- /dev/null +++ b/src/b_unset.h @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   b_unset.h                                          :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef B_UNSET_H +#define B_UNSET_H + +#include <stdint.h> + +#include "s_struct.h" + +uint8_t	b_unset(char *args[], +				t_msh *msh); + +#endif diff --git a/src/ft_d_define.h b/src/d_define.h index 4152e0d..175e256 100644 --- a/src/ft_d_define.h +++ b/src/d_define.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_d_define.h                                      :+:      :+:    :+:   */ +/*   d_define.h                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,10 +10,10 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_D_DEFINE_H -#define FT_D_DEFINE_H +#ifndef D_DEFINE_H +#define D_DEFINE_H -#include "ft_d_enum.h" +#include "d_enum.h"  /*  ** ====== CLASSICS ====== diff --git a/src/ft_d_enum.h b/src/d_enum.h index 680ff00..427e0a0 100644 --- a/src/ft_d_enum.h +++ b/src/d_enum.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_d_enum.h                                        :+:      :+:    :+:   */ +/*   d_enum.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,8 +10,8 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_D_ENUM_H -#define FT_D_ENUM_H +#ifndef D_ENUM_H +#define D_ENUM_H  /*  ** ret vals: diff --git a/src/ft_e_builtins.c b/src/e_builtins.c index 382f85d..e35416a 100644 --- a/src/ft_e_builtins.c +++ b/src/e_builtins.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_builtins.c                                    :+:      :+:    :+:   */ +/*   e_builtins.c                                       :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,27 +16,27 @@  #include <stdint.h>  #include <unistd.h> -#include "ft_m_redirs.h" -#include "ft_s_destroy.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" +#include "m_redirs.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h"  static void -	ft_e_builtin_child(const t_lcom *ptr, +	e_builtin_child(const t_lcom *ptr,  					uint8_t bu_id,  					t_msh *msh)  {  	int32_t	ret; -	ft_dup_redirs(ptr, msh); +	dup_redirs(ptr, msh);  	ret = msh->bu_ptr[bu_id](ptr->argv + 1, msh); -	ft_lcom_clear(&msh->curr); -	ft_s_destroy(msh); +	lcom_clear(&msh->curr); +	s_destroy(msh);  	exit(ret);  }  static void -	ft_e_builtin_parent(pid_t pid, +	e_builtin_parent(pid_t pid,  						const t_lcom *ptr,  						uint8_t bu_id,  						t_msh *msh) @@ -60,14 +60,14 @@ static void  			ret = ft_atoi(ptr->argv[1]);  		else  			ret = msh->ret; -		ft_lcom_clear(&msh->curr); -		ft_s_destroy(msh); +		lcom_clear(&msh->curr); +		s_destroy(msh);  		exit(ret);  	}  }  void -	ft_e_builtin(const t_lcom *ptr, +	e_builtin(const t_lcom *ptr,  				uint8_t bu_id,  				t_msh *msh)  { @@ -76,7 +76,7 @@ void  	/* TODO: find a way to handle exit | bu_id = 6 */  	if ((pid = fork()) == 0)  	{ -		ft_e_builtin_child(ptr, bu_id, msh); +		e_builtin_child(ptr, bu_id, msh);  	}  	else if (pid < 0)  	{ @@ -84,6 +84,6 @@ void  	}  	else  	{ -		ft_e_builtin_parent(pid, ptr, bu_id, msh); +		e_builtin_parent(pid, ptr, bu_id, msh);  	}  } diff --git a/src/ft_e_builtins.h b/src/e_builtins.h index 21908b8..1d0804d 100644 --- a/src/ft_e_builtins.h +++ b/src/e_builtins.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_builtins.h                                    :+:      :+:    :+:   */ +/*   e_builtins.h                                       :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_E_BUILTINS_H -#define FT_E_BUILTINS_H +#ifndef E_BUILTINS_H +#define E_BUILTINS_H  #include <stdint.h> -#include "ft_s_struct.h" -void	ft_e_builtin(const t_lcom *ptr, +#include "s_struct.h" + +void	e_builtin(const t_lcom *ptr,  					uint8_t bu_id,  					t_msh *msh); diff --git a/src/ft_e_externs.c b/src/e_externs.c index 9302d18..d7c4854 100644 --- a/src/ft_e_externs.c +++ b/src/e_externs.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_externs.c                                     :+:      :+:    :+:   */ +/*   e_externs.c                                        :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,24 +16,24 @@  #include <stdint.h>  #include <unistd.h> -#include "ft_e_externs_next.h" -#include "ft_m_redirs.h" -#include "ft_s_destroy.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" +#include "e_externs_next.h" +#include "m_redirs.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h"  static void -	ft_e_extern_child(const char *fullpath, +	e_extern_child(const char *fullpath,  					t_lcom *ptr,  					t_msh *msh)  { -	ft_dup_redirs(ptr, msh); +	dup_redirs(ptr, msh);  	execve(fullpath, ptr->argv, msh->envp);  	/* TODO: handle execve failed */  }  static void -	ft_exec_path(const char fullpath[], +	exec_path(const char fullpath[],  				t_lcom *ptr,  				t_msh *msh)  { @@ -42,7 +42,7 @@ static void  	if ((pid = fork()) == 0)  	{ -		ft_e_extern_child(fullpath, ptr, msh); +		e_extern_child(fullpath, ptr, msh);  	}  	else if (pid < 0)  	{ @@ -57,7 +57,7 @@ static void  }  void -	ft_e_extern(t_lcom *ptr, +	e_extern(t_lcom *ptr,  				t_msh *msh)  {  	char	**envpath; @@ -65,15 +65,15 @@ void  	if (ft_ischarset("/.", ptr->com[0]))  	{ -		ft_exec_path(ptr->com, ptr, msh); +		exec_path(ptr->com, ptr, msh);  		return ;  	} -	else if ((envpath = ft_get_env_path(msh)) != NULL) +	else if ((envpath = get_env_path(msh)) != NULL)  	{ -		fullpath = ft_search_in_path(ptr->com, envpath, msh); +		fullpath = search_in_path(ptr->com, envpath, msh);  		ft_delwords(envpath);  	}  	/* TODO: deal if not found etc */ -	ft_exec_path(fullpath, ptr, msh); +	exec_path(fullpath, ptr, msh);  	ft_memdel((void*)&fullpath);  } diff --git a/src/ft_e_externs.h b/src/e_externs.h index 5e02353..9bbb907 100644 --- a/src/ft_e_externs.h +++ b/src/e_externs.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_externs.h                                     :+:      :+:    :+:   */ +/*   e_externs.h                                        :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_E_EXTERNS_H -#define FT_E_EXTERNS_H +#ifndef E_EXTERNS_H +#define E_EXTERNS_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_e_extern(t_lcom *ptr, +void	e_extern(t_lcom *ptr,  					t_msh *msh);  #endif diff --git a/src/ft_e_externs_next.c b/src/e_externs_next.c index 36bf5e6..ba3c2d5 100644 --- a/src/ft_e_externs_next.c +++ b/src/e_externs_next.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_externs_next.c                                :+:      :+:    :+:   */ +/*   e_externs_next.c                                   :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,13 +15,13 @@  #include <stdlib.h>  #include <stddef.h> -#include "ft_f_fail.h" -#include "ft_s_destroy.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" +#include "f_fail.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h"  static char -	*ft_get_fullpath(const char p_path[], +	*get_fullpath(const char p_path[],  					const char d_name[],  					t_msh *msh)  { @@ -31,19 +31,19 @@ static char  	if (!(fullpath = (char*)malloc((path_len + name_len + 2) * sizeof(char))))  	{ -		ft_lcom_clear(&msh->curr); -		ft_s_destroy(msh); -		ft_fail_alloc(msh); +		lcom_clear(&msh->curr); +		s_destroy(msh); +		fail_alloc(msh);  	} -	ft_memcpy(fullpath, p_path, path_len); +	(void)ft_memcpy(fullpath, p_path, path_len);  	*(fullpath + (path_len)) = '/'; -	ft_memcpy(fullpath + path_len + 1, d_name, name_len); +	(void)ft_memcpy(fullpath + path_len + 1, d_name, name_len);  	*(fullpath + (path_len + name_len + 1)) = '\0';  	return (fullpath);  }  char -	*ft_search_in_path(const char com[], +	*search_in_path(const char com[],  					char *envpath[],  					t_msh *msh)  { @@ -63,7 +63,7 @@ char  				/* TODO: check for not bins (dirs, etc) */  				if (ft_strncmp(com, ent->d_name, ft_strlen(com) + 1) == 0)  				{ -					fullpath = ft_get_fullpath(*p_path, ent->d_name, msh); +					fullpath = get_fullpath(*p_path, ent->d_name, msh);  					closedir(dir);  					return (fullpath);  				} @@ -76,7 +76,7 @@ char  }  char -	**ft_get_env_path(t_msh *msh) +	**get_env_path(t_msh *msh)  {  	char	**p_env;  	char	**envpath; @@ -95,9 +95,9 @@ char  	{  		if (!(envpath = ft_split(envline, ':')))  		{ -			ft_lcom_clear(&msh->curr); -			ft_s_destroy(msh); -			ft_fail_alloc(msh); +			lcom_clear(&msh->curr); +			s_destroy(msh); +			fail_alloc(msh);  		}  		return (envpath);  	} diff --git a/src/ft_e_externs_next.h b/src/e_externs_next.h index bc6272c..da1cfdf 100644 --- a/src/ft_e_externs_next.h +++ b/src/e_externs_next.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_externs_next.h                                :+:      :+:    :+:   */ +/*   e_externs_next.h                                   :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,13 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_E_EXTERNS_NEXT_H -#define FT_E_EXTERNS_NEXT_H +#ifndef E_EXTERNS_NEXT_H +#define E_EXTERNS_NEXT_H -#include "ft_s_struct.h" +#include "s_struct.h" -char	**ft_get_env_path(t_msh *msh); -char	*ft_search_in_path(const char com[], +char	**get_env_path(t_msh *msh); +char	*search_in_path(const char com[],  						char *envpath[],  						t_msh *msh); diff --git a/src/ft_e_externs_pipes.c b/src/e_externs_pipes.c index c1c57b5..c8f8404 100644 --- a/src/ft_e_externs_pipes.c +++ b/src/e_externs_pipes.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_externs_pipes.c                               :+:      :+:    :+:   */ +/*   e_externs_pipes.c                                  :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -18,26 +18,26 @@  #include <string.h>  #include <errno.h> -#include "ft_d_define.h" -#include "ft_e_externs_next.h" -#include "ft_f_fail.h" -#include "ft_m_redirs.h" -#include "ft_s_destroy.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" +#include "d_define.h" +#include "e_externs_next.h" +#include "f_fail.h" +#include "m_redirs.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h"  static void -	ft_e_extern_child(const char *fullpath, +	e_extern_child(const char *fullpath,  					t_lcom *ptr,  					t_msh *msh)  { -	ft_dup_redirs(ptr, msh); +	dup_redirs(ptr, msh);  	execve(fullpath, ptr->argv, msh->envp);  	/* TODO: handle execve failed */  }  static size_t -ft_e_get_pipes_count(struct s_lpipes *ptr) +	e_get_pipes_count(struct s_lpipes *ptr)  {  	struct s_lpipes	*rptr;  	size_t			pipes; @@ -53,7 +53,7 @@ ft_e_get_pipes_count(struct s_lpipes *ptr)  }  static void -	ft_exec_path(const char *fullpath[], +	exec_path(const char *fullpath[],  				struct s_lpipes *head,  				t_msh *msh)  { @@ -65,7 +65,7 @@ static void  	int		status;  	/* TODO: norm, error mgmnt */ -	pipes = ft_e_get_pipes_count(head); +	pipes = e_get_pipes_count(head);  	i = 0;  	while (i < pipes)  	{ @@ -88,7 +88,7 @@ static void  				close(fd[j][FT_READ_END]);  				j++;  			} -			ft_e_extern_child(fullpath[i], head->one, msh); +			e_extern_child(fullpath[i], head->one, msh);  		}  		head = head->next;  		i++; @@ -108,7 +108,7 @@ static void  }  void -	ft_e_externs_pipes(struct s_lpipes *ptr, +	e_externs_pipes(struct s_lpipes *ptr,  					t_msh *msh)  {  	struct s_lpipes	*head; @@ -120,9 +120,9 @@ void  	head = ptr;  	rptr = ptr; -	pipes = ft_e_get_pipes_count(head); +	pipes = e_get_pipes_count(head);  	if (!(fullpath = (char **)malloc((pipes + 2) * sizeof(char *)))) -		ft_fail_alloc(msh); +		fail_alloc(msh);  	fullpath[pipes + 1] = NULL;  	i = 0;  	while (rptr != NULL) @@ -130,11 +130,11 @@ void  		if (ft_ischarset("/.", rptr->one->com[0]))  		{  			if (!(fullpath[i] = ft_strdup(rptr->one->com))) -				ft_fail_alloc(msh); +				fail_alloc(msh);  		} -		else if ((envpath = ft_get_env_path(msh)) != NULL) +		else if ((envpath = get_env_path(msh)) != NULL)  		{ -			fullpath[i] = ft_search_in_path(rptr->one->com, envpath, msh); +			fullpath[i] = search_in_path(rptr->one->com, envpath, msh);  			ft_delwords(envpath);  		}  		/* TODO: deal if not found etc */ @@ -142,6 +142,6 @@ void  		rptr = rptr->next;  	}  	i = 0; -	ft_exec_path((const char**)fullpath, head, msh); +	exec_path((const char**)fullpath, head, msh);  	ft_delwords(fullpath);  } diff --git a/src/e_externs_pipes.h b/src/e_externs_pipes.h new file mode 100644 index 0000000..6c242fb --- /dev/null +++ b/src/e_externs_pipes.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   e_externs_pipes.h                                  :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef E_EXTERNS_PIPES_H +#define E_EXTERNS_PIPES_H + +#include "s_struct.h" + +void	e_externs_pipes(struct s_lpipes *ptr, t_msh *msh); + +#endif diff --git a/src/ft_e_lcom.c b/src/e_lcom.c index 54db581..e8159fd 100644 --- a/src/ft_e_lcom.c +++ b/src/e_lcom.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_lcom.c                                        :+:      :+:    :+:   */ +/*   e_lcom.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,14 +13,14 @@  #include <libft.h>  #include <stdint.h> -#include "ft_e_builtins.h" -#include "ft_e_externs.h" -#include "ft_e_pipes.h" -#include "ft_s_lpipes.h" -#include "ft_s_struct.h" +#include "e_builtins.h" +#include "e_externs.h" +#include "e_pipes.h" +#include "s_lpipes.h" +#include "s_struct.h"  static uint8_t -	ft_get_builtin_id(const char com[], +	get_builtin_id(const char com[],  					t_msh *msh)  {  	uint8_t	i; @@ -35,7 +35,7 @@ static uint8_t  }  void -	ft_e_lcom(t_msh *msh) +	e_lcom(t_msh *msh)  {  	t_lcom	*ptr;  	uint8_t	bu_id; @@ -45,14 +45,14 @@ void  	{  		if (ptr->pipes)  		{ -			ft_e_pipes(ptr, msh); +			e_pipes(ptr, msh);  		}  		else if (ptr->com)  		{ -			if ((bu_id = ft_get_builtin_id(ptr->com, msh)) < FT_BUILTINS_COUNT) -				ft_e_builtin(ptr, bu_id, msh); +			if ((bu_id = get_builtin_id(ptr->com, msh)) < FT_BUILTINS_COUNT) +				e_builtin(ptr, bu_id, msh);  			else -				ft_e_extern(ptr, msh); +				e_extern(ptr, msh);  		}  		ptr = ptr->next;  	} diff --git a/src/ft_u_utils.h b/src/e_lcom.h index 1a3b324..ab0368f 100644 --- a/src/ft_u_utils.h +++ b/src/e_lcom.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_u_utils.h                                       :+:      :+:    :+:   */ +/*   e_lcom.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,11 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_U_UTILS_H -#define FT_U_UTILS_H +#ifndef E_LCOM_H +#define E_LCOM_H  #include <stdint.h> +#include "s_struct.h" -uint64_t	ft_get_argc(const char *args[]); +void	e_lcom(t_msh *msh);  #endif diff --git a/src/ft_e_pipes.c b/src/e_pipes.c index 581aec2..29ee5d4 100644 --- a/src/ft_e_pipes.c +++ b/src/e_pipes.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_pipes.c                                       :+:      :+:    :+:   */ +/*   e_pipes.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,13 +14,13 @@  #include <stdint.h>  #include <unistd.h> -#include "ft_e_builtins.h" -#include "ft_e_externs_pipes.h" -#include "ft_s_lpipes.h" -#include "ft_s_struct.h" +#include "e_builtins.h" +#include "e_externs_pipes.h" +#include "s_lpipes.h" +#include "s_struct.h"  static uint8_t -	ft_get_builtin_id(const char com[], +	get_builtin_id(const char com[],  					t_msh *msh)  {  	uint8_t	i; @@ -35,15 +35,15 @@ static uint8_t  }  void -	ft_e_pipes(t_lcom *ptr, +	e_pipes(t_lcom *ptr,  			t_msh *msh)  {  	uint8_t	bu_id; -	if ((bu_id = ft_get_builtin_id(ptr->pipes->one->com, msh)) +	if ((bu_id = get_builtin_id(ptr->pipes->one->com, msh))  		< FT_BUILTINS_COUNT) -		ft_e_builtin(ptr->pipes->one, bu_id, msh); +		e_builtin(ptr->pipes->one, bu_id, msh);  	else -		ft_e_externs_pipes(ptr->pipes, msh); -	ft_lpipes_clear(&ptr->pipes); +		e_externs_pipes(ptr->pipes, msh); +	lpipes_clear(&ptr->pipes);  } diff --git a/src/ft_m_funptr.h b/src/e_pipes.h index 889c0af..d4de639 100644 --- a/src/ft_m_funptr.h +++ b/src/e_pipes.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_funptr.h                                      :+:      :+:    :+:   */ +/*   e_pipes.h                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,11 +10,11 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_M_FUNPTR_H -#define FT_M_FUNPTR_H +#ifndef E_PIPES_H +#define E_PIPES_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_init_buptr(t_msh *msh); +void	e_pipes(t_lcom *ptr, t_msh *msh);  #endif diff --git a/src/ft_f_chdir.c b/src/f_chdir.c index 1386626..6bb0497 100644 --- a/src/ft_f_chdir.c +++ b/src/f_chdir.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_chdir.c                                       :+:      :+:    :+:   */ +/*   f_chdir.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,10 +15,10 @@  #include <errno.h>  #include <unistd.h> -#include "ft_s_struct.h" +#include "s_struct.h"  void -	ft_fail_chd(const char concern[], +	fail_chd(const char concern[],  				const char path[],  				t_msh *msh)  { diff --git a/src/ft_f_chdir.h b/src/f_chdir.h index fae82d7..be9773b 100644 --- a/src/ft_f_chdir.h +++ b/src/f_chdir.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_chdir.h                                       :+:      :+:    :+:   */ +/*   f_chdir.h                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_F_CHDIR_H -#define FT_F_CHDIR_H +#ifndef F_CHDIR_H +#define F_CHDIR_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_fail_chd(const char concern[], +void	fail_chd(const char concern[],  					const char pathp[],  					t_msh *msh); diff --git a/src/ft_f_errno.c b/src/f_errno.c index 22ee7a9..360cf9f 100644 --- a/src/ft_f_errno.c +++ b/src/f_errno.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_errno.c                                       :+:      :+:    :+:   */ +/*   f_errno.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,10 +15,10 @@  #include <errno.h>  #include <unistd.h> -#include "ft_s_struct.h" +#include "s_struct.h"  void -	ft_f_dump_errno(const char concern[], +	f_dump_errno(const char concern[],  					t_msh *msh)  {  	ft_dprintf(STDERR_FILENO, "%s: %s: %s\n", diff --git a/src/ft_m_redirs.h b/src/f_errno.h index 9021cb8..75a6159 100644 --- a/src/ft_m_redirs.h +++ b/src/f_errno.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_redirs.h                                      :+:      :+:    :+:   */ +/*   f_errno.h                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_M_REDIRS_H -#define FT_M_REDIRS_H +#ifndef F_ERRNO_H +#define F_ERRNO_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_dup_redirs(const t_lcom *ptr, +void	f_dump_errno(const char concern[],  					t_msh *msh);  #endif diff --git a/src/ft_f_fail.c b/src/f_fail.c index 3f43bae..aae00fb 100644 --- a/src/ft_f_fail.c +++ b/src/f_fail.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_fail.c                                        :+:      :+:    :+:   */ +/*   f_fail.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,11 +16,11 @@  #include <unistd.h>  #include <errno.h> -#include "ft_d_define.h" -#include "ft_s_struct.h" +#include "d_define.h" +#include "s_struct.h"  static void -	ft_write_fail(const char concern[], +	write_fail(const char concern[],  				const char msg[],  				t_msh *msh)  { @@ -28,14 +28,14 @@ static void  }  void -	ft_fail_no_options(const char concern[], +	fail_no_options(const char concern[],  					t_msh *msh)  { -	ft_write_fail(concern, FT_FAIL_NO_OPTIONS, msh); +	write_fail(concern, FT_FAIL_NO_OPTIONS, msh);  }  void -	ft_fail_identifier(const char concern[], +	fail_identifier(const char concern[],  					const char identifier[],  					t_msh *msh)  { @@ -44,14 +44,14 @@ void  }  void -	ft_fail_too_many_args(const char concern[], +	fail_too_many_args(const char concern[],  						t_msh *msh)  { -	ft_write_fail(concern, FT_FAIL_TOO_MANY_ARGS, msh); +	write_fail(concern, FT_FAIL_TOO_MANY_ARGS, msh);  }  void -	ft_fail_alloc(t_msh *msh) +	fail_alloc(t_msh *msh)  {  	ft_dprintf(STDERR_FILENO, "%s: %s\n", msh->shname, strerror(errno));  	exit(FT_RET_ALLOC); diff --git a/src/ft_f_fail.h b/src/f_fail.h index b176cbb..9699eee 100644 --- a/src/ft_f_fail.h +++ b/src/f_fail.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_fail.h                                        :+:      :+:    :+:   */ +/*   f_fail.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,21 +10,21 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_F_FAIL_H -#define FT_F_FAIL_H +#ifndef F_FAIL_H +#define F_FAIL_H -#include "ft_f_chdir.h" -#include "ft_f_errno.h" -#include "ft_f_redir.h" -#include "ft_s_struct.h" +#include "f_chdir.h" +#include "f_errno.h" +#include "f_redir.h" +#include "s_struct.h" -void	ft_fail_no_options(const char concern[], +void	fail_no_options(const char concern[],  						t_msh *msh); -void	ft_fail_too_many_args(const char concern[], +void	fail_too_many_args(const char concern[],  							t_msh *msh); -void	ft_fail_identifier(const char concern[], +void	fail_identifier(const char concern[],  						const char identifier[],  						t_msh *msh); -void	ft_fail_alloc(t_msh *msh); +void	fail_alloc(t_msh *msh);  #endif diff --git a/src/ft_f_redir.c b/src/f_redir.c index 2cd7d58..3561272 100644 --- a/src/ft_f_redir.c +++ b/src/f_redir.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_redir.c                                       :+:      :+:    :+:   */ +/*   f_redir.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,16 +16,16 @@  #include <unistd.h>  #include <errno.h> -#include "ft_s_lcom.h" -#include "ft_s_destroy.h" +#include "s_lcom.h" +#include "s_destroy.h"  void -	ft_f_redir(const char path[], +	f_redir(const char path[],  			t_msh *msh)  {  	ft_dprintf(STDERR_FILENO, "%s: %s: %s\n",  		msh->shname, path, strerror(errno)); -	ft_lcom_clear(&msh->curr); -	ft_s_destroy(msh); +	lcom_clear(&msh->curr); +	s_destroy(msh);  	exit(1);  } diff --git a/src/ft_p_line.h b/src/f_redir.h index 076be42..25f53cf 100644 --- a/src/ft_p_line.h +++ b/src/f_redir.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_p_line.h                                        :+:      :+:    :+:   */ +/*   f_redir.h                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_P_LINE_H -#define FT_P_LINE_H +#ifndef F_REDIR_H +#define F_REDIR_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_p_line(char *line, +void	f_redir(const char path[],  				t_msh *msh);  #endif diff --git a/src/ft_b_builtins.h b/src/ft_b_builtins.h deleted file mode 100644 index ed76f70..0000000 --- a/src/ft_b_builtins.h +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_b_builtins.h                                    :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_B_BUILTINS_H -#define FT_B_BUILTINS_H - -#include "ft_b_cd.h" -#include "ft_b_echo.h" -#include "ft_b_env.h" -#include "ft_b_exit.h" -#include "ft_b_export.h" -#include "ft_b_pwd.h" -#include "ft_b_type.h" -#include "ft_b_unset.h" - -#endif diff --git a/src/ft_b_type.h b/src/ft_b_type.h deleted file mode 100644 index c3d5dd6..0000000 --- a/src/ft_b_type.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_b_type.h                                        :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_B_TYPE_H -#define FT_B_TYPE_H - -#include <stdint.h> -#include "ft_s_struct.h" - -uint8_t	ft_b_type(char *args[], -				t_msh *msh); - -#endif diff --git a/src/ft_b_unset.h b/src/ft_b_unset.h deleted file mode 100644 index 5ab1b2b..0000000 --- a/src/ft_b_unset.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_b_unset.h                                       :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_B_UNSET_H -#define FT_B_UNSET_H - -#include <stdint.h> -#include "ft_s_struct.h" - -uint8_t	ft_b_unset(char *args[], -				t_msh *msh); - -#endif diff --git a/src/ft_e_externs_pipes.h b/src/ft_e_externs_pipes.h deleted file mode 100644 index 435c795..0000000 --- a/src/ft_e_externs_pipes.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_e_externs_pipes.h                               :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_E_EXTERNS_PIPES_H -#define FT_E_EXTERNS_PIPES_H - -#include "ft_s_struct.h" - -void	ft_e_externs_pipes(struct s_lpipes *ptr, t_msh *msh); - -#endif diff --git a/src/ft_m_prompt.h b/src/ft_m_prompt.h deleted file mode 100644 index 2725539..0000000 --- a/src/ft_m_prompt.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_m_prompt.h                                      :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_M_PROMPT_H -#define FT_M_PROMPT_H - -#include "ft_s_struct.h" - -void	ft_m_prompt(t_msh *msh); -void	ft_m_cont_prompt(void); -#endif diff --git a/src/ft_p_lcom_next.h b/src/ft_p_lcom_next.h deleted file mode 100644 index 54eefd2..0000000 --- a/src/ft_p_lcom_next.h +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_p_lcom_next.h                                   :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_P_LCOM_NEXT_H -#define FT_P_LCOM_NEXT_H - -#include <stdint.h> - -#include "ft_s_struct.h" - -char	**ft_subst_vars(char *words[], -						t_msh *msh); -char	**ft_subst_args(const char word[], -						int8_t redir); - -#endif diff --git a/src/ft_s_lcom.h b/src/ft_s_lcom.h deleted file mode 100644 index ea78d6f..0000000 --- a/src/ft_s_lcom.h +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_s_lcom.h                                        :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_S_LCOM_H -#define FT_S_LCOM_H - -#include "ft_s_struct.h" - -void	ft_lcom_add_back(t_lcom **alcom, t_lcom *new); -void	ft_lcom_clear(t_lcom **lcom); -t_lcom	*ft_lcom_new(const char word[], t_msh *msh); -t_lcom	*ft_lcom_last(t_lcom *lcom); - -#endif diff --git a/src/ft_u_vars.h b/src/ft_u_vars.h deleted file mode 100644 index 82aa668..0000000 --- a/src/ft_u_vars.h +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/*                                                                            */ -/*                                                        :::      ::::::::   */ -/*   ft_u_vars.h                                        :+:      :+:    :+:   */ -/*                                                    +:+ +:+         +:+     */ -/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ -/*                                                +#+#+#+#+#+   +#+           */ -/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ -/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ -/*                                                                            */ -/* ************************************************************************** */ - -#ifndef FT_U_VARS_H -#define FT_U_VARS_H - -#include "ft_s_struct.h" - -char	*ft_subst_var_value(const char varname[], -							t_msh *msh); - -#endif diff --git a/src/ft_m_argv.c b/src/m_argv.c index 7b91fbb..6a79bd7 100644 --- a/src/ft_m_argv.c +++ b/src/m_argv.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_argv.c                                        :+:      :+:    :+:   */ +/*   m_argv.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,20 +13,20 @@  #include <libft.h>  #include <stdint.h> -#include "ft_d_define.h" -#include "ft_m_comm.h" -#include "ft_m_loop.h" -#include "ft_s_struct.h" +#include "d_define.h" +#include "m_comm.h" +#include "m_loop.h" +#include "s_struct.h"  uint8_t -	ft_m_argv(int argc, +	m_argv(int argc,  			char *const argv[],  			t_msh *msh)  {  	/* TODO: better argv handling */  	if (argc == 1)  	{ -		msh->ret = ft_m_loop(msh); +		msh->ret = m_loop(msh);  		return (msh->ret);  	}  	if (!ft_strncmp(*(argv + 1), FT_OPT_COMMAND, 3)) @@ -37,7 +37,7 @@ uint8_t  				msh->shname, FT_OPT_COMMAND);  			return (2);  		} -		msh->ret = ft_m_comm(*(argv + 2), msh); +		msh->ret = m_comm(*(argv + 2), msh);  	}  	return (msh->ret);  } diff --git a/src/ft_m_argv.h b/src/m_argv.h index 783c7e4..cdda5d5 100644 --- a/src/ft_m_argv.h +++ b/src/m_argv.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_argv.h                                        :+:      :+:    :+:   */ +/*   m_argv.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,14 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_M_ARGV_H -#define FT_M_ARGV_H +#ifndef M_ARGV_H +#define M_ARGV_H  #include <stdint.h> -#include "ft_s_struct.h" +#include "s_struct.h" -uint8_t	ft_m_argv(int argc, +uint8_t	m_argv(int argc,  				char *const argv[],  				t_msh *msh); diff --git a/src/ft_m_comm.c b/src/m_comm.c index 5fca253..66e0ac2 100644 --- a/src/ft_m_comm.c +++ b/src/m_comm.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_comm.c                                        :+:      :+:    :+:   */ +/*   m_comm.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,21 +13,21 @@  #include <libft.h>  #include <stdint.h> -#include "ft_d_enum.h" -#include "ft_e_lcom.h" -#include "ft_m_prompt.h" -#include "ft_p_line.h" -#include "ft_s_lcom.h" +#include "d_enum.h" +#include "e_lcom.h" +#include "m_prompt.h" +#include "p_line.h" +#include "s_lcom.h"  uint8_t -	ft_m_comm(const char line[], +	m_comm(const char line[],  			t_msh *msh)  {  	if (line[0] != '\0')  	{ -		ft_p_line((char*)line, msh); -		ft_e_lcom(msh); -		ft_lcom_clear(&msh->curr); +		p_line((char*)line, msh); +		e_lcom(msh); +		lcom_clear(&msh->curr);  	}  	else  	{ diff --git a/src/m_comm.h b/src/m_comm.h new file mode 100644 index 0000000..a64d01e --- /dev/null +++ b/src/m_comm.h @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   m_comm.h                                           :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef M_COMM_H +#define M_COMM_H + +#include <stdint.h> + +#include "s_struct.h" + +uint8_t	m_comm(const char line[], +				t_msh *msh); + +#endif diff --git a/src/ft_m_funptr.c b/src/m_funptr.c index 305dfc9..5a02b2e 100644 --- a/src/ft_m_funptr.c +++ b/src/m_funptr.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_funptr.c                                      :+:      :+:    :+:   */ +/*   m_funptr.c                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,25 +13,25 @@  #include <libft.h>  #include <stdlib.h> -#include "ft_d_enum.h" -#include "ft_b_builtins.h" -#include "ft_f_fail.h" -#include "ft_m_funptr.h" -#include "ft_s_struct.h" +#include "d_enum.h" +#include "b_builtins.h" +#include "f_fail.h" +#include "m_funptr.h" +#include "s_struct.h"  void -	ft_init_buptr(t_msh *msh) +	init_buptr(t_msh *msh)  { -	msh->bu_ptr[0] = ft_b_echo; -	msh->bu_ptr[1] = ft_b_cd; -	msh->bu_ptr[2] = ft_b_pwd; -	msh->bu_ptr[3] = ft_b_export; -	msh->bu_ptr[4] = ft_b_unset; -	msh->bu_ptr[5] = ft_b_env; -	msh->bu_ptr[6] = ft_b_exit; -	msh->bu_ptr[7] = ft_b_type; +	msh->bu_ptr[0] = b_echo; +	msh->bu_ptr[1] = b_cd; +	msh->bu_ptr[2] = b_pwd; +	msh->bu_ptr[3] = b_export; +	msh->bu_ptr[4] = b_unset; +	msh->bu_ptr[5] = b_env; +	msh->bu_ptr[6] = b_exit; +	msh->bu_ptr[7] = b_type;  	if (!(msh->bu_ref = ft_split(FT_BUILTINS, '|')))  	{ -		ft_fail_alloc(msh); +		fail_alloc(msh);  	}  } diff --git a/src/ft_s_destroy.h b/src/m_funptr.h index 68a5c09..1a0f198 100644 --- a/src/ft_s_destroy.h +++ b/src/m_funptr.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_destroy.h                                     :+:      :+:    :+:   */ +/*   m_funptr.h                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,11 +10,11 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_S_DESTROY_H -#define FT_S_DESTROY_H +#ifndef M_FUNPTR_H +#define M_FUNPTR_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_s_destroy(t_msh *msh); +void	init_buptr(t_msh *msh);  #endif diff --git a/src/ft_m_loop.c b/src/m_loop.c index 3f40fba..fe3fbcd 100644 --- a/src/ft_m_loop.c +++ b/src/m_loop.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_loop.c                                        :+:      :+:    :+:   */ +/*   m_loop.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,14 +15,14 @@  #include <stdlib.h>  #include <unistd.h> -#include "ft_e_lcom.h" -#include "ft_m_prompt.h" -#include "ft_p_line.h" -#include "ft_s_lcom.h" +#include "e_lcom.h" +#include "m_prompt.h" +#include "p_line.h" +#include "s_lcom.h"  static char -	*ft_strjoin_m(char *s1, +	*strjoin_m(char *s1,  				  char *s2,  				  uint8_t mode)  { @@ -49,7 +49,7 @@ static char  }  void -	ft_m_loop_cont(t_msh *msh, +	m_loop_cont(t_msh *msh,  				   char *line,  				   char *quote,  				   int8_t gnl) @@ -65,24 +65,24 @@ void  	while (gnl > 0 && ((!(quote = ft_strrchr(buf, '\"'))) &&  					   (!(quote = ft_strrchr(buf, '\'')))))  	{ -		ft_m_cont_prompt(); +		m_cont_prompt();  		gnl = get_next_line(STDIN_FILENO, &line); -		buf = ft_strjoin_m(buf, line, 0); +		buf = strjoin_m(buf, line, 0);  		ft_memdel((void*)&line);  	}  	fin = ft_strtrim(buf, "\"'");  	ft_memdel((void*)&buf);  	fin = (ft_strrchr(fin, '\'')) ? ft_strsubst(fin, "\'", "") : fin; -	fin = ft_strjoin_m(prog, fin, 1); -	ft_p_line(fin, msh); +	fin = strjoin_m(prog, fin, 1); +	p_line(fin, msh);  	ft_memdel((void*)&prog);  	ft_memdel((void*)&fin); -	ft_e_lcom(msh); -	ft_lcom_clear(&msh->curr); +	e_lcom(msh); +	lcom_clear(&msh->curr);  }  uint8_t -	ft_m_loop(t_msh *msh) +	m_loop(t_msh *msh)  {  	char	*line;  	char	*quote; @@ -94,20 +94,20 @@ uint8_t  	pipefd[1] = STDIN_FILENO;  	while (gnl > 0)  	{ -		ft_m_prompt(msh); +		m_prompt(msh);  		gnl = get_next_line(STDIN_FILENO, &line);  		if (line[0] != '\0')  		{              if (!(quote = ft_strchr(line, '\'')) && !(quote = ft_strchr(line, '\"')))              { -                ft_p_line(line, msh); +                p_line(line, msh);                  ft_memdel((void*)&line); -				ft_e_lcom(msh); -				ft_lcom_clear(&msh->curr); +				e_lcom(msh); +				lcom_clear(&msh->curr);  			}  			else              { -                ft_m_loop_cont(msh, line, quote, 1); +                m_loop_cont(msh, line, quote, 1);                  if (line != NULL)                      ft_memdel((void*)&line);              } diff --git a/src/ft_b_exit.h b/src/m_loop.h index 5dd2a07..1d665e3 100644 --- a/src/ft_b_exit.h +++ b/src/m_loop.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_b_exit.h                                        :+:      :+:    :+:   */ +/*   m_loop.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,13 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_B_EXIT_H -#define FT_B_EXIT_H +#ifndef M_LOOP +#define M_LOOP  #include <stdint.h> -uint8_t -	ft_b_exit(char *args[], -			  t_msh *msh); +#include "s_struct.h" + +uint8_t	m_loop(t_msh *msh);  #endif diff --git a/src/minishell.c b/src/m_minishell.c index ee79f8f..1e065b4 100644 --- a/src/minishell.c +++ b/src/m_minishell.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   minishell.c                                        :+:      :+:    :+:   */ +/*   m_minishell.c                                      :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,11 +16,11 @@  #include <string.h>  #include <errno.h> -#include "ft_f_fail.h" -#include "ft_m_argv.h" -#include "ft_s_struct.h" -#include "ft_s_init.h" -#include "ft_s_destroy.h" +#include "f_fail.h" +#include "m_argv.h" +#include "s_struct.h" +#include "s_init.h" +#include "s_destroy.h"  int  	main(int argc, @@ -34,13 +34,13 @@ int  	/* TODO: also set $SHELL | maybe not bash does not set $SHELL */  	/* only zsh does */  	/* TODO: handle general variables | $var */ -	if (!(msh = ft_init_msh(argv, envp))) +	if (!(msh = init_msh(argv, envp)))  	{  		ft_dprintf(2, "%s\n", strerror(errno));  		return (FT_RET_ALLOC);  	} -	ret = ft_m_argv(argc, argv, msh); -	ft_s_destroy(msh); +	ret = m_argv(argc, argv, msh); +	s_destroy(msh);  	return (ret);  } @@ -48,7 +48,6 @@ int  ** ====== INFO ======  ** Files prefixes info  ** ------------------- -** ft_ -> 42  ** b_  -> builtins related  ** d_  -> defines related  ** e_  -> exec related diff --git a/src/minishell.h b/src/m_minishell.h index a30d8bc..06ecfed 100644 --- a/src/minishell.h +++ b/src/m_minishell.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   minishell.h                                        :+:      :+:    :+:   */ +/*   m_minishell.h                                      :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,7 +10,7 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef MINISHELL_H -#define MINISHELL_H +#ifndef M_MINISHELL_H +#define M_MINISHELL_H  #endif diff --git a/src/ft_m_prompt.c b/src/m_prompt.c index 4c4cc41..34aae09 100644 --- a/src/ft_m_prompt.c +++ b/src/m_prompt.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_prompt.c                                      :+:      :+:    :+:   */ +/*   m_prompt.c                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,18 +13,18 @@  #include <libft.h>  #include <unistd.h> -#include "ft_m_prompt.h" -#include "ft_s_struct.h" +#include "m_prompt.h" +#include "s_struct.h"  void -    ft_m_cont_prompt(void) +    m_cont_prompt(void)  {  	ft_dprintf(STDIN_FILENO, "> ");  	/* TODO :ft_printf("%s", msh->ps_two); */  }  void -	ft_m_prompt(t_msh *msh) +	m_prompt(t_msh *msh)  {  	ft_dprintf(STDIN_FILENO, "%s", msh->ps_one);  } diff --git a/src/m_prompt.h b/src/m_prompt.h new file mode 100644 index 0000000..f929298 --- /dev/null +++ b/src/m_prompt.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   m_prompt.h                                         :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef M_PROMPT_H +#define M_PROMPT_H + +#include "s_struct.h" + +void	m_prompt(t_msh *msh); +void	m_cont_prompt(void); +#endif diff --git a/src/ft_m_redirs.c b/src/m_redirs.c index 701a2a4..2414dcd 100644 --- a/src/ft_m_redirs.c +++ b/src/m_redirs.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_redirs.c                                      :+:      :+:    :+:   */ +/*   m_redirs.c                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,13 +14,13 @@  #include <unistd.h>  #include <errno.h> -#include "ft_f_fail.h" -#include "ft_s_destroy.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" +#include "f_fail.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h"  void -	ft_dup_redirs(const t_lcom *ptr, +	dup_redirs(const t_lcom *ptr,  				t_msh *msh)  {  	int32_t	fd; @@ -28,7 +28,7 @@ void  	if (ptr->redir == -1)  	{  		if ((fd = open(ptr->rdrpath, O_RDONLY)) == -1) -			ft_f_redir(ptr->rdrpath, msh); +			f_redir(ptr->rdrpath, msh);  		dup2(fd, STDIN_FILENO);  		close(fd);  	} @@ -36,7 +36,7 @@ void  	{  		if ((fd = open(ptr->rdrpath,  					   O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) -			ft_f_redir(ptr->rdrpath, msh); +			f_redir(ptr->rdrpath, msh);  		dup2(fd, ptr->rdrfd);  		close(fd);  	} @@ -44,7 +44,7 @@ void  	{  		if ((fd = open(ptr->rdrpath,  					   O_CREAT | O_APPEND | O_WRONLY, 0644)) == -1) -			ft_f_redir(ptr->rdrpath, msh); +			f_redir(ptr->rdrpath, msh);  		dup2(fd, ptr->rdrfd);  		close(fd);  	} diff --git a/src/ft_e_pipes.h b/src/m_redirs.h index f801b21..295ea4d 100644 --- a/src/ft_e_pipes.h +++ b/src/m_redirs.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_pipes.h                                       :+:      :+:    :+:   */ +/*   m_redirs.h                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,11 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_E_PIPES_H -#define FT_E_PIPES_H +#ifndef M_REDIRS_H +#define M_REDIRS_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_e_pipes(t_lcom *ptr, t_msh *msh); +void	dup_redirs(const t_lcom *ptr, +					t_msh *msh);  #endif diff --git a/src/ft_p_lcom.c b/src/p_lcom.c index a8449ae..f47e2c1 100644 --- a/src/ft_p_lcom.c +++ b/src/p_lcom.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_p_lcom.c                                        :+:      :+:    :+:   */ +/*   p_lcom.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -17,14 +17,14 @@  #include <unistd.h>  #include <errno.h> -#include "ft_d_define.h" -#include "ft_f_fail.h" -#include "ft_s_lcom.h" -#include "ft_s_lpipes.h" -#include "ft_s_struct.h" +#include "d_define.h" +#include "f_fail.h" +#include "s_lcom.h" +#include "s_lpipes.h" +#include "s_struct.h"  static void -	ft_rdr_err_check(char *ptr, +	rdr_err_check(char *ptr,  				t_lcom **link)  {  	if ((*link)->redir == -1 && ft_ischarset("><", *(ptr + 1))) @@ -42,7 +42,7 @@ static void  }  static int8_t -	ft_get_rdrpath(char *ptr, +	get_rdrpath(char *ptr,  				t_lcom **link)  {  	char	*p_rdrpath; @@ -68,7 +68,7 @@ static int8_t  }  static void -	ft_get_rdrfd(const char *ptr, +	get_rdrfd(const char *ptr,  				t_lcom **link)  {  	while (ft_isdigit(*ptr)) @@ -85,7 +85,7 @@ static void  }  int8_t -	ft_get_redir(const char word[], +	get_redir(const char word[],  				t_lcom **link)  {  	/* TODO: norme */ @@ -112,18 +112,18 @@ int8_t  	if ((*link)->redir > 0)  	{  		if (ft_isdigit(*(ptr - 1))) -			ft_get_rdrfd(ptr - 1, link); +			get_rdrfd(ptr - 1, link);  		else  			(*link)->rdrfd = STDOUT_FILENO; -		ft_rdr_err_check(ptr, link); -		if (ft_get_rdrpath(ptr, link) != 0) +		rdr_err_check(ptr, link); +		if (get_rdrpath(ptr, link) != 0)  			return (-1);  	}  	return (0);  }  int8_t -	ft_p_lcom(const char line[], +	p_lcom(const char line[],  			const uint64_t count,  			t_msh *msh)  { @@ -142,15 +142,15 @@ int8_t  		/* TODO: split pipes here */  		if (ft_strchr(words[i], '|'))  		{ -			if (!(link = ft_lcom_new(NULL, msh))) +			if (!(link = lcom_new(NULL, msh)))  				return (-1); -			if (!(ft_split_pipes(words[i], link, msh))) +			if (!(split_pipes(words[i], link, msh)))  				return (-1);  			next = TRUE;  		} -		if (next == FALSE && !(link = ft_lcom_new(words[i], msh))) +		if (next == FALSE && !(link = lcom_new(words[i], msh)))  			return (-1); -		ft_lcom_add_back(&msh->curr, link); +		lcom_add_back(&msh->curr, link);  		i++;  	}  	ft_delwords(words); diff --git a/src/ft_p_lcom.h b/src/p_lcom.h index 256fe75..4e37399 100644 --- a/src/ft_p_lcom.h +++ b/src/p_lcom.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_p_lcom.h                                        :+:      :+:    :+:   */ +/*   p_lcom.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,16 +10,16 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_P_LCOM_H -#define FT_P_LCOM_H +#ifndef P_LCOM_H +#define P_LCOM_H  #include <stdint.h> -#include "ft_s_struct.h" +#include "s_struct.h" -int8_t	ft_get_redir(const char word[], +int8_t	get_redir(const char word[],  				t_lcom **link); -int8_t	ft_p_lcom(const char line[], +int8_t	p_lcom(const char line[],  				const uint64_t count,  				t_msh *msh); diff --git a/src/ft_p_lcom_next.c b/src/p_lcom_next.c index 8313b08..94ac9bf 100644 --- a/src/ft_p_lcom_next.c +++ b/src/p_lcom_next.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_p_lcom_next.c                                   :+:      :+:    :+:   */ +/*   p_lcom_next.c                                      :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,11 +14,11 @@  #include <stdlib.h>  #include <stdint.h> -#include "ft_s_struct.h" -#include "ft_u_vars.h" +#include "s_struct.h" +#include "u_vars.h"  static int8_t -	ft_subst_those_vars(int64_t i, +	subst_those_vars(int64_t i,  						char **p_words,  						t_msh *msh)  { @@ -34,7 +34,7 @@ static int8_t  		varlen += 1;  	if (!(s_varname = ft_substr(*p_words, (uint32_t)i, varlen - i)))  		return (-1); -	varval = ft_subst_var_value(s_varname, msh); +	varval = subst_var_value(s_varname, msh);  	*p_words = ft_strsubst(*p_words, s_varname, varval);  	ft_memdel((void*)&s_varname);  	ft_memdel((void*)&varval); @@ -42,7 +42,7 @@ static int8_t  }  char -	**ft_subst_vars(char *words[], +	**subst_vars(char *words[],  					t_msh *msh)  {  	char	**p_words; @@ -56,7 +56,7 @@ char  		{  			if (*(*p_words) + i - 1 != '\\')  			{ -				if (ft_subst_those_vars(i, p_words, msh) != 0) +				if (subst_those_vars(i, p_words, msh) != 0)  					return (NULL);  			}  		} @@ -67,7 +67,7 @@ char  char -	**ft_subst_args(const char word[], +	**subst_args(const char word[],  					int8_t redir)  {  	char	**words; diff --git a/src/ft_m_comm.h b/src/p_lcom_next.h index 5b22f3a..3113b6b 100644 --- a/src/ft_m_comm.h +++ b/src/p_lcom_next.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_m_comm.h                                        :+:      :+:    :+:   */ +/*   p_lcom_next.h                                      :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,14 +10,16 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_M_COMM_H -#define FT_M_COMM_H +#ifndef P_LCOM_NEXT_H +#define P_LCOM_NEXT_H  #include <stdint.h> -#include "ft_s_struct.h" +#include "s_struct.h" -uint8_t	ft_m_comm(const char line[], -				t_msh *msh); +char	**subst_vars(char *words[], +					t_msh *msh); +char	**subst_args(const char word[], +					int8_t redir);  #endif diff --git a/src/ft_p_line.c b/src/p_line.c index 166b880..4a58537 100644 --- a/src/ft_p_line.c +++ b/src/p_line.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_p_line.c                                        :+:      :+:    :+:   */ +/*   p_line.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -13,15 +13,15 @@  #include <libft.h>  #include <stdlib.h> -#include "ft_d_enum.h" -#include "ft_f_fail.h" -#include "ft_p_lcom.h" -#include "ft_p_line.h" -#include "ft_s_destroy.h" -#include "ft_s_struct.h" +#include "d_enum.h" +#include "f_fail.h" +#include "p_lcom.h" +#include "p_line.h" +#include "s_destroy.h" +#include "s_struct.h"  void -	ft_p_line(char line[], +	p_line(char line[],  			t_msh *msh)  {  	char		*ptr; @@ -42,9 +42,9 @@ void  	{  		count -= 1;  	} -	if (ft_p_lcom(line, count, msh) < 0) +	if (p_lcom(line, count, msh) < 0)  	{ -		ft_s_destroy(msh); -		ft_fail_alloc(msh); +		s_destroy(msh); +		fail_alloc(msh);  	}  } diff --git a/src/ft_f_redir.h b/src/p_line.h index 2b99da7..7e8a321 100644 --- a/src/ft_f_redir.h +++ b/src/p_line.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_redir.h                                       :+:      :+:    :+:   */ +/*   p_line.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_F_REDIR_H -#define FT_F_REDIR_H +#ifndef P_LINE_H +#define P_LINE_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_f_redir(const char path[], +void	p_line(char *line,  				t_msh *msh);  #endif diff --git a/src/ft_s_destroy.c b/src/s_destroy.c index 22009c8..f9d56eb 100644 --- a/src/ft_s_destroy.c +++ b/src/s_destroy.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_destroy.c                                     :+:      :+:    :+:   */ +/*   s_destroy.c                                        :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -12,17 +12,17 @@  #include <libft.h> -#include "ft_s_destroy.h" -#include "ft_s_lvars.h" +#include "s_destroy.h" +#include "s_lvars.h"  void -	ft_s_destroy(t_msh *msh) +	s_destroy(t_msh *msh)  {  	ft_memdel((void*)&msh->ps_one);  	ft_memdel((void*)&msh->cwd);  	ft_memdel((void*)&msh->shname);  	ft_delwords(msh->bu_ref);  	ft_delwords(msh->envp); -	ft_lvars_clear(&msh->vars); +	lvars_clear(&msh->vars);  	ft_memdel((void*)&msh);  } diff --git a/src/s_destroy.h b/src/s_destroy.h new file mode 100644 index 0000000..66aea91 --- /dev/null +++ b/src/s_destroy.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   s_destroy.h                                        :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef S_DESTROY_H +#define S_DESTROY_H + +#include "s_struct.h" + +void	s_destroy(t_msh *msh); + +#endif diff --git a/src/ft_s_init.c b/src/s_init.c index 88a3817..454cb67 100644 --- a/src/ft_s_init.c +++ b/src/s_init.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_init.c                                        :+:      :+:    :+:   */ +/*   s_init.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,12 +15,12 @@  #include <stdlib.h>  #include <unistd.h> -#include "ft_d_define.h" -#include "ft_m_funptr.h" -#include "ft_s_init.h" +#include "d_define.h" +#include "m_funptr.h" +#include "s_init.h"  static char -	**ft_dupenv_del(char **nenvp, +	**dupenv_del(char **nenvp,  					uint64_t i)  {  	while (i > 0) @@ -33,7 +33,7 @@ static char  }  static char -	**ft_dupenv(char *const envp[]) +	**dupenv(char *const envp[])  {  	uint64_t	i;  	char		**nenvp; @@ -51,7 +51,7 @@ static char  	while (envp[i])  	{  		if (!(nenvp[i] = ft_strdup(envp[i]))) -			return (ft_dupenv_del(nenvp, i)); +			return (dupenv_del(nenvp, i));  		i++;  	}  	nenvp[i] = NULL; @@ -59,7 +59,7 @@ static char  }  t_msh -	*ft_init_msh(char *const argv[], +	*init_msh(char *const argv[],  				char *const envp[])  {  	t_msh	*msh; @@ -75,10 +75,10 @@ t_msh  	msh->cwd = getcwd(NULL, 0);  	/* TODO: handle getcwd failed */  	msh->envp = NULL; -	if (!(msh->envp = ft_dupenv(envp))) +	if (!(msh->envp = dupenv(envp)))  		return (NULL);  	msh->ret = 0; -	ft_init_buptr(msh); +	init_buptr(msh);  	msh->curr = NULL;  	msh->vars = NULL;  	return (msh); diff --git a/src/ft_s_init.h b/src/s_init.h index bd8edc7..8ffe954 100644 --- a/src/ft_s_init.h +++ b/src/s_init.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_init.h                                        :+:      :+:    :+:   */ +/*   s_init.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,13 +10,14 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_S_INIT_H -#define FT_S_INIT_H +#ifndef S_INIT_H +#define S_INIT_H  #include <stdlib.h> -#include "ft_s_struct.h" -t_msh	*ft_init_msh(char *const argv[], +#include "s_struct.h" + +t_msh	*init_msh(char *const argv[],  					char *const envp[]);  #endif diff --git a/src/ft_s_lcom.c b/src/s_lcom.c index d56ba7f..31b14d6 100644 --- a/src/ft_s_lcom.c +++ b/src/s_lcom.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_lcom.c                                        :+:      :+:    :+:   */ +/*   s_lcom.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,12 +14,12 @@  #include <stdlib.h>  #include <stdint.h> -#include "ft_p_lcom.h" -#include "ft_p_lcom_next.h" -#include "ft_s_struct.h" +#include "p_lcom.h" +#include "p_lcom_next.h" +#include "s_struct.h"  static int8_t -	ft_fill_lcom(char *words[], +	fill_lcom(char *words[],  				t_lcom **lcom)  {  	/* TODO: norme */ @@ -61,7 +61,7 @@ static int8_t  }  t_lcom -	*ft_lcom_last(t_lcom *lcom) +	*lcom_last(t_lcom *lcom)  {  	while (lcom->next != NULL)  		lcom = lcom->next; @@ -69,7 +69,7 @@ t_lcom  }  void -	ft_lcom_add_back(t_lcom **alcom, +	lcom_add_back(t_lcom **alcom,  					t_lcom *new)  {  	t_lcom	*tmp; @@ -78,13 +78,13 @@ void  		*alcom = new;  	else  	{ -		tmp = ft_lcom_last(*alcom); +		tmp = lcom_last(*alcom);  		tmp->next = new;  	}  }  void -	ft_lcom_clear(t_lcom **lcom) +	lcom_clear(t_lcom **lcom)  {  	t_lcom	*tmp;  	t_lcom	*renext; @@ -107,7 +107,7 @@ void  }  t_lcom -	*ft_lcom_new(const char word[], +	*lcom_new(const char word[],  				t_msh *msh)  {  	/* TODO: norme */ @@ -128,13 +128,13 @@ t_lcom  		return (link);  	}  	link->pipes = NULL; -	if (ft_get_redir(word, &link) != 0) +	if (get_redir(word, &link) != 0)  		return (NULL); -	if (!(words = ft_subst_args(word, link->redir))) +	if (!(words = subst_args(word, link->redir)))  		return (NULL); -	if (!(words = ft_subst_vars(words, msh))) +	if (!(words = subst_vars(words, msh)))  		return (NULL); -	if (ft_fill_lcom(words, &link) < 0) +	if (fill_lcom(words, &link) < 0)  	{  		ft_delwords(words);  		return (NULL); diff --git a/src/s_lcom.h b/src/s_lcom.h new file mode 100644 index 0000000..10fcf7c --- /dev/null +++ b/src/s_lcom.h @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/*                                                                            */ +/*                                                        :::      ::::::::   */ +/*   s_lcom.h                                           :+:      :+:    :+:   */ +/*                                                    +:+ +:+         +:+     */ +/*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */ +/*                                                +#+#+#+#+#+   +#+           */ +/*   Created: 2020/02/14 17:19:27 by rbousset          #+#    #+#             */ +/*   Updated: 2020/02/14 17:19:29 by rbousset         ###   ########lyon.fr   */ +/*                                                                            */ +/* ************************************************************************** */ + +#ifndef S_LCOM_H +#define S_LCOM_H + +#include "s_struct.h" + +void	lcom_add_back(t_lcom **alcom, t_lcom *new); +void	lcom_clear(t_lcom **lcom); +t_lcom	*lcom_new(const char word[], t_msh *msh); +t_lcom	*lcom_last(t_lcom *lcom); + +#endif diff --git a/src/ft_s_lpipes.c b/src/s_lpipes.c index 8bd34de..cb78df3 100644 --- a/src/ft_s_lpipes.c +++ b/src/s_lpipes.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_lpipes.c                                      :+:      :+:    :+:   */ +/*   s_lpipes.c                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,12 +14,12 @@  #include <stdlib.h>  #include <stdint.h> -#include "ft_s_lcom.h" -#include "ft_s_lpipes.h" -#include "ft_s_struct.h" +#include "s_lcom.h" +#include "s_lpipes.h" +#include "s_struct.h"  struct s_lpipes -	*ft_lpipes_last(struct s_lpipes *lpipes) +	*lpipes_last(struct s_lpipes *lpipes)  {  	while (lpipes->next != NULL)  		lpipes = lpipes->next; @@ -27,7 +27,7 @@ struct s_lpipes  }  void -	ft_lpipes_add_back(struct s_lpipes **alpipes, +	lpipes_add_back(struct s_lpipes **alpipes,  					struct s_lpipes *new)  {  	struct s_lpipes	*tmp; @@ -36,13 +36,13 @@ void  		*alpipes = new;  	else  	{ -		tmp = ft_lpipes_last(*alpipes); +		tmp = lpipes_last(*alpipes);  		tmp->next = new;  	}  }  void -	ft_lpipes_clear(struct s_lpipes **lpipes) +	lpipes_clear(struct s_lpipes **lpipes)  {  	struct s_lpipes	*tmp;  	struct s_lpipes	*renext; @@ -53,7 +53,7 @@ void  	while (tmp)  	{  		renext = tmp->next; -		ft_lcom_clear(&tmp->one); +		lcom_clear(&tmp->one);  		ft_memdel((void*)&tmp);  		tmp = renext;  	} @@ -61,7 +61,7 @@ void  }  struct s_lpipes -	*ft_lpipes_new(const char pipedword[], +	*lpipes_new(const char pipedword[],  					t_msh *msh)  {  	struct s_lpipes	*link; @@ -69,7 +69,7 @@ struct s_lpipes  	if (!(link = (struct s_lpipes*)malloc(sizeof(struct s_lpipes))))  		return (NULL);  	link->one = NULL; -	if (!(link->one = ft_lcom_new(pipedword, msh))) +	if (!(link->one = lcom_new(pipedword, msh)))  	{  		return (NULL);  	} @@ -78,7 +78,7 @@ struct s_lpipes  }  struct s_lpipes -	*ft_split_pipes(const char word[], +	*split_pipes(const char word[],  					t_lcom *lcom,  					t_msh *msh)  { @@ -93,11 +93,11 @@ struct s_lpipes  		return (NULL);  	while (words[i])  	{ -		if (!(lpipes = ft_lpipes_new(words[i], msh))) +		if (!(lpipes = lpipes_new(words[i], msh)))  		{  			return (NULL);  		} -		ft_lpipes_add_back(&lcom->pipes, lpipes); +		lpipes_add_back(&lcom->pipes, lpipes);  		i++;  	}  	ft_delwords(words); diff --git a/src/ft_s_lpipes.h b/src/s_lpipes.h index 50fd693..1fc6eec 100644 --- a/src/ft_s_lpipes.h +++ b/src/s_lpipes.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_lpipes.h                                      :+:      :+:    :+:   */ +/*   s_lpipes.h                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,16 +10,16 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_S_LPIPES_H -#define FT_S_LPIPES_H +#ifndef S_LPIPES_H +#define S_LPIPES_H -#include "ft_s_struct.h" +#include "s_struct.h" -struct s_lpipes	*ft_lpipes_last(struct s_lpipes *lpipes); -void			ft_lpipes_add_back(struct s_lpipes **alpipes, +struct s_lpipes	*lpipes_last(struct s_lpipes *lpipes); +void			lpipes_add_back(struct s_lpipes **alpipes,  								struct s_lpipes *new); -void			ft_lpipes_clear(struct s_lpipes **lpipes); -struct s_lpipes	*ft_lpipes_new(const char pipedword[], t_msh *msh); -struct s_lpipes	*ft_split_pipes(const char word[], t_lcom *lcom, t_msh *msh); +void			lpipes_clear(struct s_lpipes **lpipes); +struct s_lpipes	*lpipes_new(const char pipedword[], t_msh *msh); +struct s_lpipes	*split_pipes(const char word[], t_lcom *lcom, t_msh *msh);  #endif diff --git a/src/ft_s_lvars.c b/src/s_lvars.c index fb3a0f4..f2a1151 100644 --- a/src/ft_s_lvars.c +++ b/src/s_lvars.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_lvars.c                                       :+:      :+:    :+:   */ +/*   s_lvars.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -16,10 +16,10 @@  #include <errno.h>  #include <unistd.h> -#include "ft_s_struct.h" +#include "s_struct.h"  void -	ft_lvars_rebind(t_lvars **lvars, +	lvars_rebind(t_lvars **lvars,  					const char name[],  					const char newval[])  { @@ -43,7 +43,7 @@ void  }  void -	ft_lvars_delone(t_lvars **lvars, +	lvars_delone(t_lvars **lvars,  					const char name[])  {  	t_lvars	*tmp; @@ -72,7 +72,7 @@ void  }  void -	ft_lvars_add_front(t_lvars **alvars, +	lvars_add_front(t_lvars **alvars,  					t_lvars *new)  {  	if (!alvars || !new) @@ -84,7 +84,7 @@ void  }  void -	ft_lvars_clear(t_lvars **lvars) +	lvars_clear(t_lvars **lvars)  {  	t_lvars	*tmp;  	t_lvars	*renext; @@ -104,7 +104,7 @@ void  }  t_lvars -	*ft_lvars_new(const char name[], +	*lvars_new(const char name[],  				const char val[])  {  	t_lvars	*link; diff --git a/src/ft_s_lvars.h b/src/s_lvars.h index 0f46d7d..6bc0a99 100644 --- a/src/ft_s_lvars.h +++ b/src/s_lvars.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_lvars.h                                       :+:      :+:    :+:   */ +/*   s_lvars.h                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,20 +10,20 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_S_LVARS_H -#define FT_S_LVARS_H +#ifndef S_LVARS_H +#define S_LVARS_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_lvars_rebind(t_lvars **lvars, +void	lvars_rebind(t_lvars **lvars,  						const char name[],  						const char newval[]); -void	ft_lvars_delone(t_lvars **lvars, +void	lvars_delone(t_lvars **lvars,  						const char name[]); -void	ft_lvars_add_front(t_lvars **alvars, +void	lvars_add_front(t_lvars **alvars,  						t_lvars *new); -void	ft_lvars_clear(t_lvars **lvars); -t_lvars	*ft_lvars_new(const char name[], +void	lvars_clear(t_lvars **lvars); +t_lvars	*lvars_new(const char name[],  					const char val[]);  #endif diff --git a/src/ft_s_struct.h b/src/s_struct.h index 3a8df0a..8c72012 100644 --- a/src/ft_s_struct.h +++ b/src/s_struct.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_s_struct.h                                      :+:      :+:    :+:   */ +/*   s_struct.h                                         :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_S_STRUCT_H -#define FT_S_STRUCT_H +#ifndef S_STRUCT_H +#define S_STRUCT_H  #include <stdint.h> -#include "ft_d_define.h" +#include "d_define.h"  /*  ** redir(int8_t) index diff --git a/src/ft_u_utils.c b/src/u_utils.c index b7ab7d8..c95cbb0 100644 --- a/src/ft_u_utils.c +++ b/src/u_utils.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_u_utils.c                                       :+:      :+:    :+:   */ +/*   u_utils.c                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -15,7 +15,7 @@  #include <stdint.h>  uint64_t -	ft_get_argc(const char *args[]) +	get_argc(const char *args[])  {  	uint64_t	argc; diff --git a/src/ft_e_lcom.h b/src/u_utils.h index 5244001..a02e7e6 100644 --- a/src/ft_e_lcom.h +++ b/src/u_utils.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_e_lcom.h                                        :+:      :+:    :+:   */ +/*   u_utils.h                                          :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,11 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_E_LCOM_H -#define FT_E_LCOM_H +#ifndef U_UTILS_H +#define U_UTILS_H  #include <stdint.h> -#include "ft_s_struct.h" -void	ft_e_lcom(t_msh *msh); +uint64_t	get_argc(const char *args[]);  #endif diff --git a/src/ft_u_vars.c b/src/u_vars.c index cb020e3..3f3a1a5 100644 --- a/src/ft_u_vars.c +++ b/src/u_vars.c @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_u_vars.c                                        :+:      :+:    :+:   */ +/*   u_vars.c                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -14,24 +14,24 @@  #include <stdlib.h>  #include <stdint.h> -#include "ft_d_define.h" -#include "ft_f_fail.h" -#include "ft_s_destroy.h" -#include "ft_s_lcom.h" -#include "ft_s_struct.h" +#include "d_define.h" +#include "f_fail.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h"  static char -	*ft_set_rva(const char varname[], +	*set_rva(const char varname[],  				t_msh *msh)  {  	char	*rvarname;  	if (!(rvarname = (char*)malloc((ft_strlen(varname) + 1) * sizeof(char))))  	{ -		ft_lcom_clear(&msh->curr); -		ft_s_destroy(msh); -		ft_fail_alloc(msh); +		lcom_clear(&msh->curr); +		s_destroy(msh); +		fail_alloc(msh);  	}  	ft_memcpy((char*)rvarname, (const char*)varname + 1,  		ft_strlen(varname + 1)); @@ -41,7 +41,7 @@ static char  }  static char -	*ft_dup_env(char *p_env, +	*dup_env(char *p_env,  				char *rvarname,  				t_msh *msh)  { @@ -50,16 +50,16 @@ static char  	if (!(varval = ft_strdup(p_env)))  	{  		ft_memdel((void*)&rvarname); -		ft_lcom_clear(&msh->curr); -		ft_s_destroy(msh); -		ft_fail_alloc(msh); +		lcom_clear(&msh->curr); +		s_destroy(msh); +		fail_alloc(msh);  	}  	ft_memdel((void*)&rvarname);  	return (varval);  }  static char -	*ft_get_frm_env(char rvarname[], +	*get_frm_env(char rvarname[],  					t_msh *msh)  {  	char	**p_env; @@ -76,7 +76,7 @@ static char  				pp_env += 1;  			if (*pp_env == '=')  				pp_env += 1; -			varval = ft_dup_env(pp_env, rvarname, msh); +			varval = dup_env(pp_env, rvarname, msh);  			return (varval);  		}  		p_env += 1; @@ -85,7 +85,7 @@ static char  }  static char -	*ft_get_special_var(const char varname[], +	*get_special_var(const char varname[],  						t_msh *msh)  {  	char	*varval; @@ -94,9 +94,9 @@ static char  	{  		if (!(varval = ft_uitoa(msh->ret)))  		{ -			ft_lcom_clear(&msh->curr); -			ft_s_destroy(msh); -			ft_fail_alloc(msh); +			lcom_clear(&msh->curr); +			s_destroy(msh); +			fail_alloc(msh);  		}  		return (varval);  	} @@ -104,9 +104,9 @@ static char  	{  		if (!(varval = ft_strdup(msh->shname)))  		{ -			ft_lcom_clear(&msh->curr); -			ft_s_destroy(msh); -			ft_fail_alloc(msh); +			lcom_clear(&msh->curr); +			s_destroy(msh); +			fail_alloc(msh);  		}  		return (varval);  	} @@ -114,7 +114,7 @@ static char  }  static char -	*ft_get_cstm_vr(const char varname[], +	*get_cstm_vr(const char varname[],  					t_msh *msh)  {  	(void)varname; @@ -124,10 +124,10 @@ static char  /*  ** char * -** ft_subst_var_value(const char varname[], const t_msh *msh); +** subst_var_value(const char varname[], const t_msh *msh);  **  ** DESCRIPTION -** The ft_subst_var_value() function returns +** The subst_var_value() function returns  ** a heap-allocated, null-terminated string  ** that may later be free'd containing the  ** value of the variable varname[] including @@ -136,7 +136,7 @@ static char  */  char -	*ft_subst_var_value(const char varname[], +	*subst_var_value(const char varname[],  						t_msh *msh)  {  	/* TODO: check behaviour on empty vars -> "QWE=" */ @@ -145,18 +145,18 @@ char  	char	*rvarname;  	varval = NULL; -	if ((varval = ft_get_special_var(varname, msh)) != NULL) +	if ((varval = get_special_var(varname, msh)) != NULL)  	{  		return (varval);  	} -	else if ((varval = ft_get_cstm_vr(varname, msh)) != NULL) +	else if ((varval = get_cstm_vr(varname, msh)) != NULL)  	{  		return (varval);  	}  	else  	{ -		rvarname = ft_set_rva(varname, msh); -		varval = ft_get_frm_env(rvarname, msh); +		rvarname = set_rva(varname, msh); +		varval = get_frm_env(rvarname, msh);  		return (varval);  	}  	return (NULL); diff --git a/src/ft_f_errno.h b/src/u_vars.h index 86fce83..686a9b5 100644 --- a/src/ft_f_errno.h +++ b/src/u_vars.h @@ -1,7 +1,7 @@  /* ************************************************************************** */  /*                                                                            */  /*                                                        :::      ::::::::   */ -/*   ft_f_errno.h                                       :+:      :+:    :+:   */ +/*   u_vars.h                                           :+:      :+:    :+:   */  /*                                                    +:+ +:+         +:+     */  /*   By: rbousset <marvin@42.fr>                    +#+  +:+       +#+        */  /*                                                +#+#+#+#+#+   +#+           */ @@ -10,12 +10,12 @@  /*                                                                            */  /* ************************************************************************** */ -#ifndef FT_F_ERRNO_H -#define FT_F_ERRNO_H +#ifndef U_VARS_H +#define U_VARS_H -#include "ft_s_struct.h" +#include "s_struct.h" -void	ft_f_dump_errno(const char concern[], +char	*subst_var_value(const char varname[],  						t_msh *msh);  #endif | 
