diff --git a/allocator/src/me_alloc/functions1.c b/allocator/src/me_alloc/functions1.c index e732693f..b525cb57 100644 --- a/allocator/src/me_alloc/functions1.c +++ b/allocator/src/me_alloc/functions1.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/14 18:02:12 by maiboyer #+# #+# */ -/* Updated: 2024/05/23 14:35:35 by maiboyer ### ########.fr */ +/* Updated: 2024/05/24 13:54:11 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/flake.nix b/flake.nix index 1dd13fb4..f468d7a1 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ readline.dev generic_c.packages.${system}.default llvmPackages.bintools + norminette ]; VALGRIND_INC_OPT = "${pkgs.valgrind.dev}/include"; ASAN_OPTIONS = "strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"; diff --git a/includes/type_rust.h b/includes/type_rust.h index 61296343..33bc1822 100644 --- a/includes/type_rust.h +++ b/includes/type_rust.h @@ -34,7 +34,7 @@ typedef size_t t_usize; typedef float t_f32; typedef double t_f64; -typedef int t_file; +typedef int int; typedef bool t_error; diff --git a/sources/signal_handler.c b/sources/signal_handler.c index fd51fb86..638a5626 100644 --- a/sources/signal_handler.c +++ b/sources/signal_handler.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/02 13:22:14 by maiboyer #+# #+# */ -/* Updated: 2024/05/09 21:31:42 by maiboyer ### ########.fr */ +/* Updated: 2024/05/23 17:07:03 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,36 +19,24 @@ void sigint_handle(int sig, siginfo_t *info, void *ucontext) { - static int count = 0; (void)(sig); (void)(info); (void)(ucontext); - count++; printf("\n"); rl_replace_line("", 0); rl_on_new_line(); rl_redisplay(); - if (count == 10) - { - exit(1); - } } void sigquit_handle(int sig, siginfo_t *info, void *ucontext) { - static int count = 0; (void)(sig); (void)(info); (void)(ucontext); - count++; printf("\n"); rl_replace_line("", 0); rl_on_new_line(); rl_redisplay(); - if (count == 10) - { - exit(1); - } } void sigsegv_handle(int sig, siginfo_t *info, void *ucontext) @@ -74,7 +62,7 @@ t_error install_signal(void) data.sa_sigaction = sigquit_handle; if (sigaction(SIGQUIT, &data, NULL)) return (ERROR); - + // data.sa_sigaction = sigsegv_handle; // if (sigaction(SIGSEGV, &data, NULL)) // return (ERROR); diff --git a/stdme/include/me/fs/close.h b/stdme/include/me/fs/close.h index c764d795..8bedd585 100644 --- a/stdme/include/me/fs/close.h +++ b/stdme/include/me/fs/close.h @@ -15,6 +15,6 @@ # include "me/types.h" -bool me_close(t_file file, t_i32 *error); +bool me_close(int file, t_i32 *error); #endif diff --git a/stdme/include/me/fs/fs.h b/stdme/include/me/fs/fs.h index 47ee0081..ed402abf 100644 --- a/stdme/include/me/fs/fs.h +++ b/stdme/include/me/fs/fs.h @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/19 15:12:18 by maiboyer #+# #+# */ -/* Updated: 2024/05/19 17:08:38 by maiboyer ### ########.fr */ +/* Updated: 2024/05/24 15:03:40 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,10 +15,11 @@ #include "me/types.h" #include +#include #include #include -#if !defined(FILE_SLOT_LEN) || FILE_SLOT_LEN < 64 +#if (!defined(FILE_SLOT_LEN)) || FILE_SLOT_LEN < 64 # ifdef FILE_SLOT_LEN # undef FILE_SLOT_LEN # endif @@ -47,9 +48,37 @@ typedef enum e_fd_perm FD_WRITE = 1 << 1, } t_fd_perm; +typedef enum e_file_open_option +{ + FD_CREATE = O_CREAT, + FD_EXCLUSIVE = O_EXCL, + FD_CLOSE_ON_EXEC = O_CLOEXEC, + FD_TRUNCATE = O_TRUNC, + FD_NON_BLOCKING = O_NONBLOCK, +} t_file_open_option; + +typedef enum e_file_perm +{ + FP_OEXEC = 1 << 0, + FP_OWRITE = 1 << 1, + FP_OREAD = 1 << 2, + FP_GEXEC = 1 << 3, + FP_GWRITE = 1 << 3, + FP_GREAD = 1 << 5, + FP_UEXEC = 1 << 6, + FP_UWRITE = 1 << 7, + FP_UREAD = 1 << 8, + + FP_ALL_READ = FP_UREAD | FP_GREAD | FP_OREAD, + FP_ALL_WRITE = FP_UWRITE | FP_GWRITE | FP_OWRITE, + FP_ALL_EXEC = FP_UEXEC | FP_GEXEC | FP_OEXEC, + FP_DEFAULT = FP_UWRITE | FP_ALL_READ, + FP_DEFAULT_EXEC = FP_UWRITE | FP_ALL_EXEC | FP_ALL_READ, +} t_file_perm; + typedef struct s_fd { - char *name; + t_str name; int fd; t_fd_perm perms; t_fd_type type; @@ -58,19 +87,19 @@ typedef struct s_fd typedef struct s_dir { DIR *ptr; - char *name; + t_str name; } t_dir; -typedef struct s_file_data +typedef struct s_file { FILE *ptr; - char *name; -} t_file_data; + t_str name; +} t_file; union u_file_slot { - t_fd fd; - t_dir dir; - t_file_data file; + t_fd fd; + t_dir dir; + t_file file; }; struct s_file_slot @@ -84,8 +113,26 @@ typedef struct s_fd_array struct s_file_slot storage[FILE_SLOT_LEN]; } t_fd_array; +typedef struct stat t_stat; + +typedef struct dirent *t_dir_entry; + +/// @brief Get the fd arrays object +/// @return fd_arrays +/// @note internal function used to get the fd arrays t_fd_array *get_fd_arrays(void); struct s_file_slot *get_unused_fd_slot(void); -void close_all_fds(void); +void close_all_slots(void); +void close_slot(struct s_file_slot *slot); +t_fd *open_fd(t_str name, t_fd_perm perms, t_file_open_option open_options, + t_file_perm file_perm); +t_error read_fd(t_fd *fd, t_u8 *buffer, t_usize size, t_isize *read_count); +t_error write_fd(t_fd *fd, t_u8 *buffer, t_usize size, t_isize *read_count); +t_error stat_fd(t_fd *fd, t_stat *stat); +void close_fd(t_fd *fd); + +t_error open_dir(t_str name, t_dir *dir); +t_error read_dir(t_dir *dir, t_dir_entry *out); +t_error close_dir(t_dir *dir); #endif /* FS_H */ diff --git a/stdme/include/me/fs/open.h b/stdme/include/me/fs/open.h index 1f2f8f05..29204d0c 100644 --- a/stdme/include/me/fs/open.h +++ b/stdme/include/me/fs/open.h @@ -15,8 +15,8 @@ # include "me/types.h" -t_error me_open(t_const_str path, bool read, bool write, t_file *file_out); -t_error me_open_truncate(t_const_str path, t_file *file_out); -t_error me_open_create(t_const_str path, t_file *file_out); +t_error me_open(t_const_str path, bool read, bool write, int *file_out); +t_error me_open_truncate(t_const_str path, int *file_out); +t_error me_open_create(t_const_str path, int *file_out); #endif diff --git a/stdme/include/me/fs/putchar_fd.h b/stdme/include/me/fs/putchar_fd.h index 03039ac6..ed8e4532 100644 --- a/stdme/include/me/fs/putchar_fd.h +++ b/stdme/include/me/fs/putchar_fd.h @@ -15,6 +15,6 @@ # include "me/types.h" -void me_putchar_fd(char chr, t_file file); +void me_putchar_fd(char chr, int file); #endif diff --git a/stdme/include/me/fs/putendl_fd.h b/stdme/include/me/fs/putendl_fd.h index 0325e1ef..b4455e66 100644 --- a/stdme/include/me/fs/putendl_fd.h +++ b/stdme/include/me/fs/putendl_fd.h @@ -15,6 +15,6 @@ # include "me/types.h" -void me_putendl_fd(t_str str, t_file file); +void me_putendl_fd(t_str str, int file); #endif \ No newline at end of file diff --git a/stdme/include/me/fs/putnbr_fd.h b/stdme/include/me/fs/putnbr_fd.h index 933e945e..8a0b58f3 100644 --- a/stdme/include/me/fs/putnbr_fd.h +++ b/stdme/include/me/fs/putnbr_fd.h @@ -15,6 +15,6 @@ # include "me/types.h" -void me_putnbr_fd(t_i32 n, t_file file); +void me_putnbr_fd(t_i32 n, int file); #endif \ No newline at end of file diff --git a/stdme/include/me/fs/putstr_fd.h b/stdme/include/me/fs/putstr_fd.h index 5ada2228..67b0f436 100644 --- a/stdme/include/me/fs/putstr_fd.h +++ b/stdme/include/me/fs/putstr_fd.h @@ -15,6 +15,6 @@ # include "me/types.h" -void me_putstr_fd(t_str str, t_file file); +void me_putstr_fd(t_str str, int file); #endif diff --git a/stdme/include/me/fs/read.h b/stdme/include/me/fs/read.h index 7fc2cd76..24cc2b59 100644 --- a/stdme/include/me/fs/read.h +++ b/stdme/include/me/fs/read.h @@ -15,6 +15,6 @@ # include "me/types.h" -t_usize me_read(t_file fd, t_u8 *buffer, t_i64 buffer_max, bool *eof_out); +t_usize me_read(int fd, t_u8 *buffer, t_i64 buffer_max, bool *eof_out); #endif \ No newline at end of file diff --git a/stdme/include/me/fs/write.h b/stdme/include/me/fs/write.h index 66ea307e..fec32afb 100644 --- a/stdme/include/me/fs/write.h +++ b/stdme/include/me/fs/write.h @@ -15,6 +15,6 @@ # include "me/types.h" -bool me_write(t_file fd, t_u8 *buffer, t_i64 size); +bool me_write(int fd, t_u8 *buffer, t_i64 size); #endif diff --git a/stdme/include/me/gnl/gnl.h b/stdme/include/me/gnl/gnl.h index 85501e5e..12961a67 100644 --- a/stdme/include/me/gnl/gnl.h +++ b/stdme/include/me/gnl/gnl.h @@ -26,7 +26,7 @@ typedef struct s_static_buffer { - t_file fd; + int fd; bool used; char buf[BUFFER_SIZE + 1]; bool init; @@ -38,6 +38,6 @@ typedef struct s_copy_flags bool empty_read; } t_copy_flags; -t_string get_next_line(t_file fd, bool *error); +t_string get_next_line(int fd, bool *error); #endif diff --git a/stdme/include/me/os/pipe.h b/stdme/include/me/os/pipe.h index 764e54c6..c8350f94 100644 --- a/stdme/include/me/os/pipe.h +++ b/stdme/include/me/os/pipe.h @@ -18,8 +18,8 @@ /// @brief Pipe structure typedef struct s_pipe { - t_file read; - t_file write; + int read; + int write; } t_pipe; /// @brief Create a pipe diff --git a/stdme/include/me/os/process.h b/stdme/include/me/os/process.h index 68e04b83..95ca6628 100644 --- a/stdme/include/me/os/process.h +++ b/stdme/include/me/os/process.h @@ -31,7 +31,7 @@ union u_redirection { struct s_fd { - t_file value; + int value; } fd; struct s_piped { @@ -71,7 +71,7 @@ static inline t_redirection inherited(void) /// @brief Create a file descriptor redirection /// @param fd file descriptor to redirect /// @return the redirection -static inline t_redirection fd(t_file fd) +static inline t_redirection fd(int fd) { return ((t_redirection){.tag = R_FD, \ .vals = (union u_redirection){.fd = {.value = fd},}}); @@ -91,15 +91,15 @@ union u_wrapped_fd { struct s_read_only { - t_file fd; + int fd; } ro; struct s_write_only { - t_file fd; + int fd; } wo; struct s_read_write { - t_file fd; + int fd; } rw; }; @@ -113,7 +113,7 @@ typedef struct s_wrapped_fd /// @brief Create a Read only wrapped file descriptor /// @param fd file descriptor to wrap /// @return the wrapped file descriptor -static inline t_wrapped_fd ro(t_file fd) +static inline t_wrapped_fd ro(int fd) { return ((t_wrapped_fd){.tag = READ_ONLY, .vals = (union u_wrapped_fd){ @@ -124,7 +124,7 @@ static inline t_wrapped_fd ro(t_file fd) /// @brief Create a Write only wrapped file descriptor /// @param fd file descriptor to wrap /// @return the wrapped file descriptor -static inline t_wrapped_fd wo(t_file fd) +static inline t_wrapped_fd wo(int fd) { return ((t_wrapped_fd){.tag = WRITE_ONLY, .vals = (union u_wrapped_fd){.wo = {.fd = fd}}}); diff --git a/stdme/include/me/printf/printf.h b/stdme/include/me/printf/printf.h index 070f3383..8040512a 100644 --- a/stdme/include/me/printf/printf.h +++ b/stdme/include/me/printf/printf.h @@ -19,7 +19,7 @@ typedef struct s_fprintf_arg { t_usize total_print; - t_file fd; + int fd; } t_fprintf_arg; typedef enum e_printf_flags diff --git a/stdme/include/me/types.h b/stdme/include/me/types.h index 315b38c0..fdf69688 100644 --- a/stdme/include/me/types.h +++ b/stdme/include/me/types.h @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/03 14:31:12 by maiboyer #+# #+# */ -/* Updated: 2024/05/16 16:12:21 by maiboyer ### ########.fr */ +/* Updated: 2024/05/24 14:45:04 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -53,8 +53,6 @@ typedef float t_f32; /// @brief a 64 bit floating point number typedef double t_f64; -/// @brief a file descriptor -typedef int t_file; /// @brief a boolean value that represents an error /// @note true is an error, false is no error typedef bool t_error; diff --git a/stdme/src/fs/close.c b/stdme/src/fs/close.c index 1b4ef622..4aa2d127 100644 --- a/stdme/src/fs/close.c +++ b/stdme/src/fs/close.c @@ -14,7 +14,7 @@ #include "me/types.h" #include -bool me_close(t_file file, t_i32 *error) +bool me_close(int file, t_i32 *error) { t_i32 res; bool out; diff --git a/stdme/src/fs/fd_array_buffer.c b/stdme/src/fs/fd_array_buffer.c index 96afb4ed..1ab68951 100644 --- a/stdme/src/fs/fd_array_buffer.c +++ b/stdme/src/fs/fd_array_buffer.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/19 15:53:50 by maiboyer #+# #+# */ -/* Updated: 2024/05/19 17:05:40 by maiboyer ### ########.fr */ +/* Updated: 2024/05/24 14:44:45 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,7 +40,7 @@ struct s_file_slot *get_unused_fd_slot(void) return (NULL); } -void close_all_fds(void) +void close_all_slots(void) { t_usize i; t_fd_array *arr; @@ -48,18 +48,28 @@ void close_all_fds(void) arr = get_fd_arrays(); i = 0; while (i < FILE_SLOT_LEN) - { - if (arr->storage[i].ty == SLOT_UNUSED) - ; - else if (arr->storage[i].ty == SLOT_FD) - close(arr->storage[i].slot.fd.fd); - else if (arr->storage[i].ty == SLOT_DIR) - closedir(arr->storage[i].slot.dir.ptr); - else if (arr->storage[i].ty == SLOT_FILE) - fclose(arr->storage[i].slot.file.ptr); - else - write(2, "Unknown SLOT type", 17); - mem_set_zero(&arr->storage[i], sizeof(arr->storage[i])); - i++; - } + close_slot(&arr->storage[i++]); +} + +void close_slot(struct s_file_slot *slot) +{ + if (slot == NULL) + return; + if (slot->ty == SLOT_UNUSED) + ; + else if (slot->ty == SLOT_FD) + close(slot->slot.fd.fd); + else if (slot->ty == SLOT_DIR) + closedir(slot->slot.dir.ptr); + else if (slot->ty == SLOT_FILE) + fclose(slot->slot.file.ptr); + else + write(2, "Unknown SLOT type", 17); + mem_set_zero(slot, sizeof(*slot)); +} + +t_fd *me_open(char *pathname, t_fd_perm permission, + t_file_open_option open_options, t_file_perm fileperm) +{ + return (NULL); } diff --git a/stdme/src/fs/open.c b/stdme/src/fs/open.c index 96d6200a..8586dbda 100644 --- a/stdme/src/fs/open.c +++ b/stdme/src/fs/open.c @@ -13,9 +13,9 @@ #include "me/fs/open.h" #include -t_error me_open(t_const_str path, bool read, bool write, t_file *file_out) +t_error me_open(t_const_str path, bool read, bool write, int *file_out) { - t_file out; + int out; int flags; flags = 0; @@ -32,9 +32,9 @@ t_error me_open(t_const_str path, bool read, bool write, t_file *file_out) return (NO_ERROR); } -t_error me_open_truncate(t_const_str path, t_file *file_out) +t_error me_open_truncate(t_const_str path, int *file_out) { - t_file out; + int out; int flags; unlink(path); @@ -46,9 +46,9 @@ t_error me_open_truncate(t_const_str path, t_file *file_out) return (NO_ERROR); } -t_error me_open_create(t_const_str path, t_file *file_out) +t_error me_open_create(t_const_str path, int *file_out) { - t_file out; + int out; int flags; flags = O_WRONLY | O_CREAT | O_APPEND; diff --git a/stdme/src/fs/putchar_fd.c b/stdme/src/fs/putchar_fd.c index 68d41139..bc7984b6 100644 --- a/stdme/src/fs/putchar_fd.c +++ b/stdme/src/fs/putchar_fd.c @@ -14,7 +14,7 @@ #include "me/fs/write.h" #include "me/str/str.h" -void me_putchar_fd(char chr, t_file file) +void me_putchar_fd(char chr, int file) { me_write(file, (t_u8 *)&chr, 1); } diff --git a/stdme/src/fs/putendl_fd.c b/stdme/src/fs/putendl_fd.c index fa854f3d..ec2ef59e 100644 --- a/stdme/src/fs/putendl_fd.c +++ b/stdme/src/fs/putendl_fd.c @@ -14,7 +14,7 @@ #include "me/fs/write.h" #include "me/str/str.h" -void me_putendl_fd(t_str str, t_file file) +void me_putendl_fd(t_str str, int file) { if (str == NULL) return ; diff --git a/stdme/src/fs/putnbr_fd.c b/stdme/src/fs/putnbr_fd.c index e4746103..3df671e1 100644 --- a/stdme/src/fs/putnbr_fd.c +++ b/stdme/src/fs/putnbr_fd.c @@ -34,7 +34,7 @@ static void me_inner(t_u64 nb, t_str out, t_usize *idx) } } -void me_putnbr_fd(t_i32 n, t_file file) +void me_putnbr_fd(t_i32 n, int file) { t_usize idx; t_i64 nb; diff --git a/stdme/src/fs/putstr_fd.c b/stdme/src/fs/putstr_fd.c index 749e2df2..f07992ae 100644 --- a/stdme/src/fs/putstr_fd.c +++ b/stdme/src/fs/putstr_fd.c @@ -14,7 +14,7 @@ #include "me/fs/write.h" #include "me/str/str.h" -void me_putstr_fd(t_str str, t_file file) +void me_putstr_fd(t_str str, int file) { if (str == NULL) return ; diff --git a/stdme/src/fs/read.c b/stdme/src/fs/read.c index 6635d6be..e0cde15e 100644 --- a/stdme/src/fs/read.c +++ b/stdme/src/fs/read.c @@ -13,7 +13,7 @@ #include "me/fs/read.h" #include -t_usize me_read(t_file fd, t_u8 *buffer, t_i64 buffer_max, bool *eof_out) +t_usize me_read(int fd, t_u8 *buffer, t_i64 buffer_max, bool *eof_out) { ssize_t out; diff --git a/stdme/src/fs/read_to_vec.c b/stdme/src/fs/read_to_vec.c index 29830aa4..5ec6699c 100644 --- a/stdme/src/fs/read_to_vec.c +++ b/stdme/src/fs/read_to_vec.c @@ -21,7 +21,7 @@ bool read_to_vec(t_const_str path, t_vec_u8 *out) { t_u8 temp_buffer[READ_BUFFER_SIZE]; t_isize read_amount; - t_file f; + int f; bool eof; t_usize current_size; diff --git a/stdme/src/fs/write.c b/stdme/src/fs/write.c index a51e5fe7..60d86386 100644 --- a/stdme/src/fs/write.c +++ b/stdme/src/fs/write.c @@ -13,7 +13,7 @@ #include "me/fs/write.h" #include -bool me_write(t_file fd, t_u8 *buffer, t_i64 size) +bool me_write(int fd, t_u8 *buffer, t_i64 size) { return (write(fd, buffer, size) < 0); } diff --git a/stdme/src/gnl/get_next_line.c b/stdme/src/gnl/get_next_line.c index 77b00b70..d6b44a78 100644 --- a/stdme/src/gnl/get_next_line.c +++ b/stdme/src/gnl/get_next_line.c @@ -20,7 +20,7 @@ #include #include -static t_static_buffer *get_next_line_buffer(t_file fd) +static t_static_buffer *get_next_line_buffer(int fd) { t_usize index; static t_static_buffer bufs[BUFFER_LENGTH] = {0}; @@ -35,7 +35,7 @@ static t_static_buffer *get_next_line_buffer(t_file fd) return (&bufs[index]); } -static bool copy_next_line_into_buffer(t_file fd, t_string *out, +static bool copy_next_line_into_buffer(int fd, t_string *out, char *temp_buffer, t_usize amount) { char *buf; @@ -60,7 +60,7 @@ static bool copy_next_line_into_buffer(t_file fd, t_string *out, return (got_newline); } -static bool read_and_copy(t_file fd, t_string *out, char *tmp, +static bool read_and_copy(int fd, t_string *out, char *tmp, t_copy_flags *flags) { t_isize amount; @@ -82,7 +82,7 @@ static bool read_and_copy(t_file fd, t_string *out, char *tmp, return (copy_next_line_into_buffer(fd, out, tmp, (t_usize)amount)); } -static bool handle_leftovers(t_file fd, char *temp_buffer, t_string *buf) +static bool handle_leftovers(int fd, char *temp_buffer, t_string *buf) { t_static_buffer *static_buffer; @@ -99,7 +99,7 @@ static bool handle_leftovers(t_file fd, char *temp_buffer, t_string *buf) return (false); } -t_string get_next_line(t_file fd, bool *error) +t_string get_next_line(int fd, bool *error) { t_string buf; char *temp_buffer; diff --git a/stdme/src/img/qoi/qoi_fs.c b/stdme/src/img/qoi/qoi_fs.c index b16708cf..db38b414 100644 --- a/stdme/src/img/qoi/qoi_fs.c +++ b/stdme/src/img/qoi/qoi_fs.c @@ -21,7 +21,7 @@ t_i32 qoi_write(t_const_str filename, const void *data, const t_qoi_desc *desc) { - t_file f; + int f; void *encoded; t_i32 size; diff --git a/stdme/src/os/pipe.c b/stdme/src/os/pipe.c index c046fdf7..4916cfe5 100644 --- a/stdme/src/os/pipe.c +++ b/stdme/src/os/pipe.c @@ -14,7 +14,7 @@ t_error create_pipe(t_pipe *out) { - t_file fds[2]; + int fds[2]; if (pipe(fds)) return (ERROR);