update
This commit is contained in:
parent
5d2202a0c9
commit
1d7112f982
14 changed files with 54 additions and 91 deletions
|
|
@ -6,56 +6,63 @@
|
|||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/09 15:00:53 by rparodi #+# #+# */
|
||||
/* Updated: 2024/05/18 14:32:02 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/05/18 16:41:54 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/env.h"
|
||||
#include "app/state.h"
|
||||
#include "me/types.h"
|
||||
#include "gmr/symbols.h"
|
||||
#include "app/node.h"
|
||||
#include "app/state.h"
|
||||
#include "gmr/symbols.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_str.h"
|
||||
// #include "app/node/handle_program.h"
|
||||
#include "app/node/handle_command.h"
|
||||
#include "minishell.h"
|
||||
#include "me/string/str_clone.h"
|
||||
#include "minishell.h"
|
||||
#include <time.h>
|
||||
|
||||
t_error handle_command(t_node *self, t_utils *shcat, t_i32 *out_exit_code)
|
||||
{
|
||||
t_usize i;
|
||||
t_usize i;
|
||||
t_spawn_info spawn_info;
|
||||
t_str tmp;
|
||||
t_str tmp;
|
||||
|
||||
spawn_info.arguments = vec_str_new(self->childs_count, (void (*)(t_str))mem_free);
|
||||
spawn_info.arguments = vec_str_new(64, (void (*)(t_str))mem_free); // TODO: FIX VECTOR
|
||||
if (self->kind != sym_command)
|
||||
return (ERROR);
|
||||
return (ERROR);
|
||||
i = 0;
|
||||
while (i < self->childs_count)
|
||||
{
|
||||
if (self->childs[i].kind == sym_command_name)
|
||||
{
|
||||
spawn_info.binary_path = str_clone(node_getstr(&self->childs[i]));
|
||||
vec_str_push(&spawn_info.arguments, str_clone(spawn_info.binary_path));
|
||||
printf("%s\n", spawn_info.arguments.buffer[0]);
|
||||
}
|
||||
else if (self->childs[i].kind == sym_file_redirect)
|
||||
printf("PAS ENCORE HANDLE FDP redirect!\n");
|
||||
else if (self->childs[i].kind == sym_variable_assignment)
|
||||
printf("PAS ENCORE HANDLE FDP asignement!\n");
|
||||
else
|
||||
{
|
||||
printf("%s %s\n", self->childs[i].kind_str, node_getstr(&self->childs[i]));
|
||||
printf("arg %s %s\n", self->childs[i].kind_str,
|
||||
node_getstr(&self->childs[i]));
|
||||
if (handle_node_getstr(&self->childs[i], shcat, &tmp))
|
||||
return (vec_str_free(spawn_info.arguments), ERROR);
|
||||
if (vec_str_push(&spawn_info.arguments, tmp))
|
||||
if (vec_str_push(&spawn_info.arguments, str_clone(tmp)))
|
||||
return (ERROR);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
vec_str_push_front(&spawn_info.arguments, str_clone(spawn_info.binary_path));
|
||||
printf("%zu\n", spawn_info.arguments.len);
|
||||
vec_str_push(&spawn_info.arguments, NULL);
|
||||
for (i = 0; i < spawn_info.arguments.len; i++)
|
||||
printf("[%zu]\t%s\n", i, spawn_info.arguments.buffer[i]);
|
||||
spawn_info.stdin = inherited();
|
||||
spawn_info.stdout = inherited();
|
||||
spawn_info.stderr = inherited();
|
||||
spawn_info.forked_free = NULL;
|
||||
spawn_info.forked_free = NULL;
|
||||
if (build_envp(shcat->env, &spawn_info.environement))
|
||||
return (vec_str_free(spawn_info.arguments), ERROR);
|
||||
if (spawn_process(spawn_info, &shcat->ret))
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
|
||||
/* Updated: 2024/05/08 19:22:47 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/05/18 16:15:44 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/env.h"
|
||||
#include "app/node.h"
|
||||
#include "app/node/handle_concat.h"
|
||||
#include "app/node/handle_program.h"
|
||||
#include "app/signal_handler.h"
|
||||
#include "gmr/symbols.h"
|
||||
|
|
@ -19,7 +20,6 @@
|
|||
#include "me/string/str_len.h"
|
||||
#include "minishell.h"
|
||||
#include "parser/api.h"
|
||||
#include "app/node/handle_concat.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#undef free
|
||||
|
|
@ -35,19 +35,19 @@ t_first_tree *ts_parser_parse_string(t_first_parser *, t_first_tree *oldtree,
|
|||
void ts_parser_delete(t_first_parser *self);
|
||||
void ts_parser_set_language(t_first_parser *self, t_language *lang);
|
||||
|
||||
|
||||
t_error handle_node_getstr(t_node *self, t_utils *shcat, t_str *out)
|
||||
{
|
||||
switch (self->kind)
|
||||
*out = NULL;
|
||||
if (self->kind == sym_word)
|
||||
{
|
||||
case sym_word:
|
||||
*out = node_getstr(self);
|
||||
return (NO_ERROR);
|
||||
case sym_concatenation:
|
||||
return (handle_concat(self, shcat, out));
|
||||
default:
|
||||
return (ERROR);
|
||||
printf("word!!!\n");
|
||||
*out = node_getstr(self);
|
||||
return (NO_ERROR);
|
||||
}
|
||||
if (self->kind == sym_concatenation)
|
||||
return (handle_concat(self, shcat, out));
|
||||
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
void print_node_data(t_node *t, t_usize depth)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/28 18:36:40 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/08 18:35:15 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/05/18 16:14:55 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue