Normed most of the stdme
This commit is contained in:
parent
882d5cb5bb
commit
ac5458d42c
31 changed files with 149 additions and 617 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/19 14:57:20 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/07/10 18:04:36 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,11 +26,11 @@
|
|||
bool find_path(const t_str *s);
|
||||
bool find_null(const t_str *s);
|
||||
bool str_start_with(t_const_str s, t_const_str prefix);
|
||||
t_error handle_redirections(t_spawn_info *info, t_process *process);
|
||||
t_error handle_redirections(t_spawn_info *info, t_process *process);
|
||||
|
||||
t_error spawn_process_exec(t_spawn_info info, t_process *process)
|
||||
t_error spawn_process_exec(t_spawn_info info, t_process *process)
|
||||
{
|
||||
bool res;
|
||||
bool res;
|
||||
|
||||
if (info.forked_free)
|
||||
info.forked_free(info.forked_free_args);
|
||||
|
|
@ -52,11 +52,11 @@ t_error spawn_process_exec(t_spawn_info info, t_process *process)
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
|
||||
t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
|
||||
t_string *s)
|
||||
{
|
||||
t_str *splitted_path;
|
||||
t_usize sp_index;
|
||||
t_str *splitted_path;
|
||||
t_usize sp_index;
|
||||
|
||||
splitted_path = str_split(path + 5, ':');
|
||||
if (splitted_path == NULL)
|
||||
|
|
@ -70,7 +70,7 @@ t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
|
|||
string_push(s, info->binary_path);
|
||||
sp_index++;
|
||||
if (access(s->buf, X_OK | R_OK) == 0)
|
||||
break;
|
||||
break ;
|
||||
}
|
||||
sp_index = 0;
|
||||
while (splitted_path[sp_index])
|
||||
|
|
@ -79,16 +79,16 @@ t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
|
|||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_error find_binary(t_spawn_info *info, t_process *process)
|
||||
t_error find_binary(t_spawn_info *info, t_process *process)
|
||||
{
|
||||
t_usize p_idx;
|
||||
t_string s;
|
||||
t_usize p_idx;
|
||||
t_string s;
|
||||
|
||||
(void)(process);
|
||||
if (info->binary_path == NULL)
|
||||
return (ERROR);
|
||||
s = string_new(256);
|
||||
if (str_start_with(info->binary_path, "/") ||
|
||||
if (str_start_with(info->binary_path, "/") || \
|
||||
str_find_chr(info->binary_path, '/') != NULL)
|
||||
string_push(&s, info->binary_path);
|
||||
else
|
||||
|
|
@ -107,7 +107,8 @@ t_error find_binary(t_spawn_info *info, t_process *process)
|
|||
return (string_free(s), ERROR);
|
||||
}
|
||||
|
||||
static void cleanup(t_spawn_info info, t_process *process, bool cleanup_process)
|
||||
static void cleanup(t_spawn_info info, t_process *process, \
|
||||
bool cleanup_process)
|
||||
{
|
||||
if (cleanup_process && process->stdin.tag != INVALID)
|
||||
close(process->stdin.vals.ro.fd);
|
||||
|
|
@ -123,7 +124,7 @@ static void cleanup(t_spawn_info info, t_process *process, bool cleanup_process)
|
|||
mem_free(info.binary_path);
|
||||
}
|
||||
|
||||
t_error spawn_process(t_spawn_info info, t_process *process)
|
||||
t_error spawn_process(t_spawn_info info, t_process *process)
|
||||
{
|
||||
if (handle_redirections(&info, process))
|
||||
return (cleanup(info, process, true), ERROR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue