objc2-security 0.3.2

Bindings to the Security framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2_core_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationrightrule?language=objc)
pub const kAuthorizationRightRule: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"rule\0") };
/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationruleisadmin?language=objc)
pub const kAuthorizationRuleIsAdmin: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"is-admin\0") };
/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationruleauthenticateassessionuser?language=objc)
pub const kAuthorizationRuleAuthenticateAsSessionUser: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"authenticate-session-owner\0") };
/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationruleauthenticateasadmin?language=objc)
pub const kAuthorizationRuleAuthenticateAsAdmin: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"authenticate-admin\0") };
/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationruleclassallow?language=objc)
pub const kAuthorizationRuleClassAllow: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"allow\0") };
/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationruleclassdeny?language=objc)
pub const kAuthorizationRuleClassDeny: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"deny\0") };
/// [Apple's documentation](https://developer.apple.com/documentation/security/kauthorizationcomment?language=objc)
pub const kAuthorizationComment: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"comment\0") };
extern "C-unwind" {
    /// Retrieves a right definition as a dictionary.  There are no restrictions to keep anyone from retrieving these definitions.
    ///
    ///
    /// Parameter `rightName`: (input) the rightname (ASCII).  Wildcard rightname definitions are okay.
    ///
    /// Parameter `rightDefinition`: (output/optional) the dictionary with all keys defining the right.  See documented keys.  Passing in NULL will just check if there is a definition.  The caller is responsible for releasing the returned dictionary.
    ///
    ///
    /// Returns: errAuthorizationSuccess 0 No error.
    ///
    /// errAuthorizationDenied -60005 No definition found.
    ///
    /// # Safety
    ///
    /// - `right_name` must be a valid pointer.
    /// - `right_definition` must be a valid pointer or null.
    pub fn AuthorizationRightGet(
        right_name: NonNull<c_char>,
        right_definition: *mut *const CFDictionary,
    ) -> OSStatus;
}

extern "C-unwind" {
    /// Create or update a right entry.  Only normal rights can be registered (wildcard rights are denied); wildcard rights are considered to be put in by an administrator putting together a site configuration.
    ///
    ///
    /// Parameter `authRef`: (input) authRef to authorize modifications.
    ///
    /// Parameter `rightName`: (input) the rightname (ASCII).  Wildcard rightnames are not okay.
    ///
    /// Parameter `rightDefinition`: (input) a CFString of the name of a rule to use (delegate) or CFDictionary containing keys defining one.
    ///
    /// Parameter `descriptionKey`: (input/optional) a CFString to use as a key for looking up localized descriptions.  If no localization is found this will be the description itself.
    ///
    /// Parameter `bundle`: (input/optional) a bundle to get localizations from if not the main bundle.
    ///
    /// Parameter `localeTableName`: (input/optional) stringtable name to get localizations from.
    ///
    ///
    /// Returns: errAuthorizationSuccess 0 added right definition successfully.
    ///
    /// errAuthorizationDenied -60005 Unable to create or update right definition.
    ///
    /// errAuthorizationCanceled -60006 Authorization was canceled by user.
    ///
    /// errAuthorizationInteractionNotAllowed -60007 Interaction was required but not possible.
    ///
    /// # Safety
    ///
    /// - `auth_ref` must be a valid pointer.
    /// - `right_name` must be a valid pointer.
    /// - `right_definition` should be of the correct type.
    #[cfg(feature = "Authorization")]
    pub fn AuthorizationRightSet(
        auth_ref: AuthorizationRef,
        right_name: NonNull<c_char>,
        right_definition: &CFType,
        description_key: Option<&CFString>,
        bundle: Option<&CFBundle>,
        locale_table_name: Option<&CFString>,
    ) -> OSStatus;
}

extern "C-unwind" {
    /// Request to remove a right from the policy database.
    ///
    ///
    /// Parameter `authRef`: (input) authRef, to be used to authorize this action.
    ///
    /// Parameter `rightName`: (input) the rightname (ASCII).  Wildcard rightnames are not okay.
    ///
    /// # Safety
    ///
    /// - `auth_ref` must be a valid pointer.
    /// - `right_name` must be a valid pointer.
    #[cfg(feature = "Authorization")]
    pub fn AuthorizationRightRemove(
        auth_ref: AuthorizationRef,
        right_name: NonNull<c_char>,
    ) -> OSStatus;
}