Skip to content

Commit

Permalink
Add bindings for iconv calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Minoru committed Jan 17, 2021
1 parent bb8fe9a commit ac6ec1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libc-test/build.rs
Expand Up @@ -106,6 +106,7 @@ fn test_apple(target: &str) {
"fcntl.h",
"glob.h",
"grp.h",
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"limits.h",
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -554,6 +556,7 @@ fn test_redox(target: &str) {
"errno.h",
"fcntl.h",
"grp.h",
"iconv.h",
"limits.h",
"locale.h",
"netdb.h",
Expand Down Expand Up @@ -614,6 +617,7 @@ fn test_solarish(target: &str) {
"fcntl.h",
"glob.h",
"grp.h",
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"limits.h",
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -1325,6 +1331,7 @@ fn test_android(target: &str) {
"errno.h",
"fcntl.h",
"grp.h",
"iconv.h",
"ifaddrs.h",
"limits.h",
"locale.h",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1600,6 +1607,7 @@ fn test_freebsd(target: &str) {
"fcntl.h",
"glob.h",
"grp.h",
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"libutil.h",
Expand Down Expand Up @@ -1906,6 +1914,7 @@ fn test_emscripten(target: &str) {
"fcntl.h",
"glob.h",
"grp.h",
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"limits.h",
Expand Down Expand Up @@ -2270,6 +2279,7 @@ fn test_linux(target: &str) {
"fcntl.h",
"glob.h",
"grp.h",
"iconv.h",
"ifaddrs.h",
"langinfo.h",
"limits.h",
Expand Down
14 changes: 14 additions & 0 deletions src/unix/mod.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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! {
Expand Down

0 comments on commit ac6ec1c

Please sign in to comment.