use crate::rubysys::{
io_buffer::rb_off_t,
types::{c_char, c_int, Argc, EncodingType, Value},
};
pub const RUBY_IO_READABLE: c_int = 0x001;
pub const RUBY_IO_PRIORITY: c_int = 0x002;
pub const RUBY_IO_WRITABLE: c_int = 0x004;
pub const FMODE_READABLE: c_int = 0x0000_0001;
pub const FMODE_WRITABLE: c_int = 0x0000_0002;
pub const FMODE_READWRITE: c_int = FMODE_READABLE | FMODE_WRITABLE;
pub const FMODE_BINMODE: c_int = 0x0000_0004;
pub const FMODE_SYNC: c_int = 0x0000_0008;
pub const FMODE_TTY: c_int = 0x0000_0010;
pub const FMODE_DUPLEX: c_int = 0x0000_0020;
pub const FMODE_APPEND: c_int = 0x0000_0040;
pub const FMODE_CREATE: c_int = 0x0000_0080;
pub const FMODE_EXCL: c_int = 0x0000_0400;
pub const FMODE_TRUNC: c_int = 0x0000_0800;
pub const FMODE_TEXTMODE: c_int = 0x0000_1000;
#[cfg(ruby_gte_3_3)]
pub const FMODE_EXTERNAL: c_int = 0x0001_0000;
pub const FMODE_SETENC_BY_BOM: c_int = 0x0010_0000;
#[cfg(ruby_gte_3_3)]
#[repr(C)]
pub struct rb_io_encoding {
pub enc: EncodingType,
pub enc2: EncodingType,
pub ecflags: c_int,
pub ecopts: Value,
}
#[allow(non_camel_case_types)]
pub type rb_pid_t = crate::rubysys::scheduler::RbPid;
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
pub static rb_cFile: Value;
pub static rb_cIO: Value;
pub static rb_stderr: Value;
pub static rb_stdin: Value;
pub static rb_stdout: Value;
}
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
pub fn rb_dir_getwd() -> Value;
pub fn rb_file_absolute_path(path: Value, directory: Value) -> Value;
pub fn rb_file_dirname(path: Value) -> Value;
pub fn rb_file_expand_path(path: Value, directory: Value) -> Value;
pub fn rb_file_open(path: *const c_char, mode: *const c_char) -> Value;
pub fn rb_file_open_str(path: Value, mode: *const c_char) -> Value;
pub fn rb_find_file(path: Value) -> Value;
pub fn rb_io_addstr(io: Value, string: Value) -> Value;
pub fn rb_io_binmode(io: Value) -> Value;
pub fn rb_io_ascii8bit_binmode(io: Value) -> Value;
#[cfg(ruby_gte_3_3)]
pub fn rb_io_closed_p(io: Value) -> Value;
pub fn rb_io_wait(io: Value, events: Value, timeout: Value) -> Value;
pub fn rb_io_descriptor(io: Value) -> c_int;
#[cfg(ruby_gte_3_3)]
pub fn rb_io_mode(io: Value) -> c_int;
pub fn rb_io_maybe_wait(error: c_int, io: Value, events: Value, timeout: Value) -> Value;
pub fn rb_io_maybe_wait_readable(error: c_int, io: Value, timeout: Value) -> c_int;
pub fn rb_io_maybe_wait_writable(error: c_int, io: Value, timeout: Value) -> c_int;
#[cfg(ruby_gte_3_2)]
pub fn rb_io_timeout(io: Value) -> Value;
#[cfg(ruby_gte_3_2)]
pub fn rb_io_set_timeout(io: Value, timeout: Value) -> Value;
#[cfg(ruby_gte_3_3)]
pub fn rb_io_open_descriptor(
klass: Value,
descriptor: c_int,
mode: c_int,
path: Value,
timeout: Value,
encoding: *mut rb_io_encoding,
) -> Value;
pub fn rb_file_size(file: Value) -> rb_off_t;
pub fn rb_io_close(io: Value) -> Value;
pub fn rb_io_eof(io: Value) -> Value;
pub fn rb_io_flush(io: Value) -> Value;
pub fn rb_io_getbyte(io: Value) -> Value;
pub fn rb_io_gets(io: Value) -> Value;
pub fn rb_io_print(argc: Argc, argv: *const Value, io: Value) -> Value;
pub fn rb_io_puts(argc: Argc, argv: *const Value, io: Value) -> Value;
pub fn rb_io_ungetc(io: Value, character: Value) -> Value;
pub fn rb_io_write(io: Value, string: Value) -> Value;
}
#[cfg(ruby_gte_3_3)]
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
pub fn rb_process_status_wait(pid: rb_pid_t, flags: c_int) -> Value;
}
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
pub fn rb_marshal_dump(object: Value, port: Value) -> Value;
pub fn rb_marshal_load(port: Value) -> Value;
}
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
pub fn rb_feature_provided(feature: *const c_char, loading: *mut *const c_char) -> c_int;
pub fn rb_f_require(object: Value, name: Value) -> Value;
pub fn rb_load(path: Value, wrap: c_int);
pub fn rb_load_protect(path: Value, wrap: c_int, state: *mut c_int);
pub fn rb_provide(feature: *const c_char);
pub fn rb_provided(feature: *const c_char) -> c_int;
pub fn rb_require_string(name: Value) -> Value;
pub fn ruby_incpush(path: *const c_char);
}