update stuff

This commit is contained in:
Maix0 2024-05-20 00:35:39 +02:00
parent 5973022688
commit 544ed8b045
194 changed files with 2060 additions and 1464 deletions

View file

@ -6,16 +6,18 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/07 13:08:52 by maiboyer #+# #+# */
/* Updated: 2024/05/16 17:12:46 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 17:08:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/fs/fs.h"
#include "me/mem/_allocator.h"
#include "me/types.h"
#include <stdlib.h>
void me_exit(t_i32 exit_code)
{
close_all_fds();
uninit_global_allocator();
exit(exit_code);
}

View file

@ -6,17 +6,17 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/03 16:22:41 by maiboyer #+# #+# */
/* Updated: 2024/05/18 18:33:53 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 14:57:20 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/os/process.h"
#include "me/buffered_str/buf_str.h"
#include "me/string/string.h"
#include "me/mem/mem.h"
#include "me/os/pipe.h"
#include "me/string/str_find_chr.h"
#include "me/string/str_n_compare.h"
#include "me/string/str_split.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include <stdio.h>
@ -53,21 +53,21 @@ t_error spawn_process_exec(t_spawn_info info, t_process *process)
}
t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
t_buffer_str *s)
t_string *s)
{
t_str *splitted_path;
t_usize sp_index;
splitted_path = str_split(path + 5, ':');
if (splitted_path == NULL)
return (str_free(*s), ERROR);
return (string_free(*s), ERROR);
sp_index = 0;
while (splitted_path[sp_index])
{
((void)(process), str_clear(s));
push_str_buffer(s, splitted_path[sp_index]);
push_str_buffer(s, "/");
push_str_buffer(s, info->binary_path);
((void)(process), string_clear(s));
string_push(s, splitted_path[sp_index]);
string_push(s, "/");
string_push(s, info->binary_path);
sp_index++;
if (access(s->buf, X_OK | R_OK) == 0)
break;
@ -82,20 +82,19 @@ t_error in_path(t_spawn_info *info, t_process *process, t_const_str path,
t_error find_binary(t_spawn_info *info, t_process *process)
{
t_usize p_idx;
t_buffer_str s;
t_string s;
(void)(process);
if (info->binary_path == NULL)
return (ERROR);
s = alloc_new_buffer(256);
s = string_new(256);
if (str_start_with(info->binary_path, "/") ||
str_find_chr(info->binary_path, '/') != NULL)
push_str_buffer(&s, info->binary_path);
string_push(&s, info->binary_path);
else
{
if (vec_str_find(&info->environement, find_path, &p_idx))
return (str_free(s), ERROR);
printf("finding in path\n");
return (string_free(s), ERROR);
if (in_path(info, process, info->environement.buffer[p_idx], &s))
return (ERROR);
}
@ -105,7 +104,7 @@ t_error find_binary(t_spawn_info *info, t_process *process)
info->binary_path = s.buf;
return (NO_ERROR);
}
return (str_free(s), ERROR);
return (string_free(s), ERROR);
}
static void cleanup(t_spawn_info info, t_process *process, bool cleanup_process)

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/04 22:25:44 by maiboyer #+# #+# */
/* Updated: 2024/05/18 18:38:01 by maiboyer ### ########.fr */
/* Updated: 2024/05/19 14:51:07 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,7 +36,6 @@ bool find_path(const t_str *s)
if (*s == NULL)
return (false);
ss = *s;
printf("%s\n", ss);
return (ss[0] == 'P' && ss[1] == 'A' && ss[2] == 'T' && ss[3] == 'H' &&
ss[4] == '=');
}