Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(
- dead_code,
- mutable_transmutes,
- non_camel_case_types,
- non_snake_case,
- non_upper_case_globals,
- unused_mut
- )]
- #![feature(libc)]
- extern crate libc;
- extern "C" {
- #[no_mangle]
- static mut stderr: *mut _IO_FILE;
- #[no_mangle]
- fn fclose(__stream: *mut FILE) -> libc::c_int;
- #[no_mangle]
- fn fopen(__filename: *const libc::c_char, __modes: *const libc::c_char) -> *mut FILE;
- #[no_mangle]
- fn fprintf(_: *mut FILE, _: *const libc::c_char, ...) -> libc::c_int;
- #[no_mangle]
- fn perror(__s: *const libc::c_char);
- #[no_mangle]
- fn __errno_location() -> *mut libc::c_int;
- #[no_mangle]
- fn strerror(_: libc::c_int) -> *mut libc::c_char;
- }
- pub type size_t = libc::c_ulong;
- pub type __off_t = libc::c_long;
- pub type __off64_t = libc::c_long;
- #[derive(Copy, Clone)]
- #[repr(C)]
- pub struct _IO_FILE {
- pub _flags: libc::c_int,
- pub _IO_read_ptr: *mut libc::c_char,
- pub _IO_read_end: *mut libc::c_char,
- pub _IO_read_base: *mut libc::c_char,
- pub _IO_write_base: *mut libc::c_char,
- pub _IO_write_ptr: *mut libc::c_char,
- pub _IO_write_end: *mut libc::c_char,
- pub _IO_buf_base: *mut libc::c_char,
- pub _IO_buf_end: *mut libc::c_char,
- pub _IO_save_base: *mut libc::c_char,
- pub _IO_backup_base: *mut libc::c_char,
- pub _IO_save_end: *mut libc::c_char,
- pub _markers: *mut _IO_marker,
- pub _chain: *mut _IO_FILE,
- pub _fileno: libc::c_int,
- pub _flags2: libc::c_int,
- pub _old_offset: __off_t,
- pub _cur_column: libc::c_ushort,
- pub _vtable_offset: libc::c_schar,
- pub _shortbuf: [libc::c_char; 1],
- pub _lock: *mut libc::c_void,
- pub _offset: __off64_t,
- pub __pad1: *mut libc::c_void,
- pub __pad2: *mut libc::c_void,
- pub __pad3: *mut libc::c_void,
- pub __pad4: *mut libc::c_void,
- pub __pad5: size_t,
- pub _mode: libc::c_int,
- pub _unused2: [libc::c_char; 20],
- }
- pub type _IO_lock_t = ();
- #[derive(Copy, Clone)]
- #[repr(C)]
- pub struct _IO_marker {
- pub _next: *mut _IO_marker,
- pub _sbuf: *mut _IO_FILE,
- pub _pos: libc::c_int,
- }
- pub type FILE = _IO_FILE;
- unsafe fn main_0() -> libc::c_int {
- let mut pf: *mut FILE = 0 as *mut FILE;
- let mut errnum: libc::c_int = 0;
- pf = fopen(
- b"unexist.txt\x00" as *const u8 as *const libc::c_char,
- b"rb\x00" as *const u8 as *const libc::c_char,
- );
- if pf.is_null() {
- errnum = *__errno_location();
- fprintf(
- stderr,
- b"Value of errno: %d\n\x00" as *const u8 as *const libc::c_char,
- *__errno_location(),
- );
- perror(b"Error printed by perror\x00" as *const u8 as *const libc::c_char);
- fprintf(
- stderr,
- b"Error opening file: %s\n\x00" as *const u8 as *const libc::c_char,
- strerror(errnum),
- );
- } else {
- fclose(pf);
- }
- return 0i32;
- }
- pub fn main() {
- unsafe { ::std::process::exit(main_0() as i32) }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement