| 1 |
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT |
| 2 |
// file at the top-level directory of this distribution. |
| 3 |
// |
| 4 |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 |
// option. This file may not be copied, modified, or distributed |
| 8 |
// except according to those terms. |
| 9 |
|
| 10 |
use std::os::raw::c_void; |
| 11 |
|
| 12 |
use crate::array::CFArrayRef; |
| 13 |
#[cfg(target_os = "macos")] |
| 14 |
use crate::base::SInt32; |
| 15 |
use crate::base::{Boolean, CFAllocatorRef, CFTypeID, CFTypeRef, UInt32}; |
| 16 |
use crate::dictionary::CFDictionaryRef; |
| 17 |
use crate::error::CFErrorRef; |
| 18 |
use crate::string::CFStringRef; |
| 19 |
use crate::url::CFURLRef; |
| 20 |
use std::os::raw::{c_int, c_uint}; |
| 21 |
|
| 22 |
#[repr(C)] |
| 23 |
pub struct __CFBundle(c_void); |
| 24 |
|
| 25 |
pub type CFBundleRef = *mut __CFBundle; |
| 26 |
pub type CFPlugInRef = *mut __CFBundle; |
| 27 |
pub type CFBundleRefNum = c_int; |
| 28 |
|
| 29 |
#[allow(unused)] |
| 30 |
#[inline(always)] |
| 31 |
pub unsafe fn CFCopyLocalizedString(key: CFStringRef, comment: CFStringRef) -> CFStringRef { |
| 32 |
CFBundleCopyLocalizedString(CFBundleGetMainBundle(), key, key, std::ptr::null()) |
| 33 |
} |
| 34 |
#[allow(unused)] |
| 35 |
#[inline(always)] |
| 36 |
pub unsafe fn CFCopyLocalizedStringFromTable( |
| 37 |
key: CFStringRef, |
| 38 |
tbl: CFStringRef, |
| 39 |
comment: CFStringRef, |
| 40 |
) -> CFStringRef { |
| 41 |
CFBundleCopyLocalizedString(CFBundleGetMainBundle(), key, key, tbl) |
| 42 |
} |
| 43 |
#[allow(unused)] |
| 44 |
#[inline(always)] |
| 45 |
pub unsafe fn CFCopyLocalizedStringFromTableInBundle( |
| 46 |
key: CFStringRef, |
| 47 |
tbl: CFStringRef, |
| 48 |
bundle: CFBundleRef, |
| 49 |
comment: CFStringRef, |
| 50 |
) -> CFStringRef { |
| 51 |
CFBundleCopyLocalizedString(bundle, key, key, tbl) |
| 52 |
} |
| 53 |
#[allow(unused)] |
| 54 |
#[inline(always)] |
| 55 |
pub unsafe fn CFCopyLocalizedStringWithDefaultValue( |
| 56 |
key: CFStringRef, |
| 57 |
tbl: CFStringRef, |
| 58 |
bundle: CFBundleRef, |
| 59 |
value: CFStringRef, |
| 60 |
comment: CFStringRef, |
| 61 |
) -> CFStringRef { |
| 62 |
CFBundleCopyLocalizedString(bundle, key, value, tbl) |
| 63 |
} |
| 64 |
|
| 65 |
pub static kCFBundleExecutableArchitectureI386: c_uint = 0x00000007; |
| 66 |
pub static kCFBundleExecutableArchitecturePPC: c_uint = 0x00000012; |
| 67 |
pub static kCFBundleExecutableArchitectureX86_64: c_uint = 0x01000007; |
| 68 |
pub static kCFBundleExecutableArchitecturePPC64: c_uint = 0x01000012; |
| 69 |
//pub static kCFBundleExecutableArchitectureARM64: c_uint = 0x0100000c; //macos(11.0)+ |
| 70 |
|
| 71 |
extern "C" { |
| 72 |
/* |
| 73 |
* CFBundle.h |
| 74 |
*/ |
| 75 |
|
| 76 |
/* Information Property List Keys */ |
| 77 |
pub static kCFBundleInfoDictionaryVersionKey: CFStringRef; |
| 78 |
pub static kCFBundleExecutableKey: CFStringRef; |
| 79 |
pub static kCFBundleIdentifierKey: CFStringRef; |
| 80 |
pub static kCFBundleVersionKey: CFStringRef; |
| 81 |
pub static kCFBundleDevelopmentRegionKey: CFStringRef; |
| 82 |
pub static kCFBundleNameKey: CFStringRef; |
| 83 |
pub static kCFBundleLocalizationsKey: CFStringRef; |
| 84 |
|
| 85 |
/* Creating and Accessing Bundles */ |
| 86 |
pub fn CFBundleCreate(allocator: CFAllocatorRef, bundleURL: CFURLRef) -> CFBundleRef; |
| 87 |
pub fn CFBundleCreateBundlesFromDirectory( |
| 88 |
allocator: CFAllocatorRef, |
| 89 |
directoryURL: CFURLRef, |
| 90 |
bundleType: CFStringRef, |
| 91 |
) -> CFArrayRef; |
| 92 |
pub fn CFBundleGetAllBundles() -> CFArrayRef; |
| 93 |
pub fn CFBundleGetBundleWithIdentifier(bundleID: CFStringRef) -> CFBundleRef; |
| 94 |
pub fn CFBundleGetMainBundle() -> CFBundleRef; |
| 95 |
|
| 96 |
/* Loading and Unloading a Bundle */ |
| 97 |
pub fn CFBundleIsExecutableLoaded(bundle: CFBundleRef) -> Boolean; |
| 98 |
pub fn CFBundlePreflightExecutable(bundle: CFBundleRef, error: *mut CFErrorRef) -> Boolean; |
| 99 |
pub fn CFBundleLoadExecutable(bundle: CFBundleRef) -> Boolean; |
| 100 |
pub fn CFBundleLoadExecutableAndReturnError( |
| 101 |
bundle: CFBundleRef, |
| 102 |
error: *mut CFErrorRef, |
| 103 |
) -> Boolean; |
| 104 |
pub fn CFBundleUnloadExecutable(bundle: CFBundleRef); |
| 105 |
|
| 106 |
/* Finding Locations in a Bundle */ |
| 107 |
pub fn CFBundleCopyAuxiliaryExecutableURL( |
| 108 |
bundle: CFBundleRef, |
| 109 |
executableName: CFStringRef, |
| 110 |
) -> CFURLRef; |
| 111 |
pub fn CFBundleCopyBuiltInPlugInsURL(bundle: CFBundleRef) -> CFURLRef; |
| 112 |
pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef; |
| 113 |
pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef; |
| 114 |
pub fn CFBundleCopyResourcesDirectoryURL(bundle: CFBundleRef) -> CFURLRef; |
| 115 |
pub fn CFBundleCopySharedFrameworksURL(bundle: CFBundleRef) -> CFURLRef; |
| 116 |
pub fn CFBundleCopySharedSupportURL(bundle: CFBundleRef) -> CFURLRef; |
| 117 |
pub fn CFBundleCopySupportFilesDirectoryURL(bundle: CFBundleRef) -> CFURLRef; |
| 118 |
|
| 119 |
/* Locating Bundle Resources */ |
| 120 |
#[cfg(target_os = "macos")] |
| 121 |
pub fn CFBundleCloseBundleResourceMap(bundle: CFBundleRef, refNum: CFBundleRefNum); // DEPRECATED macosx(10.0, 10.15) |
| 122 |
pub fn CFBundleCopyResourceURL( |
| 123 |
bundle: CFBundleRef, |
| 124 |
resourceName: CFStringRef, |
| 125 |
resourceType: CFStringRef, |
| 126 |
subDirName: CFStringRef, |
| 127 |
) -> CFURLRef; |
| 128 |
pub fn CFBundleCopyResourceURLInDirectory( |
| 129 |
bundleURL: CFURLRef, |
| 130 |
resourceName: CFStringRef, |
| 131 |
resourceType: CFStringRef, |
| 132 |
subDirName: CFStringRef, |
| 133 |
) -> CFURLRef; |
| 134 |
pub fn CFBundleCopyResourceURLsOfType( |
| 135 |
bundle: CFBundleRef, |
| 136 |
resourceType: CFStringRef, |
| 137 |
subDirName: CFStringRef, |
| 138 |
) -> CFArrayRef; |
| 139 |
pub fn CFBundleCopyResourceURLsOfTypeInDirectory( |
| 140 |
bundleURL: CFURLRef, |
| 141 |
resourceType: CFStringRef, |
| 142 |
subDirName: CFStringRef, |
| 143 |
) -> CFArrayRef; |
| 144 |
pub fn CFBundleCopyResourceURLForLocalization( |
| 145 |
bundle: CFBundleRef, |
| 146 |
resourceName: CFStringRef, |
| 147 |
resourceType: CFStringRef, |
| 148 |
subDirName: CFStringRef, |
| 149 |
localizationName: CFStringRef, |
| 150 |
) -> CFURLRef; |
| 151 |
pub fn CFBundleCopyResourceURLsOfTypeForLocalization( |
| 152 |
bundle: CFBundleRef, |
| 153 |
resourceType: CFStringRef, |
| 154 |
subDirName: CFStringRef, |
| 155 |
localizationName: CFStringRef, |
| 156 |
) -> CFArrayRef; |
| 157 |
#[cfg(target_os = "macos")] |
| 158 |
pub fn CFBundleOpenBundleResourceFiles( |
| 159 |
bundle: CFBundleRef, |
| 160 |
refNum: *mut CFBundleRefNum, |
| 161 |
localizedRefNum: *mut CFBundleRefNum, |
| 162 |
) -> SInt32; // DEPRECATED macosx(10.0, 10.15) |
| 163 |
#[cfg(target_os = "macos")] |
| 164 |
pub fn CFBundleOpenBundleResourceMap(bundle: CFBundleRef) -> CFBundleRefNum; // DEPRECATED macosx(10.0, 10.15) |
| 165 |
|
| 166 |
/* Managing Localizations */ |
| 167 |
pub fn CFBundleCopyBundleLocalizations(bundle: CFBundleRef) -> CFArrayRef; |
| 168 |
pub fn CFBundleCopyLocalizedString( |
| 169 |
bundle: CFBundleRef, |
| 170 |
key: CFStringRef, |
| 171 |
value: CFStringRef, |
| 172 |
tableName: CFStringRef, |
| 173 |
) -> CFStringRef; |
| 174 |
pub fn CFBundleCopyLocalizationsForPreferences( |
| 175 |
locArray: CFArrayRef, |
| 176 |
prefArray: CFArrayRef, |
| 177 |
) -> CFArrayRef; |
| 178 |
pub fn CFBundleCopyLocalizationsForURL(url: CFURLRef) -> CFArrayRef; |
| 179 |
pub fn CFBundleCopyPreferredLocalizationsFromArray(locArray: CFArrayRef) -> CFArrayRef; |
| 180 |
|
| 181 |
/* Managing Executable Code */ |
| 182 |
pub fn CFBundleGetDataPointerForName( |
| 183 |
bundle: CFBundleRef, |
| 184 |
symbolName: CFStringRef, |
| 185 |
) -> *mut c_void; |
| 186 |
pub fn CFBundleGetDataPointersForNames( |
| 187 |
bundle: CFBundleRef, |
| 188 |
symbolNames: CFArrayRef, |
| 189 |
stbl: *mut [c_void], |
| 190 |
); |
| 191 |
pub fn CFBundleGetFunctionPointerForName( |
| 192 |
bundle: CFBundleRef, |
| 193 |
function_name: CFStringRef, |
| 194 |
) -> *const c_void; |
| 195 |
pub fn CFBundleGetFunctionPointersForNames( |
| 196 |
bundle: CFBundleRef, |
| 197 |
functionNames: CFArrayRef, |
| 198 |
ftbl: *mut [c_void], |
| 199 |
); |
| 200 |
pub fn CFBundleGetPlugIn(bundle: CFBundleRef) -> CFPlugInRef; |
| 201 |
|
| 202 |
/* Getting Bundle Properties */ |
| 203 |
pub fn CFBundleCopyBundleURL(bundle: CFBundleRef) -> CFURLRef; |
| 204 |
pub fn CFBundleGetDevelopmentRegion(bundle: CFBundleRef) -> CFStringRef; |
| 205 |
pub fn CFBundleGetIdentifier(bundle: CFBundleRef) -> CFStringRef; |
| 206 |
pub fn CFBundleGetInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef; |
| 207 |
pub fn CFBundleGetLocalInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef; |
| 208 |
pub fn CFBundleGetValueForInfoDictionaryKey(bundle: CFBundleRef, key: CFStringRef) |
| 209 |
-> CFTypeRef; |
| 210 |
pub fn CFBundleCopyInfoDictionaryInDirectory(bundleURL: CFURLRef) -> CFDictionaryRef; |
| 211 |
pub fn CFBundleCopyInfoDictionaryForURL(url: CFURLRef) -> CFDictionaryRef; |
| 212 |
pub fn CFBundleGetPackageInfo( |
| 213 |
bundle: CFBundleRef, |
| 214 |
packageType: *mut UInt32, |
| 215 |
packageCreator: *mut UInt32, |
| 216 |
); |
| 217 |
pub fn CFBundleGetPackageInfoInDirectory( |
| 218 |
url: CFURLRef, |
| 219 |
packageType: *mut UInt32, |
| 220 |
packageCreator: *mut UInt32, |
| 221 |
) -> Boolean; |
| 222 |
pub fn CFBundleCopyExecutableArchitectures(bundle: CFBundleRef) -> CFArrayRef; |
| 223 |
pub fn CFBundleCopyExecutableArchitecturesForURL(url: CFURLRef) -> CFArrayRef; |
| 224 |
pub fn CFBundleGetVersionNumber(bundle: CFBundleRef) -> UInt32; |
| 225 |
|
| 226 |
/* macos(11.0)+ |
| 227 |
pub fn CFBundleIsExecutableLoadable(bundle: CFBundleRef) -> Boolean; |
| 228 |
pub fn CFBundleIsExecutableLoadableForURL(url: CFURLRef) -> Boolean; |
| 229 |
pub fn CFBundleIsArchitectureLoadable(arch: cpu_type_t) -> Boolean; |
| 230 |
*/ |
| 231 |
|
| 232 |
/* Getting the CFBundle Type ID */ |
| 233 |
pub fn CFBundleGetTypeID() -> CFTypeID; |
| 234 |
} |