|
| 1 | +extern crate libcc2rs; |
| 2 | +use libcc2rs::*; |
| 3 | +use std::cell::RefCell; |
| 4 | +use std::collections::BTreeMap; |
| 5 | +use std::io::prelude::*; |
| 6 | +use std::io::{Read, Seek, Write}; |
| 7 | +use std::os::fd::AsFd; |
| 8 | +use std::rc::{Rc, Weak}; |
| 9 | +pub fn main() { |
| 10 | + std::process::exit(main_0()); |
| 11 | +} |
| 12 | +fn main_0() -> i32 { |
| 13 | + let fd: Value<i32> = Rc::new(RefCell::new({ |
| 14 | + let __mode = match &[].first() { |
| 15 | + Some(__m) => nix::sys::stat::Mode::from_bits_truncate(i32::get(__m) as ::libc::mode_t), |
| 16 | + None => nix::sys::stat::Mode::empty(), |
| 17 | + }; |
| 18 | + match nix::fcntl::open( |
| 19 | + Ptr::from_string_literal(b"/dev/null") |
| 20 | + .to_rust_string() |
| 21 | + .as_str(), |
| 22 | + nix::fcntl::OFlag::from_bits_retain(0), |
| 23 | + __mode, |
| 24 | + ) { |
| 25 | + Ok(__ofd) => FdRegistry::register(__ofd), |
| 26 | + Err(__e) => { |
| 27 | + libcc2rs::cpp2rust_errno().write(__e as i32); |
| 28 | + -1 |
| 29 | + } |
| 30 | + } |
| 31 | + })); |
| 32 | + FdRegistry::close((*fd.borrow())); |
| 33 | + let buf: Value<Box<[u8]>> = Rc::new(RefCell::new( |
| 34 | + (0..4).map(|_| <u8>::default()).collect::<Box<[u8]>>(), |
| 35 | + )); |
| 36 | + let n: Value<isize> = Rc::new(RefCell::new( |
| 37 | + match FdRegistry::with_fd((*fd.borrow()), |__fd| { |
| 38 | + ((buf.as_pointer() as Ptr<u8>) as Ptr<u8>) |
| 39 | + .to_any() |
| 40 | + .reinterpret_cast::<u8>() |
| 41 | + .with_slice_mut(::std::mem::size_of::<[u8; 4]>(), |__buf| { |
| 42 | + nix::unistd::read(__fd, __buf) |
| 43 | + }) |
| 44 | + }) { |
| 45 | + Ok(__n) => __n as isize, |
| 46 | + Err(__e) => { |
| 47 | + libcc2rs::cpp2rust_errno().write(__e as i32); |
| 48 | + -1 |
| 49 | + } |
| 50 | + }, |
| 51 | + )); |
| 52 | + return if ((((*n.borrow()) == (-1_i32 as isize)) as i32) != 0) { |
| 53 | + 0 |
| 54 | + } else { |
| 55 | + 1 |
| 56 | + }; |
| 57 | +} |
0 commit comments