diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-04-04 13:22:18 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-04-04 14:23:00 +0200 |
commit | f0b3d5166ef1255fac880b146875ef46d2599a13 (patch) | |
tree | 61c993cf32dedc1172bcf40cd5207e05a3b032a9 /src/c/stdio.rs | |
parent | 52b498494534784c77bfa4a93706be40620ebd9a (diff) | |
download | neco-f0b3d5166ef1255fac880b146875ef46d2599a13.tar neco-f0b3d5166ef1255fac880b146875ef46d2599a13.zip |
Reorganize
Diffstat (limited to 'src/c/stdio.rs')
-rw-r--r-- | src/c/stdio.rs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/c/stdio.rs b/src/c/stdio.rs deleted file mode 100644 index c878f19..0000000 --- a/src/c/stdio.rs +++ /dev/null @@ -1,42 +0,0 @@ -use core::fmt; - -use super::posix; -use super::string; - -pub struct OStream { - file: *mut libc::FILE -} - -pub unsafe fn stdout() -> OStream { - OStream { file: posix::stdout } -} - -pub unsafe fn stderr() -> OStream { - OStream { file: posix::stderr } -} - -impl OStream { - pub fn write(&mut self, b: &[u8]) { - unsafe { - libc::fwrite( - b.as_ptr() as *const libc::c_void, - 1, - b.len(), - self.file, - ); - } - } - - pub fn puts(&mut self, s: &string::CStr) { - unsafe { - libc::fputs(s.as_ptr(), self.file); - } - } -} - -impl fmt::Write for OStream { - fn write_str(&mut self, s: &str) -> fmt::Result { - self.write(s.as_bytes()); - Ok(()) - } -} |