Skip to content

Commit 6ffc752

Browse files
Árni DagurÁrni Dagur
authored andcommitted
Add renterant shadow functions
1 parent 248c826 commit 6ffc752

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,26 @@ cfg_if! {
10901090
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3;
10911091

10921092
extern "C" {
1093+
pub fn fgetspent_r(
1094+
fp: *mut ::FILE,
1095+
spbuf: *mut ::spwd,
1096+
buf: *mut ::c_char,
1097+
buflen: ::size_t,
1098+
spbufp: *mut *mut ::spwd,
1099+
) -> ::c_int;
1100+
pub fn sgetspent_r(
1101+
s: *const ::c_char,
1102+
spbuf: *mut ::spwd,
1103+
buf: *mut ::c_char,
1104+
buflen: ::size_t,
1105+
spbufp: *mut *mut ::spwd,
1106+
) -> ::c_int;
1107+
pub fn getspent_r(
1108+
spbuf: *mut ::spwd,
1109+
buf: *mut ::c_char,
1110+
buflen: ::size_t,
1111+
spbufp: *mut *mut ::spwd,
1112+
) -> ::c_int;
10931113
pub fn qsort_r(
10941114
base: *mut ::c_void,
10951115
num: ::size_t,

src/unix/linux_like/linux/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,17 @@ extern "C" {
25792579
pub fn endspent();
25802580
pub fn getspent() -> *mut spwd;
25812581

2582-
pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
2582+
pub fn getspnam(name: *const ::c_char) -> *mut spwd;
2583+
// Only `getspnam_r` is implemented for musl, out of all of the reenterant
2584+
// functions from `shadow.h`.
2585+
// https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
2586+
pub fn getspnam_r(
2587+
name: *const ::c_char,
2588+
spbuf: *mut spwd,
2589+
buf: *mut ::c_char,
2590+
buflen: ::size_t,
2591+
spbufp: *mut *mut spwd,
2592+
) -> ::c_int;
25832593

25842594
pub fn shm_open(
25852595
name: *const c_char,

0 commit comments

Comments
 (0)