From 511a7809cd1a212c03118cb2ab1af169631958d5 Mon Sep 17 00:00:00 2001 From: Kamal Marhubi Date: Mon, 15 Feb 2016 00:40:19 -0500 Subject: [PATCH] unix: Add mkstemp(3) and related functions --- src/unix/bsd/freebsdlike/mod.rs | 3 ++- src/unix/bsd/openbsdlike/mod.rs | 2 ++ src/unix/mod.rs | 3 +++ src/unix/notbsd/linux/mod.rs | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 73b6df96..011cf867 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -640,7 +640,8 @@ extern { pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; - + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index ea116fbf..490e8056 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -389,6 +389,8 @@ extern { pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c56246a3..f2dbf7fa 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -678,6 +678,9 @@ extern { pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int; pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; + pub fn mkstemp(template: *mut ::c_char) -> ::c_int; + pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; + pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; } cfg_if! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index a02efadd..510a33d0 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -540,6 +540,8 @@ extern { pub fn unshare(flags: ::c_int) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; } cfg_if! {