Updated Filelist

This commit is contained in:
Maieul BOYER 2024-07-30 14:54:11 +02:00
parent ed4015a8fe
commit f05826942a
No known key found for this signature in database
15 changed files with 182 additions and 163 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:04:56 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:52:09 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,6 +26,7 @@
#include <stdio.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-variable"
@ -728,3 +729,5 @@ t_error run_node(t_ast_node self, t_state *state, void *out)
}
*/
#pragma clang diagnostic pop

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_inner.c :+: :+: :+: */
/* handle_redirection.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 22:27:00 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:05:38 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:53:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,4 +16,5 @@
t_error handle_redirections(t_spawn_info *info, t_process *process)
{
return (ERROR);
}

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_iter_funcs.c :+: :+: :+: */
/* iter_funcs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 22:25:44 by maiboyer #+# #+# */
/* Updated: 2024/07/29 17:22:42 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 13:22:34 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,28 +14,17 @@
#include <stdbool.h>
#include <stdio.h>
bool exec_find_null(const t_str *s)
bool exec_find_null(const t_str *s)
{
return (s == NULL);
}
bool exec_str_start_with(t_const_str s, t_const_str prefix)
bool exec_find_path(const t_str *s)
{
while (*prefix && *s)
{
if (*prefix++ != *s++)
return (false);
}
return (*prefix == '\0');
}
bool exec_find_path(const t_str *s)
{
t_str ss;
t_str str;
if (*s == NULL)
return (false);
ss = *s;
return (ss[0] == 'P' && ss[1] == 'A' && ss[2] == 'T' && ss[3] == 'H' && \
ss[4] == '=');
str = *s;
return (str[0] == 'P' && str[1] == 'A' && str[2] == 'T' && str[3] == 'H' && str[4] == '=');
}

View file

@ -6,19 +6,33 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 17:59:48 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:05:12 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 14:48:48 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec/spawn_cmd/pipe.h"
#include "me/fs/fs.h"
#include "me/str/str.h"
t_error exec_create_pipe(t_pipe *out)
t_error exec_create_pipe(t_exec_pipe *out)
{
int fds[2];
int fd[2];
struct s_file_slot *read;
struct s_file_slot *write;
if (pipe(fds))
if (pipe(fd))
return (ERROR);
out->read = fds[0];
out->write = fds[1];
read = get_unused_fd_slot();
if (read == NULL)
return (close(fd[0]), close(fd[1]), ERROR);
read->ty = SLOT_FD;
write = get_unused_fd_slot();
if (write == NULL)
return (read->ty = SLOT_UNUSED, close(fd[0]), close(fd[1]), ERROR);
write->ty = SLOT_FD;
read->slot.fd = (t_fd){.fd = fd[0], .type = FD_PIPE, .name = str_clone("<pipe[R]>"), .perms = FD_READ};
read->slot.fd = (t_fd){.fd = fd[1], .type = FD_PIPE, .name = str_clone("<pipe[W]>"), .perms = FD_WRITE};
out->read = &read->slot.fd;
out->write = &write->slot.fd;
return (NO_ERROR);
}

View file

@ -6,13 +6,13 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
/* Updated: 2024/07/29 19:06:23 by maiboyer ### ########.fr */
/* Updated: 2024/07/30 13:22:17 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec/spawn_cmd/process.h"
#include "exec/spawn_cmd/pipe.h"
#include "me/mem/mem.h"
#include "me/os/pipe.h"
#include "me/printf/printf.h"
#include "me/str/str.h"
#include "me/string/string.h"
@ -25,7 +25,6 @@
bool exec_find_path(const t_str *s);
bool exec_find_null(const t_str *s);
bool exec_str_start_with(t_const_str s, t_const_str prefix);
t_error exec_handle_redirections(t_spawn_info *info, t_process *process);
t_error exec_spawn_process_exec(t_spawn_info info, t_process *process)
@ -40,7 +39,7 @@ t_error exec_spawn_process_exec(t_spawn_info info, t_process *process)
if (!vec_str_any(&info.environement, exec_find_null, &res) && res)
vec_str_push(&info.environement, NULL);
execve(info.binary_path, info.arguments.buffer, info.environement.buffer);
return (NO_ERROR);
return (ERROR);
}
t_error exec_in_path(t_spawn_info *info, t_process *process, t_const_str path_raw, t_string *s)
@ -71,7 +70,7 @@ t_error exec_find_binary(t_spawn_info *info, t_process *process)
if (info->binary_path == NULL)
return (ERROR);
s = string_new(256);
if (exec_str_start_with(info->binary_path, "/") || str_find_chr(info->binary_path, '/') != NULL)
if (info->binary_path[0] == '/' || str_find_chr(info->binary_path, '/') != NULL)
string_push(&s, info->binary_path);
else
{