aboutsummaryrefslogtreecommitdiff
path: root/lib/std/c.zig
diff options
context:
space:
mode:
authorChinmay Dalal <dalal.chinmay.0101@gmail.com>2025-07-31 20:52:56 +0530
committerAlex Rønne Petersen <alex@alexrp.com>2025-08-01 04:34:45 +0200
commita2d21d63270ebb5eec0d437f7726c261455da66b (patch)
treefa268a946085dd214aa63e29454c9119e486b0c5 /lib/std/c.zig
parent0294e91451ba8fb06a40cbd0d3da80e2792f5923 (diff)
downloadzig-a2d21d63270ebb5eec0d437f7726c261455da66b.tar.gz
zig-a2d21d63270ebb5eec0d437f7726c261455da66b.zip
enable pwd.h functions for other OSes
also add the layout of `struct passwd` for DragonflyBSD and FreeBSD: - https://github.com/DragonFlyBSD/DragonFlyBSD/blob/c267aac0072dae6cf4ae874605f3f0659a2fc820/include/pwd.h#L112 - https://cgit.freebsd.org/src/tree/include/pwd.h?id=d66f9c86fa3fd8d8f0a56ea96b03ca11f2fac1fb#n114
Diffstat (limited to 'lib/std/c.zig')
-rw-r--r--lib/std/c.zig24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/std/c.zig b/lib/std/c.zig
index 818a4ae0cc..6a0289f5f0 100644
--- a/lib/std/c.zig
+++ b/lib/std/c.zig
@@ -204,6 +204,19 @@ pub const passwd = switch (native_os) {
shell: ?[*:0]const u8, // default shell
expire: time_t, // account expiration
},
+ .dragonfly, .freebsd => extern struct {
+ name: ?[*:0]const u8, // user name
+ passwd: ?[*:0]const u8, // encrypted password
+ uid: uid_t, // user uid
+ gid: gid_t, // user gid
+ change: time_t, // password change time
+ class: ?[*:0]const u8, // user access class
+ gecos: ?[*:0]const u8, // Honeywell login info
+ dir: ?[*:0]const u8, // home directory
+ shell: ?[*:0]const u8, // default shell
+ expire: time_t, // account expiration
+ fields: c_int, // internal
+ },
else => void,
};
@@ -10271,9 +10284,13 @@ pub const fstatat = switch (native_os) {
},
else => private.fstatat,
};
-
+pub extern "c" fn getpwent() ?*passwd;
+pub extern "c" fn endpwent() void;
+pub extern "c" fn setpwent() void;
pub extern "c" fn getpwnam(name: [*:0]const u8) ?*passwd;
+pub extern "c" fn getpwnam_r(name: [*:0]const u8, pwd: *passwd, buf: [*]u8, buflen: usize, result: *?*passwd) c_int;
pub extern "c" fn getpwuid(uid: uid_t) ?*passwd;
+pub extern "c" fn getpwuid_r(uid: uid_t, pwd: *passwd, buf: [*]u8, buflen: usize, result: *?*passwd) c_int;
pub extern "c" fn getgrent() ?*group;
pub extern "c" fn setgrent() void;
pub extern "c" fn endgrent() void;
@@ -11009,11 +11026,7 @@ pub const bcrypt = openbsd.bcrypt;
pub const bcrypt_checkpass = openbsd.bcrypt_checkpass;
pub const bcrypt_gensalt = openbsd.bcrypt_gensalt;
pub const bcrypt_newhash = openbsd.bcrypt_newhash;
-pub const endpwent = openbsd.endpwent;
-pub const getpwent = openbsd.getpwent;
-pub const getpwnam_r = openbsd.getpwnam_r;
pub const getpwnam_shadow = openbsd.getpwnam_shadow;
-pub const getpwuid_r = openbsd.getpwuid_r;
pub const getpwuid_shadow = openbsd.getpwuid_shadow;
pub const getthrid = openbsd.getthrid;
pub const login_cap_t = openbsd.login_cap_t;
@@ -11030,7 +11043,6 @@ pub const pthread_spinlock_t = openbsd.pthread_spinlock_t;
pub const pw_dup = openbsd.pw_dup;
pub const setclasscontext = openbsd.setclasscontext;
pub const setpassent = openbsd.setpassent;
-pub const setpwent = openbsd.setpwent;
pub const setusercontext = openbsd.setusercontext;
pub const uid_from_user = openbsd.uid_from_user;
pub const unveil = openbsd.unveil;