Skip to content

Commit

Permalink
Auto merge of #2389 - devnexen:macos_sysdir_api, r=Amanieu
Browse files Browse the repository at this point in the history
apple add sysdir api
  • Loading branch information
bors committed Sep 5, 2021
2 parents 5fefaf6 + f737126 commit 9ffb4a5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-test/build.rs
Expand Up @@ -234,6 +234,7 @@ fn test_apple(target: &str) {
"stdio.h",
"stdlib.h",
"string.h",
"sysdir.h",
"sys/attr.h",
"sys/clonefile.h",
"sys/event.h",
Expand Down
4 changes: 4 additions & 0 deletions libc-test/semver/apple.txt
Expand Up @@ -1920,6 +1920,10 @@ syscall
sysctl
sysctlbyname
sysctlnametomib
sysdir_get_next_search_path_enumeration
sysdir_search_path_directory_t
sysdir_search_path_domain_mask_t
sysdir_start_search_path_enumeration
telldir
thread_basic_info_t
thread_extended_info_t
Expand Down
63 changes: 63 additions & 0 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -105,6 +105,8 @@ pub type vm_statistics_data_t = vm_statistics;
pub type vm_statistics64_t = *mut vm_statistics64;
pub type vm_statistics64_data_t = vm_statistics64;

pub type sysdir_search_path_enumeration_state = ::c_uint;

pub type CCStatus = i32;
pub type CCCryptorStatus = i32;
pub type CCRNGStatus = ::CCCryptorStatus;
Expand Down Expand Up @@ -140,6 +142,57 @@ impl ::Clone for qos_class_t {
}
}

#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[repr(u32)]
pub enum sysdir_search_path_directory_t {
SYSDIR_DIRECTORY_APPLICATION = 1,
SYSDIR_DIRECTORY_DEMO_APPLICATION = 2,
SYSDIR_DIRECTORY_DEVELOPER_APPLICATION = 3,
SYSDIR_DIRECTORY_ADMIN_APPLICATION = 4,
SYSDIR_DIRECTORY_LIBRARY = 5,
SYSDIR_DIRECTORY_DEVELOPER = 6,
SYSDIR_DIRECTORY_USER = 7,
SYSDIR_DIRECTORY_DOCUMENTATION = 8,
SYSDIR_DIRECTORY_DOCUMENT = 9,
SYSDIR_DIRECTORY_CORESERVICE = 10,
SYSDIR_DIRECTORY_AUTOSAVED_INFORMATION = 11,
SYSDIR_DIRECTORY_DESKTOP = 12,
SYSDIR_DIRECTORY_CACHES = 13,
SYSDIR_DIRECTORY_APPLICATION_SUPPORT = 14,
SYSDIR_DIRECTORY_DOWNLOADS = 15,
SYSDIR_DIRECTORY_INPUT_METHODS = 16,
SYSDIR_DIRECTORY_MOVIES = 17,
SYSDIR_DIRECTORY_MUSIC = 18,
SYSDIR_DIRECTORY_PICTURES = 19,
SYSDIR_DIRECTORY_PRINTER_DESCRIPTION = 20,
SYSDIR_DIRECTORY_SHARED_PUBLIC = 21,
SYSDIR_DIRECTORY_PREFERENCE_PANES = 22,
SYSDIR_DIRECTORY_ALL_APPLICATIONS = 100,
SYSDIR_DIRECTORY_ALL_LIBRARIES = 101,
}
impl ::Copy for sysdir_search_path_directory_t {}
impl ::Clone for sysdir_search_path_directory_t {
fn clone(&self) -> sysdir_search_path_directory_t {
*self
}
}

#[cfg_attr(feature = "extra_traits", derive(Debug))]
#[repr(u32)]
pub enum sysdir_search_path_domain_mask_t {
SYSDIR_DOMAIN_MASK_USER = (1 << 0),
SYSDIR_DOMAIN_MASK_LOCAL = (1 << 1),
SYSDIR_DOMAIN_MASK_NETWORK = (1 << 2),
SYSDIR_DOMAIN_MASK_SYSTEM = (1 << 3),
SYSDIR_DOMAIN_MASK_ALL = 0x0ffff,
}
impl ::Copy for sysdir_search_path_domain_mask_t {}
impl ::Clone for sysdir_search_path_domain_mask_t {
fn clone(&self) -> sysdir_search_path_domain_mask_t {
*self
}
}

s! {
pub struct ip_mreq {
pub imr_multiaddr: in_addr,
Expand Down Expand Up @@ -4971,6 +5024,16 @@ extern "C" {
) -> ::kern_return_t;

pub static mut mach_task_self_: mach_port_t;

// sysdir.h
pub fn sysdir_start_search_path_enumeration(
dir: sysdir_search_path_directory_t,
domainMask: sysdir_search_path_domain_mask_t,
) -> ::sysdir_search_path_enumeration_state;
pub fn sysdir_get_next_search_path_enumeration(
state: ::sysdir_search_path_enumeration_state,
path: *mut ::c_char,
) -> ::sysdir_search_path_enumeration_state;
}

pub unsafe fn mach_task_self() -> mach_port_t {
Expand Down

0 comments on commit 9ffb4a5

Please sign in to comment.