diff --git a/src/c/stddef.rs b/src/c/stddef.rs index 17e033c..9470882 100644 --- a/src/c/stddef.rs +++ b/src/c/stddef.rs @@ -1,3 +1,7 @@ /// This defines the size_t type. #[allow(non_camel_case_types)] pub type size_t = usize; + +/// This defines the wchar_t type. +#[allow(non_camel_case_types)] +pub type wchar_t = i32; diff --git a/src/c/string.rs b/src/c/string.rs index c4b12ce..cd4540e 100644 --- a/src/c/string.rs +++ b/src/c/string.rs @@ -1,3 +1,8 @@ +use binding::{CChar, CInt}; + +use crate::stddef::{size_t, wchar_t}; + + #[cfg(not(feature="no_mem_manip"))] #[link(name="c")] extern @@ -49,3 +54,36 @@ extern /// to the specified value c (interpreted as an unsigned char). pub fn memset(s: *mut u8, c: i32, n: usize); } + +#[link(name="c")] +extern +{ + pub fn strcpy(dst: *mut CChar, src: *const CChar) -> *mut CChar; + pub fn strncpy(dst: *mut CChar, src: *const CChar, + n: size_t) -> *mut CChar; + pub fn strcat(s: *mut CChar, ct: *const CChar) -> *mut CChar; + pub fn strncat(s: *mut CChar, ct: *const CChar, + n: size_t) -> *mut CChar; + pub fn strcmp(cs: *const CChar, ct: *const CChar) -> CInt; + pub fn strncmp(cs: *const CChar, ct: *const CChar, n: size_t) -> CInt; + pub fn strcoll(cs: *const CChar, ct: *const CChar) -> CInt; + pub fn strchr(cs: *const CChar, c: CInt) -> *mut CChar; + pub fn strrchr(cs: *const CChar, c: CInt) -> *mut CChar; + pub fn strspn(cs: *const CChar, ct: *const CChar) -> size_t; + pub fn strcspn(cs: *const CChar, ct: *const CChar) -> size_t; + pub fn strdup(cs: *const CChar) -> *mut CChar; + pub fn strpbrk(cs: *const CChar, ct: *const CChar) -> *mut CChar; + pub fn strstr(cs: *const CChar, ct: *const CChar) -> *mut CChar; + pub fn strcasecmp(s1: *const CChar, s2: *const CChar) -> CInt; + pub fn strncasecmp(s1: *const CChar, s2: *const CChar, + n: size_t) -> CInt; + pub fn strlen(cs: *const CChar) -> size_t; + pub fn strnlen(cs: *const CChar, maxlen: size_t) -> size_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "strerror$UNIX2003")] + pub fn strerror(n: CInt) -> *mut CChar; + pub fn strtok(s: *mut CChar, t: *const CChar) -> *mut CChar; + pub fn strxfrm(s: *mut CChar, ct: *const CChar, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut CChar, src: *const wchar_t, n: size_t) -> size_t; +}