comparison src/macros.rs @ 59:3f4a77aa88be

Fix string copyting and improve error situation. This change is too big and includes several things: - Fix copying strings from PAM by fixing const and mut on pam funcs. - Improve error enums by simplifying conversions and removing unnecessary and ambiguous "success" variants. - Make a bunch of casts nicer. - Assorted other cleanup.
author Paul Fisher <paul@pfish.zone>
date Wed, 21 May 2025 00:27:18 -0400
parents daa2cde64601
children
comparison
equal deleted inserted replaced
58:868a278a362c 59:3f4a77aa88be
34 ($ident:ident) => { 34 ($ident:ident) => {
35 pub use self::pam_hooks_scope::*; 35 pub use self::pam_hooks_scope::*;
36 mod pam_hooks_scope { 36 mod pam_hooks_scope {
37 use std::ffi::CStr; 37 use std::ffi::CStr;
38 use std::os::raw::{c_char, c_int}; 38 use std::os::raw::{c_char, c_int};
39 use $crate::constants::{Flags, ErrorCode}; 39 use $crate::constants::{ErrorCode, Flags};
40 use $crate::module::{PamHandle, PamHooks}; 40 use $crate::module::{PamHandle, PamHooks};
41 41
42 fn extract_argv<'a>(argc: c_int, argv: *const *const c_char) -> Vec<&'a CStr> { 42 fn extract_argv<'a>(argc: c_int, argv: *const *const c_char) -> Vec<&'a CStr> {
43 (0..argc) 43 (0..argc)
44 .map(|o| unsafe { CStr::from_ptr(*argv.offset(o as isize) as *const c_char) }) 44 .map(|o| unsafe { CStr::from_ptr(*argv.offset(o as isize) as *const c_char) })