diff --git a/utshell-0.5/r_general/src/lib.rs b/utshell-0.5/r_general/src/lib.rs index b43c64397a050d244ce47d50d6e3346d455e62bc..a6a68e80bfe20cac00b832b317210897dc5c374d 100644 --- a/utshell-0.5/r_general/src/lib.rs +++ b/utshell-0.5/r_general/src/lib.rs @@ -102,3 +102,273 @@ extern "C" { static mut tilde_additional_suffixes: *mut *mut libc::c_char; fn tilde_expand(_: *const libc::c_char) -> *mut libc::c_char; } + + +pub const _ISalnum: libc::c_int = 8; +pub const _ISalpha: libc::c_int = 1024; +pub const _ISblank: libc::c_int = 1; +pub const _CS_PATH: libc::c_int = 0; +pub const W_HASDOLLAR: libc::c_int = 1 << 0; +pub const W_QUOTED: libc::c_int = 1 << 1; +pub const CBLANK: libc::c_int = 0x2000; +pub const CSHBRK: libc::c_int = 0x0002; +pub const CXQUOTE: libc::c_int = 0x0400; +pub const F_GETFL: libc::c_int = 3; +pub const F_SETFL: libc::c_int = 4; +pub const O_NONBLOCK: libc::c_int = 0o4000; +pub const O_NDELAY: libc::c_int = 0o4000; +pub const F_SETFD: libc::c_int = 2; +pub const FD_CLOEXEC: libc::c_int = 1; +pub const F_GETFD: libc::c_int = 1; +pub const SEEK_CUR: libc::c_int = 1; +pub const ESPIPE: libc::c_int = 29; +pub const O_RDWR: libc::c_int = 0o2; +pub const HIGH_FD_MAX: libc::c_int = 256; +pub const W_OK: libc::c_int = 2; +pub const MP_DOCWD: libc::c_int = 0x02; +pub const MP_RMDOT: libc::c_int = 0x04; +pub const PATH_MAX: libc::c_int = 4096; + +pub type size_t = libc::c_ulong; +pub type __off64_t = libc::c_long; +pub type _IO_lock_t = (); +pub type __off_t = libc::c_long; +pub type __intmax_t = libc::c_long; +pub type __dev_t = libc::c_ulong; +pub type __uid_t = libc::c_uint; +pub type __gid_t = libc::c_uint; +pub type __ino_t = libc::c_ulong; +pub type __mode_t = libc::c_uint; +pub type __nlink_t = libc::c_ulong; +pub type __rlim_t = libc::c_ulong; +pub type __time_t = libc::c_long; +pub type __blksize_t = libc::c_long; +pub type __blkcnt_t = libc::c_long; +pub type __syscall_slong_t = libc::c_long; +pub type __sig_atomic_t = libc::c_int; +pub type gid_t = __gid_t; +pub type uid_t = __uid_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct timespec { + pub tv_sec: __time_t, + pub tv_nsec: __syscall_slong_t, +} +pub type intmax_t = __intmax_t; +pub type sig_atomic_t = __sig_atomic_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct stat { + pub st_dev: __dev_t, + pub st_ino: __ino_t, + pub st_nlink: __nlink_t, + pub st_mode: __mode_t, + pub st_uid: __uid_t, + pub st_gid: __gid_t, + pub __pad0: libc::c_int, + pub st_rdev: __dev_t, + pub st_size: __off_t, + pub st_blksize: __blksize_t, + pub st_blocks: __blkcnt_t, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + pub __glibc_reserved: [__syscall_slong_t; 3], +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct user_info { + pub uid: uid_t, + pub euid: uid_t, + pub gid: gid_t, + pub egid: gid_t, + pub user_name: *mut libc::c_char, + pub shell: *mut libc::c_char, + pub home_dir: *mut libc::c_char, +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct word_desc { + pub word: *mut libc::c_char, + pub flags: libc::c_int, +} +pub type WORD_DESC = word_desc; +pub type rlim_t = __rlim_t; +#[derive(Copy, Clone)] +#[repr(C)] +pub struct C2RustUnnamed_1 { + pub posix_mode_var: *mut libc::c_int, +} +pub type tilde_hook_func_t = unsafe extern "C" fn(*mut libc::c_char) -> *mut libc::c_char; + +#[macro_export] +macro_rules! whitespace { + ($c:expr) => { + ($c as libc::c_int == ' ' as i32 || $c as libc::c_int == '\t' as i32) + }; +} +#[macro_export] +macro_rules! DIGIT { + ($c:expr) => { + ($c as libc::c_int >= '0' as i32 && $c as libc::c_int <= '9' as i32) + }; +} +#[macro_export] +macro_rules! TODIGIT { + ($c:expr) => { + ($c as libc::c_int - '0' as i32) + }; +} +#[macro_export] +macro_rules! savestring { + ($x:expr) => { + strcpy( + libc::malloc((strlen($x as *const libc::c_char) + 1) as usize) as *mut libc::c_char, + $x, + ) as *mut libc::c_char + }; +} +#[macro_export] +macro_rules! IN_CTYPE_DOMAIN { + ($c:expr) => { + 1 as i32 + }; +} +#[macro_export] +macro_rules! ISALPHA { + ($c:expr) => { + IN_CTYPE_DOMAIN!($c) != 0 && isalpha!($c) != 0 as libc::c_int + }; +} +#[macro_export] +macro_rules! isalpha { + ($c:expr) => { + __isctype_f!($c, _ISalpha) + }; +} +#[macro_export] +macro_rules! __isctype_f { + ($c:expr,$type:expr) => { + *(*__ctype_b_loc()).offset($c as libc::c_int as isize) as libc::c_int + & ($type as libc::c_int as libc::c_ushort as libc::c_int) + }; +} +#[macro_export] +macro_rules! legal_variable_starter { + ($c: expr) => { + (ISALPHA!($c) || ($c as i32 == '_' as i32)) + }; +} +#[macro_export] +macro_rules! legal_variable_char { + ($c: expr) => { + (ISALNUM!($c) || ($c as i32 == '_' as i32)) + }; +} +#[macro_export] +macro_rules! ISALNUM { + ($c:expr) => { + IN_CTYPE_DOMAIN!($c) != 0 && isalnum!($c) != 0 as libc::c_int + }; +} +#[macro_export] +macro_rules! isalnum { + ($c:expr) => { + __isctype_f!($c, _ISalnum) + }; +} + +#[macro_export] +macro_rules! STREQ { + ($a:expr, $b:expr) => { + (*$a.offset(0 as libc::c_int as isize) as libc::c_int + == *$b.offset(0 as libc::c_int as isize) as libc::c_int + && strcmp($a, $b) == 0 as libc::c_int) + }; +} + +#[macro_export] +macro_rules! shellblank { + ($c: expr) => { + (*sh_syntaxtab.as_mut_ptr().offset($c) & CBLANK) + }; +} +#[macro_export] +macro_rules! shellbreak { + ($c: expr) => { + (*sh_syntaxtab.as_mut_ptr().offset($c) & CSHBRK) + }; +} +#[macro_export] +macro_rules! shellxquote { + ($c: expr) => { + (*sh_syntaxtab.as_mut_ptr().offset($c) & CXQUOTE) + }; +} +#[macro_export] +macro_rules! shellexp { + ($c: expr) => { + ($c == '$' as i32 || $c == '<' as i32 || $c == '>' as i32) + }; +} +#[macro_export] +macro_rules! isblank { + ($c: expr) => { + (__isctype_f!(($c), _ISblank)) + }; +} +#[macro_export] +macro_rules! SET_CLOSE_ON_EXEC { + ($fd: expr) => { + (fcntl(($fd), F_SETFD, FD_CLOEXEC)) + }; +} +#[macro_export] +macro_rules! S_ISDIR { + ($mode:expr) => { + $mode & 0o170000 as libc::c_uint == 0o40000 as libc::c_uint + }; +} +#[macro_export] +macro_rules! PATHSEP { + ($c: expr) => { + (ISDIRSEP!($c) || ($c) == 0) + }; +} +#[macro_export] +macro_rules! ISDIRSEP { + ($c: expr) => { + (($c) == '/' as i32) + }; +} +#[macro_export] +macro_rules! ABSPATH { + ($c: expr) => { + (*$c.offset(0 as libc::c_int as isize) as libc::c_int == '/' as i32) + }; +} +#[macro_export] +macro_rules! TILDE_END { + ($c: expr) => { + (($c) == '\0' as i32 || ($c) == '/' as i32 || ($c) == ':' as i32) + }; +} +#[macro_export] +macro_rules! QUIT { + () => { + if terminating_signal != 0 { + termsig_handler(terminating_signal); + } + if interrupt_state != 0 { + throw_to_top_level(); + } + }; +} +#[macro_export] +macro_rules! STANDARD_UTILS_PATH { + () => { + (b"/bin:/usr/bin:/usr/sbin:/sbin\0" as *const u8 as *const libc::c_char) + }; +} \ No newline at end of file