read script queue ok
This commit is contained in:
parent
fbe52ade64
commit
e4682de358
17 changed files with 53 additions and 50 deletions
BIN
42sh/includes/.readscript.h.swp
Normal file
BIN
42sh/includes/.readscript.h.swp
Normal file
Binary file not shown.
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/21 22:50:22 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/22 00:37:21 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 21:24:47 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,7 +25,6 @@ struct s_script
|
|||
{
|
||||
char *buffer;
|
||||
int b_size;
|
||||
int used;
|
||||
int q_size;
|
||||
t_list *queue;
|
||||
};
|
||||
|
|
@ -36,8 +35,6 @@ typedef struct s_script t_script;
|
|||
* Read_script setup/cleanup
|
||||
*/
|
||||
|
||||
int rs_setup(t_script *script);
|
||||
|
||||
int ft_read_script();
|
||||
int ft_read_script(char *file);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 15:14:47 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/10 17:24:06 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/01/22 20:56:45 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/11 14:51:27 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/01/22 19:03:32 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/09 16:37:32 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/01/22 17:22:10 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
BIN
42sh/src/line-editing/.ft_readline.c.swp
Normal file
BIN
42sh/src/line-editing/.ft_readline.c.swp
Normal file
Binary file not shown.
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 18:03:48 by sbenning #+# #+# */
|
||||
/* Updated: 2017/01/22 00:37:17 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 21:06:24 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 18:42:31 by sbenning #+# #+# */
|
||||
/* Updated: 2017/01/21 22:41:19 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 21:24:09 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 18:07:47 by sbenning #+# #+# */
|
||||
/* Updated: 2017/01/21 23:27:14 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 21:25:10 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
BIN
42sh/src/main/.main.c.swo
Normal file
BIN
42sh/src/main/.main.c.swo
Normal file
Binary file not shown.
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/19 21:06:33 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 17:20:29 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/21 23:28:31 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 17:20:04 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/22 00:37:15 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 21:18:37 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -49,14 +49,14 @@ int main(int ac, char **av)
|
|||
shell_single_command(shell_get_avdata());
|
||||
return (0);
|
||||
}
|
||||
if (ft_read_script(av[1]))
|
||||
return (0);
|
||||
while (1)
|
||||
{
|
||||
// if (ft_read_script())
|
||||
// return (1);
|
||||
// else if (ft_readline())
|
||||
// return (1);
|
||||
// if (shell_single_command(data_singleton()->line.input))
|
||||
// return (1);
|
||||
if (ft_readline())
|
||||
return (1);
|
||||
if (shell_single_command(data_singleton()->line.input))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/21 22:02:05 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 20:56:35 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
BIN
42sh/src/read-script/.ft_read_script.c.swp
Normal file
BIN
42sh/src/read-script/.ft_read_script.c.swp
Normal file
Binary file not shown.
|
|
@ -6,20 +6,49 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/21 22:49:31 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/22 00:33:09 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/22 21:39:49 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int ft_read_script()
|
||||
static int rs_loop(char *file, t_script *script)
|
||||
{
|
||||
int fd;
|
||||
|
||||
script->queue = ft_memalloc(sizeof(t_list));
|
||||
fd = open(file, O_RDONLY);
|
||||
while (get_next_line(fd, &script->buffer) > 0)
|
||||
{
|
||||
ft_lsteadd(&script->queue,
|
||||
ft_lstnew(script->buffer, ft_strlen(script->buffer)));
|
||||
ft_strdel(&script->buffer);
|
||||
}
|
||||
close(fd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int rs_setup(t_script *script)
|
||||
{
|
||||
ft_bzero(script, sizeof(script));
|
||||
script->buffer = NULL;
|
||||
script->b_size = 0;
|
||||
script->q_size = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ft_read_script(char *file)
|
||||
{
|
||||
t_script *script;
|
||||
|
||||
script = &data_singleton()->script;
|
||||
if (!file)
|
||||
return (0);
|
||||
if (rs_setup(script) < 0)
|
||||
return (-1);
|
||||
// if (rs_loop(script) < 0)
|
||||
// return (-1);
|
||||
return (0);
|
||||
if (rs_loop(file, script) < 0)
|
||||
return (-1);
|
||||
script->buffer = NULL;
|
||||
DG("{inv}{bol}{gre}read of script{eoc} script detected");
|
||||
return (1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rs_setup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/21 23:08:04 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/22 00:33:27 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int rs_setup(t_script *script)
|
||||
{
|
||||
ft_bzero(script, sizeof(script));
|
||||
script->buffer = 0;
|
||||
script->b_size = 0;
|
||||
script->used = 0;
|
||||
script->q_size = 0;
|
||||
return (0);
|
||||
}
|
||||
Loading…
Reference in a new issue