the big error refactor

This commit is contained in:
nora 2023-10-03 21:39:32 +02:00
parent 5057c0f977
commit 3829dddcea
19 changed files with 1027 additions and 456 deletions

View file

@ -1,9 +1,9 @@
use core::ffi::{c_char, c_int};
use libuwuc::{
io::{stream::FileStream, traits::WriteCounter, STDERR, STDIN, STDOUT},
error::IntoOkOrErrno,
io::{fd::Fd, stream::FileStream, traits::WriteCounter, STDERR, STDIN, STDOUT},
utils::SharedThinCstr,
error::IntoOkOrErrno
};
#[no_mangle]
@ -11,6 +11,13 @@ pub unsafe extern "C" fn puts(s: *const c_char) -> i32 {
libuwuc::io::puts(s)
}
// RAW FD:
#[no_mangle]
pub unsafe extern "C" fn open(path: SharedThinCstr, flags: i32) -> Fd {
libuwuc::io::fd::open(path, flags).into_ok_or_errno()
}
// PRINTF:
#[no_mangle]
@ -79,6 +86,14 @@ pub static stdout: &FileStream = &FileStream::from_raw_fd(STDOUT);
#[no_mangle]
pub static stderr: &FileStream = &FileStream::from_raw_fd(STDERR);
#[no_mangle]
pub unsafe extern "C" fn fopen<'a>(
pathname: SharedThinCstr,
mode: SharedThinCstr,
) -> Option<&'a FileStream> {
todo!()
}
#[no_mangle]
pub unsafe extern "C" fn fgetc(_stream: *mut FileStream) -> c_int {
todo!()