oxidize: Add pub mod directives and run rustfmt
Makes all translated files part of the crate, and then runs rustfmt on all of them, hopefully making them marginally more bearable.
This commit is contained in:
+21
-23
@@ -50,29 +50,28 @@ pub enum Enum2 {
|
|||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Struct1 {
|
pub struct Struct1 {
|
||||||
pub rc : Enum2,
|
pub rc: Enum2,
|
||||||
pub name : *const u8,
|
pub name: *const u8,
|
||||||
pub description : *const u8,
|
pub description: *const u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Struct1 {
|
impl Clone for Struct1 {
|
||||||
fn clone(&self) -> Self { *self }
|
fn clone(&self) -> Self {
|
||||||
|
*self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut errors
|
static mut errors: *const Struct1 = Enum2::YKPIV_OK as (*const Struct1);
|
||||||
: *const Struct1
|
|
||||||
= Enum2::YKPIV_OK as (*const Struct1);
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern fn ykpiv_strerror(mut err : Enum2) -> *const u8 {
|
pub unsafe extern "C" fn ykpiv_strerror(mut err: Enum2) -> *const u8 {
|
||||||
static mut unknown
|
static mut unknown: *const u8 = (*b"Unknown ykpiv error\0").as_ptr();
|
||||||
: *const u8
|
let mut p: *const u8;
|
||||||
= (*b"Unknown ykpiv error\0").as_ptr();
|
if -(err as (i32)) < 0i32
|
||||||
let mut p : *const u8;
|
|| -(err as (i32))
|
||||||
if -(err as (i32)) < 0i32 || -(err as (i32)) >= ::std::mem::size_of::<*const Struct1>(
|
>= ::std::mem::size_of::<*const Struct1>()
|
||||||
).wrapping_div(
|
.wrapping_div(::std::mem::size_of::<Struct1>()) as (i32)
|
||||||
::std::mem::size_of::<Struct1>()
|
{
|
||||||
) as (i32) {
|
|
||||||
unknown
|
unknown
|
||||||
} else {
|
} else {
|
||||||
p = (*errors.offset(-(err as (i32)) as (isize))).description;
|
p = (*errors.offset(-(err as (i32)) as (isize))).description;
|
||||||
@@ -84,13 +83,12 @@ pub unsafe extern fn ykpiv_strerror(mut err : Enum2) -> *const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern fn ykpiv_strerror_name(
|
pub unsafe extern "C" fn ykpiv_strerror_name(mut err: Enum2) -> *const u8 {
|
||||||
mut err : Enum2
|
if -(err as (i32)) < 0i32
|
||||||
) -> *const u8 {
|
|| -(err as (i32))
|
||||||
if -(err as (i32)) < 0i32 || -(err as (i32)) >= ::std::mem::size_of::<*const Struct1>(
|
>= ::std::mem::size_of::<*const Struct1>()
|
||||||
).wrapping_div(
|
.wrapping_div(::std::mem::size_of::<Struct1>()) as (i32)
|
||||||
::std::mem::size_of::<Struct1>()
|
{
|
||||||
) as (i32) {
|
|
||||||
0i32 as (*mut ::std::os::raw::c_void) as (*const u8)
|
0i32 as (*mut ::std::os::raw::c_void) as (*const u8)
|
||||||
} else {
|
} else {
|
||||||
(*errors.offset(-(err as (i32)) as (isize))).name
|
(*errors.offset(-(err as (i32)) as (isize))).name
|
||||||
|
|||||||
+330
-347
File diff suppressed because it is too large
Load Diff
+1757
-1767
File diff suppressed because it is too large
Load Diff
+1879
-1917
File diff suppressed because it is too large
Load Diff
+44
-47
@@ -25,47 +25,45 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
extern {
|
extern "C" {
|
||||||
fn strcmp(__s1 : *const u8, __s2 : *const u8) -> i32;
|
fn strcmp(__s1: *const u8, __s2: *const u8) -> i32;
|
||||||
fn strcspn(__s : *const u8, __charset : *const u8) -> usize;
|
fn strcspn(__s: *const u8, __charset: *const u8) -> usize;
|
||||||
fn strncmp(__s1 : *const u8, __s2 : *const u8, __n : usize) -> i32;
|
fn strncmp(__s1: *const u8, __s2: *const u8, __n: usize) -> i32;
|
||||||
fn strspn(__s : *const u8, __charset : *const u8) -> usize;
|
fn strspn(__s: *const u8, __charset: *const u8) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern fn my_strverscmp(
|
unsafe extern "C" fn my_strverscmp(mut s1: *const u8, mut s2: *const u8) -> i32 {
|
||||||
mut s1 : *const u8, mut s2 : *const u8
|
|
||||||
) -> i32 {
|
|
||||||
let mut _currentBlock;
|
let mut _currentBlock;
|
||||||
static mut digits : *const u8 = (*b"0123456789\0").as_ptr();
|
static mut digits: *const u8 = (*b"0123456789\0").as_ptr();
|
||||||
let mut p1 : usize;
|
let mut p1: usize;
|
||||||
let mut p2 : usize;
|
let mut p2: usize;
|
||||||
p1 = strcspn(s1,digits);
|
p1 = strcspn(s1, digits);
|
||||||
p2 = strcspn(s2,digits);
|
p2 = strcspn(s2, digits);
|
||||||
'loop1: loop {
|
'loop1: loop {
|
||||||
if !(p1 == p2 && (*s1.offset(
|
if !(p1 == p2
|
||||||
p1 as (isize)
|
&& (*s1.offset(p1 as (isize)) as (i32) != b'\0' as (i32))
|
||||||
) as (i32) != b'\0' as (i32)) && (*s2.offset(
|
&& (*s2.offset(p2 as (isize)) as (i32) != b'\0' as (i32)))
|
||||||
p2 as (isize)
|
{
|
||||||
) as (i32) != b'\0' as (i32))) {
|
|
||||||
_currentBlock = 2;
|
_currentBlock = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let mut ret : i32;
|
let mut ret: i32;
|
||||||
let mut lz1 : i32;
|
let mut lz1: i32;
|
||||||
let mut lz2 : i32;
|
let mut lz2: i32;
|
||||||
if {
|
if {
|
||||||
ret = strncmp(s1,s2,p1);
|
ret = strncmp(s1, s2, p1);
|
||||||
ret
|
ret
|
||||||
} != 0i32 {
|
} != 0i32
|
||||||
|
{
|
||||||
_currentBlock = 37;
|
_currentBlock = 37;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s1 = s1.offset(p1 as (isize));
|
s1 = s1.offset(p1 as (isize));
|
||||||
s2 = s2.offset(p2 as (isize));
|
s2 = s2.offset(p2 as (isize));
|
||||||
lz1 = {
|
lz1 = {
|
||||||
lz2 = 0i32;
|
lz2 = 0i32;
|
||||||
lz2
|
lz2
|
||||||
};
|
};
|
||||||
if *s1 as (i32) == b'0' as (i32) {
|
if *s1 as (i32) == b'0' as (i32) {
|
||||||
lz1 = 1i32;
|
lz1 = 1i32;
|
||||||
}
|
}
|
||||||
@@ -92,8 +90,8 @@ unsafe extern fn my_strverscmp(
|
|||||||
s2 = s2.offset(1isize);
|
s2 = s2.offset(1isize);
|
||||||
_currentBlock = 11;
|
_currentBlock = 11;
|
||||||
} else {
|
} else {
|
||||||
p1 = strspn(s1,digits);
|
p1 = strspn(s1, digits);
|
||||||
p2 = strspn(s2,digits);
|
p2 = strspn(s2, digits);
|
||||||
if p1 == 0usize && (p2 > 0usize) {
|
if p1 == 0usize && (p2 > 0usize) {
|
||||||
_currentBlock = 33;
|
_currentBlock = 33;
|
||||||
break 'loop1;
|
break 'loop1;
|
||||||
@@ -102,7 +100,10 @@ unsafe extern fn my_strverscmp(
|
|||||||
_currentBlock = 32;
|
_currentBlock = 32;
|
||||||
break 'loop1;
|
break 'loop1;
|
||||||
}
|
}
|
||||||
if *s1 as (i32) != *s2 as (i32) && (*s1 as (i32) != b'0' as (i32)) && (*s2 as (i32) != b'0' as (i32)) {
|
if *s1 as (i32) != *s2 as (i32)
|
||||||
|
&& (*s1 as (i32) != b'0' as (i32))
|
||||||
|
&& (*s2 as (i32) != b'0' as (i32))
|
||||||
|
{
|
||||||
if p1 < p2 {
|
if p1 < p2 {
|
||||||
_currentBlock = 31;
|
_currentBlock = 31;
|
||||||
break 'loop1;
|
break 'loop1;
|
||||||
@@ -115,9 +116,9 @@ unsafe extern fn my_strverscmp(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if p1 < p2 {
|
if p1 < p2 {
|
||||||
ret = strncmp(s1,s2,p1);
|
ret = strncmp(s1, s2, p1);
|
||||||
} else if p1 > p2 {
|
} else if p1 > p2 {
|
||||||
ret = strncmp(s1,s2,p2);
|
ret = strncmp(s1, s2, p2);
|
||||||
}
|
}
|
||||||
if ret != 0i32 {
|
if ret != 0i32 {
|
||||||
_currentBlock = 20;
|
_currentBlock = 20;
|
||||||
@@ -128,8 +129,8 @@ unsafe extern fn my_strverscmp(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p1 = strspn(s1,digits);
|
p1 = strspn(s1, digits);
|
||||||
p2 = strspn(s2,digits);
|
p2 = strspn(s2, digits);
|
||||||
if p1 < p2 {
|
if p1 < p2 {
|
||||||
_currentBlock = 29;
|
_currentBlock = 29;
|
||||||
break 'loop1;
|
break 'loop1;
|
||||||
@@ -143,19 +144,20 @@ unsafe extern fn my_strverscmp(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if {
|
if {
|
||||||
ret = strncmp(s1,s2,p1);
|
ret = strncmp(s1, s2, p1);
|
||||||
ret
|
ret
|
||||||
} != 0i32 {
|
} != 0i32
|
||||||
|
{
|
||||||
_currentBlock = 27;
|
_currentBlock = 27;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s1 = s1.offset(p1 as (isize));
|
s1 = s1.offset(p1 as (isize));
|
||||||
s2 = s2.offset(p2 as (isize));
|
s2 = s2.offset(p2 as (isize));
|
||||||
p1 = strcspn(s1,digits);
|
p1 = strcspn(s1, digits);
|
||||||
p2 = strcspn(s2,digits);
|
p2 = strcspn(s2, digits);
|
||||||
}
|
}
|
||||||
if _currentBlock == 2 {
|
if _currentBlock == 2 {
|
||||||
strcmp(s1,s2)
|
strcmp(s1, s2)
|
||||||
} else if _currentBlock == 20 {
|
} else if _currentBlock == 20 {
|
||||||
ret
|
ret
|
||||||
} else if _currentBlock == 27 {
|
} else if _currentBlock == 27 {
|
||||||
@@ -182,13 +184,8 @@ unsafe extern fn my_strverscmp(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern fn ykpiv_check_version(
|
pub unsafe extern "C" fn ykpiv_check_version(mut req_version: *const u8) -> *const u8 {
|
||||||
mut req_version : *const u8
|
if req_version.is_null() || my_strverscmp(req_version, (*b"@VERSION@\0").as_ptr()) <= 0i32 {
|
||||||
) -> *const u8 {
|
|
||||||
if req_version.is_null() || my_strverscmp(
|
|
||||||
req_version,
|
|
||||||
(*b"@VERSION@\0").as_ptr()
|
|
||||||
) <= 0i32 {
|
|
||||||
(*b"@VERSION@\0").as_ptr()
|
(*b"@VERSION@\0").as_ptr()
|
||||||
} else {
|
} else {
|
||||||
0i32 as (*mut ::std::os::raw::c_void) as (*const u8)
|
0i32 as (*mut ::std::os::raw::c_void) as (*const u8)
|
||||||
|
|||||||
Reference in New Issue
Block a user