FreeBSD fixes

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2024-08-04 11:04:23 +02:00
parent b73c78d2fb
commit 7b9f03176d
2 changed files with 13 additions and 7 deletions

View File

@@ -41,8 +41,9 @@ pub const grp = @cImport({
@cInclude("grp.h");
});
// FreeBSD-specific headers
// FreeBSD-specific headers (except for pwd.h)
pub const logincap = @cImport({
@cInclude("pwd.h");
@cInclude("login_cap.h");
});
@@ -60,6 +61,11 @@ pub const vt = @cImport({
@cInclude("sys/vt.h");
});
// On FreeBSD, login_cap.h references the passwd struct directly, so we must use logincap.passwd instead
pub const passwd = if (builtin.os.tag == .freebsd) logincap.passwd else pwd.passwd;
pub const endpwent = if (builtin.os.tag == .freebsd) logincap.endpwent else pwd.endpwent;
pub const getpwnam = if (builtin.os.tag == .freebsd) logincap.getpwnam else pwd.getpwnam;
// Used for getting & setting the lock state
const LedState = if (builtin.os.tag.isBSD()) c_int else c_char;
const get_led_state = if (builtin.os.tag.isBSD()) kbio.KDGETLED else kd.KDGKBLED;