objc2_system_configuration/generated/
SCDynamicStoreCopyDHCPInfo.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2_core_foundation::*;
5
6use crate::*;
7
8#[cfg(feature = "SCDynamicStore")]
9impl SCDynamicStore {
10    /// Copies the DHCP information for the requested serviceID,
11    /// or the primary service if serviceID == NULL.
12    ///
13    /// Parameter `store`: An SCDynamicStoreRef representing the dynamic store session
14    /// that should be used for communication with the server.
15    /// If NULL, a temporary session will be used.
16    ///
17    /// Parameter `serviceID`: A CFStringRef containing the requested service.
18    /// If NULL, returns information for the primary service.
19    ///
20    /// Returns: Returns a dictionary containing DHCP information if successful;
21    /// NULL otherwise.
22    /// Use the DHCPInfoGetOption function to retrieve
23    /// individual options from the returned dictionary.
24    ///
25    /// A non-NULL return value must be released using CFRelease().
26    #[doc(alias = "SCDynamicStoreCopyDHCPInfo")]
27    #[cfg(feature = "SCDynamicStore")]
28    #[inline]
29    pub fn dhcp_info(
30        store: Option<&SCDynamicStore>,
31        service_id: Option<&CFString>,
32    ) -> Option<CFRetained<CFDictionary>> {
33        extern "C-unwind" {
34            fn SCDynamicStoreCopyDHCPInfo(
35                store: Option<&SCDynamicStore>,
36                service_id: Option<&CFString>,
37            ) -> Option<NonNull<CFDictionary>>;
38        }
39        let ret = unsafe { SCDynamicStoreCopyDHCPInfo(store, service_id) };
40        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
41    }
42}
43
44/// Returns a non-NULL CFDataRef containing the DHCP
45/// option data, if present.
46///
47/// Parameter `info`: The non-NULL DHCP information dictionary returned by
48/// calling SCDynamicStoreCopyDHCPInfo.
49///
50/// Parameter `code`: The DHCP option code (see RFC 2132) to return
51/// data for.
52///
53/// Returns: Returns a non-NULL CFDataRef containing the option data;
54/// NULL if the requested option data is not present.
55///
56/// The return value must NOT be released.
57///
58/// # Safety
59///
60/// `info` generics must be of the correct type.
61#[inline]
62pub unsafe extern "C-unwind" fn DHCPInfoGetOptionData(
63    info: &CFDictionary,
64    code: u8,
65) -> Option<CFRetained<CFData>> {
66    extern "C-unwind" {
67        fn DHCPInfoGetOptionData(info: &CFDictionary, code: u8) -> Option<NonNull<CFData>>;
68    }
69    let ret = unsafe { DHCPInfoGetOptionData(info, code) };
70    ret.map(|ret| unsafe { CFRetained::retain(ret) })
71}
72
73/// Returns a CFDateRef corresponding to the lease start time,
74/// if present.
75///
76/// Parameter `info`: The non-NULL DHCP information dictionary returned by
77/// calling SCDynamicStoreCopyDHCPInfo.
78///
79/// Returns: Returns a non-NULL CFDateRef if lease start time information is
80/// present; NULL if the information is not present or if the
81/// configuration method is not DHCP.
82///
83/// The return value must NOT be released.
84///
85/// # Safety
86///
87/// `info` generics must be of the correct type.
88#[inline]
89pub unsafe extern "C-unwind" fn DHCPInfoGetLeaseStartTime(
90    info: &CFDictionary,
91) -> Option<CFRetained<CFDate>> {
92    extern "C-unwind" {
93        fn DHCPInfoGetLeaseStartTime(info: &CFDictionary) -> Option<NonNull<CFDate>>;
94    }
95    let ret = unsafe { DHCPInfoGetLeaseStartTime(info) };
96    ret.map(|ret| unsafe { CFRetained::retain(ret) })
97}
98
99/// Returns a CFDateRef corresponding to the lease expiration time,
100/// if present.
101///
102/// Parameter `info`: The non-NULL DHCP information dictionary returned by
103/// calling SCDynamicStoreCopyDHCPInfo.
104///
105/// Returns: Returns a non-NULL CFDateRef if the DHCP lease has an expiration;
106/// NULL if the lease is infinite i.e. has no expiration, or the
107/// configuration method is not DHCP. An infinite lease can be determined
108/// by a non-NULL lease start time (see DHCPInfoGetLeaseStartTime above).
109///
110/// The return value must NOT be released.
111///
112/// # Safety
113///
114/// `info` generics must be of the correct type.
115#[inline]
116pub unsafe extern "C-unwind" fn DHCPInfoGetLeaseExpirationTime(
117    info: &CFDictionary,
118) -> Option<CFRetained<CFDate>> {
119    extern "C-unwind" {
120        fn DHCPInfoGetLeaseExpirationTime(info: &CFDictionary) -> Option<NonNull<CFDate>>;
121    }
122    let ret = unsafe { DHCPInfoGetLeaseExpirationTime(info) };
123    ret.map(|ret| unsafe { CFRetained::retain(ret) })
124}
125
126#[cfg(feature = "SCDynamicStore")]
127#[deprecated = "renamed to `SCDynamicStore::dhcp_info`"]
128#[inline]
129pub extern "C-unwind" fn SCDynamicStoreCopyDHCPInfo(
130    store: Option<&SCDynamicStore>,
131    service_id: Option<&CFString>,
132) -> Option<CFRetained<CFDictionary>> {
133    extern "C-unwind" {
134        fn SCDynamicStoreCopyDHCPInfo(
135            store: Option<&SCDynamicStore>,
136            service_id: Option<&CFString>,
137        ) -> Option<NonNull<CFDictionary>>;
138    }
139    let ret = unsafe { SCDynamicStoreCopyDHCPInfo(store, service_id) };
140    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
141}