Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binding to SCDynamicStoreKey.h #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ FRAMEWORK_PATH="$SDK_PATH/System/Library/Frameworks/"
PREFERENCES_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCPreferences.h"
DYNAMIC_STORE_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCDynamicStore.h"
DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCDynamicStoreCopySpecific.h"
DYNAMIC_STORE_KEY_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCDynamicStoreKey.h"
NETWORK_CONFIGURATION_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCNetworkConfiguration.h"
NETWORK_REACHABILITY_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCNetworkReachability.h"
SCHEMA_DEFINITIONS_HEADER_PATH="$FRAMEWORK_PATH/SystemConfiguration.framework/Headers/SCSchemaDefinitions.h"

PREFERENCES_BINDING_PATH="./system-configuration-sys/src/preferences.rs"
DYNAMIC_STORE_BINDING_PATH="./system-configuration-sys/src/dynamic_store.rs"
DYNAMIC_STORE_COPY_SPECIFIC_BINDING_PATH="./system-configuration-sys/src/dynamic_store_copy_specific.rs"
DYNAMIC_STORE_KEY_BINDING_PATH="./system-configuration-sys/src/dynamic_store_key.rs"
NETWORK_CONFIGURATION_BINDING_PATH="./system-configuration-sys/src/network_configuration.rs"
NETWORK_REACHABILITY_BINDING_PATH="./system-configuration-sys/src/network_reachability.rs"
SCHEMA_DEFINITIONS_BINDING_PATH="./system-configuration-sys/src/schema_definitions.rs"
Expand Down Expand Up @@ -137,6 +139,24 @@ bindgen \

cleanup_binding $DYNAMIC_STORE_BINDING_PATH

echo ""
echo ""
echo "Generating bindings for $DYNAMIC_STORE_KEY_HEADER_PATH"

bindgen \
"${BINDGEN_COMMON_ARGUMENTS[@]}" \
--allowlist-function "SCDynamicStoreKeyCreate.*" \
--blocklist-type "(__)?CF.*" \
--blocklist-type "dispatch_queue_[ts]" \
--raw-line "use core_foundation_sys::base::CFAllocatorRef;" \
--raw-line "use core_foundation_sys::string::CFStringRef;" \
-o $DYNAMIC_STORE_KEY_BINDING_PATH \
$DYNAMIC_STORE_KEY_HEADER_PATH -- \
-I$SDK_PATH/usr/include \
-F$FRAMEWORK_PATH

cleanup_binding $DYNAMIC_STORE_KEY_BINDING_PATH

echo ""
echo ""
echo "Generating bindings for $DYNAMIC_STORE_COPY_SPECIFIC_HEADER_PATH"
Expand Down Expand Up @@ -215,7 +235,7 @@ bindgen \
--blocklist-type "Boolean" \
--blocklist-type "dispatch_.*" \
--blocklist-type "(sockaddr|socklen_t|sa_family_t|__darwin_socklen_t|__uint.*_t)" \
--raw-line '#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]' \
--raw-line '#![cfg_attr(feature = "clippy", allow(clippy::unreadable_literal))]' \
--raw-line "use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFTypeID, CFIndex};" \
--raw-line "use core_foundation_sys::string::CFStringRef;" \
--raw-line "use core_foundation_sys::runloop::CFRunLoopRef;" \
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/dynamic_store.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.66.1 */
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.66.1
// macOS SDK 13.3.
// bindgen 0.69.4
// macOS SDK 14.5.

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/dynamic_store_copy_specific.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.66.1 */
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.66.1
// macOS SDK 13.3.
// bindgen 0.69.4
// macOS SDK 14.5.

use crate::dynamic_store::SCDynamicStoreRef;
use core_foundation_sys::dictionary::CFDictionaryRef;
Expand Down
48 changes: 48 additions & 0 deletions system-configuration-sys/src/dynamic_store_key.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.69.4
// macOS SDK 14.5.

use core_foundation_sys::base::CFAllocatorRef;
use core_foundation_sys::string::CFStringRef;

extern "C" {
pub fn SCDynamicStoreKeyCreate(allocator: CFAllocatorRef, fmt: CFStringRef, ...)
-> CFStringRef;

pub fn SCDynamicStoreKeyCreateNetworkGlobalEntity(
allocator: CFAllocatorRef,
domain: CFStringRef,
entity: CFStringRef,
) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateNetworkInterface(
allocator: CFAllocatorRef,
domain: CFStringRef,
) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateNetworkInterfaceEntity(
allocator: CFAllocatorRef,
domain: CFStringRef,
ifname: CFStringRef,
entity: CFStringRef,
) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateNetworkServiceEntity(
allocator: CFAllocatorRef,
domain: CFStringRef,
serviceID: CFStringRef,
entity: CFStringRef,
) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateComputerName(allocator: CFAllocatorRef) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateConsoleUser(allocator: CFAllocatorRef) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateHostNames(allocator: CFAllocatorRef) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateLocation(allocator: CFAllocatorRef) -> CFStringRef;

pub fn SCDynamicStoreKeyCreateProxies(allocator: CFAllocatorRef) -> CFStringRef;
}
1 change: 1 addition & 0 deletions system-configuration-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub type dispatch_queue_t = *mut libc::c_void;

pub mod dynamic_store;
pub mod dynamic_store_copy_specific;
pub mod dynamic_store_key;
pub mod network_configuration;
pub mod network_reachability;
pub mod preferences;
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/network_configuration.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.66.1 */
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.66.1
// macOS SDK 13.3.
// bindgen 0.69.4
// macOS SDK 14.5.

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
Expand Down
8 changes: 4 additions & 4 deletions system-configuration-sys/src/network_reachability.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* automatically generated by rust-bindgen 0.66.1 */
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.66.1
// macOS SDK 13.3.
// bindgen 0.69.4
// macOS SDK 14.5.

#![cfg_attr(feature = "cargo-clippy", allow(clippy::unreadable_literal))]
#![cfg_attr(feature = "clippy", allow(clippy::unreadable_literal))]
use crate::dispatch_queue_t;
use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
use core_foundation_sys::runloop::CFRunLoopRef;
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/preferences.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.66.1 */
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.66.1
// macOS SDK 13.3.
// bindgen 0.69.4
// macOS SDK 14.5.

use core::ffi::c_void;
use core_foundation_sys::array::CFArrayRef;
Expand Down
6 changes: 3 additions & 3 deletions system-configuration-sys/src/schema_definitions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* automatically generated by rust-bindgen 0.66.1 */
/* automatically generated by rust-bindgen 0.69.4 */

// Generated using:
// bindgen 0.66.1
// macOS SDK 13.3.
// bindgen 0.69.4
// macOS SDK 14.5.

use core_foundation_sys::string::CFStringRef;

Expand Down
3 changes: 1 addition & 2 deletions system-configuration/src/network_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ mod test {
assert!(service_order.iter().all(|service_id| {
services
.iter()
.find(|service| service.id().as_ref() == Some(&*service_id))
.is_some()
.any(|service| service.id().as_ref() == Some(&*service_id))
}))
}

Expand Down
2 changes: 1 addition & 1 deletion system-configuration/src/network_reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ mod test {

// Can only testify that an empty string is invalid, everything else seems to work
assert!(
!SCNetworkReachability::from_host(&get_cstring("")).is_some(),
SCNetworkReachability::from_host(&get_cstring("")).is_none(),
"Constructed valid SCNetworkReachability from empty string"
);
}
Expand Down