This commit is contained in:
Jack Halford 2017-03-27 18:07:20 +02:00
parent 2e49e0c302
commit a2545bb2e7
10 changed files with 33 additions and 31 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */
/* Updated: 2017/03/25 14:59:53 by jhalford ### ########.fr */
/* Updated: 2017/03/27 17:59:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@ typedef struct s_cliopts t_cliopts;
typedef struct s_data_template t_data_template;
typedef long long t_flag;
struct s_cliopts
struct s_cliopts
{
char c;
char *str;
@ -30,15 +30,14 @@ struct s_cliopts
int arg_required:1;
};
struct s_data_template
struct s_data_template
{
t_flag flag;
char **av_data;
};
int cliopts_get(char **av, t_cliopts opt_map[], void *data);
int cliopts_get(char **av, t_cliopts opt_map[], void *data);
t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg);
t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg);
int cliopts_has(char **av, char c);
#endif

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 18:20:42 by ariard #+# #+# */
/* Updated: 2017/03/25 21:23:11 by ariard ### ########.fr */
/* Updated: 2017/03/27 18:00:06 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,7 +31,7 @@ static t_cliopts g_cdopts[] =
{0, NULL, 0, 0, NULL, 0},
};
int cd_file_autorisations(char *target, int flag)
int cd_file_autorisations(char *target, int flag)
{
(void)flag;
if (access(target, F_OK))

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/09/20 14:50:33 by alao #+# #+# */
/* Updated: 2017/03/27 09:30:40 by alao ### ########.fr */
/* Updated: 2017/03/27 18:01:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -29,7 +29,7 @@ static void c_mv_tab(t_comp *c, int next)
ptr->next->cursor = 1;
else
ptr->prev->cursor = 1;
}
}
/*
** Once the completion has been processed, this is the return point.

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */
/* Updated: 2017/03/26 22:36:18 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:00:35 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,8 +22,7 @@ int redirect_dgreat(t_redir *redir)
if ((try_access(redir->word, 0, W_OK)))
return (ft_perror(NULL));
if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
exit (1);
exit(1);
fd_replace(fdold, fdnew);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
/* Updated: 2017/03/27 01:02:30 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:00:45 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,7 @@ int redirect_less(t_redir *redir)
if ((try_access(redir->word, 1, R_OK)) != 0)
return (ft_perror(NULL));
if ((fdold = open(redir->word, O_RDONLY, 0644)) < 0)
exit (1);
exit(1);
fd_replace(fdold, fdnew);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
/* Updated: 2017/03/22 12:09:59 by gwojda ### ########.fr */
/* Updated: 2017/03/27 18:01:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,6 @@ static int check_validity(char *str, int i)
else if (!str[i + 1] || str[i + 1] == '"')
return (0);
return (1);
}
static int history_parsing_nb_and_name(char *str, int *i)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:04:32 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:02:20 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,6 @@ void data_exit(void)
t_data *data;
data = data_singleton();
/* ft_strdel(&data->line.input); */
ft_strdel(&data->binary);
ft_sstrfree(data->env);
ft_sstrfree(data->local_var);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:00:19 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:04:11 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -66,6 +66,15 @@ static int shlvl_inc(void)
return (0);
}
int modules_init(t_data *data)
{
lexer_init(&data->lexer);
parser_init(&data->parser);
exec_init(&data->exec);
jobc_init(&data->jobc);
return (0);
}
int data_init(int ac, char **av, char **env)
{
t_data *data;
@ -80,13 +89,10 @@ int data_init(int ac, char **av, char **env)
localenv_init();
if (shlvl_inc())
return (-1);
modules_init(data);
data->comp = NULL;
data->opts = SH_INTERACTIVE | SH_OPTS_JOBC;
data->lst_func = NULL;
lexer_init(&data->lexer);
parser_init(&data->parser);
exec_init(&data->exec);
jobc_init(&data->jobc);
if ((term_name = ft_getenv(data->env, "TERM")) == NULL)
term_name = "dumb";
if (tgetent(NULL, term_name) != 1)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/27 15:32:13 by jhalford #+# #+# */
/* Updated: 2017/03/27 15:57:21 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:02:46 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -56,7 +56,7 @@ int shell_fds_pop(void)
return (0);
}
void shell_fds_reset(void)
void shell_fds_reset(void)
{
t_data *data;
int i;
@ -72,7 +72,7 @@ void shell_fds_reset(void)
}
}
void shell_fds_destroy(void)
void shell_fds_destroy(void)
{
t_data *data;
int i;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:04:45 by jhalford ### ########.fr */
/* Updated: 2017/03/27 18:06:12 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -89,10 +89,10 @@ int shell_init(int ac, char **av, char **env)
if (data_init(ac, av, env) < 0)
return (-1);
if (cliopts_get(av, g_opts, data))
return (ft_perror(NULL)
&& SH_ERR("%s", SHELL_USAGE1)
&& SH_ERR("%s", SHELL_USAGE2)
&& SH_ERR("%s", SHELL_USAGE3));
{
return (ft_perror(NULL) && SH_ERR("%s", SHELL_USAGE1)
&& SH_ERR("%s", SHELL_USAGE2) && SH_ERR("%s", SHELL_USAGE3));
}
if (!isatty(STDIN) || *data->av_data)
data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC);
if ((data->fd = get_input_fd(data, NULL)) < 0)