diff --git a/bzip2.rs b/bzip2.rs index 6964113fe..e8f46ee80 100644 --- a/bzip2.rs +++ b/bzip2.rs @@ -4,8 +4,9 @@ #![allow(unused_assignments)] #![allow(unused_mut)] -use std::ffi::CStr; +use std::ffi::{c_char, CStr}; use std::mem::zeroed; +use std::ptr; use libbzip2_rs_sys::bzlib::{ BZ2_bzRead, BZ2_bzReadClose, BZ2_bzReadGetUnused, BZ2_bzReadOpen, BZ2_bzWrite, @@ -33,7 +34,7 @@ struct UInt64 { #[derive(Copy, Clone)] #[repr(C)] struct zzzz { - name: *mut i8, + name: *mut c_char, link: *mut zzzz, } type Cell = zzzz; @@ -52,12 +53,12 @@ static mut exitValue: i32 = 0; static mut opMode: i32 = 0; static mut srcMode: i32 = 0; static mut longestFileName: i32 = 0; -static mut inName: [i8; 1034] = [0; 1034]; -static mut outName: [i8; 1034] = [0; 1034]; -static mut tmpName: [i8; 1034] = [0; 1034]; -static mut progName: *mut i8 = 0 as *const i8 as *mut i8; -static mut progNameReally: [i8; 1034] = [0; 1034]; -static mut outputHandleJustInCase: *mut FILE = 0 as *const FILE as *mut FILE; +static mut inName: [c_char; 1034] = [0; 1034]; +static mut outName: [c_char; 1034] = [0; 1034]; +static mut tmpName: [c_char; 1034] = [0; 1034]; +static mut progName: *mut c_char = ptr::null_mut(); +static mut progNameReally: [c_char; 1034] = [0; 1034]; +static mut outputHandleJustInCase: *mut FILE = ptr::null_mut(); static mut workFactor: i32 = 0; unsafe fn uInt64_from_UInt32s(mut n: *mut UInt64, mut lo32: u32, mut hi32: u32) { (*n).b[7 as libc::c_int as usize] = @@ -253,8 +254,8 @@ unsafe fn compressStream(mut stream: *mut FILE, mut zStream: *mut FILE) { as *const libc::c_char, ); } else { - let mut buf_nin: [i8; 32] = [0; 32]; - let mut buf_nout: [i8; 32] = [0; 32]; + let mut buf_nin: [c_char; 32] = [0; 32]; + let mut buf_nout: [c_char; 32] = [0; 32]; let mut nbytes_in: UInt64 = UInt64 { b: [0; 8] }; let mut nbytes_out: UInt64 = @@ -1355,7 +1356,7 @@ unsafe fn cleanUpAndFail(mut ec: i32) -> ! { setExit(ec); exit(exitValue); } -unsafe fn panic(mut s: *const i8) -> ! { +unsafe fn panic(mut s: *const c_char) -> ! { fprintf( stderr, b"\n%s: PANIC -- internal consistency error:\n\t%s\n\tThis is a BUG. Please report it at:\n\thttps://gitlab.com/bzip2/bzip2/-/issues\n\0" @@ -1478,7 +1479,7 @@ unsafe fn configError() -> ! { setExit(3 as libc::c_int); exit(exitValue); } -unsafe fn pad(mut s: *mut i8) { +unsafe fn pad(mut s: *mut c_char) { let mut i: i32 = 0; if strlen(s) as i32 >= longestFileName { return; @@ -1489,7 +1490,7 @@ unsafe fn pad(mut s: *mut i8) { i += 1; } } -unsafe fn copyFileName(mut to: *mut i8, mut from: *mut i8) { +unsafe fn copyFileName(mut to: *mut c_char, mut from: *const c_char) { if strlen(from) > (1034 as libc::c_int - 10 as libc::c_int) as libc::size_t { fprintf( stderr, @@ -1506,9 +1507,9 @@ unsafe fn copyFileName(mut to: *mut i8, mut from: *mut i8) { from, (1034 as libc::c_int - 10 as libc::c_int) as libc::size_t, ); - *to.offset((1034 as libc::c_int - 10 as libc::c_int) as isize) = '\0' as i32 as i8; + *to.offset((1034 as libc::c_int - 10 as libc::c_int) as isize) = '\0' as i32 as c_char; } -unsafe fn fileExists(mut name: *mut i8) -> Bool { +unsafe fn fileExists(mut name: *mut c_char) -> Bool { let mut tmp: *mut FILE = fopen(name, b"rb\0" as *const u8 as *const libc::c_char); let mut exists: Bool = (tmp != std::ptr::null_mut::() as *mut FILE) as Bool; if !tmp.is_null() { @@ -1516,7 +1517,7 @@ unsafe fn fileExists(mut name: *mut i8) -> Bool { } exists } -unsafe fn fopen_output_safely(mut name: *mut i8, mut mode: *const libc::c_char) -> *mut FILE { +unsafe fn fopen_output_safely(mut name: *mut c_char, mut mode: *const libc::c_char) -> *mut FILE { let mut fp: *mut FILE = std::ptr::null_mut::(); let mut fh: IntNative = 0; fh = open( @@ -1533,7 +1534,7 @@ unsafe fn fopen_output_safely(mut name: *mut i8, mut mode: *const libc::c_char) } fp } -unsafe fn notAStandardFile(mut name: *mut i8) -> Bool { +unsafe fn notAStandardFile(mut name: *mut c_char) -> Bool { let mut i: IntNative = 0; let mut statBuf: stat = zeroed(); i = lstat(name, &mut statBuf); @@ -1545,7 +1546,7 @@ unsafe fn notAStandardFile(mut name: *mut i8) -> Bool { } 1 as Bool } -unsafe fn countHardLinks(mut name: *mut i8) -> i32 { +unsafe fn countHardLinks(mut name: *mut c_char) -> i32 { let mut i: IntNative = 0; let mut statBuf: stat = zeroed(); i = lstat(name, &mut statBuf); @@ -1555,14 +1556,14 @@ unsafe fn countHardLinks(mut name: *mut i8) -> i32 { (statBuf.st_nlink).wrapping_sub(1) as i32 } static mut fileMetaInfo: stat = unsafe { zeroed() }; -unsafe fn saveInputFileMetaInfo(mut srcName: *mut i8) { +unsafe fn saveInputFileMetaInfo(mut srcName: *mut c_char) { let mut retVal: IntNative = 0; retVal = stat(srcName, core::ptr::addr_of_mut!(fileMetaInfo)); if retVal != 0 as libc::c_int { ioError(); } } -unsafe fn applySavedTimeInfoToOutputFile(mut dstName: *mut i8) { +unsafe fn applySavedTimeInfoToOutputFile(mut dstName: *mut c_char) { let mut retVal: IntNative = 0; let mut uTimBuf: utimbuf = utimbuf { actime: 0, @@ -1583,22 +1584,22 @@ unsafe fn applySavedFileAttrToOutputFile(mut fd: IntNative) { } fchown(fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid); } -unsafe fn containsDubiousChars(_: *mut i8) -> Bool { +unsafe fn containsDubiousChars(_: *mut c_char) -> Bool { 0 } -static mut zSuffix: [*const i8; 4] = [ +static mut zSuffix: [*const c_char; 4] = [ b".bz2\0" as *const u8 as *const libc::c_char, b".bz\0" as *const u8 as *const libc::c_char, b".tbz2\0" as *const u8 as *const libc::c_char, b".tbz\0" as *const u8 as *const libc::c_char, ]; -static mut unzSuffix: [*const i8; 4] = [ +static mut unzSuffix: [*const c_char; 4] = [ b"\0" as *const u8 as *const libc::c_char, b"\0" as *const u8 as *const libc::c_char, b".tar\0" as *const u8 as *const libc::c_char, b".tar\0" as *const u8 as *const libc::c_char, ]; -unsafe fn hasSuffix(mut s: *mut i8, mut suffix: *const i8) -> Bool { +unsafe fn hasSuffix(mut s: *mut c_char, mut suffix: *const c_char) -> Bool { let mut ns: i32 = strlen(s) as i32; let mut nx: i32 = strlen(suffix) as i32; if ns < nx { @@ -1609,15 +1610,19 @@ unsafe fn hasSuffix(mut s: *mut i8, mut suffix: *const i8) -> Bool { } 0 as Bool } -unsafe fn mapSuffix(mut name: *mut i8, mut oldSuffix: *const i8, mut newSuffix: *const i8) -> Bool { +unsafe fn mapSuffix( + mut name: *mut c_char, + mut oldSuffix: *const c_char, + mut newSuffix: *const c_char, +) -> Bool { if hasSuffix(name, oldSuffix) == 0 { return 0 as Bool; } - *name.add((strlen(name)).wrapping_sub(strlen(oldSuffix))) = 0 as libc::c_int as i8; + *name.add((strlen(name)).wrapping_sub(strlen(oldSuffix))) = 0 as libc::c_int as c_char; strcat(name, newSuffix); 1 as Bool } -unsafe fn compress(mut name: *mut i8) { +unsafe fn compress(mut name: *mut c_char) { let mut inStr: *mut FILE = std::ptr::null_mut::(); let mut outStr: *mut FILE = std::ptr::null_mut::(); let mut n: i32 = 0; @@ -1631,11 +1636,11 @@ unsafe fn compress(mut name: *mut i8) { 1 => { copyFileName( inName.as_mut_ptr(), - b"(stdin)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdin)\0" as *const u8 as *const libc::c_char, ); copyFileName( outName.as_mut_ptr(), - b"(stdout)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdout)\0" as *const u8 as *const libc::c_char, ); } 3 => { @@ -1650,7 +1655,7 @@ unsafe fn compress(mut name: *mut i8) { copyFileName(inName.as_mut_ptr(), name); copyFileName( outName.as_mut_ptr(), - b"(stdout)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdout)\0" as *const u8 as *const libc::c_char, ); } _ => {} @@ -1880,7 +1885,7 @@ unsafe fn compress(mut name: *mut i8) { } deleteOutputOnInterrupt = 0 as Bool; } -unsafe fn uncompress(mut name: *mut i8) { +unsafe fn uncompress(mut name: *mut c_char) { let mut current_block: u64; let mut inStr: *mut FILE = std::ptr::null_mut::(); let mut outStr: *mut FILE = std::ptr::null_mut::(); @@ -1898,11 +1903,11 @@ unsafe fn uncompress(mut name: *mut i8) { 1 => { copyFileName( inName.as_mut_ptr(), - b"(stdin)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdin)\0" as *const u8 as *const libc::c_char, ); copyFileName( outName.as_mut_ptr(), - b"(stdout)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdout)\0" as *const u8 as *const libc::c_char, ); } 3 => { @@ -1940,7 +1945,7 @@ unsafe fn uncompress(mut name: *mut i8) { copyFileName(inName.as_mut_ptr(), name); copyFileName( outName.as_mut_ptr(), - b"(stdout)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdout)\0" as *const u8 as *const libc::c_char, ); } _ => {} @@ -2179,7 +2184,7 @@ unsafe fn uncompress(mut name: *mut i8) { } }; } -unsafe fn testf(mut name: *mut i8) { +unsafe fn testf(mut name: *mut c_char) { let mut inStr: *mut FILE = std::ptr::null_mut::(); let mut allOK: Bool = 0; let mut statBuf: stat = zeroed(); @@ -2189,13 +2194,13 @@ unsafe fn testf(mut name: *mut i8) { } copyFileName( outName.as_mut_ptr(), - b"(none)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(none)\0" as *const u8 as *const libc::c_char, ); match srcMode { 1 => { copyFileName( inName.as_mut_ptr(), - b"(stdin)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(stdin)\0" as *const u8 as *const libc::c_char, ); } 3 => { @@ -2308,7 +2313,7 @@ unsafe fn license() { BZ2_bzlibVersion(), ); } -unsafe fn usage(mut fullProgName: *mut i8) { +unsafe fn usage(mut fullProgName: *mut c_char) { fprintf( stderr, b"bzip2, a block-sorting file compressor. Version %s.\n\n usage: %s [flags and input files in any order]\n\n -h --help print this message\n -d --decompress force decompression\n -z --compress force compression\n -k --keep keep (don't delete) input files\n -f --force overwrite existing output files\n -t --test test compressed file integrity\n -c --stdout output to standard out\n -q --quiet suppress noncritical error messages\n -v --verbose be verbose (a 2nd -v gives more)\n -L --license display software version & license\n -V --version display software version & license\n -s --small use less memory (at most 2500k)\n -1 .. -9 set block size to 100k .. 900k\n --fast alias for -1\n --best alias for -9\n\n If invoked as `bzip2', default action is to compress.\n as `bunzip2', default action is to decompress.\n as `bzcat', default action is to decompress to stdout.\n\n If no file names are given, bzip2 compresses or decompresses\n from standard input to standard output. You can combine\n short flags, so `-v -4' means the same as -v4 or -4v, &c.\n\n\0" @@ -2317,7 +2322,7 @@ unsafe fn usage(mut fullProgName: *mut i8) { fullProgName, ); } -unsafe fn redundant(mut flag: *mut i8) { +unsafe fn redundant(mut flag: *mut c_char) { fprintf( stderr, b"%s: %s is redundant in versions 0.9.5 and above\n\0" as *const u8 as *const libc::c_char, @@ -2336,15 +2341,15 @@ unsafe fn myMalloc(mut n: i32) -> *mut libc::c_void { unsafe fn mkCell() -> *mut Cell { let mut c: *mut Cell = std::ptr::null_mut::(); c = myMalloc(core::mem::size_of::() as libc::c_ulong as i32) as *mut Cell; - (*c).name = std::ptr::null_mut::(); + (*c).name = std::ptr::null_mut(); (*c).link = std::ptr::null_mut::(); c } -unsafe fn snocString(mut root: *mut Cell, mut name: *mut i8) -> *mut Cell { +unsafe fn snocString(mut root: *mut Cell, mut name: *mut c_char) -> *mut Cell { if root.is_null() { let mut tmp: *mut Cell = mkCell(); (*tmp).name = myMalloc((5 as libc::c_int as libc::size_t).wrapping_add(strlen(name)) as i32) - as *mut i8; + as *mut c_char; strcpy((*tmp).name, name); tmp } else { @@ -2356,12 +2361,12 @@ unsafe fn snocString(mut root: *mut Cell, mut name: *mut i8) -> *mut Cell { root } } -unsafe fn addFlagsFromEnvVar(mut argList: *mut *mut Cell, mut varName: *mut i8) { +unsafe fn addFlagsFromEnvVar(mut argList: *mut *mut Cell, mut varName: *const c_char) { let mut i: i32 = 0; let mut j: i32 = 0; let mut k: i32 = 0; - let mut envbase: *mut i8 = std::ptr::null_mut::(); - let mut p: *mut i8 = std::ptr::null_mut::(); + let mut envbase: *mut c_char = std::ptr::null_mut(); + let mut p: *mut c_char = std::ptr::null_mut(); envbase = getenv(varName); if !envbase.is_null() { p = envbase; @@ -2390,16 +2395,16 @@ unsafe fn addFlagsFromEnvVar(mut argList: *mut *mut Cell, mut varName: *mut i8) tmpName[j as usize] = *p.offset(j as isize); j += 1; } - tmpName[k as usize] = 0 as libc::c_int as i8; + tmpName[k as usize] = 0 as libc::c_int as c_char; *argList = snocString(*argList, tmpName.as_mut_ptr()); } } } } -unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { +unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut c_char) -> IntNative { let mut i: i32 = 0; let mut j: i32 = 0; - let mut tmp: *mut i8 = std::ptr::null_mut::(); + let mut tmp: *mut c_char = ptr::null_mut(); let mut argList: *mut Cell = std::ptr::null_mut::(); let mut aa: *mut Cell = std::ptr::null_mut::(); let mut decode: Bool = 0; @@ -2438,11 +2443,11 @@ unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { ); copyFileName( inName.as_mut_ptr(), - b"(none)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(none)\0" as *const u8 as *const libc::c_char, ); copyFileName( outName.as_mut_ptr(), - b"(none)\0" as *const u8 as *const libc::c_char as *mut i8, + b"(none)\0" as *const u8 as *const libc::c_char, ); copyFileName( progNameReally.as_mut_ptr(), @@ -2450,10 +2455,10 @@ unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { ); progName = &mut *progNameReally .as_mut_ptr() - .offset(0 as libc::c_int as isize) as *mut i8; + .offset(0 as libc::c_int as isize); tmp = &mut *progNameReally .as_mut_ptr() - .offset(0 as libc::c_int as isize) as *mut i8; + .offset(0 as libc::c_int as isize); while *tmp as libc::c_int != '\0' as i32 { if *tmp as libc::c_int == '/' as i32 { progName = tmp.offset(1 as libc::c_int as isize); @@ -2461,14 +2466,8 @@ unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { tmp = tmp.offset(1); } argList = std::ptr::null_mut::(); - addFlagsFromEnvVar( - &mut argList, - b"BZIP2\0" as *const u8 as *const libc::c_char as *mut i8, - ); - addFlagsFromEnvVar( - &mut argList, - b"BZIP\0" as *const u8 as *const libc::c_char as *mut i8, - ); + addFlagsFromEnvVar(&mut argList, b"BZIP2\0" as *const u8 as *const libc::c_char); + addFlagsFromEnvVar(&mut argList, b"BZIP\0" as *const u8 as *const libc::c_char); i = 1 as libc::c_int; while i <= argc - 1 as libc::c_int { argList = snocString(argList, *argv.offset(i as isize)); @@ -2753,7 +2752,7 @@ unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { } if opMode == 1 as libc::c_int { if srcMode == 1 as libc::c_int { - compress(std::ptr::null_mut::()); + compress(std::ptr::null_mut()); } else { decode = 1 as Bool; aa = argList; @@ -2775,7 +2774,7 @@ unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { } else if opMode == 2 as libc::c_int { unzFailsExist = 0 as Bool; if srcMode == 1 as libc::c_int { - uncompress(std::ptr::null_mut::()); + uncompress(std::ptr::null_mut()); } else { decode = 1 as Bool; aa = argList; @@ -2801,7 +2800,7 @@ unsafe fn main_0(mut argc: IntNative, mut argv: *mut *mut i8) -> IntNative { } else { testFailsExist = 0 as Bool; if srcMode == 1 as libc::c_int { - testf(std::ptr::null_mut::()); + testf(std::ptr::null_mut()); } else { decode = 1 as Bool; aa = argList; @@ -2856,7 +2855,7 @@ fn main() { unsafe { ::std::process::exit(main_0( (args.len() - 1) as IntNative, - args.as_mut_ptr() as *mut *mut i8, + args.as_mut_ptr() as *mut *mut c_char, ) as i32) } } diff --git a/bzip2recover.rs b/bzip2recover.rs index d2d183397..87b240333 100644 --- a/bzip2recover.rs +++ b/bzip2recover.rs @@ -5,6 +5,8 @@ #![allow(unused_assignments)] #![allow(unused_mut)] +use std::ffi::c_char; + use libc::{fprintf, FILE}; use libc::{ @@ -25,11 +27,11 @@ pub struct BitStream { pub handle: *mut FILE, pub buffer: i32, pub buffLive: i32, - pub mode: i8, + pub mode: u8, } -pub static mut inFileName: [i8; 2000] = [0; 2000]; -pub static mut outFileName: [i8; 2000] = [0; 2000]; -pub static mut progName: [i8; 2000] = [0; 2000]; +pub static mut inFileName: [c_char; 2000] = [0; 2000]; +pub static mut outFileName: [c_char; 2000] = [0; 2000]; +pub static mut progName: [c_char; 2000] = [0; 2000]; pub static mut bytesOut: MaybeUInt64 = 0 as libc::c_int as MaybeUInt64; pub static mut bytesIn: MaybeUInt64 = 0 as libc::c_int as MaybeUInt64; unsafe fn readError() { @@ -107,7 +109,7 @@ unsafe fn bsOpenReadStream(mut stream: *mut FILE) -> *mut BitStream { (*bs).handle = stream; (*bs).buffer = 0 as libc::c_int; (*bs).buffLive = 0 as libc::c_int; - (*bs).mode = 'r' as i32 as i8; + (*bs).mode = b'r'; bs } unsafe fn bsOpenWriteStream(mut stream: *mut FILE) -> *mut BitStream { @@ -118,7 +120,7 @@ unsafe fn bsOpenWriteStream(mut stream: *mut FILE) -> *mut BitStream { (*bs).handle = stream; (*bs).buffer = 0 as libc::c_int; (*bs).buffLive = 0 as libc::c_int; - (*bs).mode = 'w' as i32 as i8; + (*bs).mode = b'w'; bs } unsafe fn bsPutBit(mut bs: *mut BitStream, mut bit: i32) { @@ -152,7 +154,7 @@ unsafe fn bsGetBit(mut bs: *mut BitStream) -> i32 { } unsafe fn bsClose(mut bs: *mut BitStream) { let mut retVal: i32 = 0; - if (*bs).mode as libc::c_int == 'w' as i32 { + if (*bs).mode == b'w' { while (*bs).buffLive < 8 as libc::c_int { (*bs).buffLive += 1; (*bs).buffer <<= 1 as libc::c_int; @@ -169,7 +171,7 @@ unsafe fn bsClose(mut bs: *mut BitStream) { } retVal = fclose((*bs).handle); if retVal == -1 as libc::c_int { - if (*bs).mode as libc::c_int == 'w' as i32 { + if (*bs).mode == b'w' { writeError(); } else { readError(); @@ -196,7 +198,7 @@ unsafe fn bsPutUInt32(mut bs: *mut BitStream, mut c: u32) { i -= 1; } } -unsafe fn endsInBz2(mut name: *mut i8) -> Bool { +unsafe fn endsInBz2(mut name: *mut c_char) -> Bool { let mut n: i32 = strlen(name) as i32; if n <= 4 as libc::c_int { return 0 as Bool; @@ -206,7 +208,7 @@ unsafe fn endsInBz2(mut name: *mut i8) -> Bool { && *name.offset((n - 2 as libc::c_int) as isize) as libc::c_int == 'z' as i32 && *name.offset((n - 1 as libc::c_int) as isize) as libc::c_int == '2' as i32) as Bool } -unsafe fn fopen_output_safely(mut name: *mut i8, mut mode: *const libc::c_char) -> *mut FILE { +unsafe fn fopen_output_safely(mut name: *mut c_char, mut mode: *const libc::c_char) -> *mut FILE { let mut fp: *mut FILE = std::ptr::null_mut::(); let mut fh: libc::c_int = 0; fh = open( @@ -227,7 +229,7 @@ pub static mut bStart: [MaybeUInt64; 50000] = [0; 50000]; pub static mut bEnd: [MaybeUInt64; 50000] = [0; 50000]; pub static mut rbStart: [MaybeUInt64; 50000] = [0; 50000]; pub static mut rbEnd: [MaybeUInt64; 50000] = [0; 50000]; -unsafe fn main_0(mut argc: i32, mut argv: *mut *mut i8) -> i32 { +unsafe fn main_0(mut argc: i32, mut argv: *mut *mut c_char) -> i32 { let mut inFile: *mut FILE = std::ptr::null_mut::(); let mut outFile: *mut FILE = std::ptr::null_mut::(); let mut bsIn: *mut BitStream = std::ptr::null_mut::(); @@ -240,14 +242,14 @@ unsafe fn main_0(mut argc: i32, mut argv: *mut *mut i8) -> i32 { let mut buffHi: u32 = 0; let mut buffLo: u32 = 0; let mut blockCRC: u32 = 0; - let mut p: *mut i8 = std::ptr::null_mut::(); + let mut p: *mut c_char = std::ptr::null_mut(); strncpy( progName.as_mut_ptr(), *argv.offset(0 as libc::c_int as isize), (2000 as libc::c_int - 1 as libc::c_int) as usize, ); - progName[(2000 as libc::c_int - 1 as libc::c_int) as usize] = '\0' as i32 as i8; - outFileName[0 as libc::c_int as usize] = 0 as libc::c_int as i8; + progName[(2000 as libc::c_int - 1 as libc::c_int) as usize] = '\0' as i32 as c_char; + outFileName[0 as libc::c_int as usize] = 0 as libc::c_int as c_char; inFileName[0 as libc::c_int as usize] = outFileName[0 as libc::c_int as usize]; fprintf( stderr, @@ -463,12 +465,12 @@ unsafe fn main_0(mut argc: i32, mut argv: *mut *mut i8) -> i32 { } wrBlock += 1; } else if bitsRead == rbStart[wrBlock as usize] { - let mut split: *mut i8 = std::ptr::null_mut::(); + let mut split: *mut c_char = std::ptr::null_mut(); let mut ofs: i32 = 0; let mut k: i32 = 0; k = 0 as libc::c_int; while k < 2000 as libc::c_int { - outFileName[k as usize] = 0 as libc::c_int as i8; + outFileName[k as usize] = 0 as libc::c_int as c_char; k += 1; } strcpy(outFileName.as_mut_ptr(), inFileName.as_mut_ptr()); @@ -487,7 +489,7 @@ unsafe fn main_0(mut argc: i32, mut argv: *mut *mut i8) -> i32 { p = split; while *p != 0 { if *p as libc::c_int == ' ' as i32 { - *p = '0' as i32 as i8; + *p = '0' as i32 as c_char; } p = p.offset(1); } @@ -553,7 +555,7 @@ pub fn main() { unsafe { ::std::process::exit(main_0( (args.len() - 1) as i32, - args.as_mut_ptr() as *mut *mut i8, + args.as_mut_ptr() as *mut *mut c_char, )) } } diff --git a/bzlib.rs b/bzlib.rs index d760815b8..b2c2cd377 100644 --- a/bzlib.rs +++ b/bzlib.rs @@ -1788,7 +1788,7 @@ pub unsafe extern "C" fn BZ2_bzWrite( (*bzf).strm.next_in = buf as *mut libc::c_char; loop { (*bzf).strm.avail_out = 5000 as libc::c_int as libc::c_uint; - (*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr(); + (*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr().cast::(); ret = BZ2_bzCompress(&mut (*bzf).strm, 0 as libc::c_int); if ret != 1 as libc::c_int { if !bzerror.is_null() { @@ -1902,7 +1902,7 @@ pub unsafe extern "C" fn BZ2_bzWriteClose64( if abandon == 0 && (*bzf).lastErr == 0 as libc::c_int { loop { (*bzf).strm.avail_out = 5000 as libc::c_int as libc::c_uint; - (*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr(); + (*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr().cast::(); ret = BZ2_bzCompress(&mut (*bzf).strm, 2 as libc::c_int); if ret != 3 as libc::c_int && ret != 4 as libc::c_int { if !bzerror.is_null() { @@ -2052,7 +2052,7 @@ pub unsafe extern "C" fn BZ2_bzReadOpen( return std::ptr::null_mut::(); } (*bzf).strm.avail_in = (*bzf).bufN as libc::c_uint; - (*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr(); + (*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr().cast::(); (*bzf).initialisedOk = true; bzf as *mut libc::c_void } @@ -2162,7 +2162,7 @@ pub unsafe extern "C" fn BZ2_bzRead( } (*bzf).bufN = n; (*bzf).strm.avail_in = (*bzf).bufN as libc::c_uint; - (*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr(); + (*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr().cast::(); } ret = BZ2_bzDecompress(&mut (*bzf).strm); if ret != 0 as libc::c_int && ret != 4 as libc::c_int {