From ac6ec1c88e0b3a439703777508cd254bbacb818c Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Sun, 17 Jan 2021 22:43:33 +0300 Subject: [PATCH] Add bindings for iconv calls --- libc-test/build.rs | 12 +++++++++++- src/unix/mod.rs | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index ccbef16c5cd13..031a1f6e87f3d 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -106,6 +106,7 @@ fn test_apple(target: &str) { "fcntl.h", "glob.h", "grp.h", + "iconv.h", "ifaddrs.h", "langinfo.h", "limits.h", @@ -356,6 +357,7 @@ fn test_openbsd(target: &str) { "pthread_np.h", "sys/syscall.h", "sys/shm.h", + "iconv.h", } cfg.skip_struct(move |ty| { @@ -554,6 +556,7 @@ fn test_redox(target: &str) { "errno.h", "fcntl.h", "grp.h", + "iconv.h", "limits.h", "locale.h", "netdb.h", @@ -614,6 +617,7 @@ fn test_solarish(target: &str) { "fcntl.h", "glob.h", "grp.h", + "iconv.h", "ifaddrs.h", "langinfo.h", "limits.h", @@ -889,6 +893,7 @@ fn test_netbsd(target: &str) { "sys/event.h", "sys/quota.h", "sys/shm.h", + "iconv.h", } cfg.type_name(move |ty, is_struct, is_union| { @@ -1096,6 +1101,7 @@ fn test_dragonflybsd(target: &str) { "utime.h", "utmpx.h", "wchar.h", + "iconv.h", } cfg.type_name(move |ty, is_struct, is_union| { @@ -1325,6 +1331,7 @@ fn test_android(target: &str) { "errno.h", "fcntl.h", "grp.h", + "iconv.h", "ifaddrs.h", "limits.h", "locale.h", @@ -1377,8 +1384,8 @@ fn test_android(target: &str) { "sys/syscall.h", "sys/sysinfo.h", "sys/time.h", - "sys/times.h", "sys/timerfd.h", + "sys/times.h", "sys/types.h", "sys/ucontext.h", "sys/uio.h", @@ -1600,6 +1607,7 @@ fn test_freebsd(target: &str) { "fcntl.h", "glob.h", "grp.h", + "iconv.h", "ifaddrs.h", "langinfo.h", "libutil.h", @@ -1906,6 +1914,7 @@ fn test_emscripten(target: &str) { "fcntl.h", "glob.h", "grp.h", + "iconv.h", "ifaddrs.h", "langinfo.h", "limits.h", @@ -2270,6 +2279,7 @@ fn test_linux(target: &str) { "fcntl.h", "glob.h", "grp.h", + "iconv.h", "ifaddrs.h", "langinfo.h", "limits.h", diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 9db5a747d22dd..e1ad78fb96175 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -39,6 +39,7 @@ impl ::Clone for DIR { } } pub type locale_t = *mut ::c_void; +pub type iconv_t = *mut ::c_void; s! { pub struct group { @@ -1542,6 +1543,19 @@ extern "C" { cmd: ::c_int, len: ::off_t, ) -> ::c_int; + + pub fn iconv_open( + tocode: *const ::c_char, + fromcode: *const ::c_char, + ) -> iconv_t; + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut ::c_char, + inbytesleft: *mut ::size_t, + outbuf: *mut *mut ::c_char, + outbytesleft: *mut ::size_t, + ) -> ::size_t; + pub fn iconv_close(cd: iconv_t) -> ::c_int; } cfg_if! {