0

Import temporal_capi

Bug: 401065166
Change-Id: I94e54786863d8ada78c1980d55db019b7042a886
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6373767
Auto-Submit: Manish Goregaokar <manishearth@google.com>
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Manish Goregaokar <manishearth@google.com>
Commit-Queue: Dustin Mitchell <djmitche@chromium.org>
Reviewed-by: Dustin Mitchell <djmitche@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1435648}
This commit is contained in:
Manish Goregaokar
2025-03-20 13:30:32 -07:00
committed by Chromium LUCI CQ
parent 73c548d588
commit 539f793de9
328 changed files with 45906 additions and 21 deletions
infra
third_party/rust
android_system_properties
chromium_crates_io
Cargo.lockCargo.tomlgnrt_config.toml
supply-chain
vendor
android_system_properties-0.1.5
bumpalo-3.17.0
core-foundation-sys-0.8.7
iana-time-zone-0.1.61
iana-time-zone-haiku-0.1.2
js-sys-0.3.77
once_cell-1.21.1
temporal_capi-0.0.6
.cargo-checksum.json.cargo_vcs_info.jsonCargo.lockCargo.tomlCargo.toml.origLICENSE-ApacheLICENSE-MITREADME.md
bindings
src
temporal_rs-0.0.6
wasm-bindgen-0.2.100
wasm-bindgen-backend-0.2.100
wasm-bindgen-macro-0.2.100
wasm-bindgen-macro-support-0.2.100
wasm-bindgen-shared-0.2.100
windows-core-0.52.0
core_foundation_sys
iana_time_zone
ixdtf
num_traits
temporal_capi
temporal_rs
windows_aarch64_msvc
windows_core
windows_i686_msvc
windows_targets
windows_x86_64_msvc

@ -208,7 +208,7 @@ extensions/common/manifest_handlers 1 1
extensions/shell/common 1 1
google_apis/gaia 1 1
gpu/config 1 1
infra 5 3
infra 4 2
infra/config/generated/luci 1 1
infra/config/generators 2 1
infra/config/gn_args 1 1
@ -665,6 +665,7 @@ third_party/rapidhash 5 2
third_party/rust/chromium_crates_io/supply-chain 1 1
third_party/rust/chromium_crates_io/vendor/adler2-2.0.0/.github/workflows 2 1
third_party/rust/chromium_crates_io/vendor/aho-corasick-1.1.3/.github/workflows 5 1
third_party/rust/chromium_crates_io/vendor/android_system_properties-0.1.5 2 1
third_party/rust/chromium_crates_io/vendor/anstyle-1.0.10 1 1
third_party/rust/chromium_crates_io/vendor/anyhow-1.0.97 2 1
third_party/rust/chromium_crates_io/vendor/anyhow-1.0.97/.github/workflows 3 1
@ -769,6 +770,7 @@ third_party/rust/chromium_crates_io/vendor/unicode-ident-1.0.18 1 1
third_party/rust/chromium_crates_io/vendor/unicode-ident-1.0.18/.github/workflows 2 1
third_party/rust/chromium_crates_io/vendor/utf8_iter-1.0.4 1 1
third_party/rust/chromium_crates_io/vendor/winapi-util-0.1.9/.github/workflows 4 1
third_party/rust/chromium_crates_io/vendor/windows-core-0.52.0 1 1
third_party/rust/chromium_crates_io/vendor/windows-sys-0.52.0 1 1
third_party/rust/chromium_crates_io/vendor/windows-sys-0.52.0/src/Windows/Wdk/System/SystemServices 1 1
third_party/rust/chromium_crates_io/vendor/windows-sys-0.52.0/src/Windows/Win32/Networking/Clustering 2 1

@ -0,0 +1,41 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by
# tools/crates/gnrt.
# Do not edit!
import("//build/rust/cargo_crate.gni")
cargo_crate("lib") {
crate_name = "android_system_properties"
epoch = "0.1"
crate_type = "rlib"
crate_root = "//third_party/rust/chromium_crates_io/vendor/android_system_properties-0.1.5/src/lib.rs"
sources = [ "//third_party/rust/chromium_crates_io/vendor/android_system_properties-0.1.5/src/lib.rs" ]
inputs = []
build_native_rust_unit_tests = false
edition = "2018"
cargo_pkg_version = "0.1.5"
cargo_pkg_authors = "Nicolas Silva <nical@fastmail.com>"
cargo_pkg_name = "android_system_properties"
cargo_pkg_description = "Minimal Android system properties wrapper"
library_configs -= [ "//build/config/coverage:default_coverage" ]
library_configs -= [ "//build/config/compiler:chromium_code" ]
library_configs += [ "//build/config/compiler:no_chromium_code" ]
executable_configs -= [ "//build/config/compiler:chromium_code" ]
executable_configs += [ "//build/config/compiler:no_chromium_code" ]
proc_macro_configs -= [ "//build/config/compiler:chromium_code" ]
proc_macro_configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [ "//third_party/rust/libc/v0_2:lib" ]
rustflags = [
"--cap-lints=allow", # Suppress all warnings in crates.io crates
]
# Only for usage from third-party crates. Add the crate to
# //third_party/rust/chromium_crates_io/Cargo.toml to use
# it from first-party code.
visibility = [ "//third_party/rust/*" ]
}

@ -0,0 +1,10 @@
Name: android_system_properties
URL: https://crates.io/crates/android_system_properties
Version: 0.1.5
Revision: fb87625f1807dff7623db2d80df682a199358515
License: Apache-2.0
License File: //third_party/rust/chromium_crates_io/vendor/android_system_properties-0.1.5/LICENSE-APACHE
Shipped: yes
Security Critical: yes
Description: Minimal Android system properties wrapper

@ -15,6 +15,14 @@ dependencies = [
"memchr",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc",
]
[[package]]
name = "anstyle"
version = "1.0.10"
@ -54,6 +62,11 @@ dependencies = [
"serde",
]
[[package]]
name = "bumpalo"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bytemuck"
version = "1.22.0"
@ -151,6 +164,7 @@ dependencies = [
"strum",
"strum_macros",
"syn",
"temporal_capi",
"tinyvec",
"unicode-linebreak",
"zerocopy 0.7.35",
@ -188,6 +202,11 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "core_maths"
version = "0.1.1"
@ -374,6 +393,27 @@ name = "hex-literal"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "iana-time-zone"
version = "0.1.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc",
]
[[package]]
name = "icu_calendar"
version = "2.0.0-beta2"
@ -843,6 +883,15 @@ dependencies = [
"utf8_iter",
]
[[package]]
name = "js-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
@ -939,6 +988,11 @@ dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "png"
version = "0.18.0-rc"
@ -1305,6 +1359,30 @@ dependencies = [
"syn",
]
[[package]]
name = "temporal_capi"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"diplomat",
"diplomat-runtime",
"icu_calendar",
"temporal_rs",
]
[[package]]
name = "temporal_rs"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"iana-time-zone",
"icu_calendar",
"ixdtf",
"num-traits",
"tinystr",
"writeable",
]
[[package]]
name = "termcolor"
version = "1.4.1"
@ -1362,6 +1440,59 @@ name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-ident",
]
[[package]]
name = "winapi-util"
version = "0.1.9"
@ -1370,6 +1501,14 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.52.0"

@ -48,6 +48,7 @@ small_ctor = "0.1"
static_assertions = "1"
strum = "0.25.0"
strum_macros = "0.25.3"
temporal_capi = "0.0.6"
[dependencies.bstr]
version = "1"

@ -293,6 +293,12 @@ group = 'test'
[crate.smallvec]
ban_features = ['malloc_size_of']
[crate.temporal_capi]
license_files = ["LICENSE-MIT", "LICENSE-APACHE"]
[crate.temporal_rs]
license_files = ["LICENSE-MIT", "LICENSE-APACHE"]
[crate.unicode-linebreak]
allow_first_party_usage = false
build_script_outputs = [ "tables.rs" ]

@ -105,6 +105,12 @@ who = "Dustin J. Mitchell <djmitche@chromium.org>"
criteria = ["safe-to-run", "does-not-implement-crypto"]
delta = "1.1.2 -> 1.1.3"
[[audits.android_system_properties]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
version = "0.1.5"
notes = "Android system API FFI"
[[audits.anstyle]]
who = "danakj@chromium.org"
criteria = ["safe-to-run", "does-not-implement-crypto"]
@ -934,6 +940,12 @@ Reviewed in https://crrev.com/c/5171063
Previously reviewed during security review and the audit is grandparented in.
"""
[[audits.core-foundation-sys]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
version = "0.8.7"
notes = "OSX system APIs"
[[audits.core_maths]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
@ -1771,6 +1783,12 @@ Reviewed in https://crrev.com/c/5171063
Previously reviewed during security review and the audit is grandparented in.
"""
[[audits.iana-time-zone]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
version = "0.1.61"
notes = "Some unsafe: interfacing with system timezone APIs"
[[audits.icu_calendar]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
@ -3930,6 +3948,18 @@ criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
version = "0.13.1"
notes = "Exposes unsafe codegen APIs but does not itself contain unsafe"
[[audits.temporal_capi]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]
version = "0.0.6"
notes = "No unsafe or crypto."
[[audits.temporal_rs]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-1"]
version = "0.0.6"
notes = "No crypto. Minor unsafe maintaining some additional invariants that are not actually safety-critical."
[[audits.termcolor]]
who = "danakj@chromium.org"
criteria = ["safe-to-run", "does-not-implement-crypto"]
@ -4141,6 +4171,12 @@ criteria = ["safe-to-run", "does-not-implement-crypto"]
delta = "0.1.8 -> 0.1.9"
notes = "The delta only changes Cargo.toml."
[[audits.windows-core]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-2"]
version = "0.52.0"
notes = "Implements Windows system APIs"
[[audits.write16]]
who = "Manish Goregaokar <manishearth@google.com>"
criteria = ["safe-to-deploy", "does-not-implement-crypto", "ub-risk-0"]

@ -47,6 +47,9 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."aho-corasick:1.1.3"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."android_system_properties:0.1.5"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."anstyle:1.0.10"]
criteria = ["crypto-safe", "safe-to-run"]
@ -68,6 +71,9 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."bstr:1.11.3"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."bumpalo:3.17.0"]
criteria = []
[policy."bytemuck:1.22.0"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@ -101,6 +107,9 @@ criteria = ["crypto-safe", "safe-to-run"]
[policy."codespan-reporting:0.11.1"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."core-foundation-sys:0.8.7"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."core_maths:0.1.1"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@ -173,6 +182,12 @@ criteria = ["crypto-safe", "safe-to-run"]
[policy."hex:0.4.3"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."iana-time-zone-haiku:0.1.2"]
criteria = []
[policy."iana-time-zone:0.1.61"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."icu_calendar:2.0.0-beta2"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@ -284,6 +299,9 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."ixdtf:0.4.0"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."js-sys:0.3.77"]
criteria = []
[policy."lazy_static:1.5.0"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@ -326,6 +344,9 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."num-traits:0.2.19"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."once_cell:1.21.1"]
criteria = []
[policy."png:0.18.0-rc"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@ -461,6 +482,12 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."synstructure:0.13.1"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."temporal_capi:0.0.6"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."temporal_rs:0.0.6"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."termcolor:1.4.1"]
criteria = ["crypto-safe", "safe-to-run"]
@ -491,20 +518,38 @@ criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."wasi:0.11.0+wasi-snapshot-preview1"]
criteria = []
[policy."wasm-bindgen-backend:0.2.100"]
criteria = []
[policy."wasm-bindgen-macro-support:0.2.100"]
criteria = []
[policy."wasm-bindgen-macro:0.2.100"]
criteria = []
[policy."wasm-bindgen-shared:0.2.100"]
criteria = []
[policy."wasm-bindgen:0.2.100"]
criteria = []
[policy."winapi-util:0.1.9"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."windows-core:0.52.0"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."windows-sys:0.52.0"]
criteria = ["crypto-safe", "safe-to-run"]
[policy."windows-targets:0.52.6"]
criteria = ["crypto-safe", "safe-to-run"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."windows_aarch64_gnullvm:0.52.6"]
criteria = []
[policy."windows_aarch64_msvc:0.52.6"]
criteria = ["crypto-safe", "safe-to-run"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."windows_i686_gnu:0.52.6"]
criteria = []
@ -513,7 +558,7 @@ criteria = []
criteria = []
[policy."windows_i686_msvc:0.52.6"]
criteria = ["crypto-safe", "safe-to-run"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."windows_x86_64_gnu:0.52.6"]
criteria = []
@ -522,7 +567,7 @@ criteria = []
criteria = []
[policy."windows_x86_64_msvc:0.52.6"]
criteria = ["crypto-safe", "safe-to-run"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
[policy."writeable:0.6.1"]
criteria = ["crypto-safe", "safe-to-deploy", "ub-risk-2"]
@ -804,7 +849,7 @@ https://crbug.com/366411886
[[exemptions.zerocopy]]
version = "0.8.23"
criteria = ["safe-to-deploy", "crypto-safe", "ub-risk-2"]
criteria = ["safe-to-run", "crypto-safe"]
notes = """
Requires unsafe review audit. Authored in Google and audit should come from there as well.

@ -174,16 +174,6 @@ who = "Ying Hsu <yinghsu@chromium.org>"
criteria = ["safe-to-run", "does-not-implement-crypto"]
version = "2.7.2"
[[audits.chromeos.audits.rand_chacha]]
who = "Android Legacy"
criteria = "safe-to-run"
version = "0.3.1"
[[audits.chromeos.audits.rand_core]]
who = "Android Legacy"
criteria = "safe-to-run"
version = "0.6.4"
[[audits.chromeos.audits.rustc-demangle-capi]]
who = "George Burgess IV <gbiv@google.com>"
criteria = ["safe-to-run", "does-not-implement-crypto"]

@ -0,0 +1,6 @@
{
"git": {
"sha1": "fb87625f1807dff7623db2d80df682a199358515"
},
"path_in_vcs": ""
}

@ -0,0 +1,40 @@
# Contributing
Contributions are very much welcome. Here are the guidelines if you are thinking of helping us:
## Contributions
Contributions should be made in the form of GitHub pull requests.
Each pull request will be reviewed by a core contributor (someone with
permission to land patches) and either landed in the main tree or
given feedback for changes that would be required.
Should you wish to work on an issue, please claim it first by commenting on
the GitHub issue that you want to work on it. This is to prevent duplicated
efforts from contributors on the same issue.
## Pull Request Checklist
- Branch from the master branch and, if needed, rebase to the current master
branch before submitting your pull request. If it doesn't merge cleanly with
master you may be asked to rebase your changes.
- Commits should be as small as possible, while ensuring that each commit is
correct independently (i.e., each commit should compile and pass tests).
- If your patch is not getting reviewed or you need a specific person to review
it, you can @-reply a reviewer asking for a review in the pull request or a
comment.
- Whenever applicable, add tests relevant to the fixed bug or new feature.
For specific git instructions, see [GitHub workflow 101](https://github.com/servo/servo/wiki/Github-workflow).
## Conduct
We follow the [Rust Code of Conduct](http://www.rust-lang.org/conduct.html).
For escalation or moderation issues, please contact Nical (nical@fastmail.com) instead of the Rust moderation team.
## License
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed dual MIT/Apache 2, without any additional terms or conditions.

@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "android_system_properties"
version = "0.1.5"
dependencies = [
"libc",
]
[[package]]
name = "libc"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"

@ -0,0 +1,36 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "android_system_properties"
version = "0.1.5"
authors = ["Nicolas Silva <nical@fastmail.com>"]
description = "Minimal Android system properties wrapper"
homepage = "https://github.com/nical/android_system_properties"
documentation = "https://docs.rs/android_system_properties"
readme = "README.md"
keywords = ["android"]
license = "MIT/Apache-2.0"
repository = "https://github.com/nical/android_system_properties"
[package.metadata.docs.rs]
targets = [
"arm-linux-androideabi",
"armv7-linux-androideabi",
"aarch64-linux-android",
"i686-linux-android",
"x86_64-linux-android",
"x86_64-unknown-linux-gnu",
]
[dependencies.libc]
version = "0.2.126"

@ -0,0 +1,20 @@
[package]
name = "android_system_properties"
description = "Minimal Android system properties wrapper"
version = "0.1.5"
authors = ["Nicolas Silva <nical@fastmail.com>"]
edition = "2018"
license = "MIT/Apache-2.0"
repository = "https://github.com/nical/android_system_properties"
homepage = "https://github.com/nical/android_system_properties"
documentation = "https://docs.rs/android_system_properties"
readme = "README.md"
keywords = [
"android",
]
[dependencies]
libc = "0.2.126"
[package.metadata.docs.rs]
targets = ["arm-linux-androideabi", "armv7-linux-androideabi", "aarch64-linux-android", "i686-linux-android", "x86_64-linux-android", "x86_64-unknown-linux-gnu"]

@ -0,0 +1,13 @@
Copyright 2016 Nicolas Silva
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Nicolas Silva
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,36 @@
# android_system_properties
A thin rust wrapper for Android system properties.
This crate is similar to the `android-properties` crate with the exception that
the necessary Android libc symbols are loaded dynamically instead of linked
statically. In practice this means that the same binary will work with old and
new versions of Android, even though the API for reading system properties changed
around Android L.
## Example
```rust
use android_system_properties::AndroidSystemProperties;
let properties = AndroidSystemProperties::new();
if let Some(value) = properties.get("persist.sys.timezone") {
println!("{}", value);
}
```
## Listing and setting properties
For the sake of simplicity this crate currently only contains what's needed by wgpu.
The implementations for listing and setting properties can be added back if anyone needs
them (let me know by filing an issue).
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.

@ -0,0 +1,9 @@
/// Prints the current time zone, e.g. "Europe/Paris".
use android_system_properties::AndroidSystemProperties;
fn main() {
let android_system_properties = AndroidSystemProperties::new();
let tz = android_system_properties.get("persist.sys.timezone");
println!("Your time zone is: {}", tz.as_deref().unwrap_or("<unknown>"));
}

@ -0,0 +1,221 @@
//! A thin rust wrapper for Android system properties.
//!
//! This crate is similar to the `android-properties` crate with the exception that
//! the necessary Android libc symbols are loaded dynamically instead of linked
//! statically. In practice this means that the same binary will work with old and
//! new versions of Android, even though the API for reading system properties changed
//! around Android L.
//!
//! ## Example
//!
//! ```rust
//! use android_system_properties::AndroidSystemProperties;
//!
//! let properties = AndroidSystemProperties::new();
//!
//! if let Some(value) = properties.get("persist.sys.timezone") {
//! println!("{}", value);
//! }
//! ```
//!
//! ## Listing and setting properties
//!
//! For the sake of simplicity this crate currently only contains what's needed by wgpu.
//! The implementations for listing and setting properties can be added back if anyone needs
//! them (let me know by filing an issue).
//!
//! ## License
//!
//! Licensed under either of
//!
//! * Apache License, Version 2.0 ([LICENSE-APACHE] or <http://www.apache.org/licenses/LICENSE-2.0>)
//! * MIT license ([LICENSE-MIT] or <http://opensource.org/licenses/MIT>)
//!
//! at your option.
//!
//! [LICENSE-APACHE]: https://github.com/nical/android_system_properties/blob/804681c5c1c93d4fab29c1a2f47b7d808dc70fd3/LICENSE-APACHE
//! [LICENSE-MIT]: https://github.com/nical/android_system_properties/blob/804681c5c1c93d4fab29c1a2f47b7d808dc70fd3/LICENSE-MIT
use std::{
ffi::{CStr, CString},
os::raw::{c_char, c_int, c_void},
};
#[cfg(target_os = "android")]
use std::mem;
unsafe fn property_callback(payload: *mut String, _name: *const c_char, value: *const c_char, _serial: u32) {
let cvalue = CStr::from_ptr(value);
(*payload) = cvalue.to_str().unwrap().to_string();
}
type Callback = unsafe fn(*mut String, *const c_char, *const c_char, u32);
type SystemPropertyGetFn = unsafe extern "C" fn(*const c_char, *mut c_char) -> c_int;
type SystemPropertyFindFn = unsafe extern "C" fn(*const c_char) -> *const c_void;
type SystemPropertyReadCallbackFn = unsafe extern "C" fn(*const c_void, Callback, *mut String) -> *const c_void;
#[derive(Debug)]
/// An object that can retrieve android system properties.
///
/// ## Example
///
/// ```
/// use android_system_properties::AndroidSystemProperties;
///
/// let properties = AndroidSystemProperties::new();
///
/// if let Some(value) = properties.get("persist.sys.timezone") {
/// println!("{}", value);
/// }
/// ```
pub struct AndroidSystemProperties {
libc_so: *mut c_void,
get_fn: Option<SystemPropertyGetFn>,
find_fn: Option<SystemPropertyFindFn>,
read_callback_fn: Option<SystemPropertyReadCallbackFn>,
}
unsafe impl Send for AndroidSystemProperties {}
unsafe impl Sync for AndroidSystemProperties {}
impl AndroidSystemProperties {
#[cfg(not(target_os = "android"))]
/// Create an entry point for accessing Android properties.
pub fn new() -> Self {
AndroidSystemProperties {
libc_so: std::ptr::null_mut(),
find_fn: None,
read_callback_fn: None,
get_fn: None,
}
}
#[cfg(target_os = "android")]
/// Create an entry point for accessing Android properties.
pub fn new() -> Self {
let libc_so = unsafe { libc::dlopen(b"libc.so\0".as_ptr().cast(), libc::RTLD_NOLOAD) };
let mut properties = AndroidSystemProperties {
libc_so,
find_fn: None,
read_callback_fn: None,
get_fn: None,
};
if libc_so.is_null() {
return properties;
}
unsafe fn load_fn(libc_so: *mut c_void, name: &[u8]) -> Option<*const c_void> {
let fn_ptr = libc::dlsym(libc_so, name.as_ptr().cast());
if fn_ptr.is_null() {
return None;
}
Some(fn_ptr)
}
unsafe {
properties.read_callback_fn = load_fn(libc_so, b"__system_property_read_callback\0")
.map(|raw| mem::transmute::<*const c_void, SystemPropertyReadCallbackFn>(raw));
properties.find_fn = load_fn(libc_so, b"__system_property_find\0")
.map(|raw| mem::transmute::<*const c_void, SystemPropertyFindFn>(raw));
// Fallback for old versions of Android.
if properties.read_callback_fn.is_none() || properties.find_fn.is_none() {
properties.get_fn = load_fn(libc_so, b"__system_property_get\0")
.map(|raw| mem::transmute::<*const c_void, SystemPropertyGetFn>(raw));
}
}
properties
}
/// Retrieve a system property.
///
/// Returns None if the operation fails.
///
/// # Example
///
/// ```
/// # use android_system_properties::AndroidSystemProperties;
/// let properties = AndroidSystemProperties::new();
///
/// if let Some(value) = properties.get("persist.sys.timezone") {
/// println!("{}", value);
/// }
/// ```
pub fn get(&self, name: &str) -> Option<String> {
let cname = CString::new(name).ok()?;
self.get_from_cstr(&cname)
}
/// Retrieve a system property using a [`CStr`] key.
///
/// Returns None if the operation fails.
///
/// # Example
///
/// ```
/// # use android_system_properties::AndroidSystemProperties;
/// # use std::ffi::CStr;
/// let properties = AndroidSystemProperties::new();
///
/// let key = unsafe { CStr::from_bytes_with_nul_unchecked(b"persist.sys.timezone\0") };
/// if let Some(value) = properties.get_from_cstr(key) {
/// println!("{}", value);
/// }
/// ```
pub fn get_from_cstr(&self, cname: &std::ffi::CStr) -> Option<String> {
// If available, use the recommended approach to accessing properties (Android L and onward).
if let (Some(find_fn), Some(read_callback_fn)) = (self.find_fn, self.read_callback_fn) {
let info = unsafe { (find_fn)(cname.as_ptr()) };
if info.is_null() {
return None;
}
let mut result = String::new();
unsafe {
(read_callback_fn)(info, property_callback, &mut result);
}
return Some(result);
}
// Fall back to the older approach.
if let Some(get_fn) = self.get_fn {
// The constant is PROP_VALUE_MAX in Android's libc/include/sys/system_properties.h
const PROPERTY_VALUE_MAX: usize = 92;
let mut buffer: Vec<u8> = Vec::with_capacity(PROPERTY_VALUE_MAX);
let raw = buffer.as_mut_ptr() as *mut c_char;
let len = unsafe { (get_fn)(cname.as_ptr(), raw) };
if len > 0 {
assert!(len as usize <= buffer.capacity());
unsafe { buffer.set_len(len as usize); }
String::from_utf8(buffer).ok()
} else {
None
}
} else {
None
}
}
}
impl Drop for AndroidSystemProperties {
fn drop(&mut self) {
if !self.libc_so.is_null() {
unsafe {
libc::dlclose(self.libc_so);
}
}
}
}

@ -0,0 +1,23 @@
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# @generated from third_party/rust/chromium_crates_io/removed_Cargo.toml
# by tools/crates/gnrt. Do not edit!
# This is an empty crate that has replaced the 'bumpalo' crate, since
# it was listed in `resolve.remove_crates` in gnrt_config.toml.
[package]
name = "bumpalo"
version = "3.17.0"
[features]
"allocator-api2" = []
"allocator_api" = []
"boxed" = []
"collections" = []
"default" = []
"serde" = []
"std" = []

@ -0,0 +1,9 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @generated from third_party/rust/chromium_crates_io/removed_lib.rs
// by tools/crates/gnrt. Do not edit!
// This is an empty crate that has replaced the 'bumpalo' crate, since
// it was listed in `resolve.remove_crates` in gnrt_config.toml.

@ -0,0 +1,6 @@
{
"git": {
"sha1": "652bab0a62d87df8a974ffad2ad9f7be218a8b56"
},
"path_in_vcs": "core-foundation-sys"
}

@ -0,0 +1,42 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "core-foundation-sys"
version = "0.8.7"
authors = ["The Servo Project Developers"]
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Bindings to Core Foundation for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
readme = false
license = "MIT OR Apache-2.0"
repository = "https://github.com/servo/core-foundation-rs"
[package.metadata.docs.rs]
all-features = true
default-target = "x86_64-apple-darwin"
[lib]
name = "core_foundation_sys"
path = "src/lib.rs"
[dependencies]
[features]
default = ["link"]
link = []
mac_os_10_7_support = []
mac_os_10_8_features = []

@ -0,0 +1,22 @@
[package]
name = "core-foundation-sys"
description = "Bindings to Core Foundation for macOS"
homepage = "https://github.com/servo/core-foundation-rs"
repository = "https://github.com/servo/core-foundation-rs"
version = "0.8.7"
authors = ["The Servo Project Developers"]
license = "MIT OR Apache-2.0"
edition = "2018"
[dependencies]
[features]
default = ["link"]
mac_os_10_7_support = [] # backwards compatibility
mac_os_10_8_features = [] # enables new features
# Disable to manually link. Enabled by default.
link = []
[package.metadata.docs.rs]
all-features = true
default-target = "x86_64-apple-darwin"

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -0,0 +1,25 @@
Copyright (c) 2012-2013 Mozilla Foundation
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

@ -0,0 +1,142 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFComparatorFunction, CFIndex, CFRange, CFTypeID};
use crate::string::CFStringRef;
pub type CFArrayRetainCallBack =
extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
pub type CFArrayReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
pub type CFArrayCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
pub type CFArrayEqualCallBack =
extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
pub type CFArrayApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void);
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct CFArrayCallBacks {
pub version: CFIndex,
pub retain: CFArrayRetainCallBack,
pub release: CFArrayReleaseCallBack,
pub copyDescription: CFArrayCopyDescriptionCallBack,
pub equal: CFArrayEqualCallBack,
}
#[repr(C)]
pub struct __CFArray(c_void);
pub type CFArrayRef = *const __CFArray;
pub type CFMutableArrayRef = *mut __CFArray;
extern "C" {
/*
* CFArray.h
*/
pub static kCFTypeArrayCallBacks: CFArrayCallBacks;
/* CFArray */
/* Creating an Array */
pub fn CFArrayCreate(
allocator: CFAllocatorRef,
values: *const *const c_void,
numValues: CFIndex,
callBacks: *const CFArrayCallBacks,
) -> CFArrayRef;
pub fn CFArrayCreateCopy(allocator: CFAllocatorRef, theArray: CFArrayRef) -> CFArrayRef;
/* Examining an Array */
pub fn CFArrayBSearchValues(
theArray: CFArrayRef,
range: CFRange,
value: *const c_void,
comparator: CFComparatorFunction,
context: *mut c_void,
) -> CFIndex;
pub fn CFArrayContainsValue(
theArray: CFArrayRef,
range: CFRange,
value: *const c_void,
) -> Boolean;
pub fn CFArrayGetCount(theArray: CFArrayRef) -> CFIndex;
pub fn CFArrayGetCountOfValue(
theArray: CFArrayRef,
range: CFRange,
value: *const c_void,
) -> CFIndex;
pub fn CFArrayGetFirstIndexOfValue(
theArray: CFArrayRef,
range: CFRange,
value: *const c_void,
) -> CFIndex;
pub fn CFArrayGetLastIndexOfValue(
theArray: CFArrayRef,
range: CFRange,
value: *const c_void,
) -> CFIndex;
pub fn CFArrayGetValues(theArray: CFArrayRef, range: CFRange, values: *mut *const c_void);
pub fn CFArrayGetValueAtIndex(theArray: CFArrayRef, idx: CFIndex) -> *const c_void;
/* Applying a Function to Elements */
pub fn CFArrayApplyFunction(
theArray: CFArrayRef,
range: CFRange,
applier: CFArrayApplierFunction,
context: *mut c_void,
);
/* Getting the CFArray Type ID */
pub fn CFArrayGetTypeID() -> CFTypeID;
/* CFMutableArray */
/* CFMutableArray Miscellaneous Functions */
pub fn CFArrayAppendArray(
theArray: CFMutableArrayRef,
otherArray: CFArrayRef,
otherRange: CFRange,
);
pub fn CFArrayAppendValue(theArray: CFMutableArrayRef, value: *const c_void);
pub fn CFArrayCreateMutable(
allocator: CFAllocatorRef,
capacity: CFIndex,
callBacks: *const CFArrayCallBacks,
) -> CFMutableArrayRef;
pub fn CFArrayCreateMutableCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
theArray: CFArrayRef,
) -> CFMutableArrayRef;
pub fn CFArrayExchangeValuesAtIndices(
theArray: CFMutableArrayRef,
idx1: CFIndex,
idx2: CFIndex,
);
pub fn CFArrayInsertValueAtIndex(
theArray: CFMutableArrayRef,
idx: CFIndex,
value: *const c_void,
);
pub fn CFArrayRemoveAllValues(theArray: CFMutableArrayRef);
pub fn CFArrayRemoveValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex);
pub fn CFArrayReplaceValues(
theArray: CFMutableArrayRef,
range: CFRange,
newValues: *mut *const c_void,
newCount: CFIndex,
);
pub fn CFArraySetValueAtIndex(theArray: CFMutableArrayRef, idx: CFIndex, value: *const c_void);
pub fn CFArraySortValues(
theArray: CFMutableArrayRef,
range: CFRange,
comparator: CFComparatorFunction,
context: *mut c_void,
);
}

@ -0,0 +1,120 @@
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, CFTypeRef};
use crate::dictionary::CFDictionaryRef;
use crate::string::CFMutableStringRef;
use crate::string::CFStringRef;
use std::os::raw::c_void;
#[repr(C)]
pub struct __CFAttributedString(c_void);
pub type CFAttributedStringRef = *const __CFAttributedString;
pub type CFMutableAttributedStringRef = *mut __CFAttributedString;
extern "C" {
/*
* CFAttributedString.h
*/
/* CFAttributedString */
/* Creating a CFAttributedString */
pub fn CFAttributedStringCreate(
allocator: CFAllocatorRef,
str: CFStringRef,
attributes: CFDictionaryRef,
) -> CFAttributedStringRef;
pub fn CFAttributedStringCreateCopy(
alloc: CFAllocatorRef,
aStr: CFAttributedStringRef,
) -> CFAttributedStringRef;
pub fn CFAttributedStringCreateWithSubstring(
alloc: CFAllocatorRef,
aStr: CFAttributedStringRef,
range: CFRange,
) -> CFAttributedStringRef;
pub fn CFAttributedStringGetLength(astr: CFAttributedStringRef) -> CFIndex;
pub fn CFAttributedStringGetString(aStr: CFAttributedStringRef) -> CFStringRef;
/* Accessing Attributes */
pub fn CFAttributedStringGetAttribute(
aStr: CFAttributedStringRef,
loc: CFIndex,
attrName: CFStringRef,
effectiveRange: *mut CFRange,
) -> CFTypeRef;
pub fn CFAttributedStringGetAttributes(
aStr: CFAttributedStringRef,
loc: CFIndex,
effectiveRange: *mut CFRange,
) -> CFDictionaryRef;
pub fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
aStr: CFAttributedStringRef,
loc: CFIndex,
attrName: CFStringRef,
inRange: CFRange,
longestEffectiveRange: *mut CFRange,
) -> CFTypeRef;
pub fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
aStr: CFAttributedStringRef,
loc: CFIndex,
inRange: CFRange,
longestEffectiveRange: *mut CFRange,
) -> CFDictionaryRef;
/* Getting Attributed String Properties */
pub fn CFAttributedStringGetTypeID() -> CFTypeID;
/* CFMutableAttributedString */
/* Creating a CFMutableAttributedString */
pub fn CFAttributedStringCreateMutable(
allocator: CFAllocatorRef,
max_length: CFIndex,
) -> CFMutableAttributedStringRef;
pub fn CFAttributedStringCreateMutableCopy(
allocator: CFAllocatorRef,
max_length: CFIndex,
astr: CFAttributedStringRef,
) -> CFMutableAttributedStringRef;
/* Modifying a CFMutableAttributedString */
pub fn CFAttributedStringBeginEditing(aStr: CFMutableAttributedStringRef);
pub fn CFAttributedStringEndEditing(aStr: CFMutableAttributedStringRef);
pub fn CFAttributedStringGetMutableString(
aStr: CFMutableAttributedStringRef,
) -> CFMutableStringRef;
pub fn CFAttributedStringRemoveAttribute(
aStr: CFMutableAttributedStringRef,
range: CFRange,
attrName: CFStringRef,
);
pub fn CFAttributedStringReplaceString(
aStr: CFMutableAttributedStringRef,
range: CFRange,
replacement: CFStringRef,
);
pub fn CFAttributedStringReplaceAttributedString(
aStr: CFMutableAttributedStringRef,
range: CFRange,
replacement: CFAttributedStringRef,
);
pub fn CFAttributedStringSetAttribute(
aStr: CFMutableAttributedStringRef,
range: CFRange,
attrName: CFStringRef,
value: CFTypeRef,
);
pub fn CFAttributedStringSetAttributes(
aStr: CFMutableAttributedStringRef,
range: CFRange,
replacement: CFDictionaryRef,
clearOtherAttributes: Boolean,
);
}

@ -0,0 +1,101 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFBag(c_void);
pub type CFBagRef = *const __CFBag;
pub type CFMutableBagRef = *mut __CFBag;
pub type CFBagRetainCallBack =
extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
pub type CFBagReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
pub type CFBagCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
pub type CFBagEqualCallBack =
extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
pub type CFBagHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFBagCallBacks {
pub version: CFIndex,
pub retain: CFBagRetainCallBack,
pub release: CFBagReleaseCallBack,
pub copyDescription: CFBagCopyDescriptionCallBack,
pub equal: CFBagEqualCallBack,
pub hash: CFBagHashCallBack,
}
pub type CFBagApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void);
extern "C" {
/*
* CFBag.h
*/
/* Predefined Callback Structures */
pub static kCFTypeBagCallBacks: CFBagCallBacks;
pub static kCFCopyStringBagCallBacks: CFBagCallBacks;
/* CFBag */
/* Creating a Bag */
pub fn CFBagCreate(
allocator: CFAllocatorRef,
values: *const *const c_void,
numValues: CFIndex,
callBacks: *const CFBagCallBacks,
) -> CFBagRef;
pub fn CFBagCreateCopy(allocator: CFAllocatorRef, theBag: CFBagRef) -> CFBagRef;
/* Examining a Bag */
pub fn CFBagContainsValue(theBag: CFBagRef, value: *const c_void) -> Boolean;
pub fn CFBagGetCount(theBag: CFBagRef) -> CFIndex;
pub fn CFBagGetCountOfValue(theBag: CFBagRef, value: *const c_void) -> CFIndex;
pub fn CFBagGetValue(theBag: CFBagRef, value: *const c_void) -> *const c_void;
pub fn CFBagGetValueIfPresent(
theBag: CFBagRef,
candidate: *const c_void,
value: *const *const c_void,
) -> Boolean;
pub fn CFBagGetValues(theBag: CFBagRef, values: *const *const c_void);
/* Applying a Function to the Contents of a Bag */
pub fn CFBagApplyFunction(
theBag: CFBagRef,
applier: CFBagApplierFunction,
context: *mut c_void,
);
/* Getting the CFBag Type ID */
pub fn CFBagGetTypeID() -> CFTypeID;
/* CFMutableBag */
/* Creating a Mutable Bag */
pub fn CFBagCreateMutable(
allocator: CFAllocatorRef,
capacity: CFIndex,
callBacks: *const CFBagCallBacks,
) -> CFMutableBagRef;
pub fn CFBagCreateMutableCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
theBag: CFBagRef,
) -> CFMutableBagRef;
/* Modifying a Mutable Bag */
pub fn CFBagAddValue(theBag: CFMutableBagRef, value: *const c_void);
pub fn CFBagRemoveAllValues(theBag: CFMutableBagRef);
pub fn CFBagRemoveValue(theBag: CFMutableBagRef, value: *const c_void);
pub fn CFBagReplaceValue(theBag: CFMutableBagRef, value: *const c_void);
pub fn CFBagSetValue(theBag: CFMutableBagRef, value: *const c_void);
}

@ -0,0 +1,197 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::string::CFStringRef;
use std::cmp::Ordering;
use std::os::raw::{c_int, c_short, c_uchar, c_uint, c_ushort, c_void};
pub type Boolean = u8;
pub type mach_port_t = c_uint;
pub type CFAllocatorRef = *const c_void;
pub type CFNullRef = *const c_void;
pub type CFTypeRef = *const c_void;
pub type ConstStr255Param = *const c_uchar;
pub type StringPtr = *mut c_uchar;
pub type ConstStringPtr = *const c_uchar;
pub type OSStatus = i32;
pub type UInt8 = c_uchar;
pub type UInt16 = c_ushort;
pub type SInt16 = c_short;
pub type SInt32 = c_int;
pub type UInt32 = c_uint;
pub type CFTypeID = usize;
pub type CFOptionFlags = usize;
pub type CFHashCode = usize;
pub type CFIndex = isize;
pub type LangCode = SInt16;
pub type RegionCode = SInt16;
pub type UTF32Char = c_uint;
pub type UTF16Char = c_ushort;
pub type UTF8Char = c_uchar;
#[repr(isize)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CFComparisonResult {
LessThan = -1,
EqualTo = 0,
GreaterThan = 1,
}
pub type CFComparatorFunction = extern "C" fn(
val1: *const c_void,
val2: *const c_void,
context: *mut c_void,
) -> CFComparisonResult;
impl From<CFComparisonResult> for Ordering {
fn from(val: CFComparisonResult) -> Self {
match val {
CFComparisonResult::LessThan => Ordering::Less,
CFComparisonResult::EqualTo => Ordering::Equal,
CFComparisonResult::GreaterThan => Ordering::Greater,
}
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CFRange {
pub location: CFIndex,
pub length: CFIndex,
}
// for back-compat
impl CFRange {
pub fn init(location: CFIndex, length: CFIndex) -> CFRange {
CFRange { location, length }
}
}
pub type CFAllocatorRetainCallBack = extern "C" fn(info: *mut c_void) -> *mut c_void;
pub type CFAllocatorReleaseCallBack = extern "C" fn(info: *mut c_void);
pub type CFAllocatorCopyDescriptionCallBack = extern "C" fn(info: *mut c_void) -> CFStringRef;
pub type CFAllocatorAllocateCallBack =
extern "C" fn(allocSize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void;
pub type CFAllocatorReallocateCallBack = extern "C" fn(
ptr: *mut c_void,
newsize: CFIndex,
hint: CFOptionFlags,
info: *mut c_void,
) -> *mut c_void;
pub type CFAllocatorDeallocateCallBack = extern "C" fn(ptr: *mut c_void, info: *mut c_void);
pub type CFAllocatorPreferredSizeCallBack =
extern "C" fn(size: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> CFIndex;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct CFAllocatorContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<CFAllocatorRetainCallBack>,
pub release: Option<CFAllocatorReleaseCallBack>,
pub copyDescription: Option<CFAllocatorCopyDescriptionCallBack>,
pub allocate: Option<CFAllocatorAllocateCallBack>,
pub reallocate: Option<CFAllocatorReallocateCallBack>,
pub deallocate: Option<CFAllocatorDeallocateCallBack>,
pub preferredSize: Option<CFAllocatorPreferredSizeCallBack>,
}
/// Trait for all types which are Core Foundation reference types.
pub trait TCFTypeRef {
fn as_void_ptr(&self) -> *const c_void;
unsafe fn from_void_ptr(ptr: *const c_void) -> Self;
}
impl<T> TCFTypeRef for *const T {
fn as_void_ptr(&self) -> *const c_void {
(*self) as *const c_void
}
unsafe fn from_void_ptr(ptr: *const c_void) -> Self {
ptr as *const T
}
}
impl<T> TCFTypeRef for *mut T {
fn as_void_ptr(&self) -> *const c_void {
(*self) as *const T as *const c_void
}
unsafe fn from_void_ptr(ptr: *const c_void) -> Self {
ptr as *const T as *mut T
}
}
/// Constant used by some functions to indicate failed searches.
pub static kCFNotFound: CFIndex = -1;
extern "C" {
/*
* CFBase.h
*/
/* CFAllocator Reference */
pub static kCFAllocatorDefault: CFAllocatorRef;
pub static kCFAllocatorSystemDefault: CFAllocatorRef;
pub static kCFAllocatorMalloc: CFAllocatorRef;
pub static kCFAllocatorMallocZone: CFAllocatorRef;
pub static kCFAllocatorNull: CFAllocatorRef;
pub static kCFAllocatorUseContext: CFAllocatorRef;
pub fn CFAllocatorCreate(
allocator: CFAllocatorRef,
context: *mut CFAllocatorContext,
) -> CFAllocatorRef;
pub fn CFAllocatorAllocate(
allocator: CFAllocatorRef,
size: CFIndex,
hint: CFOptionFlags,
) -> *mut c_void;
pub fn CFAllocatorDeallocate(allocator: CFAllocatorRef, ptr: *mut c_void);
pub fn CFAllocatorGetPreferredSizeForSize(
allocator: CFAllocatorRef,
size: CFIndex,
hint: CFOptionFlags,
) -> CFIndex;
pub fn CFAllocatorReallocate(
allocator: CFAllocatorRef,
ptr: *mut c_void,
newsize: CFIndex,
hint: CFOptionFlags,
) -> *mut c_void;
pub fn CFAllocatorGetDefault() -> CFAllocatorRef;
pub fn CFAllocatorSetDefault(allocator: CFAllocatorRef);
pub fn CFAllocatorGetContext(allocator: CFAllocatorRef, context: *mut CFAllocatorContext);
pub fn CFAllocatorGetTypeID() -> CFTypeID;
/* CFNull Reference */
pub static kCFNull: CFNullRef;
pub fn CFNullGetTypeID() -> CFTypeID;
/* CFType Reference */
pub fn CFCopyTypeIDDescription(type_id: CFTypeID) -> CFStringRef;
pub fn CFGetAllocator(cf: CFTypeRef) -> CFAllocatorRef;
pub fn CFCopyDescription(cf: CFTypeRef) -> CFStringRef;
pub fn CFEqual(cf1: CFTypeRef, cf2: CFTypeRef) -> Boolean;
pub fn CFGetRetainCount(cf: CFTypeRef) -> CFIndex;
pub fn CFGetTypeID(cf: CFTypeRef) -> CFTypeID;
pub fn CFHash(cf: CFTypeRef) -> CFHashCode;
//fn CFMakeCollectable
pub fn CFRelease(cf: CFTypeRef);
pub fn CFRetain(cf: CFTypeRef) -> CFTypeRef;
pub fn CFShow(obj: CFTypeRef);
/* Base Utilities Reference */
// N.B. Some things missing here.
}

@ -0,0 +1,83 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID};
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFBinaryHeap(c_void);
pub type CFBinaryHeapRef = *mut __CFBinaryHeap;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFBinaryHeapCompareContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: extern "C" fn(info: *const c_void) -> *const c_void,
pub release: extern "C" fn(info: *const c_void),
pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFBinaryHeapCallBacks {
pub version: CFIndex,
pub retain: extern "C" fn(allocator: CFAllocatorRef, ptr: *const c_void) -> *const c_void,
pub release: extern "C" fn(allocator: CFAllocatorRef, ptr: *const c_void),
pub copyDescription: extern "C" fn(ptr: *const c_void) -> CFStringRef,
pub compare: extern "C" fn(
ptr1: *const c_void,
ptr2: *const c_void,
context: *mut c_void,
) -> CFComparisonResult,
}
pub type CFBinaryHeapApplierFunction = extern "C" fn(val: *const c_void, context: *const c_void);
extern "C" {
/*
* CFBinaryHeap.h
*/
/* Predefined Callback Structures */
pub static kCFStringBinaryHeapCallBacks: CFBinaryHeapCallBacks;
/* CFBinaryHeap Miscellaneous Functions */
pub fn CFBinaryHeapAddValue(heap: CFBinaryHeapRef, value: *const c_void);
pub fn CFBinaryHeapApplyFunction(
heap: CFBinaryHeapRef,
applier: CFBinaryHeapApplierFunction,
context: *mut c_void,
);
pub fn CFBinaryHeapContainsValue(heap: CFBinaryHeapRef, value: *const c_void) -> Boolean;
pub fn CFBinaryHeapCreate(
allocator: CFAllocatorRef,
capacity: CFIndex,
callBacks: *const CFBinaryHeapCallBacks,
compareContext: *const CFBinaryHeapCompareContext,
) -> CFBinaryHeapRef;
pub fn CFBinaryHeapCreateCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
heap: CFBinaryHeapRef,
) -> CFBinaryHeapRef;
pub fn CFBinaryHeapGetCount(heap: CFBinaryHeapRef) -> CFIndex;
pub fn CFBinaryHeapGetCountOfValue(heap: CFBinaryHeapRef, value: *const c_void) -> CFIndex;
pub fn CFBinaryHeapGetMinimum(heap: CFBinaryHeapRef) -> *const c_void;
pub fn CFBinaryHeapGetMinimumIfPresent(
heap: CFBinaryHeapRef,
value: *const *const c_void,
) -> Boolean;
pub fn CFBinaryHeapGetTypeID() -> CFTypeID;
pub fn CFBinaryHeapGetValues(heap: CFBinaryHeapRef, values: *const *const c_void);
pub fn CFBinaryHeapRemoveAllValues(heap: CFBinaryHeapRef);
pub fn CFBinaryHeapRemoveMinimumValue(heap: CFBinaryHeapRef);
}

@ -0,0 +1,74 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UInt32, UInt8};
#[repr(C)]
pub struct __CFBitVector(c_void);
pub type CFBitVectorRef = *const __CFBitVector;
pub type CFMutableBitVectorRef = *mut __CFBitVector;
pub type CFBit = UInt32;
extern "C" {
/*
* CFBitVector.h
*/
/* CFBitVector */
/* Creating a Bit Vector */
pub fn CFBitVectorCreate(
allocator: CFAllocatorRef,
bytes: *const UInt8,
numBits: CFIndex,
) -> CFBitVectorRef;
pub fn CFBitVectorCreateCopy(allocator: CFAllocatorRef, bv: CFBitVectorRef) -> CFBitVectorRef;
/* Getting Information About a Bit Vector */
pub fn CFBitVectorContainsBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> Boolean;
pub fn CFBitVectorGetBitAtIndex(bv: CFBitVectorRef, idx: CFIndex) -> CFBit;
pub fn CFBitVectorGetBits(bv: CFBitVectorRef, range: CFRange, bytes: *mut UInt8);
pub fn CFBitVectorGetCount(bv: CFBitVectorRef) -> CFIndex;
pub fn CFBitVectorGetCountOfBit(bv: CFBitVectorRef, range: CFRange, value: CFBit) -> CFIndex;
pub fn CFBitVectorGetFirstIndexOfBit(
bv: CFBitVectorRef,
range: CFRange,
value: CFBit,
) -> CFIndex;
pub fn CFBitVectorGetLastIndexOfBit(
bv: CFBitVectorRef,
range: CFRange,
value: CFBit,
) -> CFIndex;
/* Getting the CFBitVector Type ID */
pub fn CFBitVectorGetTypeID() -> CFTypeID;
/* CFMutableBitVector */
/* Creating a CFMutableBitVector Object */
pub fn CFBitVectorCreateMutable(
allocator: CFAllocatorRef,
capacity: CFIndex,
) -> CFMutableBitVectorRef;
pub fn CFBitVectorCreateMutableCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
bv: CFBitVectorRef,
) -> CFMutableBitVectorRef;
/* Modifying a Bit Vector */
pub fn CFBitVectorFlipBitAtIndex(bv: CFMutableBitVectorRef, idx: CFIndex);
pub fn CFBitVectorFlipBits(bv: CFMutableBitVectorRef, range: CFRange);
pub fn CFBitVectorSetAllBits(bv: CFMutableBitVectorRef, value: CFBit);
pub fn CFBitVectorSetBitAtIndex(bv: CFMutableBitVectorRef, idx: CFIndex, value: CFBit);
pub fn CFBitVectorSetBits(bv: CFMutableBitVectorRef, range: CFRange, value: CFBit);
pub fn CFBitVectorSetCount(bv: CFMutableBitVectorRef, count: CFIndex);
}

@ -0,0 +1,234 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFArrayRef;
#[cfg(target_os = "macos")]
use crate::base::SInt32;
use crate::base::{Boolean, CFAllocatorRef, CFTypeID, CFTypeRef, UInt32};
use crate::dictionary::CFDictionaryRef;
use crate::error::CFErrorRef;
use crate::string::CFStringRef;
use crate::url::CFURLRef;
use std::os::raw::{c_int, c_uint};
#[repr(C)]
pub struct __CFBundle(c_void);
pub type CFBundleRef = *mut __CFBundle;
pub type CFPlugInRef = *mut __CFBundle;
pub type CFBundleRefNum = c_int;
#[allow(unused)]
#[inline(always)]
pub unsafe fn CFCopyLocalizedString(key: CFStringRef, comment: CFStringRef) -> CFStringRef {
CFBundleCopyLocalizedString(CFBundleGetMainBundle(), key, key, std::ptr::null())
}
#[allow(unused)]
#[inline(always)]
pub unsafe fn CFCopyLocalizedStringFromTable(
key: CFStringRef,
tbl: CFStringRef,
comment: CFStringRef,
) -> CFStringRef {
CFBundleCopyLocalizedString(CFBundleGetMainBundle(), key, key, tbl)
}
#[allow(unused)]
#[inline(always)]
pub unsafe fn CFCopyLocalizedStringFromTableInBundle(
key: CFStringRef,
tbl: CFStringRef,
bundle: CFBundleRef,
comment: CFStringRef,
) -> CFStringRef {
CFBundleCopyLocalizedString(bundle, key, key, tbl)
}
#[allow(unused)]
#[inline(always)]
pub unsafe fn CFCopyLocalizedStringWithDefaultValue(
key: CFStringRef,
tbl: CFStringRef,
bundle: CFBundleRef,
value: CFStringRef,
comment: CFStringRef,
) -> CFStringRef {
CFBundleCopyLocalizedString(bundle, key, value, tbl)
}
pub static kCFBundleExecutableArchitectureI386: c_uint = 0x00000007;
pub static kCFBundleExecutableArchitecturePPC: c_uint = 0x00000012;
pub static kCFBundleExecutableArchitectureX86_64: c_uint = 0x01000007;
pub static kCFBundleExecutableArchitecturePPC64: c_uint = 0x01000012;
//pub static kCFBundleExecutableArchitectureARM64: c_uint = 0x0100000c; //macos(11.0)+
extern "C" {
/*
* CFBundle.h
*/
/* Information Property List Keys */
pub static kCFBundleInfoDictionaryVersionKey: CFStringRef;
pub static kCFBundleExecutableKey: CFStringRef;
pub static kCFBundleIdentifierKey: CFStringRef;
pub static kCFBundleVersionKey: CFStringRef;
pub static kCFBundleDevelopmentRegionKey: CFStringRef;
pub static kCFBundleNameKey: CFStringRef;
pub static kCFBundleLocalizationsKey: CFStringRef;
/* Creating and Accessing Bundles */
pub fn CFBundleCreate(allocator: CFAllocatorRef, bundleURL: CFURLRef) -> CFBundleRef;
pub fn CFBundleCreateBundlesFromDirectory(
allocator: CFAllocatorRef,
directoryURL: CFURLRef,
bundleType: CFStringRef,
) -> CFArrayRef;
pub fn CFBundleGetAllBundles() -> CFArrayRef;
pub fn CFBundleGetBundleWithIdentifier(bundleID: CFStringRef) -> CFBundleRef;
pub fn CFBundleGetMainBundle() -> CFBundleRef;
/* Loading and Unloading a Bundle */
pub fn CFBundleIsExecutableLoaded(bundle: CFBundleRef) -> Boolean;
pub fn CFBundlePreflightExecutable(bundle: CFBundleRef, error: *mut CFErrorRef) -> Boolean;
pub fn CFBundleLoadExecutable(bundle: CFBundleRef) -> Boolean;
pub fn CFBundleLoadExecutableAndReturnError(
bundle: CFBundleRef,
error: *mut CFErrorRef,
) -> Boolean;
pub fn CFBundleUnloadExecutable(bundle: CFBundleRef);
/* Finding Locations in a Bundle */
pub fn CFBundleCopyAuxiliaryExecutableURL(
bundle: CFBundleRef,
executableName: CFStringRef,
) -> CFURLRef;
pub fn CFBundleCopyBuiltInPlugInsURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyResourcesDirectoryURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopySharedFrameworksURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopySharedSupportURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopySupportFilesDirectoryURL(bundle: CFBundleRef) -> CFURLRef;
/* Locating Bundle Resources */
#[cfg(target_os = "macos")]
pub fn CFBundleCloseBundleResourceMap(bundle: CFBundleRef, refNum: CFBundleRefNum); // DEPRECATED macosx(10.0, 10.15)
pub fn CFBundleCopyResourceURL(
bundle: CFBundleRef,
resourceName: CFStringRef,
resourceType: CFStringRef,
subDirName: CFStringRef,
) -> CFURLRef;
pub fn CFBundleCopyResourceURLInDirectory(
bundleURL: CFURLRef,
resourceName: CFStringRef,
resourceType: CFStringRef,
subDirName: CFStringRef,
) -> CFURLRef;
pub fn CFBundleCopyResourceURLsOfType(
bundle: CFBundleRef,
resourceType: CFStringRef,
subDirName: CFStringRef,
) -> CFArrayRef;
pub fn CFBundleCopyResourceURLsOfTypeInDirectory(
bundleURL: CFURLRef,
resourceType: CFStringRef,
subDirName: CFStringRef,
) -> CFArrayRef;
pub fn CFBundleCopyResourceURLForLocalization(
bundle: CFBundleRef,
resourceName: CFStringRef,
resourceType: CFStringRef,
subDirName: CFStringRef,
localizationName: CFStringRef,
) -> CFURLRef;
pub fn CFBundleCopyResourceURLsOfTypeForLocalization(
bundle: CFBundleRef,
resourceType: CFStringRef,
subDirName: CFStringRef,
localizationName: CFStringRef,
) -> CFArrayRef;
#[cfg(target_os = "macos")]
pub fn CFBundleOpenBundleResourceFiles(
bundle: CFBundleRef,
refNum: *mut CFBundleRefNum,
localizedRefNum: *mut CFBundleRefNum,
) -> SInt32; // DEPRECATED macosx(10.0, 10.15)
#[cfg(target_os = "macos")]
pub fn CFBundleOpenBundleResourceMap(bundle: CFBundleRef) -> CFBundleRefNum; // DEPRECATED macosx(10.0, 10.15)
/* Managing Localizations */
pub fn CFBundleCopyBundleLocalizations(bundle: CFBundleRef) -> CFArrayRef;
pub fn CFBundleCopyLocalizedString(
bundle: CFBundleRef,
key: CFStringRef,
value: CFStringRef,
tableName: CFStringRef,
) -> CFStringRef;
pub fn CFBundleCopyLocalizationsForPreferences(
locArray: CFArrayRef,
prefArray: CFArrayRef,
) -> CFArrayRef;
pub fn CFBundleCopyLocalizationsForURL(url: CFURLRef) -> CFArrayRef;
pub fn CFBundleCopyPreferredLocalizationsFromArray(locArray: CFArrayRef) -> CFArrayRef;
/* Managing Executable Code */
pub fn CFBundleGetDataPointerForName(
bundle: CFBundleRef,
symbolName: CFStringRef,
) -> *mut c_void;
pub fn CFBundleGetDataPointersForNames(
bundle: CFBundleRef,
symbolNames: CFArrayRef,
stbl: *mut [c_void],
);
pub fn CFBundleGetFunctionPointerForName(
bundle: CFBundleRef,
function_name: CFStringRef,
) -> *const c_void;
pub fn CFBundleGetFunctionPointersForNames(
bundle: CFBundleRef,
functionNames: CFArrayRef,
ftbl: *mut [c_void],
);
pub fn CFBundleGetPlugIn(bundle: CFBundleRef) -> CFPlugInRef;
/* Getting Bundle Properties */
pub fn CFBundleCopyBundleURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleGetDevelopmentRegion(bundle: CFBundleRef) -> CFStringRef;
pub fn CFBundleGetIdentifier(bundle: CFBundleRef) -> CFStringRef;
pub fn CFBundleGetInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef;
pub fn CFBundleGetLocalInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef;
pub fn CFBundleGetValueForInfoDictionaryKey(bundle: CFBundleRef, key: CFStringRef)
-> CFTypeRef;
pub fn CFBundleCopyInfoDictionaryInDirectory(bundleURL: CFURLRef) -> CFDictionaryRef;
pub fn CFBundleCopyInfoDictionaryForURL(url: CFURLRef) -> CFDictionaryRef;
pub fn CFBundleGetPackageInfo(
bundle: CFBundleRef,
packageType: *mut UInt32,
packageCreator: *mut UInt32,
);
pub fn CFBundleGetPackageInfoInDirectory(
url: CFURLRef,
packageType: *mut UInt32,
packageCreator: *mut UInt32,
) -> Boolean;
pub fn CFBundleCopyExecutableArchitectures(bundle: CFBundleRef) -> CFArrayRef;
pub fn CFBundleCopyExecutableArchitecturesForURL(url: CFURLRef) -> CFArrayRef;
pub fn CFBundleGetVersionNumber(bundle: CFBundleRef) -> UInt32;
/* macos(11.0)+
pub fn CFBundleIsExecutableLoadable(bundle: CFBundleRef) -> Boolean;
pub fn CFBundleIsExecutableLoadableForURL(url: CFURLRef) -> Boolean;
pub fn CFBundleIsArchitectureLoadable(arch: cpu_type_t) -> Boolean;
*/
/* Getting the CFBundle Type ID */
pub fn CFBundleGetTypeID() -> CFTypeID;
}

@ -0,0 +1,128 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_char, c_void};
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID};
use crate::date::{CFAbsoluteTime, CFTimeInterval};
use crate::locale::{CFCalendarIdentifier, CFLocaleRef};
use crate::timezone::CFTimeZoneRef;
#[repr(C)]
pub struct __CFCalendar(c_void);
pub type CFCalendarRef = *mut __CFCalendar;
pub type CFCalendarUnit = CFOptionFlags;
pub const kCFCalendarUnitEra: CFCalendarUnit = 1 << 1;
pub const kCFCalendarUnitYear: CFCalendarUnit = 1 << 2;
pub const kCFCalendarUnitMonth: CFCalendarUnit = 1 << 3;
pub const kCFCalendarUnitDay: CFCalendarUnit = 1 << 4;
pub const kCFCalendarUnitHour: CFCalendarUnit = 1 << 5;
pub const kCFCalendarUnitMinute: CFCalendarUnit = 1 << 6;
pub const kCFCalendarUnitSecond: CFCalendarUnit = 1 << 7;
pub const kCFCalendarUnitWeek: CFCalendarUnit = 1 << 8; // deprecated since macos 10.10
pub const kCFCalendarUnitWeekday: CFCalendarUnit = 1 << 9;
pub const kCFCalendarUnitWeekdayOrdinal: CFCalendarUnit = 1 << 10;
pub const kCFCalendarUnitQuarter: CFCalendarUnit = 1 << 11;
pub const kCFCalendarUnitWeekOfMonth: CFCalendarUnit = 1 << 12;
pub const kCFCalendarUnitWeekOfYear: CFCalendarUnit = 1 << 13;
pub const kCFCalendarUnitYearForWeekOfYear: CFCalendarUnit = 1 << 14;
pub const kCFCalendarComponentsWrap: CFOptionFlags = 1 << 0;
extern "C" {
/*
* CFCalendar.h
*/
/* Creating a Calendar */
pub fn CFCalendarCopyCurrent() -> CFCalendarRef;
pub fn CFCalendarCreateWithIdentifier(
allocator: CFAllocatorRef,
identifier: CFCalendarIdentifier,
) -> CFCalendarRef;
/* Calendrical Calculations */
pub fn CFCalendarAddComponents(
identifier: CFCalendarIdentifier,
/* inout */ at: *mut CFAbsoluteTime,
options: CFOptionFlags,
componentDesc: *const char,
...
) -> Boolean;
pub fn CFCalendarComposeAbsoluteTime(
identifier: CFCalendarIdentifier,
/* out */ at: *mut CFAbsoluteTime,
componentDesc: *const c_char,
...
) -> Boolean;
pub fn CFCalendarDecomposeAbsoluteTime(
identifier: CFCalendarIdentifier,
at: CFAbsoluteTime,
componentDesc: *const c_char,
...
) -> Boolean;
pub fn CFCalendarGetComponentDifference(
identifier: CFCalendarIdentifier,
startingAT: CFAbsoluteTime,
resultAT: CFAbsoluteTime,
options: CFOptionFlags,
componentDesc: *const c_char,
...
) -> Boolean;
/* Getting Ranges of Units */
pub fn CFCalendarGetRangeOfUnit(
identifier: CFCalendarIdentifier,
smallerUnit: CFCalendarUnit,
biggerUnit: CFCalendarUnit,
at: CFAbsoluteTime,
) -> CFRange;
pub fn CFCalendarGetOrdinalityOfUnit(
identifier: CFCalendarIdentifier,
smallerUnit: CFCalendarUnit,
biggerUnit: CFCalendarUnit,
at: CFAbsoluteTime,
) -> CFIndex;
pub fn CFCalendarGetTimeRangeOfUnit(
identifier: CFCalendarIdentifier,
unit: CFCalendarUnit,
at: CFAbsoluteTime,
startp: *mut CFAbsoluteTime,
tip: *mut CFTimeInterval,
) -> Boolean;
pub fn CFCalendarGetMaximumRangeOfUnit(
identifier: CFCalendarIdentifier,
unit: CFCalendarUnit,
) -> CFRange;
pub fn CFCalendarGetMinimumRangeOfUnit(
identifier: CFCalendarIdentifier,
unit: CFCalendarUnit,
) -> CFRange;
/* Getting and Setting the Time Zone */
pub fn CFCalendarCopyTimeZone(identifier: CFCalendarIdentifier) -> CFTimeZoneRef;
pub fn CFCalendarSetTimeZone(identifier: CFCalendarIdentifier, tz: CFTimeZoneRef);
/* Getting the Identifier */
pub fn CFCalendarGetIdentifier(identifier: CFCalendarIdentifier) -> CFCalendarIdentifier;
/* Getting and Setting the Locale */
pub fn CFCalendarCopyLocale(identifier: CFCalendarIdentifier) -> CFLocaleRef;
pub fn CFCalendarSetLocale(identifier: CFCalendarIdentifier, locale: CFLocaleRef);
/* Getting and Setting Day Information */
pub fn CFCalendarGetFirstWeekday(identifier: CFCalendarIdentifier) -> CFIndex;
pub fn CFCalendarSetFirstWeekday(identifier: CFCalendarIdentifier, wkdy: CFIndex);
pub fn CFCalendarGetMinimumDaysInFirstWeek(identifier: CFCalendarIdentifier) -> CFIndex;
pub fn CFCalendarSetMinimumDaysInFirstWeek(identifier: CFCalendarIdentifier, mwd: CFIndex);
/* Getting the Type ID */
pub fn CFCalendarGetTypeID() -> CFTypeID;
}

@ -0,0 +1,124 @@
// Copyright 2019 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFRange, CFTypeID, UTF32Char};
use crate::data::CFDataRef;
use crate::string::{CFStringRef, UniChar};
use std::os::raw::c_void;
pub type CFCharacterSetPredefinedSet = CFIndex;
// Members of CFCharacterSetPredefinedSet enum
pub static kCFCharacterSetControl: CFCharacterSetPredefinedSet = 1;
pub static kCFCharacterSetWhitespace: CFCharacterSetPredefinedSet = 2;
pub static kCFCharacterSetWhitespaceAndNewline: CFCharacterSetPredefinedSet = 3;
pub static kCFCharacterSetDecimalDigit: CFCharacterSetPredefinedSet = 4;
pub static kCFCharacterSetLetter: CFCharacterSetPredefinedSet = 5;
pub static kCFCharacterSetLowercaseLetter: CFCharacterSetPredefinedSet = 6;
pub static kCFCharacterSetUppercaseLetter: CFCharacterSetPredefinedSet = 7;
pub static kCFCharacterSetNonBase: CFCharacterSetPredefinedSet = 8;
pub static kCFCharacterSetDecomposable: CFCharacterSetPredefinedSet = 9;
pub static kCFCharacterSetAlphaNumeric: CFCharacterSetPredefinedSet = 10;
pub static kCFCharacterSetPunctuation: CFCharacterSetPredefinedSet = 11;
pub static kCFCharacterSetIllegal: CFCharacterSetPredefinedSet = 12;
pub static kCFCharacterSetCapitalizedLetter: CFCharacterSetPredefinedSet = 13;
pub static kCFCharacterSetSymbol: CFCharacterSetPredefinedSet = 14;
pub static kCFCharacterSetNewline: CFCharacterSetPredefinedSet = 15;
#[repr(C)]
pub struct __CFCharacterSet(c_void);
pub type CFCharacterSetRef = *const __CFCharacterSet;
pub type CFMutableCharacterSetRef = *mut __CFCharacterSet;
extern "C" {
/*
* CFCharacterSet.h
*/
/* CFCharacterSet */
/* Creating Character Sets */
pub fn CFCharacterSetCreateCopy(
alloc: CFAllocatorRef,
theSet: CFCharacterSetRef,
) -> CFCharacterSetRef;
pub fn CFCharacterSetCreateInvertedSet(
alloc: CFAllocatorRef,
theSet: CFCharacterSetRef,
) -> CFCharacterSetRef;
pub fn CFCharacterSetCreateWithCharactersInRange(
alloc: CFAllocatorRef,
theRange: CFRange,
) -> CFCharacterSetRef;
pub fn CFCharacterSetCreateWithCharactersInString(
alloc: CFAllocatorRef,
theString: CFStringRef,
) -> CFCharacterSetRef;
pub fn CFCharacterSetCreateWithBitmapRepresentation(
alloc: CFAllocatorRef,
theData: CFDataRef,
) -> CFCharacterSetRef;
/* Getting Predefined Character Sets */
pub fn CFCharacterSetGetPredefined(
theSetIdentifier: CFCharacterSetPredefinedSet,
) -> CFCharacterSetRef;
/* Querying Character Sets */
pub fn CFCharacterSetCreateBitmapRepresentation(
alloc: CFAllocatorRef,
theSet: CFCharacterSetRef,
) -> CFDataRef;
pub fn CFCharacterSetHasMemberInPlane(theSet: CFCharacterSetRef, thePlane: CFIndex) -> Boolean;
pub fn CFCharacterSetIsCharacterMember(theSet: CFCharacterSetRef, theChar: UniChar) -> Boolean;
pub fn CFCharacterSetIsLongCharacterMember(
theSet: CFCharacterSetRef,
theChar: UTF32Char,
) -> Boolean;
pub fn CFCharacterSetIsSupersetOfSet(
theSet: CFCharacterSetRef,
theOtherset: CFCharacterSetRef,
) -> Boolean;
/* Getting the Character Set Type Identifier */
pub fn CFCharacterSetGetTypeID() -> CFTypeID;
/* CFMutableCharacterSet */
/* Creating a Mutable Character Set */
pub fn CFCharacterSetCreateMutable(alloc: CFAllocatorRef) -> CFMutableCharacterSetRef;
pub fn CFCharacterSetCreateMutableCopy(
alloc: CFAllocatorRef,
theSet: CFCharacterSetRef,
) -> CFMutableCharacterSetRef;
/* Adding Characters */
pub fn CFCharacterSetAddCharactersInRange(theSet: CFMutableCharacterSetRef, theRange: CFRange);
pub fn CFCharacterSetAddCharactersInString(
theSet: CFMutableCharacterSetRef,
theString: CFStringRef,
);
/* Removing Characters */
pub fn CFCharacterSetRemoveCharactersInRange(
theSet: CFMutableCharacterSetRef,
theRange: CFRange,
);
pub fn CFCharacterSetRemoveCharactersInString(
theSet: CFMutableCharacterSetRef,
theString: CFStringRef,
);
/* Logical Operations */
pub fn CFCharacterSetIntersect(
theSet: CFMutableCharacterSetRef,
theOtherSet: CFCharacterSetRef,
);
pub fn CFCharacterSetInvert(theSet: CFMutableCharacterSetRef);
pub fn CFCharacterSetUnion(theSet: CFMutableCharacterSetRef, theOtherSet: CFCharacterSetRef);
}

@ -0,0 +1,77 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID};
use std::os::raw::c_void;
#[repr(C)]
pub struct __CFData(c_void);
pub type CFDataRef = *const __CFData;
pub type CFMutableDataRef = *mut __CFData;
pub type CFDataSearchFlags = CFOptionFlags;
// typedef CF_OPTIONS(CFOptionFlags, CFDataSearchFlags)
pub const kCFDataSearchBackwards: CFDataSearchFlags = 1usize << 0;
pub const kCFDataSearchAnchored: CFDataSearchFlags = 1usize << 1;
extern "C" {
/*
* CFData.h
*/
/* CFData */
/* Creating a CFData Object */
pub fn CFDataCreate(allocator: CFAllocatorRef, bytes: *const u8, length: CFIndex) -> CFDataRef;
pub fn CFDataCreateCopy(allocator: CFAllocatorRef, theData: CFDataRef) -> CFDataRef;
pub fn CFDataCreateWithBytesNoCopy(
allocator: CFAllocatorRef,
bytes: *const u8,
length: CFIndex,
bytesDeallocator: CFAllocatorRef,
) -> CFDataRef;
/* Examining a CFData Object */
pub fn CFDataGetBytePtr(theData: CFDataRef) -> *const u8;
pub fn CFDataGetBytes(theData: CFDataRef, range: CFRange, buffer: *mut u8);
pub fn CFDataGetLength(theData: CFDataRef) -> CFIndex;
pub fn CFDataFind(
theData: CFDataRef,
dataToFind: CFDataRef,
searchRange: CFRange,
compareOptions: CFDataSearchFlags,
) -> CFRange;
/* Getting the CFData Type ID */
pub fn CFDataGetTypeID() -> CFTypeID;
/* CFMutableData */
/* Creating a Mutable Data Object */
pub fn CFDataCreateMutable(allocator: CFAllocatorRef, capacity: CFIndex) -> CFMutableDataRef;
pub fn CFDataCreateMutableCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
theData: CFDataRef,
) -> CFMutableDataRef;
/* Accessing Data */
pub fn CFDataGetMutableBytePtr(theData: CFMutableDataRef) -> *mut u8;
/* Modifying a Mutable Data Object */
pub fn CFDataAppendBytes(theData: CFMutableDataRef, bytes: *const u8, length: CFIndex);
pub fn CFDataDeleteBytes(theData: CFMutableDataRef, range: CFRange);
pub fn CFDataReplaceBytes(
theData: CFMutableDataRef,
range: CFRange,
newBytes: *const u8,
newLength: CFIndex,
);
pub fn CFDataIncreaseLength(theData: CFMutableDataRef, extraLength: CFIndex);
pub fn CFDataSetLength(theData: CFMutableDataRef, length: CFIndex);
}

@ -0,0 +1,38 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{CFAllocatorRef, CFComparisonResult, CFTypeID};
#[repr(C)]
pub struct __CFDate(c_void);
pub type CFDateRef = *const __CFDate;
pub type CFTimeInterval = f64;
pub type CFAbsoluteTime = CFTimeInterval;
extern "C" {
pub static kCFAbsoluteTimeIntervalSince1904: CFTimeInterval;
pub static kCFAbsoluteTimeIntervalSince1970: CFTimeInterval;
pub fn CFAbsoluteTimeGetCurrent() -> CFAbsoluteTime;
pub fn CFDateCreate(allocator: CFAllocatorRef, at: CFAbsoluteTime) -> CFDateRef;
pub fn CFDateGetAbsoluteTime(date: CFDateRef) -> CFAbsoluteTime;
pub fn CFDateGetTimeIntervalSinceDate(date: CFDateRef, other: CFDateRef) -> CFTimeInterval;
pub fn CFDateCompare(
date: CFDateRef,
other: CFDateRef,
context: *mut c_void,
) -> CFComparisonResult;
pub fn CFDateGetTypeID() -> CFTypeID;
}

@ -0,0 +1,147 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef};
use crate::date::{CFAbsoluteTime, CFDateRef};
use crate::locale::CFLocaleRef;
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFDateFormatter(c_void);
pub type CFDateFormatterRef = *mut __CFDateFormatter;
pub type CFDateFormatterKey = CFStringRef;
pub type CFDateFormatterStyle = CFIndex;
pub type CFISO8601DateFormatOptions = CFOptionFlags;
/* Date Formatter Styles */
pub const kCFDateFormatterNoStyle: CFDateFormatterStyle = 0;
pub const kCFDateFormatterShortStyle: CFDateFormatterStyle = 1;
pub const kCFDateFormatterMediumStyle: CFDateFormatterStyle = 2;
pub const kCFDateFormatterLongStyle: CFDateFormatterStyle = 3;
pub const kCFDateFormatterFullStyle: CFDateFormatterStyle = 4;
//pub const kCFISO8601DateFormatWithYear: CFISO8601DateFormatOptions = 1 << 0; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithMonth: CFISO8601DateFormatOptions = 1 << 1; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithWeekOfYear: CFISO8601DateFormatOptions = 1 << 2; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithDay: CFISO8601DateFormatOptions = 1 << 4; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithTime: CFISO8601DateFormatOptions = 1 << 5; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithTimeZone: CFISO8601DateFormatOptions = 1 << 6; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithSpaceBetweenDateAndTime: CFISO8601DateFormatOptions = 1 << 7; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithDashSeparatorInDate: CFISO8601DateFormatOptions = 1 << 8; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithColonSeparatorInTime: CFISO8601DateFormatOptions = 1 << 9; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithColonSeparatorInTimeZone: CFISO8601DateFormatOptions = 1 << 10; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithFractionalSeconds: CFISO8601DateFormatOptions = 1 << 11; // macosx(10.13)+
//pub const kCFISO8601DateFormatWithFullDate: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithYear | kCFISO8601DateFormatWithMonth | kCFISO8601DateFormatWithDay | kCFISO8601DateFormatWithDashSeparatorInDate; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithFullTime: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithTime | kCFISO8601DateFormatWithColonSeparatorInTime | kCFISO8601DateFormatWithTimeZone | kCFISO8601DateFormatWithColonSeparatorInTimeZone; // macosx(10.12)+
//pub const kCFISO8601DateFormatWithInternetDateTime: CFISO8601DateFormatOptions = kCFISO8601DateFormatWithFullDate | kCFISO8601DateFormatWithFullTime; // macosx(10.12)+
extern "C" {
/*
* CFDateFormatter.h
*/
/* Date Formatter Property Keys */
// The values for these keys are all CFType objects.
// The specific types for each key are specified above.
pub static kCFDateFormatterIsLenient: CFDateFormatterKey; // CFBoolean
pub static kCFDateFormatterTimeZone: CFDateFormatterKey; // CFTimeZone
pub static kCFDateFormatterCalendarName: CFDateFormatterKey; // CFString
pub static kCFDateFormatterDefaultFormat: CFDateFormatterKey; // CFString
pub static kCFDateFormatterTwoDigitStartDate: CFDateFormatterKey; // CFDate
pub static kCFDateFormatterDefaultDate: CFDateFormatterKey; // CFDate
pub static kCFDateFormatterCalendar: CFDateFormatterKey; // CFCalendar
pub static kCFDateFormatterEraSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterMonthSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterShortMonthSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterShortWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterAMSymbol: CFDateFormatterKey; // CFString
pub static kCFDateFormatterPMSymbol: CFDateFormatterKey; // CFString
pub static kCFDateFormatterLongEraSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterVeryShortMonthSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterShortStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterVeryShortStandaloneMonthSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterVeryShortWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterShortStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterVeryShortStandaloneWeekdaySymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterQuarterSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterShortQuarterSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterStandaloneQuarterSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterShortStandaloneQuarterSymbols: CFDateFormatterKey; // CFArray of CFString
pub static kCFDateFormatterGregorianStartDate: CFDateFormatterKey; // CFDate
pub static kCFDateFormatterDoesRelativeDateFormattingKey: CFDateFormatterKey; // CFBoolean
/* Creating a Date Formatter */
pub fn CFDateFormatterCreate(
allocator: CFAllocatorRef,
locale: CFLocaleRef,
dateStyle: CFDateFormatterStyle,
timeStyle: CFDateFormatterStyle,
) -> CFDateFormatterRef;
/* Configuring a Date Formatter */
pub fn CFDateFormatterSetFormat(formatter: CFDateFormatterRef, formatString: CFStringRef);
pub fn CFDateFormatterSetProperty(
formatter: CFDateFormatterRef,
key: CFStringRef,
value: CFTypeRef,
);
/* Parsing Strings */
pub fn CFDateFormatterCreateDateFromString(
allocator: CFAllocatorRef,
formatter: CFDateFormatterRef,
string: CFStringRef,
rangep: *mut CFRange,
) -> CFDateRef;
pub fn CFDateFormatterGetAbsoluteTimeFromString(
formatter: CFDateFormatterRef,
string: CFStringRef,
rangep: *mut CFRange,
atp: *mut CFAbsoluteTime,
) -> Boolean;
/* Creating Strings From Data */
pub fn CFDateFormatterCreateStringWithAbsoluteTime(
allocator: CFAllocatorRef,
formatter: CFDateFormatterRef,
at: CFAbsoluteTime,
) -> CFStringRef;
pub fn CFDateFormatterCreateStringWithDate(
allocator: CFAllocatorRef,
formatter: CFDateFormatterRef,
date: CFDateRef,
) -> CFStringRef;
pub fn CFDateFormatterCreateDateFormatFromTemplate(
allocator: CFAllocatorRef,
tmplate: CFStringRef,
options: CFOptionFlags,
locale: CFLocaleRef,
) -> CFStringRef;
/* Getting Information About a Date Formatter */
pub fn CFDateFormatterCopyProperty(
formatter: CFDateFormatterRef,
key: CFDateFormatterKey,
) -> CFTypeRef;
pub fn CFDateFormatterGetDateStyle(formatter: CFDateFormatterRef) -> CFDateFormatterStyle;
pub fn CFDateFormatterGetFormat(formatter: CFDateFormatterRef) -> CFStringRef;
pub fn CFDateFormatterGetLocale(formatter: CFDateFormatterRef) -> CFLocaleRef;
pub fn CFDateFormatterGetTimeStyle(formatter: CFDateFormatterRef) -> CFDateFormatterStyle;
/* Getting the CFDateFormatter Type ID */
pub fn CFDateFormatterGetTypeID() -> CFTypeID;
//pub fn CFDateFormatterCreateISO8601Formatter(allocator: CFAllocatorRef, formatOptions: CFISO8601DateFormatOptions) -> CFDateFormatterRef; // macosx(10.12)+
}

@ -0,0 +1,139 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
use crate::string::CFStringRef;
pub type CFDictionaryApplierFunction =
extern "C" fn(key: *const c_void, value: *const c_void, context: *mut c_void);
pub type CFDictionaryRetainCallBack =
extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
pub type CFDictionaryReleaseCallBack =
extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
pub type CFDictionaryCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
pub type CFDictionaryEqualCallBack =
extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
pub type CFDictionaryHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFDictionaryKeyCallBacks {
pub version: CFIndex,
pub retain: CFDictionaryRetainCallBack,
pub release: CFDictionaryReleaseCallBack,
pub copyDescription: CFDictionaryCopyDescriptionCallBack,
pub equal: CFDictionaryEqualCallBack,
pub hash: CFDictionaryHashCallBack,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFDictionaryValueCallBacks {
pub version: CFIndex,
pub retain: CFDictionaryRetainCallBack,
pub release: CFDictionaryReleaseCallBack,
pub copyDescription: CFDictionaryCopyDescriptionCallBack,
pub equal: CFDictionaryEqualCallBack,
}
#[repr(C)]
pub struct __CFDictionary(c_void);
pub type CFDictionaryRef = *const __CFDictionary;
pub type CFMutableDictionaryRef = *mut __CFDictionary;
extern "C" {
/*
* CFDictionary.h
*/
pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
pub static kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks;
/* CFDictionary */
/* Creating a dictionary */
pub fn CFDictionaryCreate(
allocator: CFAllocatorRef,
keys: *const *const c_void,
values: *const *const c_void,
numValues: CFIndex,
keyCallBacks: *const CFDictionaryKeyCallBacks,
valueCallBacks: *const CFDictionaryValueCallBacks,
) -> CFDictionaryRef;
pub fn CFDictionaryCreateCopy(
allocator: CFAllocatorRef,
theDict: CFDictionaryRef,
) -> CFDictionaryRef;
/* Examining a dictionary */
pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean;
pub fn CFDictionaryContainsValue(theDict: CFDictionaryRef, value: *const c_void) -> Boolean;
pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex;
pub fn CFDictionaryGetCountOfKey(theDict: CFDictionaryRef, key: *const c_void) -> CFIndex;
pub fn CFDictionaryGetCountOfValue(heDict: CFDictionaryRef, value: *const c_void) -> CFIndex;
pub fn CFDictionaryGetKeysAndValues(
theDict: CFDictionaryRef,
keys: *mut *const c_void,
values: *mut *const c_void,
);
pub fn CFDictionaryGetValue(theDict: CFDictionaryRef, key: *const c_void) -> *const c_void;
pub fn CFDictionaryGetValueIfPresent(
theDict: CFDictionaryRef,
key: *const c_void,
value: *mut *const c_void,
) -> Boolean;
/* Applying a function to a dictionary */
pub fn CFDictionaryApplyFunction(
theDict: CFDictionaryRef,
applier: CFDictionaryApplierFunction,
context: *mut c_void,
);
/* Getting the CFDictionary type ID */
pub fn CFDictionaryGetTypeID() -> CFTypeID;
/* CFMutableDictionary */
/* Creating a Mutable Dictionary */
pub fn CFDictionaryCreateMutable(
allocator: CFAllocatorRef,
capacity: CFIndex,
keyCallbacks: *const CFDictionaryKeyCallBacks,
valueCallbacks: *const CFDictionaryValueCallBacks,
) -> CFMutableDictionaryRef;
pub fn CFDictionaryCreateMutableCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
theDict: CFDictionaryRef,
) -> CFMutableDictionaryRef;
/* Modifying a Dictionary */
pub fn CFDictionaryAddValue(
theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void,
);
pub fn CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef);
pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, key: *const c_void);
pub fn CFDictionaryReplaceValue(
theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void,
);
pub fn CFDictionarySetValue(
theDict: CFMutableDictionaryRef,
key: *const c_void,
value: *const c_void,
);
}

@ -0,0 +1,62 @@
// Copyright 2016 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{CFAllocatorRef, CFIndex, CFTypeID};
use crate::dictionary::CFDictionaryRef;
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFError(c_void);
pub type CFErrorRef = *mut __CFError;
pub type CFErrorDomain = CFStringRef;
extern "C" {
/*
* CFError.h
*/
/* Error domains */
pub static kCFErrorDomainPOSIX: CFStringRef;
pub static kCFErrorDomainOSStatus: CFStringRef;
pub static kCFErrorDomainMach: CFStringRef;
pub static kCFErrorDomainCocoa: CFStringRef;
/* Keys for the user info dictionary */
pub static kCFErrorLocalizedDescriptionKey: CFStringRef;
// pub static kCFErrorLocalizedFailureKey: CFStringRef; // macos(10.13)+
pub static kCFErrorLocalizedFailureReasonKey: CFStringRef;
pub static kCFErrorLocalizedRecoverySuggestionKey: CFStringRef;
pub static kCFErrorDescriptionKey: CFStringRef;
pub static kCFErrorUnderlyingErrorKey: CFStringRef;
pub static kCFErrorURLKey: CFStringRef;
pub static kCFErrorFilePathKey: CFStringRef;
/* Creating a CFError */
pub fn CFErrorCreate(
allocator: CFAllocatorRef,
domain: CFErrorDomain,
code: CFIndex,
userInfo: CFDictionaryRef,
) -> CFErrorRef;
//pub fn CFErrorCreateWithUserInfoKeysAndValues
/* Getting Information About an Error */
pub fn CFErrorGetDomain(err: CFErrorRef) -> CFStringRef;
pub fn CFErrorGetCode(err: CFErrorRef) -> CFIndex;
pub fn CFErrorCopyUserInfo(err: CFErrorRef) -> CFDictionaryRef;
pub fn CFErrorCopyDescription(err: CFErrorRef) -> CFStringRef;
pub fn CFErrorCopyFailureReason(err: CFErrorRef) -> CFStringRef;
pub fn CFErrorCopyRecoverySuggestion(err: CFErrorRef) -> CFStringRef;
/* Getting the CFError Type ID */
pub fn CFErrorGetTypeID() -> CFTypeID;
}

@ -0,0 +1,71 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
#[cfg(feature = "mac_os_10_8_features")]
use crate::base::CFOptionFlags;
use crate::base::{Boolean, CFAllocatorRef, CFTypeID};
use crate::uuid::CFUUIDRef;
#[repr(C)]
pub struct __CFFileSecurity(c_void);
pub type CFFileSecurityRef = *mut __CFFileSecurity;
#[cfg(feature = "mac_os_10_8_features")]
pub type CFFileSecurityClearOptions = CFOptionFlags;
#[cfg(feature = "mac_os_10_8_features")]
pub const kCFFileSecurityClearOwner: CFFileSecurityClearOptions = 1 << 0;
#[cfg(feature = "mac_os_10_8_features")]
pub const kCFFileSecurityClearGroup: CFFileSecurityClearOptions = 1 << 1;
#[cfg(feature = "mac_os_10_8_features")]
pub const kCFFileSecurityClearMode: CFFileSecurityClearOptions = 1 << 2;
#[cfg(feature = "mac_os_10_8_features")]
pub const kCFFileSecurityClearOwnerUUID: CFFileSecurityClearOptions = 1 << 3;
#[cfg(feature = "mac_os_10_8_features")]
pub const kCFFileSecurityClearGroupUUID: CFFileSecurityClearOptions = 1 << 4;
#[cfg(feature = "mac_os_10_8_features")]
pub const kCFFileSecurityClearAccessControlList: CFFileSecurityClearOptions = 1 << 5;
extern "C" {
/*
* CFFileSecurity.h
*/
pub fn CFFileSecurityGetTypeID() -> CFTypeID;
pub fn CFFileSecurityCreate(allocator: CFAllocatorRef) -> CFFileSecurityRef;
pub fn CFFileSecurityCreateCopy(
allocator: CFAllocatorRef,
fileSec: CFFileSecurityRef,
) -> CFFileSecurityRef;
pub fn CFFileSecurityCopyOwnerUUID(
fileSec: CFFileSecurityRef,
ownerUUID: *mut CFUUIDRef,
) -> Boolean;
pub fn CFFileSecuritySetOwnerUUID(fileSec: CFFileSecurityRef, ownerUUID: CFUUIDRef) -> Boolean;
pub fn CFFileSecurityCopyGroupUUID(
fileSec: CFFileSecurityRef,
groupUUID: *mut CFUUIDRef,
) -> Boolean;
pub fn CFFileSecuritySetGroupUUID(fileSec: CFFileSecurityRef, groupUUID: CFUUIDRef) -> Boolean;
//pub fn CFFileSecurityCopyAccessControlList(fileSec: CFFileSecurityRef, accessControlList: *mut acl_t) -> Boolean;
//pub fn CFFileSecuritySetAccessControlList(fileSec: CFFileSecurityRef, accessControlList: acl_t) -> Boolean;
//pub fn CFFileSecurityGetOwner(fileSec: CFFileSecurityRef, owner: *mut uid_t) -> Boolean;
//pub fn CFFileSecuritySetOwner(fileSec: CFFileSecurityRef, owner: uid_t) -> Boolean;
//pub fn CFFileSecurityGetGroup(fileSec: CFFileSecurityRef, group: *mut gid_t) -> Boolean;
//pub fn CFFileSecuritySetGroup(fileSec: CFFileSecurityRef, group: gid_t) -> Boolean;
//pub fn CFFileSecurityGetMode(fileSec: CFFileSecurityRef, mode: *mut mode_t) -> Boolean;
//pub fn CFFileSecuritySetMode(fileSec: CFFileSecurityRef, mode: mode_t) -> Boolean;
#[cfg(feature = "mac_os_10_8_features")]
#[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")]
pub fn CFFileSecurityClearProperties(
fileSec: CFFileSecurityRef,
clearPropertyMask: CFFileSecurityClearOptions,
) -> Boolean;
}

@ -0,0 +1,80 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_int, c_void};
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID};
use crate::runloop::CFRunLoopSourceRef;
use crate::string::CFStringRef;
pub type CFFileDescriptorNativeDescriptor = c_int;
#[repr(C)]
pub struct __CFFileDescriptor(c_void);
pub type CFFileDescriptorRef = *mut __CFFileDescriptor;
/* Callback Reason Types */
pub const kCFFileDescriptorReadCallBack: CFOptionFlags = 1 << 0;
pub const kCFFileDescriptorWriteCallBack: CFOptionFlags = 1 << 1;
pub type CFFileDescriptorCallBack =
extern "C" fn(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags, info: *mut c_void);
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFFileDescriptorContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>,
pub release: Option<extern "C" fn(info: *const c_void)>,
pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>,
}
extern "C" {
/*
* CFFileDescriptor.h
*/
/* Creating a CFFileDescriptor */
pub fn CFFileDescriptorCreate(
allocator: CFAllocatorRef,
fd: CFFileDescriptorNativeDescriptor,
closeOnInvalidate: Boolean,
callout: CFFileDescriptorCallBack,
context: *const CFFileDescriptorContext,
) -> CFFileDescriptorRef;
/* Getting Information About a File Descriptor */
pub fn CFFileDescriptorGetNativeDescriptor(
f: CFFileDescriptorRef,
) -> CFFileDescriptorNativeDescriptor;
pub fn CFFileDescriptorIsValid(f: CFFileDescriptorRef) -> Boolean;
pub fn CFFileDescriptorGetContext(
f: CFFileDescriptorRef,
context: *mut CFFileDescriptorContext,
);
/* Invalidating a File Descriptor */
pub fn CFFileDescriptorInvalidate(f: CFFileDescriptorRef);
/* Managing Callbacks */
pub fn CFFileDescriptorEnableCallBacks(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags);
pub fn CFFileDescriptorDisableCallBacks(f: CFFileDescriptorRef, callBackTypes: CFOptionFlags);
/* Creating a Run Loop Source */
pub fn CFFileDescriptorCreateRunLoopSource(
allocator: CFAllocatorRef,
f: CFFileDescriptorRef,
order: CFIndex,
) -> CFRunLoopSourceRef;
/* Getting the CFFileDescriptor Type ID */
pub fn CFFileDescriptorGetTypeID() -> CFTypeID;
}

@ -0,0 +1,80 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(
non_snake_case,
non_camel_case_types,
non_upper_case_globals,
improper_ctypes
)]
#![cfg_attr(
all(feature = "mac_os_10_7_support", feature = "mac_os_10_8_features"),
feature(linkage)
)] // back-compat requires weak linkage
// Link to CoreFoundation on any Apple device.
//
// We don't use `target_vendor` since that is going to be deprecated:
// https://github.com/rust-lang/lang-team/issues/102
#[cfg_attr(
all(
any(
target_os = "macos",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
),
feature = "link"
),
link(name = "CoreFoundation", kind = "framework")
)]
extern "C" {}
pub mod array;
pub mod attributed_string;
pub mod bag;
pub mod base;
pub mod binary_heap;
pub mod bit_vector;
pub mod bundle;
pub mod calendar;
pub mod characterset;
pub mod data;
pub mod date;
pub mod date_formatter;
pub mod dictionary;
pub mod error;
pub mod file_security;
pub mod filedescriptor;
pub mod locale;
pub mod mach_port;
pub mod messageport;
pub mod notification_center;
pub mod number;
pub mod number_formatter;
pub mod plugin;
pub mod preferences;
pub mod propertylist;
pub mod runloop;
pub mod set;
pub mod socket;
pub mod stream;
pub mod string;
pub mod string_tokenizer;
pub mod timezone;
pub mod tree;
pub mod url;
pub mod url_enumerator;
#[cfg(target_os = "macos")]
pub mod user_notification;
pub mod uuid;
#[cfg(target_os = "macos")]
pub mod xml_node;
#[cfg(target_os = "macos")]
pub mod xml_parser;

@ -0,0 +1,146 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::array::CFArrayRef;
use crate::base::{CFAllocatorRef, CFIndex, CFTypeID, CFTypeRef, LangCode, RegionCode};
use crate::dictionary::CFDictionaryRef;
use crate::notification_center::CFNotificationName;
use crate::string::CFStringRef;
use std::os::raw::c_void;
#[repr(C)]
pub struct __CFLocale(c_void);
pub type CFLocaleRef = *const __CFLocale;
pub type CFLocaleIdentifier = CFStringRef;
pub type CFLocaleKey = CFStringRef;
pub type CFCalendarIdentifier = CFStringRef;
pub type CFLocaleLanguageDirection = CFIndex;
pub const kCFLocaleLanguageDirectionUnknown: CFLocaleLanguageDirection = 0;
pub const kCFLocaleLanguageDirectionLeftToRight: CFLocaleLanguageDirection = 1;
pub const kCFLocaleLanguageDirectionRightToLeft: CFLocaleLanguageDirection = 2;
pub const kCFLocaleLanguageDirectionTopToBottom: CFLocaleLanguageDirection = 3;
pub const kCFLocaleLanguageDirectionBottomToTop: CFLocaleLanguageDirection = 4;
extern "C" {
/*
* CFLocale.h
*/
/* Locale Change Notification */
pub static kCFLocaleCurrentLocaleDidChangeNotification: CFNotificationName;
/* Locale Property Keys */
pub static kCFLocaleIdentifier: CFLocaleKey;
pub static kCFLocaleLanguageCode: CFLocaleKey;
pub static kCFLocaleCountryCode: CFLocaleKey;
pub static kCFLocaleScriptCode: CFLocaleKey;
pub static kCFLocaleVariantCode: CFLocaleKey;
pub static kCFLocaleExemplarCharacterSet: CFLocaleKey;
pub static kCFLocaleCalendarIdentifier: CFLocaleKey;
pub static kCFLocaleCalendar: CFLocaleKey;
pub static kCFLocaleCollationIdentifier: CFLocaleKey;
pub static kCFLocaleUsesMetricSystem: CFLocaleKey;
pub static kCFLocaleMeasurementSystem: CFLocaleKey;
pub static kCFLocaleDecimalSeparator: CFLocaleKey;
pub static kCFLocaleGroupingSeparator: CFLocaleKey;
pub static kCFLocaleCurrencySymbol: CFLocaleKey;
pub static kCFLocaleCurrencyCode: CFLocaleKey;
pub static kCFLocaleCollatorIdentifier: CFLocaleKey;
pub static kCFLocaleQuotationBeginDelimiterKey: CFLocaleKey;
pub static kCFLocaleQuotationEndDelimiterKey: CFLocaleKey;
pub static kCFLocaleAlternateQuotationBeginDelimiterKey: CFLocaleKey;
pub static kCFLocaleAlternateQuotationEndDelimiterKey: CFLocaleKey;
/* Locale Calendar Identifiers */
pub static kCFGregorianCalendar: CFCalendarIdentifier;
pub static kCFBuddhistCalendar: CFCalendarIdentifier;
pub static kCFChineseCalendar: CFCalendarIdentifier;
pub static kCFHebrewCalendar: CFCalendarIdentifier;
pub static kCFIslamicCalendar: CFCalendarIdentifier;
pub static kCFIslamicCivilCalendar: CFCalendarIdentifier;
pub static kCFJapaneseCalendar: CFCalendarIdentifier;
pub static kCFRepublicOfChinaCalendar: CFCalendarIdentifier;
pub static kCFPersianCalendar: CFCalendarIdentifier;
pub static kCFIndianCalendar: CFCalendarIdentifier;
pub static kCFISO8601Calendar: CFCalendarIdentifier;
//pub static kCFIslamicTabularCalendar: CFCalendarIdentifier; // macos(10.10)+
//pub static kCFIslamicUmmAlQuraCalendar: CFCalendarIdentifier; // macos(10.10)+
/* Creating a Locale */
pub fn CFLocaleCopyCurrent() -> CFLocaleRef;
pub fn CFLocaleCreate(
allocator: CFAllocatorRef,
localeIdentifier: CFLocaleIdentifier,
) -> CFLocaleRef;
pub fn CFLocaleCreateCopy(allocator: CFAllocatorRef, locale: CFLocaleRef) -> CFLocaleRef;
pub fn CFLocaleGetSystem() -> CFLocaleRef;
/* Getting System Locale Information */
pub fn CFLocaleCopyAvailableLocaleIdentifiers() -> CFArrayRef;
/* Getting ISO Information */
pub fn CFLocaleCopyISOCountryCodes() -> CFArrayRef;
pub fn CFLocaleCopyISOLanguageCodes() -> CFArrayRef;
pub fn CFLocaleCopyISOCurrencyCodes() -> CFArrayRef;
pub fn CFLocaleCopyCommonISOCurrencyCodes() -> CFArrayRef;
/* Language Preferences */
pub fn CFLocaleCopyPreferredLanguages() -> CFArrayRef;
/* Getting Information About a Locale */
pub fn CFLocaleCopyDisplayNameForPropertyValue(
displayLocale: CFLocaleRef,
key: CFLocaleKey,
value: CFStringRef,
) -> CFStringRef;
pub fn CFLocaleGetValue(locale: CFLocaleRef, key: CFLocaleKey) -> CFTypeRef;
pub fn CFLocaleGetIdentifier(locale: CFLocaleRef) -> CFLocaleIdentifier;
/* Getting and Creating Locale Identifiers */
pub fn CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(
allocator: CFAllocatorRef,
lcode: LangCode,
rcode: RegionCode,
) -> CFLocaleIdentifier;
pub fn CFLocaleCreateCanonicalLanguageIdentifierFromString(
allocator: CFAllocatorRef,
localeIdentifier: CFStringRef,
) -> CFLocaleIdentifier;
pub fn CFLocaleCreateCanonicalLocaleIdentifierFromString(
allocator: CFAllocatorRef,
localeIdentifier: CFStringRef,
) -> CFLocaleIdentifier;
pub fn CFLocaleCreateComponentsFromLocaleIdentifier(
allocator: CFAllocatorRef,
localeID: CFLocaleIdentifier,
) -> CFDictionaryRef;
pub fn CFLocaleCreateLocaleIdentifierFromComponents(
allocator: CFAllocatorRef,
dictionary: CFDictionaryRef,
) -> CFLocaleIdentifier;
pub fn CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(
allocator: CFAllocatorRef,
lcid: u32,
) -> CFLocaleIdentifier;
pub fn CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(
localeIdentifier: CFLocaleIdentifier,
) -> u32;
/* Getting Line and Character Direction for a Language */
pub fn CFLocaleGetLanguageCharacterDirection(
isoLangCode: CFStringRef,
) -> CFLocaleLanguageDirection;
pub fn CFLocaleGetLanguageLineDirection(isoLangCode: CFStringRef) -> CFLocaleLanguageDirection;
/* Getting the CFLocale Type ID */
pub fn CFLocaleGetTypeID() -> CFTypeID;
}

@ -0,0 +1,75 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::base::{mach_port_t, Boolean};
pub use crate::base::{CFAllocatorRef, CFIndex, CFTypeID};
use crate::runloop::CFRunLoopSourceRef;
use crate::string::CFStringRef;
use std::os::raw::c_void;
#[repr(C)]
pub struct __CFMachPort(c_void);
pub type CFMachPortRef = *mut __CFMachPort;
pub type CFMachPortCallBack =
extern "C" fn(port: CFMachPortRef, msg: *mut c_void, size: CFIndex, info: *mut c_void);
pub type CFMachPortInvalidationCallBack = extern "C" fn(port: CFMachPortRef, info: *mut c_void);
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFMachPortContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: extern "C" fn(info: *const c_void) -> *const c_void,
pub release: extern "C" fn(info: *const c_void),
pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef,
}
extern "C" {
/*
* CFMachPort.h
*/
/* Creating a CFMachPort Object */
pub fn CFMachPortCreate(
allocator: CFAllocatorRef,
callout: CFMachPortCallBack,
context: *mut CFMachPortContext,
shouldFreeInfo: *mut Boolean,
) -> CFMachPortRef;
pub fn CFMachPortCreateWithPort(
allocator: CFAllocatorRef,
portNum: mach_port_t,
callout: CFMachPortCallBack,
context: *mut CFMachPortContext,
shouldFreeInfo: *mut Boolean,
) -> CFMachPortRef;
/* Configuring a CFMachPort Object */
pub fn CFMachPortInvalidate(port: CFMachPortRef);
pub fn CFMachPortCreateRunLoopSource(
allocator: CFAllocatorRef,
port: CFMachPortRef,
order: CFIndex,
) -> CFRunLoopSourceRef;
pub fn CFMachPortSetInvalidationCallBack(
port: CFMachPortRef,
callout: CFMachPortInvalidationCallBack,
);
/* Examining a CFMachPort Object */
pub fn CFMachPortGetContext(port: CFMachPortRef, context: *mut CFMachPortContext);
pub fn CFMachPortGetInvalidationCallBack(port: CFMachPortRef)
-> CFMachPortInvalidationCallBack;
pub fn CFMachPortGetPort(port: CFMachPortRef) -> mach_port_t;
pub fn CFMachPortIsValid(port: CFMachPortRef) -> Boolean;
/* Getting the CFMachPort Type ID */
pub fn CFMachPortGetTypeID() -> CFTypeID;
}

@ -0,0 +1,106 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID, SInt32};
use crate::data::CFDataRef;
use crate::date::CFTimeInterval;
use crate::runloop::CFRunLoopSourceRef;
use crate::string::CFStringRef;
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct CFMessagePortContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<unsafe extern "C" fn(info: *const c_void) -> *const c_void>,
pub release: Option<unsafe extern "C" fn(info: *const c_void)>,
pub copyDescription: Option<unsafe extern "C" fn(info: *const c_void) -> CFStringRef>,
}
pub type CFMessagePortCallBack = Option<
unsafe extern "C" fn(
local: CFMessagePortRef,
msgid: i32,
data: CFDataRef,
info: *mut c_void,
) -> CFDataRef,
>;
pub type CFMessagePortInvalidationCallBack =
Option<unsafe extern "C" fn(ms: CFMessagePortRef, info: *mut c_void)>;
/* CFMessagePortSendRequest Error Codes */
pub const kCFMessagePortSuccess: SInt32 = 0;
pub const kCFMessagePortSendTimeout: SInt32 = -1;
pub const kCFMessagePortReceiveTimeout: SInt32 = -2;
pub const kCFMessagePortIsInvalid: SInt32 = -3;
pub const kCFMessagePortTransportError: SInt32 = -4;
pub const kCFMessagePortBecameInvalidError: SInt32 = -5;
#[repr(C)]
pub struct __CFMessagePort(c_void);
pub type CFMessagePortRef = *mut __CFMessagePort;
extern "C" {
/*
* CFMessagePort.h
*/
/* Creating a CFMessagePort Object */
pub fn CFMessagePortCreateLocal(
allocator: CFAllocatorRef,
name: CFStringRef,
callout: CFMessagePortCallBack,
context: *const CFMessagePortContext,
shouldFreeInfo: *mut Boolean,
) -> CFMessagePortRef;
pub fn CFMessagePortCreateRemote(
allocator: CFAllocatorRef,
name: CFStringRef,
) -> CFMessagePortRef;
/* Configuring a CFMessagePort Object */
pub fn CFMessagePortCreateRunLoopSource(
allocator: CFAllocatorRef,
local: CFMessagePortRef,
order: CFIndex,
) -> CFRunLoopSourceRef;
pub fn CFMessagePortSetInvalidationCallBack(
ms: CFMessagePortRef,
callout: CFMessagePortInvalidationCallBack,
);
pub fn CFMessagePortSetName(ms: CFMessagePortRef, newName: CFStringRef) -> Boolean;
/* Using a Message Port */
pub fn CFMessagePortInvalidate(ms: CFMessagePortRef);
pub fn CFMessagePortSendRequest(
remote: CFMessagePortRef,
msgid: i32,
data: CFDataRef,
sendTimeout: CFTimeInterval,
rcvTimeout: CFTimeInterval,
replyMode: CFStringRef,
returnData: *mut CFDataRef,
) -> i32;
//pub fn CFMessagePortSetDispatchQueue(ms: CFMessagePortRef, queue: dispatch_queue_t);
/* Examining a Message Port */
pub fn CFMessagePortGetContext(ms: CFMessagePortRef, context: *mut CFMessagePortContext);
pub fn CFMessagePortGetInvalidationCallBack(
ms: CFMessagePortRef,
) -> CFMessagePortInvalidationCallBack;
pub fn CFMessagePortGetName(ms: CFMessagePortRef) -> CFStringRef;
pub fn CFMessagePortIsRemote(ms: CFMessagePortRef) -> Boolean;
pub fn CFMessagePortIsValid(ms: CFMessagePortRef) -> Boolean;
/* Getting the CFMessagePort Type ID */
pub fn CFMessagePortGetTypeID() -> CFTypeID;
}

@ -0,0 +1,89 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFIndex, CFOptionFlags, CFTypeID};
use crate::dictionary::CFDictionaryRef;
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFNotificationCenter(c_void);
pub type CFNotificationCenterRef = *mut __CFNotificationCenter;
pub type CFNotificationName = CFStringRef;
pub type CFNotificationCallback = extern "C" fn(
center: CFNotificationCenterRef,
observer: *mut c_void,
name: CFNotificationName,
object: *const c_void,
userInfo: CFDictionaryRef,
);
pub type CFNotificationSuspensionBehavior = CFIndex;
pub const CFNotificationSuspensionBehaviorDrop: CFNotificationSuspensionBehavior = 1;
pub const CFNotificationSuspensionBehaviorCoalesce: CFNotificationSuspensionBehavior = 2;
pub const CFNotificationSuspensionBehaviorHold: CFNotificationSuspensionBehavior = 3;
pub const CFNotificationSuspensionBehaviorDeliverImmediately: CFNotificationSuspensionBehavior = 4;
/* Notification Posting Options */
pub const kCFNotificationDeliverImmediately: CFOptionFlags = 1usize << 0;
pub const kCFNotificationPostToAllSessions: CFOptionFlags = 1usize << 1;
extern "C" {
/*
* CFNotificationCenter.h
*/
/* Accessing a Notification Center */
pub fn CFNotificationCenterGetDarwinNotifyCenter() -> CFNotificationCenterRef;
#[cfg(any(target_os = "macos", target_os = "windows"))]
pub fn CFNotificationCenterGetDistributedCenter() -> CFNotificationCenterRef;
pub fn CFNotificationCenterGetLocalCenter() -> CFNotificationCenterRef;
/* Posting a Notification */
pub fn CFNotificationCenterPostNotification(
center: CFNotificationCenterRef,
name: CFNotificationName,
object: *const c_void,
userInfo: CFDictionaryRef,
deliverImmediately: Boolean,
);
pub fn CFNotificationCenterPostNotificationWithOptions(
center: CFNotificationCenterRef,
name: CFNotificationName,
object: *const c_void,
userInfo: CFDictionaryRef,
options: CFOptionFlags,
);
/* Adding and Removing Observers */
pub fn CFNotificationCenterAddObserver(
center: CFNotificationCenterRef,
observer: *const c_void,
callBack: CFNotificationCallback,
name: CFStringRef,
object: *const c_void,
suspensionBehavior: CFNotificationSuspensionBehavior,
);
pub fn CFNotificationCenterRemoveEveryObserver(
center: CFNotificationCenterRef,
observer: *const c_void,
);
pub fn CFNotificationCenterRemoveObserver(
center: CFNotificationCenterRef,
observer: *const c_void,
name: CFNotificationName,
object: *const c_void,
);
/* Getting the CFNotificationCenter Type ID */
pub fn CFNotificationCenterGetTypeID() -> CFTypeID;
}

@ -0,0 +1,106 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID};
#[repr(C)]
pub struct __CFBoolean(c_void);
pub type CFBooleanRef = *const __CFBoolean;
pub type CFNumberType = u32;
// members of enum CFNumberType
pub const kCFNumberSInt8Type: CFNumberType = 1;
pub const kCFNumberSInt16Type: CFNumberType = 2;
pub const kCFNumberSInt32Type: CFNumberType = 3;
pub const kCFNumberSInt64Type: CFNumberType = 4;
pub const kCFNumberFloat32Type: CFNumberType = 5;
pub const kCFNumberFloat64Type: CFNumberType = 6;
pub const kCFNumberCharType: CFNumberType = 7;
pub const kCFNumberShortType: CFNumberType = 8;
pub const kCFNumberIntType: CFNumberType = 9;
pub const kCFNumberLongType: CFNumberType = 10;
pub const kCFNumberLongLongType: CFNumberType = 11;
pub const kCFNumberFloatType: CFNumberType = 12;
pub const kCFNumberDoubleType: CFNumberType = 13;
pub const kCFNumberCFIndexType: CFNumberType = 14;
pub const kCFNumberNSIntegerType: CFNumberType = 15;
pub const kCFNumberCGFloatType: CFNumberType = 16;
pub const kCFNumberMaxType: CFNumberType = 16;
// This is an enum due to zero-sized types warnings.
// For more details see https://github.com/rust-lang/rust/issues/27303
pub enum __CFNumber {}
pub type CFNumberRef = *const __CFNumber;
extern "C" {
/*
* CFNumber.h
*/
pub static kCFBooleanTrue: CFBooleanRef;
pub static kCFBooleanFalse: CFBooleanRef;
pub static kCFNumberPositiveInfinity: CFNumberRef;
pub static kCFNumberNegativeInfinity: CFNumberRef;
pub static kCFNumberNaN: CFNumberRef;
/* Creating a Number */
pub fn CFNumberCreate(
allocator: CFAllocatorRef,
theType: CFNumberType,
valuePtr: *const c_void,
) -> CFNumberRef;
/* Getting Information About Numbers */
pub fn CFNumberGetByteSize(number: CFNumberRef) -> CFIndex;
pub fn CFNumberGetType(number: CFNumberRef) -> CFNumberType;
pub fn CFNumberGetValue(
number: CFNumberRef,
theType: CFNumberType,
valuePtr: *mut c_void,
) -> bool;
pub fn CFNumberIsFloatType(number: CFNumberRef) -> Boolean;
/* Comparing Numbers */
pub fn CFNumberCompare(
date: CFNumberRef,
other: CFNumberRef,
context: *mut c_void,
) -> CFComparisonResult;
/* Getting the CFNumber Type ID */
pub fn CFNumberGetTypeID() -> CFTypeID;
pub fn CFBooleanGetValue(boolean: CFBooleanRef) -> bool;
pub fn CFBooleanGetTypeID() -> CFTypeID;
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn match_for_type_id_should_be_backwards_compatible() {
let type_id = kCFNumberFloat32Type;
// this is the old style of matching for static variables
match type_id {
vf64 if vf64 == kCFNumberFloat32Type => assert!(true),
_ => panic!("should not happen"),
};
// this is new new style of matching for consts
match type_id {
kCFNumberFloat32Type => assert!(true),
_ => panic!("should not happen"),
};
}
}

@ -0,0 +1,163 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_double, c_void};
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef};
use crate::locale::CFLocaleRef;
use crate::number::{CFNumberRef, CFNumberType};
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFNumberFormatter(c_void);
pub type CFNumberFormatterRef = *mut __CFNumberFormatter;
pub type CFNumberFormatterKey = CFStringRef;
pub type CFNumberFormatterStyle = CFIndex;
pub type CFNumberFormatterOptionFlags = CFOptionFlags;
pub type CFNumberFormatterRoundingMode = CFIndex;
pub type CFNumberFormatterPadPosition = CFIndex;
/* Number Formatter Styles */
pub const kCFNumberFormatterNoStyle: CFNumberFormatterStyle = 0;
pub const kCFNumberFormatterDecimalStyle: CFNumberFormatterStyle = 1;
pub const kCFNumberFormatterCurrencyStyle: CFNumberFormatterStyle = 2;
pub const kCFNumberFormatterPercentStyle: CFNumberFormatterStyle = 3;
pub const kCFNumberFormatterScientificStyle: CFNumberFormatterStyle = 4;
pub const kCFNumberFormatterSpellOutStyle: CFNumberFormatterStyle = 5;
//pub const kCFNumberFormatterOrdinalStyle: CFNumberFormatterStyle = 6; // macos(10.11)+
//pub const kCFNumberFormatterCurrencyISOCodeStyle: CFNumberFormatterStyle = 8; // macos(10.11)+
//pub const kCFNumberFormatterCurrencyPluralStyle: CFNumberFormatterStyle = 9; // macos(10.11)+
//pub const kCFNumberFormatterCurrencyAccountingStyle: CFNumberFormatterStyle = 10; // macos(10.11)+
/* Number Format Options */
pub const kCFNumberFormatterParseIntegersOnly: CFNumberFormatterOptionFlags = 1;
/* CFNumberFormatterRoundingMode */
pub const kCFNumberFormatterRoundCeiling: CFNumberFormatterRoundingMode = 0;
pub const kCFNumberFormatterRoundFloor: CFNumberFormatterRoundingMode = 1;
pub const kCFNumberFormatterRoundDown: CFNumberFormatterRoundingMode = 2;
pub const kCFNumberFormatterRoundUp: CFNumberFormatterRoundingMode = 3;
pub const kCFNumberFormatterRoundHalfEven: CFNumberFormatterRoundingMode = 4;
pub const kCFNumberFormatterRoundHalfDown: CFNumberFormatterRoundingMode = 5;
pub const kCFNumberFormatterRoundHalfUp: CFNumberFormatterRoundingMode = 6;
/* Padding Positions */
pub const kCFNumberFormatterPadBeforePrefix: CFNumberFormatterPadPosition = 0;
pub const kCFNumberFormatterPadAfterPrefix: CFNumberFormatterPadPosition = 1;
pub const kCFNumberFormatterPadBeforeSuffix: CFNumberFormatterPadPosition = 2;
pub const kCFNumberFormatterPadAfterSuffix: CFNumberFormatterPadPosition = 3;
extern "C" {
/*
* CFNumberFormatter.h
*/
/* Number Formatter Property Keys */
// The values for these keys are all CFType objects.
// The specific types for each key are specified above.
pub static kCFNumberFormatterCurrencyCode: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterDecimalSeparator: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterCurrencyDecimalSeparator: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterAlwaysShowDecimalSeparator: CFNumberFormatterKey; // CFBoolean
pub static kCFNumberFormatterGroupingSeparator: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterUseGroupingSeparator: CFNumberFormatterKey; // CFBoolean
pub static kCFNumberFormatterPercentSymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterZeroSymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterNaNSymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterInfinitySymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterMinusSign: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterPlusSign: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterCurrencySymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterExponentSymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterMinIntegerDigits: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterMaxIntegerDigits: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterMinFractionDigits: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterMaxFractionDigits: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterGroupingSize: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterSecondaryGroupingSize: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterRoundingMode: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterRoundingIncrement: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterFormatWidth: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterPaddingPosition: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterPaddingCharacter: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterDefaultFormat: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterMultiplier: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterPositivePrefix: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterPositiveSuffix: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterNegativePrefix: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterNegativeSuffix: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterPerMillSymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterInternationalCurrencySymbol: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterCurrencyGroupingSeparator: CFNumberFormatterKey; // CFString
pub static kCFNumberFormatterIsLenient: CFNumberFormatterKey; // CFBoolean
pub static kCFNumberFormatterUseSignificantDigits: CFNumberFormatterKey; // CFBoolean
pub static kCFNumberFormatterMinSignificantDigits: CFNumberFormatterKey; // CFNumber
pub static kCFNumberFormatterMaxSignificantDigits: CFNumberFormatterKey; // CFNumber
/* Creating a Number Formatter */
pub fn CFNumberFormatterCreate(
allocator: CFAllocatorRef,
locale: CFLocaleRef,
style: CFNumberFormatterStyle,
) -> CFNumberFormatterRef;
/* Configuring a Number Formatter */
pub fn CFNumberFormatterSetFormat(formatter: CFNumberFormatterRef, formatString: CFStringRef);
pub fn CFNumberFormatterSetProperty(
formatter: CFNumberFormatterRef,
key: CFNumberFormatterKey,
value: CFTypeRef,
);
/* Formatting Values */
pub fn CFNumberFormatterCreateNumberFromString(
allocator: CFAllocatorRef,
formatter: CFNumberFormatterRef,
string: CFStringRef,
rangep: *mut CFRange,
options: CFOptionFlags,
) -> CFNumberRef;
pub fn CFNumberFormatterCreateStringWithNumber(
allocator: CFAllocatorRef,
formatter: CFNumberFormatterRef,
number: CFNumberRef,
) -> CFStringRef;
pub fn CFNumberFormatterCreateStringWithValue(
allocator: CFAllocatorRef,
formatter: CFNumberFormatterRef,
numberType: CFNumberType,
valuePtr: *const c_void,
) -> CFStringRef;
pub fn CFNumberFormatterGetDecimalInfoForCurrencyCode(
currencyCode: CFStringRef,
defaultFractionDigits: *mut i32,
roundingIncrement: *mut c_double,
) -> Boolean;
pub fn CFNumberFormatterGetValueFromString(
formatter: CFNumberFormatterRef,
string: CFStringRef,
rangep: *mut CFRange,
numberType: CFNumberType,
valuePtr: *mut c_void,
) -> Boolean;
/* Examining a Number Formatter */
pub fn CFNumberFormatterCopyProperty(
formatter: CFNumberFormatterRef,
key: CFNumberFormatterKey,
) -> CFTypeRef;
pub fn CFNumberFormatterGetFormat(formatter: CFNumberFormatterRef) -> CFStringRef;
pub fn CFNumberFormatterGetLocale(formatter: CFNumberFormatterRef) -> CFLocaleRef;
pub fn CFNumberFormatterGetStyle(formatter: CFNumberFormatterRef) -> CFNumberFormatterStyle;
/* Getting the CFNumberFormatter Type ID */
pub fn CFNumberFormatterGetTypeID() -> CFTypeID;
}

@ -0,0 +1,99 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
use crate::bundle::{CFBundleRef, CFPlugInRef};
use crate::string::CFStringRef;
use crate::url::CFURLRef;
use crate::uuid::CFUUIDRef;
#[repr(C)]
pub struct __CFPlugInInstance(c_void);
pub type CFPlugInInstanceRef = *mut __CFPlugInInstance;
pub type CFPlugInDynamicRegisterFunction = extern "C" fn(plugIn: CFPlugInRef);
pub type CFPlugInUnloadFunction = extern "C" fn(plugIn: CFPlugInRef);
pub type CFPlugInFactoryFunction =
extern "C" fn(allocator: CFAllocatorRef, typeUUID: CFUUIDRef) -> *mut c_void;
pub type CFPlugInInstanceGetInterfaceFunction = extern "C" fn(
instance: CFPlugInInstanceRef,
interfaceName: CFStringRef,
ftbl: *mut *mut c_void,
) -> Boolean;
pub type CFPlugInInstanceDeallocateInstanceDataFunction = extern "C" fn(instanceData: *mut c_void);
extern "C" {
/*
* CFPlugIn.h
*/
/* CFPlugIn */
/* Information Property List Keys */
pub static kCFPlugInDynamicRegistrationKey: CFStringRef;
pub static kCFPlugInDynamicRegisterFunctionKey: CFStringRef;
pub static kCFPlugInUnloadFunctionKey: CFStringRef;
pub static kCFPlugInFactoriesKey: CFStringRef;
pub static kCFPlugInTypesKey: CFStringRef;
/* Creating Plug-ins */
pub fn CFPlugInCreate(allocator: CFAllocatorRef, plugInURL: CFURLRef) -> CFPlugInRef;
pub fn CFPlugInInstanceCreate(
allocator: CFAllocatorRef,
factoryUUID: CFUUIDRef,
typeUUID: CFUUIDRef,
) -> *mut c_void;
/* Registration */
pub fn CFPlugInRegisterFactoryFunction(
factoryUUID: CFUUIDRef,
func: CFPlugInFactoryFunction,
) -> Boolean;
pub fn CFPlugInRegisterFactoryFunctionByName(
CfactoryUUID: CFUUIDRef,
plugIn: CFPlugInRef,
functionName: CFStringRef,
) -> Boolean;
pub fn CFPlugInRegisterPlugInType(factoryUUID: CFUUIDRef, typeUUID: CFUUIDRef) -> Boolean;
pub fn CFPlugInUnregisterFactory(factoryUUID: CFUUIDRef) -> Boolean;
pub fn CFPlugInUnregisterPlugInType(factoryUUID: CFUUIDRef, typeUUID: CFUUIDRef) -> Boolean;
/* CFPlugIn Miscellaneous Functions */
pub fn CFPlugInAddInstanceForFactory(factoryID: CFUUIDRef);
pub fn CFPlugInFindFactoriesForPlugInType(typeUUID: CFUUIDRef) -> CFArrayRef;
pub fn CFPlugInFindFactoriesForPlugInTypeInPlugIn(
typeUUID: CFUUIDRef,
plugIn: CFPlugInRef,
) -> CFArrayRef;
pub fn CFPlugInGetBundle(plugIn: CFPlugInRef) -> CFBundleRef;
pub fn CFPlugInGetTypeID() -> CFTypeID;
pub fn CFPlugInIsLoadOnDemand(plugIn: CFPlugInRef) -> Boolean;
pub fn CFPlugInRemoveInstanceForFactory(factoryID: CFUUIDRef);
pub fn CFPlugInSetLoadOnDemand(plugIn: CFPlugInRef, flag: Boolean);
/* CFPlugInInstance: deprecated */
pub fn CFPlugInInstanceCreateWithInstanceDataSize(
allocator: CFAllocatorRef,
instanceDataSize: CFIndex,
deallocateInstanceFunction: CFPlugInInstanceDeallocateInstanceDataFunction,
factoryName: CFStringRef,
getInterfaceFunction: CFPlugInInstanceGetInterfaceFunction,
) -> CFPlugInInstanceRef;
pub fn CFPlugInInstanceGetFactoryName(instance: CFPlugInInstanceRef) -> CFStringRef;
pub fn CFPlugInInstanceGetInstanceData(instance: CFPlugInInstanceRef) -> *mut c_void;
pub fn CFPlugInInstanceGetInterfaceFunctionTable(
instance: CFPlugInInstanceRef,
interfaceName: CFStringRef,
ftbl: *mut *mut c_void,
) -> Boolean;
pub fn CFPlugInInstanceGetTypeID() -> CFTypeID;
}

@ -0,0 +1,103 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFIndex};
use crate::dictionary::CFDictionaryRef;
use crate::propertylist::CFPropertyListRef;
use crate::string::CFStringRef;
extern "C" {
/*
* CFPreferences.h
*/
/* Application, Host, and User Keys */
pub static kCFPreferencesAnyApplication: CFStringRef;
pub static kCFPreferencesCurrentApplication: CFStringRef;
pub static kCFPreferencesAnyHost: CFStringRef;
pub static kCFPreferencesCurrentHost: CFStringRef;
pub static kCFPreferencesAnyUser: CFStringRef;
pub static kCFPreferencesCurrentUser: CFStringRef;
/* Getting Preference Values */
pub fn CFPreferencesCopyAppValue(
key: CFStringRef,
applicationID: CFStringRef,
) -> CFPropertyListRef;
pub fn CFPreferencesCopyKeyList(
applicationID: CFStringRef,
userName: CFStringRef,
hostName: CFStringRef,
) -> CFArrayRef;
pub fn CFPreferencesCopyMultiple(
keysToFetch: CFArrayRef,
applicationID: CFStringRef,
userName: CFStringRef,
hostName: CFStringRef,
) -> CFDictionaryRef;
pub fn CFPreferencesCopyValue(
key: CFStringRef,
applicationID: CFStringRef,
userName: CFStringRef,
hostName: CFStringRef,
) -> CFPropertyListRef;
pub fn CFPreferencesGetAppBooleanValue(
key: CFStringRef,
applicationID: CFStringRef,
keyExistsAndHasValidFormat: *mut Boolean,
) -> Boolean;
pub fn CFPreferencesGetAppIntegerValue(
key: CFStringRef,
applicationID: CFStringRef,
keyExistsAndHasValidFormat: *mut Boolean,
) -> CFIndex;
/* Setting Preference Values */
pub fn CFPreferencesSetAppValue(
key: CFStringRef,
value: CFPropertyListRef,
applicationID: CFStringRef,
);
pub fn CFPreferencesSetMultiple(
keysToSet: CFDictionaryRef,
keysToRemove: CFArrayRef,
applicationID: CFStringRef,
userName: CFStringRef,
hostName: CFStringRef,
);
pub fn CFPreferencesSetValue(
key: CFStringRef,
value: CFPropertyListRef,
applicationID: CFStringRef,
userName: CFStringRef,
hostName: CFStringRef,
);
/* Synchronizing Preferences */
pub fn CFPreferencesAppSynchronize(applicationID: CFStringRef) -> Boolean;
pub fn CFPreferencesSynchronize(
applicationID: CFStringRef,
userName: CFStringRef,
hostName: CFStringRef,
) -> Boolean;
/* Adding and Removing Suite Preferences */
pub fn CFPreferencesAddSuitePreferencesToApp(applicationID: CFStringRef, suiteID: CFStringRef);
pub fn CFPreferencesRemoveSuitePreferencesFromApp(
applicationID: CFStringRef,
suiteID: CFStringRef,
);
/* Miscellaneous Functions */
pub fn CFPreferencesAppValueIsForced(key: CFStringRef, applicationID: CFStringRef) -> Boolean;
pub fn CFPreferencesCopyApplicationList(
userName: CFStringRef,
hostName: CFStringRef,
) -> CFArrayRef; // deprecated since macos 10.9
}

@ -0,0 +1,104 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeRef};
use crate::data::CFDataRef;
use crate::error::CFErrorRef;
use crate::stream::{CFReadStreamRef, CFWriteStreamRef};
use crate::string::CFStringRef;
pub type CFPropertyListRef = CFTypeRef;
pub type CFPropertyListFormat = CFIndex;
pub const kCFPropertyListOpenStepFormat: CFPropertyListFormat = 1;
pub const kCFPropertyListXMLFormat_v1_0: CFPropertyListFormat = 100;
pub const kCFPropertyListBinaryFormat_v1_0: CFPropertyListFormat = 200;
pub type CFPropertyListMutabilityOptions = CFOptionFlags;
pub const kCFPropertyListImmutable: CFPropertyListMutabilityOptions = 0;
pub const kCFPropertyListMutableContainers: CFPropertyListMutabilityOptions = 1;
pub const kCFPropertyListMutableContainersAndLeaves: CFPropertyListMutabilityOptions = 2;
/* Reading and Writing Error Codes */
pub const kCFPropertyListReadCorruptError: CFIndex = 3840;
pub const kCFPropertyListReadUnknownVersionError: CFIndex = 3841;
pub const kCFPropertyListReadStreamError: CFIndex = 3842;
pub const kCFPropertyListWriteStreamError: CFIndex = 3851;
extern "C" {
/*
* CFPropertyList.h
*/
/* Creating a Property List */
pub fn CFPropertyListCreateWithData(
allocator: CFAllocatorRef,
data: CFDataRef,
options: CFPropertyListMutabilityOptions,
format: *mut CFPropertyListFormat,
error: *mut CFErrorRef,
) -> CFPropertyListRef;
pub fn CFPropertyListCreateWithStream(
allocator: CFAllocatorRef,
stream: CFReadStreamRef,
streamLength: CFIndex,
options: CFOptionFlags,
format: *mut CFPropertyListFormat,
error: *mut CFErrorRef,
) -> CFPropertyListRef;
pub fn CFPropertyListCreateDeepCopy(
allocator: CFAllocatorRef,
propertyList: CFPropertyListRef,
mutabilityOption: CFOptionFlags,
) -> CFPropertyListRef;
pub fn CFPropertyListCreateFromXMLData(
allocator: CFAllocatorRef,
xmlData: CFDataRef,
mutabilityOption: CFOptionFlags,
errorString: *mut CFStringRef,
) -> CFPropertyListRef; // deprecated
pub fn CFPropertyListCreateFromStream(
allocator: CFAllocatorRef,
stream: CFReadStreamRef,
streamLength: CFIndex,
mutabilityOption: CFOptionFlags,
format: *mut CFPropertyListFormat,
errorString: *mut CFStringRef,
) -> CFPropertyListRef; // deprecated
/* Exporting a Property List */
pub fn CFPropertyListCreateData(
allocator: CFAllocatorRef,
propertyList: CFPropertyListRef,
format: CFPropertyListFormat,
options: CFOptionFlags,
error: *mut CFErrorRef,
) -> CFDataRef;
pub fn CFPropertyListWrite(
propertyList: CFPropertyListRef,
stream: CFWriteStreamRef,
format: CFPropertyListFormat,
options: CFOptionFlags,
error: *mut CFErrorRef,
) -> CFIndex;
pub fn CFPropertyListCreateXMLData(
allocator: CFAllocatorRef,
propertyList: CFPropertyListRef,
) -> CFDataRef; // deprecated
pub fn CFPropertyListWriteToStream(
propertyList: CFPropertyListRef,
stream: CFWriteStreamRef,
format: CFPropertyListFormat,
errorString: *mut CFStringRef,
) -> CFIndex;
/* Validating a Property List */
pub fn CFPropertyListIsValid(plist: CFPropertyListRef, format: CFPropertyListFormat)
-> Boolean;
}

@ -0,0 +1,256 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFArrayRef;
use crate::base::{
mach_port_t, Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFOptionFlags, CFTypeID,
};
use crate::date::{CFAbsoluteTime, CFTimeInterval};
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFRunLoop(c_void);
pub type CFRunLoopRef = *mut __CFRunLoop;
#[repr(C)]
pub struct __CFRunLoopSource(c_void);
pub type CFRunLoopSourceRef = *mut __CFRunLoopSource;
#[repr(C)]
pub struct __CFRunLoopObserver(c_void);
pub type CFRunLoopObserverRef = *mut __CFRunLoopObserver;
// Reasons for CFRunLoopRunInMode() to Return
pub const kCFRunLoopRunFinished: i32 = 1;
pub const kCFRunLoopRunStopped: i32 = 2;
pub const kCFRunLoopRunTimedOut: i32 = 3;
pub const kCFRunLoopRunHandledSource: i32 = 4;
// Run Loop Observer Activities
//typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) {
pub type CFRunLoopActivity = CFOptionFlags;
pub const kCFRunLoopEntry: CFOptionFlags = 1 << 0;
pub const kCFRunLoopBeforeTimers: CFOptionFlags = 1 << 1;
pub const kCFRunLoopBeforeSources: CFOptionFlags = 1 << 2;
pub const kCFRunLoopBeforeWaiting: CFOptionFlags = 1 << 5;
pub const kCFRunLoopAfterWaiting: CFOptionFlags = 1 << 6;
pub const kCFRunLoopExit: CFOptionFlags = 1 << 7;
pub const kCFRunLoopAllActivities: CFOptionFlags = 0x0FFFFFFF;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFRunLoopSourceContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>,
pub release: Option<extern "C" fn(info: *const c_void)>,
pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>,
pub equal: Option<extern "C" fn(info1: *const c_void, info2: *const c_void) -> Boolean>,
pub hash: Option<extern "C" fn(info: *const c_void) -> CFHashCode>,
pub schedule: Option<extern "C" fn(info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef)>,
pub cancel: Option<extern "C" fn(info: *const c_void, rl: CFRunLoopRef, mode: CFStringRef)>,
pub perform: extern "C" fn(info: *const c_void),
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFRunLoopSourceContext1 {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>,
pub release: Option<extern "C" fn(info: *const c_void)>,
pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>,
pub equal: Option<extern "C" fn(info1: *const c_void, info2: *const c_void) -> Boolean>,
pub hash: Option<extern "C" fn(info: *const c_void) -> CFHashCode>,
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub getPort: extern "C" fn(info: *mut c_void) -> mach_port_t,
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub perform: extern "C" fn(
msg: *mut c_void,
size: CFIndex,
allocator: CFAllocatorRef,
info: *mut c_void,
) -> *mut c_void,
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
pub getPort: extern "C" fn(info: *mut c_void) -> *mut c_void,
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
pub perform: extern "C" fn(info: *mut c_void) -> *mut c_void,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFRunLoopObserverContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>,
pub release: Option<extern "C" fn(info: *const c_void)>,
pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>,
}
pub type CFRunLoopObserverCallBack =
extern "C" fn(observer: CFRunLoopObserverRef, activity: CFRunLoopActivity, info: *mut c_void);
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct CFRunLoopTimerContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: Option<extern "C" fn(info: *const c_void) -> *const c_void>,
pub release: Option<extern "C" fn(info: *const c_void)>,
pub copyDescription: Option<extern "C" fn(info: *const c_void) -> CFStringRef>,
}
pub type CFRunLoopTimerCallBack = extern "C" fn(timer: CFRunLoopTimerRef, info: *mut c_void);
#[repr(C)]
pub struct __CFRunLoopTimer(c_void);
pub type CFRunLoopTimerRef = *mut __CFRunLoopTimer;
extern "C" {
/*
* CFRunLoop.h
*/
pub static kCFRunLoopDefaultMode: CFStringRef;
pub static kCFRunLoopCommonModes: CFStringRef;
/* CFRunLoop */
/* Getting a Run Loop */
pub fn CFRunLoopGetCurrent() -> CFRunLoopRef;
pub fn CFRunLoopGetMain() -> CFRunLoopRef;
/* Starting and Stopping a Run Loop */
pub fn CFRunLoopRun();
pub fn CFRunLoopRunInMode(
mode: CFStringRef,
seconds: CFTimeInterval,
returnAfterSourceHandled: Boolean,
) -> i32;
pub fn CFRunLoopWakeUp(rl: CFRunLoopRef);
pub fn CFRunLoopStop(rl: CFRunLoopRef);
pub fn CFRunLoopIsWaiting(rl: CFRunLoopRef) -> Boolean;
/* Managing Sources */
pub fn CFRunLoopAddSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef);
pub fn CFRunLoopContainsSource(
rl: CFRunLoopRef,
source: CFRunLoopSourceRef,
mode: CFStringRef,
) -> Boolean;
pub fn CFRunLoopRemoveSource(rl: CFRunLoopRef, source: CFRunLoopSourceRef, mode: CFStringRef);
/* Managing Observers */
pub fn CFRunLoopAddObserver(
rl: CFRunLoopRef,
observer: CFRunLoopObserverRef,
mode: CFStringRef,
);
pub fn CFRunLoopContainsObserver(
rl: CFRunLoopRef,
observer: CFRunLoopObserverRef,
mode: CFStringRef,
) -> Boolean;
pub fn CFRunLoopRemoveObserver(
rl: CFRunLoopRef,
observer: CFRunLoopObserverRef,
mode: CFStringRef,
);
/* Managing Run Loop Modes */
pub fn CFRunLoopAddCommonMode(rl: CFRunLoopRef, mode: CFStringRef);
pub fn CFRunLoopCopyAllModes(rl: CFRunLoopRef) -> CFArrayRef;
pub fn CFRunLoopCopyCurrentMode(rl: CFRunLoopRef) -> CFStringRef;
/* Managing Timers */
pub fn CFRunLoopAddTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef);
pub fn CFRunLoopGetNextTimerFireDate(rl: CFRunLoopRef, mode: CFStringRef) -> CFAbsoluteTime;
pub fn CFRunLoopRemoveTimer(rl: CFRunLoopRef, timer: CFRunLoopTimerRef, mode: CFStringRef);
pub fn CFRunLoopContainsTimer(
rl: CFRunLoopRef,
timer: CFRunLoopTimerRef,
mode: CFStringRef,
) -> Boolean;
/* Scheduling Blocks */
// fn CFRunLoopPerformBlock(rl: CFRunLoopRef, mode: CFTypeRef, block: void (^)(void));
/* Getting the CFRunLoop Type ID */
pub fn CFRunLoopGetTypeID() -> CFTypeID;
/* CFRunLoopSource */
/* CFRunLoopSource Miscellaneous Functions */
pub fn CFRunLoopSourceCreate(
allocator: CFAllocatorRef,
order: CFIndex,
context: *mut CFRunLoopSourceContext,
) -> CFRunLoopSourceRef;
pub fn CFRunLoopSourceGetContext(
source: CFRunLoopSourceRef,
context: *mut CFRunLoopSourceContext,
);
pub fn CFRunLoopSourceGetOrder(source: CFRunLoopSourceRef) -> CFIndex;
pub fn CFRunLoopSourceGetTypeID() -> CFTypeID;
pub fn CFRunLoopSourceInvalidate(source: CFRunLoopSourceRef);
pub fn CFRunLoopSourceIsValid(source: CFRunLoopSourceRef) -> Boolean;
pub fn CFRunLoopSourceSignal(source: CFRunLoopSourceRef);
/* CFRunLoopObserver */
/* CFRunLoopObserver Miscellaneous Functions */
// fn CFRunLoopObserverCreateWithHandler(allocator: CFAllocatorRef, activities: CFOptionFlags, repeats: Boolean, order: CFIndex, block: void (^) (CFRunLoopObserverRef observer, CFRunLoopActivity activity)) -> CFRunLoopObserverRef;
pub fn CFRunLoopObserverCreate(
allocator: CFAllocatorRef,
activities: CFOptionFlags,
repeats: Boolean,
order: CFIndex,
callout: CFRunLoopObserverCallBack,
context: *mut CFRunLoopObserverContext,
) -> CFRunLoopObserverRef;
pub fn CFRunLoopObserverDoesRepeat(observer: CFRunLoopObserverRef) -> Boolean;
pub fn CFRunLoopObserverGetActivities(observer: CFRunLoopObserverRef) -> CFOptionFlags;
pub fn CFRunLoopObserverGetContext(
observer: CFRunLoopObserverRef,
context: *mut CFRunLoopObserverContext,
);
pub fn CFRunLoopObserverGetOrder(observer: CFRunLoopObserverRef) -> CFIndex;
pub fn CFRunLoopObserverGetTypeID() -> CFTypeID;
pub fn CFRunLoopObserverInvalidate(observer: CFRunLoopObserverRef);
pub fn CFRunLoopObserverIsValid(observer: CFRunLoopObserverRef) -> Boolean;
/* CFRunLoopTimer */
/* CFRunLoopTimer Miscellaneous Functions */
// fn CFRunLoopTimerCreateWithHandler(allocator: CFAllocatorRef, fireDate: CFAbsoluteTime, interval: CFTimeInterval, flags: CFOptionFlags, order: CFIndex, block: void (^) (CFRunLoopTimerRef timer)) -> CFRunLoopTimerRef;
pub fn CFRunLoopTimerCreate(
allocator: CFAllocatorRef,
fireDate: CFAbsoluteTime,
interval: CFTimeInterval,
flags: CFOptionFlags,
order: CFIndex,
callout: CFRunLoopTimerCallBack,
context: *mut CFRunLoopTimerContext,
) -> CFRunLoopTimerRef;
pub fn CFRunLoopTimerDoesRepeat(timer: CFRunLoopTimerRef) -> Boolean;
pub fn CFRunLoopTimerGetContext(timer: CFRunLoopTimerRef, context: *mut CFRunLoopTimerContext);
pub fn CFRunLoopTimerGetInterval(timer: CFRunLoopTimerRef) -> CFTimeInterval;
pub fn CFRunLoopTimerGetNextFireDate(timer: CFRunLoopTimerRef) -> CFAbsoluteTime;
pub fn CFRunLoopTimerGetOrder(timer: CFRunLoopTimerRef) -> CFIndex;
pub fn CFRunLoopTimerGetTypeID() -> CFTypeID;
pub fn CFRunLoopTimerInvalidate(timer: CFRunLoopTimerRef);
pub fn CFRunLoopTimerIsValid(timer: CFRunLoopTimerRef) -> Boolean;
pub fn CFRunLoopTimerSetNextFireDate(timer: CFRunLoopTimerRef, fireDate: CFAbsoluteTime);
pub fn CFRunLoopTimerGetTolerance(timer: CFRunLoopTimerRef) -> CFTimeInterval; //macos(10.9)+
pub fn CFRunLoopTimerSetTolerance(timer: CFRunLoopTimerRef, tolerance: CFTimeInterval); //macos(10.9)+
}

@ -0,0 +1,98 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
use crate::string::CFStringRef;
pub type CFSetApplierFunction = extern "C" fn(value: *const c_void, context: *const c_void);
pub type CFSetRetainCallBack =
extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
pub type CFSetReleaseCallBack = extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
pub type CFSetCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
pub type CFSetEqualCallBack =
extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
pub type CFSetHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFSetCallBacks {
pub version: CFIndex,
pub retain: CFSetRetainCallBack,
pub release: CFSetReleaseCallBack,
pub copyDescription: CFSetCopyDescriptionCallBack,
pub equal: CFSetEqualCallBack,
pub hash: CFSetHashCallBack,
}
#[repr(C)]
pub struct __CFSet(c_void);
pub type CFSetRef = *const __CFSet;
pub type CFMutableSetRef = *mut __CFSet;
extern "C" {
/*
* CFSet.h
*/
pub static kCFTypeSetCallBacks: CFSetCallBacks;
pub static kCFCopyStringSetCallBacks: CFSetCallBacks;
/* CFSet */
/* Creating Sets */
pub fn CFSetCreate(
allocator: CFAllocatorRef,
values: *const *const c_void,
numValues: CFIndex,
callBacks: *const CFSetCallBacks,
) -> CFSetRef;
pub fn CFSetCreateCopy(allocator: CFAllocatorRef, theSet: CFSetRef) -> CFSetRef;
/* Examining a Set */
pub fn CFSetContainsValue(theSet: CFSetRef, value: *const c_void) -> Boolean;
pub fn CFSetGetCount(theSet: CFSetRef) -> CFIndex;
pub fn CFSetGetCountOfValue(theSet: CFSetRef, value: *const c_void) -> CFIndex;
pub fn CFSetGetValue(theSet: CFSetRef, value: *const c_void) -> *const c_void;
pub fn CFSetGetValueIfPresent(
theSet: CFSetRef,
candidate: *const c_void,
value: *mut *const c_void,
) -> Boolean;
pub fn CFSetGetValues(theSet: CFSetRef, values: *mut *const c_void);
/* Applying a Function to Set Members */
pub fn CFSetApplyFunction(
theSet: CFSetRef,
applier: CFSetApplierFunction,
context: *const c_void,
);
/* Getting the CFSet Type ID */
pub fn CFSetGetTypeID() -> CFTypeID;
/* CFMutableSet */
/* CFMutableSet Miscellaneous Functions */
pub fn CFSetAddValue(theSet: CFMutableSetRef, value: *const c_void);
pub fn CFSetCreateMutable(
allocator: CFAllocatorRef,
capacity: CFIndex,
callBacks: *const CFSetCallBacks,
) -> CFMutableSetRef;
pub fn CFSetCreateMutableCopy(
allocator: CFAllocatorRef,
capacity: CFIndex,
theSet: CFSetRef,
) -> CFMutableSetRef;
pub fn CFSetRemoveAllValues(theSet: CFMutableSetRef);
pub fn CFSetRemoveValue(theSet: CFMutableSetRef, value: *const c_void);
pub fn CFSetReplaceValue(theSet: CFMutableSetRef, value: *const c_void);
pub fn CFSetSetValue(theSet: CFMutableSetRef, value: *const c_void);
}

@ -0,0 +1,188 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32, UInt16};
use crate::data::CFDataRef;
use crate::date::CFTimeInterval;
use crate::propertylist::CFPropertyListRef;
use crate::runloop::CFRunLoopSourceRef;
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFSocket(c_void);
pub type CFSocketRef = *mut __CFSocket;
pub type CFSocketError = CFIndex;
pub type CFSocketCallBackType = CFOptionFlags;
pub type CFSocketCallBack = extern "C" fn(
s: CFSocketRef,
_type: CFSocketCallBackType,
address: CFDataRef,
cdata: *const c_void,
info: *mut c_void,
);
#[cfg(not(target_os = "windows"))]
pub type CFSocketNativeHandle = std::os::raw::c_int;
#[cfg(target_os = "windows")]
pub type CFSocketNativeHandle = std::os::raw::c_ulong;
pub const kCFSocketSuccess: CFSocketError = 0;
pub const kCFSocketError: CFSocketError = -1;
pub const kCFSocketTimeout: CFSocketError = -2;
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub struct CFSocketSignature {
pub protocolFamily: SInt32,
pub socketType: SInt32,
pub protocol: SInt32,
pub address: CFDataRef,
}
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub struct CFSocketContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: extern "C" fn(info: *const c_void) -> *const c_void,
pub release: extern "C" fn(info: *const c_void),
pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef,
}
pub const kCFSocketNoCallBack: CFSocketError = 0;
pub const kCFSocketReadCallBack: CFSocketError = 1;
pub const kCFSocketAcceptCallBack: CFSocketError = 2;
pub const kCFSocketDataCallBack: CFSocketError = 3;
pub const kCFSocketConnectCallBack: CFSocketError = 4;
pub const kCFSocketWriteCallBack: CFSocketError = 8;
pub const kCFSocketAutomaticallyReenableReadCallBack: CFOptionFlags = 1;
pub const kCFSocketAutomaticallyReenableAcceptCallBack: CFOptionFlags = 2;
pub const kCFSocketAutomaticallyReenableDataCallBack: CFOptionFlags = 3;
pub const kCFSocketAutomaticallyReenableWriteCallBack: CFOptionFlags = 8;
pub const kCFSocketLeaveErrors: CFOptionFlags = 64;
pub const kCFSocketCloseOnInvalidate: CFOptionFlags = 128;
extern "C" {
/*
* CFSocket.h
*/
/* CFSocket Name Server Keys: Not used */
pub static kCFSocketCommandKey: CFStringRef;
pub static kCFSocketNameKey: CFStringRef;
pub static kCFSocketValueKey: CFStringRef;
pub static kCFSocketResultKey: CFStringRef;
pub static kCFSocketErrorKey: CFStringRef;
pub static kCFSocketRegisterCommand: CFStringRef;
pub static kCFSocketRetrieveCommand: CFStringRef;
/* Creating Sockets */
pub fn CFSocketCreate(
allocator: CFAllocatorRef,
protocolFamily: SInt32,
socketType: SInt32,
protocol: SInt32,
callBackTypes: CFOptionFlags,
callout: CFSocketCallBack,
context: *const CFSocketContext,
) -> CFSocketRef;
pub fn CFSocketCreateConnectedToSocketSignature(
allocator: CFAllocatorRef,
signature: *const CFSocketSignature,
callBackTypes: CFOptionFlags,
callout: CFSocketCallBack,
context: *const CFSocketContext,
timeout: CFTimeInterval,
) -> CFSocketRef;
pub fn CFSocketCreateWithNative(
allocator: CFAllocatorRef,
sock: CFSocketNativeHandle,
callBackTypes: CFOptionFlags,
callout: CFSocketCallBack,
context: *const CFSocketContext,
) -> CFSocketRef;
pub fn CFSocketCreateWithSocketSignature(
allocator: CFAllocatorRef,
signature: *const CFSocketSignature,
callBackTypes: CFOptionFlags,
callout: CFSocketCallBack,
context: *const CFSocketContext,
) -> CFSocketRef;
/* Configuring Sockets */
pub fn CFSocketCopyAddress(s: CFSocketRef) -> CFDataRef;
pub fn CFSocketCopyPeerAddress(s: CFSocketRef) -> CFDataRef;
pub fn CFSocketDisableCallBacks(s: CFSocketRef, callBackTypes: CFOptionFlags);
pub fn CFSocketEnableCallBacks(s: CFSocketRef, callBackTypes: CFOptionFlags);
pub fn CFSocketGetContext(s: CFSocketRef, context: *mut CFSocketContext);
pub fn CFSocketGetNative(s: CFSocketRef) -> CFSocketNativeHandle;
pub fn CFSocketGetSocketFlags(s: CFSocketRef) -> CFOptionFlags;
pub fn CFSocketSetAddress(s: CFSocketRef, address: CFDataRef) -> CFSocketError;
pub fn CFSocketSetSocketFlags(s: CFSocketRef, flags: CFOptionFlags);
/* Using Sockets */
pub fn CFSocketConnectToAddress(
s: CFSocketRef,
address: CFDataRef,
timeout: CFTimeInterval,
) -> CFSocketError;
pub fn CFSocketCreateRunLoopSource(
allocator: CFAllocatorRef,
s: CFSocketRef,
order: CFIndex,
) -> CFRunLoopSourceRef;
pub fn CFSocketGetTypeID() -> CFTypeID;
pub fn CFSocketInvalidate(s: CFSocketRef);
pub fn CFSocketIsValid(s: CFSocketRef) -> Boolean;
pub fn CFSocketSendData(
s: CFSocketRef,
address: CFDataRef,
data: CFDataRef,
timeout: CFTimeInterval,
) -> CFSocketError;
/* Socket Name Server Utilities */
pub fn CFSocketCopyRegisteredSocketSignature(
nameServerSignature: *const CFSocketSignature,
timeout: CFTimeInterval,
name: CFStringRef,
signature: *mut CFSocketSignature,
nameServerAddress: *mut CFDataRef,
) -> CFSocketError;
pub fn CFSocketCopyRegisteredValue(
nameServerSignature: *const CFSocketSignature,
timeout: CFTimeInterval,
name: CFStringRef,
value: *mut CFPropertyListRef,
nameServerAddress: *mut CFDataRef,
) -> CFSocketError;
pub fn CFSocketGetDefaultNameRegistryPortNumber() -> UInt16;
pub fn CFSocketRegisterSocketSignature(
nameServerSignature: *const CFSocketSignature,
timeout: CFTimeInterval,
name: CFStringRef,
signature: *const CFSocketSignature,
) -> CFSocketError;
pub fn CFSocketRegisterValue(
nameServerSignature: *const CFSocketSignature,
timeout: CFTimeInterval,
name: CFStringRef,
value: CFPropertyListRef,
) -> CFSocketError;
pub fn CFSocketSetDefaultNameRegistryPortNumber(port: UInt16);
pub fn CFSocketUnregister(
nameServerSignature: *const CFSocketSignature,
timeout: CFTimeInterval,
name: CFStringRef,
) -> CFSocketError;
}

@ -0,0 +1,281 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_int, c_void};
use crate::base::{
Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, CFTypeRef, SInt32, UInt32, UInt8,
};
use crate::error::CFErrorRef;
use crate::runloop::CFRunLoopRef;
use crate::socket::{CFSocketNativeHandle, CFSocketSignature};
use crate::string::CFStringRef;
use crate::url::CFURLRef;
#[repr(C)]
pub struct __CFReadStream(c_void);
#[repr(C)]
pub struct __CFWriteStream(c_void);
pub type CFReadStreamRef = *mut __CFReadStream;
pub type CFWriteStreamRef = *mut __CFWriteStream;
pub type CFStreamPropertyKey = CFStringRef;
pub type CFStreamStatus = CFIndex;
pub type CFStreamEventType = CFOptionFlags;
pub type CFStreamErrorDomain = CFIndex;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CFStreamError {
pub domain: CFIndex,
pub error: SInt32,
}
/* CFStreamStatus: Constants that describe the status of a stream */
pub const kCFStreamStatusNotOpen: CFStreamStatus = 0;
pub const kCFStreamStatusOpening: CFStreamStatus = 1;
pub const kCFStreamStatusOpen: CFStreamStatus = 2;
pub const kCFStreamStatusReading: CFStreamStatus = 3;
pub const kCFStreamStatusWriting: CFStreamStatus = 4;
pub const kCFStreamStatusAtEnd: CFStreamStatus = 5;
pub const kCFStreamStatusClosed: CFStreamStatus = 6;
pub const kCFStreamStatusError: CFStreamStatus = 7;
// deprecated
pub const kCFStreamErrorDomainCustom: CFStreamErrorDomain = -1;
pub const kCFStreamErrorDomainPOSIX: CFStreamErrorDomain = 1;
pub const kCFStreamErrorDomainMacOSStatus: CFStreamErrorDomain = 2;
/* CFStreamEventType: Defines constants for stream-related events */
pub const kCFStreamEventNone: CFStreamEventType = 0;
pub const kCFStreamEventOpenCompleted: CFStreamEventType = 1;
pub const kCFStreamEventHasBytesAvailable: CFStreamEventType = 2;
pub const kCFStreamEventCanAcceptBytes: CFStreamEventType = 4;
pub const kCFStreamEventErrorOccurred: CFStreamEventType = 8;
pub const kCFStreamEventEndEncountered: CFStreamEventType = 16;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFStreamClientContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: extern "C" fn(info: *const c_void) -> *const c_void,
pub release: extern "C" fn(info: *const c_void),
pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef,
}
pub type CFReadStreamClientCallBack = extern "C" fn(
stream: CFReadStreamRef,
_type: CFStreamEventType,
clientCallBackInfo: *mut c_void,
);
pub type CFWriteStreamClientCallBack = extern "C" fn(
stream: CFWriteStreamRef,
_type: CFStreamEventType,
clientCallBackInfo: *mut c_void,
);
extern "C" {
/*
* CFStream.h
*/
/* Stream Properties */
pub static kCFStreamPropertyAppendToFile: CFStreamPropertyKey;
pub static kCFStreamPropertyDataWritten: CFStreamPropertyKey;
pub static kCFStreamPropertyFileCurrentOffset: CFStreamPropertyKey;
pub static kCFStreamPropertySocketNativeHandle: CFStreamPropertyKey;
pub static kCFStreamPropertySocketRemoteHostName: CFStreamPropertyKey;
pub static kCFStreamPropertySocketRemotePortNumber: CFStreamPropertyKey;
pub static kCFStreamPropertyShouldCloseNativeSocket: CFStringRef;
pub static kCFStreamPropertySocketSecurityLevel: CFStringRef;
/* CFStream Socket Security Level Constants */
pub static kCFStreamSocketSecurityLevelNone: CFStringRef;
pub static kCFStreamSocketSecurityLevelSSLv2: CFStringRef;
pub static kCFStreamSocketSecurityLevelSSLv3: CFStringRef;
pub static kCFStreamSocketSecurityLevelTLSv1: CFStringRef;
pub static kCFStreamSocketSecurityLevelNegotiatedSSL: CFStringRef;
/* CFStream SOCKS Proxy Key Constants */
pub static kCFStreamPropertySOCKSProxy: CFStringRef;
pub static kCFStreamPropertySOCKSProxyHost: CFStringRef;
pub static kCFStreamPropertySOCKSProxyPort: CFStringRef;
pub static kCFStreamPropertySOCKSVersion: CFStringRef;
pub static kCFStreamSocketSOCKSVersion4: CFStringRef;
pub static kCFStreamSocketSOCKSVersion5: CFStringRef;
pub static kCFStreamPropertySOCKSUser: CFStringRef;
pub static kCFStreamPropertySOCKSPassword: CFStringRef;
/* CFStream Error Domain Constants (CFHost) */
pub static kCFStreamErrorDomainSOCKS: c_int;
pub static kCFStreamErrorDomainSSL: c_int;
/* CFStream: Creating Streams */
pub fn CFStreamCreatePairWithPeerSocketSignature(
alloc: CFAllocatorRef,
signature: *const CFSocketSignature,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
); // deprecated
pub fn CFStreamCreatePairWithSocketToHost(
alloc: CFAllocatorRef,
host: CFStringRef,
port: UInt32,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
); // deprecated
pub fn CFStreamCreatePairWithSocket(
alloc: CFAllocatorRef,
sock: CFSocketNativeHandle,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
); // deprecated
pub fn CFStreamCreateBoundPair(
alloc: CFAllocatorRef,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
transferBufferSize: CFIndex,
);
//pub fn CFReadStreamSetDispatchQueue(stream: CFReadStreamRef, q: dispatch_queue_t); // macos(10.9)+
//pub fn CFWriteStreamSetDispatchQueue(stream: CFWriteStreamRef, q: dispatch_queue_t); // macos(10.9)+
//pub fn CFReadStreamCopyDispatchQueue(stream: CFReadStreamRef) -> dispatch_queue_t; // macos(10.9)+
//pub fn CFWriteStreamCopyDispatchQueue(stream: CFReadStreamRef) -> dispatch_queue_t; // macos(10.9)+
/* CFReadStream */
/* Creating a Read Stream */
pub fn CFReadStreamCreateWithBytesNoCopy(
alloc: CFAllocatorRef,
bytes: *const UInt8,
length: CFIndex,
bytesDeallocator: CFAllocatorRef,
) -> CFReadStreamRef;
pub fn CFReadStreamCreateWithFile(alloc: CFAllocatorRef, fileURL: CFURLRef) -> CFReadStreamRef;
/* Opening and Closing a Read Stream */
pub fn CFReadStreamClose(stream: CFReadStreamRef);
pub fn CFReadStreamOpen(stream: CFReadStreamRef) -> Boolean;
/* Reading from a Stream */
pub fn CFReadStreamRead(
stream: CFReadStreamRef,
buffer: *mut UInt8,
bufferLength: CFIndex,
) -> CFIndex;
/* Scheduling a Read Stream */
pub fn CFReadStreamScheduleWithRunLoop(
stream: CFReadStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
pub fn CFReadStreamUnscheduleFromRunLoop(
stream: CFReadStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
/* Examining Stream Properties */
pub fn CFReadStreamCopyProperty(
stream: CFReadStreamRef,
propertyName: CFStreamPropertyKey,
) -> CFTypeRef;
pub fn CFReadStreamGetBuffer(
stream: CFReadStreamRef,
maxBytesToRead: CFIndex,
numBytesRead: *mut CFIndex,
) -> *const UInt8;
pub fn CFReadStreamCopyError(stream: CFReadStreamRef) -> CFErrorRef;
pub fn CFReadStreamGetError(stream: CFReadStreamRef) -> CFStreamError; // deprecated
pub fn CFReadStreamGetStatus(stream: CFReadStreamRef) -> CFStreamStatus;
pub fn CFReadStreamHasBytesAvailable(stream: CFReadStreamRef) -> Boolean;
/* Setting Stream Properties */
pub fn CFReadStreamSetClient(
stream: CFReadStreamRef,
streamEvents: CFOptionFlags,
clientCB: CFReadStreamClientCallBack,
clientContext: *mut CFStreamClientContext,
) -> Boolean;
pub fn CFReadStreamSetProperty(
stream: CFReadStreamRef,
propertyName: CFStreamPropertyKey,
propertyValue: CFTypeRef,
) -> Boolean;
/* Getting the CFReadStream Type ID */
pub fn CFReadStreamGetTypeID() -> CFTypeID;
/* CFWriteStream */
/* Creating a Write Stream */
pub fn CFWriteStreamCreateWithAllocatedBuffers(
alloc: CFAllocatorRef,
bufferAllocator: CFAllocatorRef,
) -> CFWriteStreamRef;
pub fn CFWriteStreamCreateWithBuffer(
alloc: CFAllocatorRef,
buffer: *mut UInt8,
bufferCapacity: CFIndex,
) -> CFWriteStreamRef;
pub fn CFWriteStreamCreateWithFile(
alloc: CFAllocatorRef,
fileURL: CFURLRef,
) -> CFWriteStreamRef;
/* Opening and Closing a Stream */
pub fn CFWriteStreamClose(stream: CFWriteStreamRef);
pub fn CFWriteStreamOpen(stream: CFWriteStreamRef) -> Boolean;
/* Writing to a Stream */
pub fn CFWriteStreamWrite(
stream: CFWriteStreamRef,
buffer: *const UInt8,
bufferLength: CFIndex,
) -> CFIndex;
/* Scheduling a Write Stream */
pub fn CFWriteStreamScheduleWithRunLoop(
stream: CFWriteStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
pub fn CFWriteStreamUnscheduleFromRunLoop(
stream: CFWriteStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
/* Examining Stream Properties */
pub fn CFWriteStreamCanAcceptBytes(stream: CFWriteStreamRef) -> Boolean;
pub fn CFWriteStreamCopyProperty(
stream: CFWriteStreamRef,
propertyName: CFStreamPropertyKey,
) -> CFTypeRef;
pub fn CFWriteStreamCopyError(stream: CFWriteStreamRef) -> CFErrorRef;
pub fn CFWriteStreamGetError(stream: CFWriteStreamRef) -> CFStreamError; // deprecated
pub fn CFWriteStreamGetStatus(stream: CFWriteStreamRef) -> CFStreamStatus;
/* Setting Stream Properties */
pub fn CFWriteStreamSetClient(
stream: CFWriteStreamRef,
streamEvents: CFOptionFlags,
clientCB: CFWriteStreamClientCallBack,
clientContext: *mut CFStreamClientContext,
) -> Boolean;
pub fn CFWriteStreamSetProperty(
stream: CFWriteStreamRef,
propertyName: CFStreamPropertyKey,
propertyValue: CFTypeRef,
) -> Boolean;
/* Getting the CFWriteStream Type ID */
pub fn CFWriteStreamGetTypeID() -> CFTypeID;
}

@ -0,0 +1,546 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::array::CFArrayRef;
use crate::base::{
Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFOptionFlags, CFRange, CFTypeID,
ConstStr255Param, ConstStringPtr, SInt32, StringPtr, UInt32, UInt8, UTF32Char,
};
use crate::characterset::CFCharacterSetRef;
use crate::data::CFDataRef;
use crate::dictionary::CFDictionaryRef;
use crate::locale::CFLocaleRef;
use std::os::raw::{c_char, c_double, c_ulong, c_ushort, c_void};
pub type CFStringCompareFlags = CFOptionFlags;
pub const kCFCompareCaseInsensitive: CFStringCompareFlags = 1;
pub const kCFCompareBackwards: CFStringCompareFlags = 4;
pub const kCFCompareAnchored: CFStringCompareFlags = 8;
pub const kCFCompareNonliteral: CFStringCompareFlags = 16;
pub const kCFCompareLocalized: CFStringCompareFlags = 32;
pub const kCFCompareNumerically: CFStringCompareFlags = 64;
pub const kCFCompareDiacriticInsensitive: CFStringCompareFlags = 128;
pub const kCFCompareWidthInsensitive: CFStringCompareFlags = 256;
pub const kCFCompareForcedOrdering: CFStringCompareFlags = 512;
pub type CFStringEncoding = UInt32;
pub type UniChar = c_ushort;
// macOS built-in encodings.
pub const kCFStringEncodingMacRoman: CFStringEncoding = 0;
pub const kCFStringEncodingWindowsLatin1: CFStringEncoding = 0x0500;
pub const kCFStringEncodingISOLatin1: CFStringEncoding = 0x0201;
pub const kCFStringEncodingNextStepLatin: CFStringEncoding = 0x0B01;
pub const kCFStringEncodingASCII: CFStringEncoding = 0x0600;
pub const kCFStringEncodingUnicode: CFStringEncoding = 0x0100;
pub const kCFStringEncodingUTF8: CFStringEncoding = 0x08000100;
pub const kCFStringEncodingNonLossyASCII: CFStringEncoding = 0x0BFF;
pub const kCFStringEncodingUTF16: CFStringEncoding = 0x0100;
pub const kCFStringEncodingUTF16BE: CFStringEncoding = 0x10000100;
pub const kCFStringEncodingUTF16LE: CFStringEncoding = 0x14000100;
pub const kCFStringEncodingUTF32: CFStringEncoding = 0x0c000100;
pub const kCFStringEncodingUTF32BE: CFStringEncoding = 0x18000100;
pub const kCFStringEncodingUTF32LE: CFStringEncoding = 0x1c000100;
// CFStringEncodingExt.h
// External encodings, except those defined above.
pub const kCFStringEncodingMacJapanese: CFStringEncoding = 1;
pub const kCFStringEncodingMacChineseTrad: CFStringEncoding = 2;
pub const kCFStringEncodingMacKorean: CFStringEncoding = 3;
pub const kCFStringEncodingMacArabic: CFStringEncoding = 4;
pub const kCFStringEncodingMacHebrew: CFStringEncoding = 5;
pub const kCFStringEncodingMacGreek: CFStringEncoding = 6;
pub const kCFStringEncodingMacCyrillic: CFStringEncoding = 7;
pub const kCFStringEncodingMacDevanagari: CFStringEncoding = 9;
pub const kCFStringEncodingMacGurmukhi: CFStringEncoding = 10;
pub const kCFStringEncodingMacGujarati: CFStringEncoding = 11;
pub const kCFStringEncodingMacOriya: CFStringEncoding = 12;
pub const kCFStringEncodingMacBengali: CFStringEncoding = 13;
pub const kCFStringEncodingMacTamil: CFStringEncoding = 14;
pub const kCFStringEncodingMacTelugu: CFStringEncoding = 15;
pub const kCFStringEncodingMacKannada: CFStringEncoding = 16;
pub const kCFStringEncodingMacMalayalam: CFStringEncoding = 17;
pub const kCFStringEncodingMacSinhalese: CFStringEncoding = 18;
pub const kCFStringEncodingMacBurmese: CFStringEncoding = 19;
pub const kCFStringEncodingMacKhmer: CFStringEncoding = 20;
pub const kCFStringEncodingMacThai: CFStringEncoding = 21;
pub const kCFStringEncodingMacLaotian: CFStringEncoding = 22;
pub const kCFStringEncodingMacGeorgian: CFStringEncoding = 23;
pub const kCFStringEncodingMacArmenian: CFStringEncoding = 24;
pub const kCFStringEncodingMacChineseSimp: CFStringEncoding = 25;
pub const kCFStringEncodingMacTibetan: CFStringEncoding = 26;
pub const kCFStringEncodingMacMongolian: CFStringEncoding = 27;
pub const kCFStringEncodingMacEthiopic: CFStringEncoding = 28;
pub const kCFStringEncodingMacCentralEurRoman: CFStringEncoding = 29;
pub const kCFStringEncodingMacVietnamese: CFStringEncoding = 30;
pub const kCFStringEncodingMacExtArabic: CFStringEncoding = 31;
pub const kCFStringEncodingMacSymbol: CFStringEncoding = 33;
pub const kCFStringEncodingMacDingbats: CFStringEncoding = 34;
pub const kCFStringEncodingMacTurkish: CFStringEncoding = 35;
pub const kCFStringEncodingMacCroatian: CFStringEncoding = 36;
pub const kCFStringEncodingMacIcelandic: CFStringEncoding = 37;
pub const kCFStringEncodingMacRomanian: CFStringEncoding = 38;
pub const kCFStringEncodingMacCeltic: CFStringEncoding = 39;
pub const kCFStringEncodingMacGaelic: CFStringEncoding = 40;
pub const kCFStringEncodingMacFarsi: CFStringEncoding = 0x8C;
pub const kCFStringEncodingMacUkrainian: CFStringEncoding = 0x98;
pub const kCFStringEncodingMacInuit: CFStringEncoding = 0xEC;
pub const kCFStringEncodingMacVT100: CFStringEncoding = 0xFC;
pub const kCFStringEncodingMacHFS: CFStringEncoding = 0xFF;
pub const kCFStringEncodingISOLatin2: CFStringEncoding = 0x0202;
pub const kCFStringEncodingISOLatin3: CFStringEncoding = 0x0203;
pub const kCFStringEncodingISOLatin4: CFStringEncoding = 0x0204;
pub const kCFStringEncodingISOLatinCyrillic: CFStringEncoding = 0x0205;
pub const kCFStringEncodingISOLatinArabic: CFStringEncoding = 0x0206;
pub const kCFStringEncodingISOLatinGreek: CFStringEncoding = 0x0207;
pub const kCFStringEncodingISOLatinHebrew: CFStringEncoding = 0x0208;
pub const kCFStringEncodingISOLatin5: CFStringEncoding = 0x0209;
pub const kCFStringEncodingISOLatin6: CFStringEncoding = 0x020A;
pub const kCFStringEncodingISOLatinThai: CFStringEncoding = 0x020B;
pub const kCFStringEncodingISOLatin7: CFStringEncoding = 0x020D;
pub const kCFStringEncodingISOLatin8: CFStringEncoding = 0x020E;
pub const kCFStringEncodingISOLatin9: CFStringEncoding = 0x020F;
pub const kCFStringEncodingISOLatin10: CFStringEncoding = 0x0210;
pub const kCFStringEncodingDOSLatinUS: CFStringEncoding = 0x0400;
pub const kCFStringEncodingDOSGreek: CFStringEncoding = 0x0405;
pub const kCFStringEncodingDOSBalticRim: CFStringEncoding = 0x0406;
pub const kCFStringEncodingDOSLatin1: CFStringEncoding = 0x0410;
pub const kCFStringEncodingDOSGreek1: CFStringEncoding = 0x0411;
pub const kCFStringEncodingDOSLatin2: CFStringEncoding = 0x0412;
pub const kCFStringEncodingDOSCyrillic: CFStringEncoding = 0x0413;
pub const kCFStringEncodingDOSTurkish: CFStringEncoding = 0x0414;
pub const kCFStringEncodingDOSPortuguese: CFStringEncoding = 0x0415;
pub const kCFStringEncodingDOSIcelandic: CFStringEncoding = 0x0416;
pub const kCFStringEncodingDOSHebrew: CFStringEncoding = 0x0417;
pub const kCFStringEncodingDOSCanadianFrench: CFStringEncoding = 0x0418;
pub const kCFStringEncodingDOSArabic: CFStringEncoding = 0x0419;
pub const kCFStringEncodingDOSNordic: CFStringEncoding = 0x041A;
pub const kCFStringEncodingDOSRussian: CFStringEncoding = 0x041B;
pub const kCFStringEncodingDOSGreek2: CFStringEncoding = 0x041C;
pub const kCFStringEncodingDOSThai: CFStringEncoding = 0x041D;
pub const kCFStringEncodingDOSJapanese: CFStringEncoding = 0x0420;
pub const kCFStringEncodingDOSChineseSimplif: CFStringEncoding = 0x0421;
pub const kCFStringEncodingDOSKorean: CFStringEncoding = 0x0422;
pub const kCFStringEncodingDOSChineseTrad: CFStringEncoding = 0x0423;
pub const kCFStringEncodingWindowsLatin2: CFStringEncoding = 0x0501;
pub const kCFStringEncodingWindowsCyrillic: CFStringEncoding = 0x0502;
pub const kCFStringEncodingWindowsGreek: CFStringEncoding = 0x0503;
pub const kCFStringEncodingWindowsLatin5: CFStringEncoding = 0x0504;
pub const kCFStringEncodingWindowsHebrew: CFStringEncoding = 0x0505;
pub const kCFStringEncodingWindowsArabic: CFStringEncoding = 0x0506;
pub const kCFStringEncodingWindowsBalticRim: CFStringEncoding = 0x0507;
pub const kCFStringEncodingWindowsVietnamese: CFStringEncoding = 0x0508;
pub const kCFStringEncodingWindowsKoreanJohab: CFStringEncoding = 0x0510;
pub const kCFStringEncodingANSEL: CFStringEncoding = 0x0601;
pub const kCFStringEncodingJIS_X0201_76: CFStringEncoding = 0x0620;
pub const kCFStringEncodingJIS_X0208_83: CFStringEncoding = 0x0621;
pub const kCFStringEncodingJIS_X0208_90: CFStringEncoding = 0x0622;
pub const kCFStringEncodingJIS_X0212_90: CFStringEncoding = 0x0623;
pub const kCFStringEncodingJIS_C6226_78: CFStringEncoding = 0x0624;
pub const kCFStringEncodingShiftJIS_X0213: CFStringEncoding = 0x0628;
pub const kCFStringEncodingShiftJIS_X0213_MenKuTen: CFStringEncoding = 0x0629;
pub const kCFStringEncodingGB_2312_80: CFStringEncoding = 0x0630;
pub const kCFStringEncodingGBK_95: CFStringEncoding = 0x0631;
pub const kCFStringEncodingGB_18030_2000: CFStringEncoding = 0x0632;
pub const kCFStringEncodingKSC_5601_87: CFStringEncoding = 0x0640;
pub const kCFStringEncodingKSC_5601_92_Johab: CFStringEncoding = 0x0641;
pub const kCFStringEncodingCNS_11643_92_P1: CFStringEncoding = 0x0651;
pub const kCFStringEncodingCNS_11643_92_P2: CFStringEncoding = 0x0652;
pub const kCFStringEncodingCNS_11643_92_P3: CFStringEncoding = 0x0653;
pub const kCFStringEncodingISO_2022_JP: CFStringEncoding = 0x0820;
pub const kCFStringEncodingISO_2022_JP_2: CFStringEncoding = 0x0821;
pub const kCFStringEncodingISO_2022_JP_1: CFStringEncoding = 0x0822;
pub const kCFStringEncodingISO_2022_JP_3: CFStringEncoding = 0x0823;
pub const kCFStringEncodingISO_2022_CN: CFStringEncoding = 0x0830;
pub const kCFStringEncodingISO_2022_CN_EXT: CFStringEncoding = 0x0831;
pub const kCFStringEncodingISO_2022_KR: CFStringEncoding = 0x0840;
pub const kCFStringEncodingEUC_JP: CFStringEncoding = 0x0920;
pub const kCFStringEncodingEUC_CN: CFStringEncoding = 0x0930;
pub const kCFStringEncodingEUC_TW: CFStringEncoding = 0x0931;
pub const kCFStringEncodingEUC_KR: CFStringEncoding = 0x0940;
pub const kCFStringEncodingShiftJIS: CFStringEncoding = 0x0A01;
pub const kCFStringEncodingKOI8_R: CFStringEncoding = 0x0A02;
pub const kCFStringEncodingBig5: CFStringEncoding = 0x0A03;
pub const kCFStringEncodingMacRomanLatin1: CFStringEncoding = 0x0A04;
pub const kCFStringEncodingHZ_GB_2312: CFStringEncoding = 0x0A05;
pub const kCFStringEncodingBig5_HKSCS_1999: CFStringEncoding = 0x0A06;
pub const kCFStringEncodingVISCII: CFStringEncoding = 0x0A07;
pub const kCFStringEncodingKOI8_U: CFStringEncoding = 0x0A08;
pub const kCFStringEncodingBig5_E: CFStringEncoding = 0x0A09;
pub const kCFStringEncodingNextStepJapanese: CFStringEncoding = 0x0B02;
pub const kCFStringEncodingEBCDIC_US: CFStringEncoding = 0x0C01;
pub const kCFStringEncodingEBCDIC_CP037: CFStringEncoding = 0x0C02;
pub const kCFStringEncodingUTF7: CFStringEncoding = 0x04000100;
pub const kCFStringEncodingUTF7_IMAP: CFStringEncoding = 0x0A10;
pub const kCFStringEncodingShiftJIS_X0213_00: CFStringEncoding = 0x0628; /* Deprecated */
pub const kCFStringEncodingInvalidId: u32 = 0xffffffff;
pub type CFStringNormalizationForm = CFIndex;
pub const kCFStringNormalizationFormD: CFStringNormalizationForm = 0;
pub const kCFStringNormalizationFormKD: CFStringNormalizationForm = 1;
pub const kCFStringNormalizationFormC: CFStringNormalizationForm = 2;
pub const kCFStringNormalizationFormKC: CFStringNormalizationForm = 3;
#[repr(C)]
pub struct __CFString(c_void);
pub type CFStringRef = *const __CFString;
pub type CFMutableStringRef = *mut __CFString;
/* todo: The source code of the following functions is right in CFString.h */
/*
pub fn CFStringGetLongCharacterForSurrogatePair(surrogateHigh: UniChar, surrogateLow: UniChar) -> UTF32Char;
pub fn CFStringGetSurrogatePairForLongCharacter(character: UTF32Char, surrogates: *mut UniChar) -> Boolean;
pub fn CFStringIsSurrogateHighCharacter(character: UniChar) -> Boolean;
pub fn CFStringIsSurrogateLowCharacter(character: UniChar) -> Boolean;
pub fn CFStringInitInlineBuffer(str: CFStringRef, buf: *mut CFStringInlineBuffer, range: CFRange);
pub fn CFStringGetCharacterFromInlineBuffer(buf: *mut CFStringInlineBuffer, idx: CFIndex) -> UniChar;
*/
extern "C" {
/*
* CFString.h
*/
// N.B. organized according to "Functions by task" in docs
/* CFString */
/* Creating a CFString */
//fn CFSTR
pub fn CFStringCreateArrayBySeparatingStrings(
alloc: CFAllocatorRef,
theString: CFStringRef,
separatorString: CFStringRef,
) -> CFArrayRef;
pub fn CFStringCreateByCombiningStrings(
alloc: CFAllocatorRef,
theArray: CFArrayRef,
separatorString: CFStringRef,
) -> CFStringRef;
pub fn CFStringCreateCopy(alloc: CFAllocatorRef, theString: CFStringRef) -> CFStringRef;
pub fn CFStringCreateFromExternalRepresentation(
alloc: CFAllocatorRef,
data: CFDataRef,
encoding: CFStringEncoding,
) -> CFStringRef;
pub fn CFStringCreateWithBytes(
alloc: CFAllocatorRef,
bytes: *const UInt8,
numBytes: CFIndex,
encoding: CFStringEncoding,
isExternalRepresentation: Boolean,
) -> CFStringRef;
pub fn CFStringCreateWithBytesNoCopy(
alloc: CFAllocatorRef,
bytes: *const UInt8,
numBytes: CFIndex,
encoding: CFStringEncoding,
isExternalRepresentation: Boolean,
contentsDeallocator: CFAllocatorRef,
) -> CFStringRef;
pub fn CFStringCreateWithCharacters(
alloc: CFAllocatorRef,
chars: *const UniChar,
numChars: CFIndex,
) -> CFStringRef;
pub fn CFStringCreateWithCharactersNoCopy(
alloc: CFAllocatorRef,
chars: *const UniChar,
numChars: CFIndex,
contentsDeallocator: CFAllocatorRef,
) -> CFStringRef;
pub fn CFStringCreateWithCString(
alloc: CFAllocatorRef,
cStr: *const c_char,
encoding: CFStringEncoding,
) -> CFStringRef;
pub fn CFStringCreateWithCStringNoCopy(
alloc: CFAllocatorRef,
cStr: *const c_char,
encoding: CFStringEncoding,
contentsDeallocator: CFAllocatorRef,
) -> CFStringRef;
pub fn CFStringCreateWithFormat(
alloc: CFAllocatorRef,
formatOptions: CFDictionaryRef,
format: CFStringRef,
...
) -> CFStringRef;
//pub fn CFStringCreateWithFormatAndArguments(alloc: CFAllocatorRef, formatOptions: CFDictionaryRef, format: CFStringRef, arguments: va_list) -> CFStringRef;
pub fn CFStringCreateWithPascalString(
alloc: CFAllocatorRef,
pStr: ConstStr255Param,
encoding: CFStringEncoding,
) -> CFStringRef;
pub fn CFStringCreateWithPascalStringNoCopy(
alloc: CFAllocatorRef,
pStr: ConstStr255Param,
encoding: CFStringEncoding,
contentsDeallocator: CFAllocatorRef,
) -> CFStringRef;
pub fn CFStringCreateWithSubstring(
alloc: CFAllocatorRef,
str: CFStringRef,
range: CFRange,
) -> CFStringRef;
/* Searching Strings */
pub fn CFStringCreateArrayWithFindResults(
alloc: CFAllocatorRef,
theString: CFStringRef,
stringToFind: CFStringRef,
rangeToSearch: CFRange,
compareOptions: CFStringCompareFlags,
) -> CFArrayRef;
pub fn CFStringFind(
theString: CFStringRef,
stringToFind: CFStringRef,
compareOptions: CFStringCompareFlags,
) -> CFRange;
pub fn CFStringFindCharacterFromSet(
theString: CFStringRef,
theSet: CFCharacterSetRef,
rangeToSearch: CFRange,
searchOptions: CFStringCompareFlags,
result: *mut CFRange,
) -> Boolean;
pub fn CFStringFindWithOptions(
theString: CFStringRef,
stringToFind: CFStringRef,
rangeToSearch: CFRange,
searchOptions: CFStringCompareFlags,
result: *mut CFRange,
) -> Boolean;
pub fn CFStringFindWithOptionsAndLocale(
theString: CFStringRef,
stringToFind: CFStringRef,
rangeToSearch: CFRange,
searchOptions: CFStringCompareFlags,
locale: CFLocaleRef,
result: *mut CFRange,
) -> Boolean;
pub fn CFStringGetLineBounds(
theString: CFStringRef,
range: CFRange,
lineBeginIndex: *mut CFIndex,
lineEndIndex: *mut CFIndex,
contentsEndIndex: *mut CFIndex,
);
/* Comparing Strings */
pub fn CFStringCompare(
theString1: CFStringRef,
theString2: CFStringRef,
compareOptions: CFStringCompareFlags,
) -> CFComparisonResult;
pub fn CFStringCompareWithOptions(
theString1: CFStringRef,
theString2: CFStringRef,
rangeToCompare: CFRange,
compareOptions: CFStringCompareFlags,
) -> CFComparisonResult;
pub fn CFStringCompareWithOptionsAndLocale(
theString1: CFStringRef,
theString2: CFStringRef,
rangeToCompare: CFRange,
compareOptions: CFStringCompareFlags,
locale: CFLocaleRef,
) -> CFComparisonResult;
pub fn CFStringHasPrefix(theString: CFStringRef, prefix: CFStringRef) -> Boolean;
pub fn CFStringHasSuffix(theString: CFStringRef, suffix: CFStringRef) -> Boolean;
/* Accessing Characters */
pub fn CFStringCreateExternalRepresentation(
alloc: CFAllocatorRef,
theString: CFStringRef,
encoding: CFStringEncoding,
lossByte: UInt8,
) -> CFDataRef;
pub fn CFStringGetBytes(
theString: CFStringRef,
range: CFRange,
encoding: CFStringEncoding,
lossByte: UInt8,
isExternalRepresentation: Boolean,
buffer: *mut UInt8,
maxBufLen: CFIndex,
usedBufLen: *mut CFIndex,
) -> CFIndex;
pub fn CFStringGetCharacterAtIndex(theString: CFStringRef, idx: CFIndex) -> UniChar;
pub fn CFStringGetCharacters(theString: CFStringRef, range: CFRange, buffer: *mut UniChar);
pub fn CFStringGetCharactersPtr(theString: CFStringRef) -> *const UniChar;
pub fn CFStringGetCString(
theString: CFStringRef,
buffer: *mut c_char,
bufferSize: CFIndex,
encoding: CFStringEncoding,
) -> Boolean;
pub fn CFStringGetCStringPtr(
theString: CFStringRef,
encoding: CFStringEncoding,
) -> *const c_char;
pub fn CFStringGetLength(theString: CFStringRef) -> CFIndex;
pub fn CFStringGetPascalString(
theString: CFStringRef,
buffer: StringPtr,
bufferSize: CFIndex,
encoding: CFStringEncoding,
) -> Boolean;
pub fn CFStringGetPascalStringPtr(
theString: CFStringRef,
encoding: CFStringEncoding,
) -> ConstStringPtr;
pub fn CFStringGetRangeOfComposedCharactersAtIndex(
theString: CFStringRef,
theIndex: CFIndex,
) -> CFRange;
/* Working With Hyphenation */
pub fn CFStringGetHyphenationLocationBeforeIndex(
string: CFStringRef,
location: CFIndex,
limitRange: CFRange,
options: CFOptionFlags,
locale: CFLocaleRef,
character: *mut UTF32Char,
) -> CFIndex;
pub fn CFStringIsHyphenationAvailableForLocale(locale: CFLocaleRef) -> Boolean;
/* Working With Encodings */
pub fn CFStringConvertEncodingToIANACharSetName(encoding: CFStringEncoding) -> CFStringRef;
pub fn CFStringConvertEncodingToNSStringEncoding(encoding: CFStringEncoding) -> c_ulong;
pub fn CFStringConvertEncodingToWindowsCodepage(encoding: CFStringEncoding) -> UInt32;
pub fn CFStringConvertIANACharSetNameToEncoding(theString: CFStringRef) -> CFStringEncoding;
pub fn CFStringConvertNSStringEncodingToEncoding(encoding: c_ulong) -> CFStringEncoding;
pub fn CFStringConvertWindowsCodepageToEncoding(codepage: UInt32) -> CFStringEncoding;
pub fn CFStringGetFastestEncoding(theString: CFStringRef) -> CFStringEncoding;
pub fn CFStringGetListOfAvailableEncodings() -> *const CFStringEncoding;
pub fn CFStringGetMaximumSizeForEncoding(
length: CFIndex,
encoding: CFStringEncoding,
) -> CFIndex;
pub fn CFStringGetMostCompatibleMacStringEncoding(
encoding: CFStringEncoding,
) -> CFStringEncoding;
pub fn CFStringGetNameOfEncoding(encoding: CFStringEncoding) -> CFStringRef;
pub fn CFStringGetSmallestEncoding(theString: CFStringRef) -> CFStringEncoding;
pub fn CFStringGetSystemEncoding() -> CFStringEncoding;
pub fn CFStringIsEncodingAvailable(encoding: CFStringEncoding) -> Boolean;
/* Getting Numeric Values */
pub fn CFStringGetDoubleValue(str: CFStringRef) -> c_double;
pub fn CFStringGetIntValue(str: CFStringRef) -> SInt32;
/* Getting String Properties */
pub fn CFShowStr(str: CFStringRef);
pub fn CFStringGetTypeID() -> CFTypeID;
/* String File System Representations */
pub fn CFStringCreateWithFileSystemRepresentation(
alloc: CFAllocatorRef,
buffer: *const c_char,
) -> CFStringRef;
pub fn CFStringGetFileSystemRepresentation(
string: CFStringRef,
buffer: *mut c_char,
maxBufLen: CFIndex,
) -> Boolean;
pub fn CFStringGetMaximumSizeOfFileSystemRepresentation(string: CFStringRef) -> CFIndex;
/* Getting Paragraph Bounds */
pub fn CFStringGetParagraphBounds(
string: CFStringRef,
range: CFRange,
parBeginIndex: *mut CFIndex,
parEndIndex: *mut CFIndex,
contentsEndIndex: *mut CFIndex,
);
/* CFMutableString */
/* CFMutableString Miscellaneous Functions */
pub fn CFStringAppend(theString: CFMutableStringRef, appendedString: CFStringRef);
pub fn CFStringAppendCharacters(
theString: CFMutableStringRef,
chars: *const UniChar,
numChars: CFIndex,
);
pub fn CFStringAppendCString(
theString: CFMutableStringRef,
cStr: *const c_char,
encoding: CFStringEncoding,
);
pub fn CFStringAppendFormat(
theString: CFMutableStringRef,
formatOptions: CFDictionaryRef,
format: CFStringRef,
...
);
//pub fn CFStringAppendFormatAndArguments(theString: CFMutableStringRef, formatOptions: CFDictionaryRef, format: CFStringRef, arguments: va_list);
pub fn CFStringAppendPascalString(
theString: CFMutableStringRef,
pStr: ConstStr255Param,
encoding: CFStringEncoding,
);
pub fn CFStringCapitalize(theString: CFMutableStringRef, locale: CFLocaleRef);
pub fn CFStringCreateMutable(alloc: CFAllocatorRef, maxLength: CFIndex) -> CFMutableStringRef;
pub fn CFStringCreateMutableCopy(
alloc: CFAllocatorRef,
maxLength: CFIndex,
theString: CFStringRef,
) -> CFMutableStringRef;
pub fn CFStringCreateMutableWithExternalCharactersNoCopy(
alloc: CFAllocatorRef,
chars: *mut UniChar,
numChars: CFIndex,
capacity: CFIndex,
externalCharactersAllocator: CFAllocatorRef,
) -> CFMutableStringRef;
pub fn CFStringDelete(theString: CFMutableStringRef, range: CFRange);
pub fn CFStringFindAndReplace(
theString: CFMutableStringRef,
stringToFind: CFStringRef,
replacementString: CFStringRef,
rangeToSearch: CFRange,
compareOptions: CFStringCompareFlags,
) -> CFIndex;
pub fn CFStringFold(
theString: CFMutableStringRef,
theFlags: CFStringCompareFlags,
theLocale: CFLocaleRef,
);
pub fn CFStringInsert(str: CFMutableStringRef, idx: CFIndex, insertedStr: CFStringRef);
pub fn CFStringLowercase(theString: CFMutableStringRef, locale: CFLocaleRef);
pub fn CFStringNormalize(theString: CFMutableStringRef, theForm: CFStringNormalizationForm);
pub fn CFStringPad(
theString: CFMutableStringRef,
padString: CFStringRef,
length: CFIndex,
indexIntoPad: CFIndex,
);
pub fn CFStringReplace(theString: CFMutableStringRef, range: CFRange, replacement: CFStringRef);
pub fn CFStringReplaceAll(theString: CFMutableStringRef, replacement: CFStringRef);
pub fn CFStringSetExternalCharactersNoCopy(
theString: CFMutableStringRef,
chars: *mut UniChar,
length: CFIndex,
capacity: CFIndex,
);
pub fn CFStringTransform(
string: CFMutableStringRef,
range: *mut CFRange,
transform: CFStringRef,
reverse: Boolean,
) -> Boolean;
pub fn CFStringTrim(theString: CFMutableStringRef, trimString: CFStringRef);
pub fn CFStringTrimWhitespace(theString: CFMutableStringRef);
pub fn CFStringUppercase(theString: CFMutableStringRef, locale: CFLocaleRef);
}

@ -0,0 +1,91 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFMutableArrayRef;
use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef};
use crate::locale::CFLocaleRef;
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFStringTokenizer(c_void);
pub type CFStringTokenizerRef = *mut __CFStringTokenizer;
pub type CFStringTokenizerTokenType = CFOptionFlags;
pub const kCFStringTokenizerTokenNone: CFStringTokenizerTokenType = 0;
pub const kCFStringTokenizerTokenNormal: CFStringTokenizerTokenType = 1 << 0;
pub const kCFStringTokenizerTokenHasSubTokensMask: CFStringTokenizerTokenType = 1 << 1;
pub const kCFStringTokenizerTokenHasDerivedSubTokensMask: CFStringTokenizerTokenType = 1 << 2;
pub const kCFStringTokenizerTokenHasHasNumbersMask: CFStringTokenizerTokenType = 1 << 3;
pub const kCFStringTokenizerTokenHasNonLettersMask: CFStringTokenizerTokenType = 1 << 4;
pub const kCFStringTokenizerTokenIsCJWordMask: CFStringTokenizerTokenType = 1 << 5;
/* Tokenization Modifiers */
pub const kCFStringTokenizerUnitWord: CFOptionFlags = 0;
pub const kCFStringTokenizerUnitSentence: CFOptionFlags = 1;
pub const kCFStringTokenizerUnitParagraph: CFOptionFlags = 2;
pub const kCFStringTokenizerUnitLineBreak: CFOptionFlags = 3;
pub const kCFStringTokenizerUnitWordBoundary: CFOptionFlags = 4;
pub const kCFStringTokenizerAttributeLatinTranscription: CFOptionFlags = 1 << 16;
pub const kCFStringTokenizerAttributeLanguage: CFOptionFlags = 1 << 17;
extern "C" {
/*
* CFStringTokenizer.h
*/
/* Creating a Tokenizer */
pub fn CFStringTokenizerCreate(
alloc: CFAllocatorRef,
string: CFStringRef,
range: CFRange,
options: CFOptionFlags,
locale: CFLocaleRef,
) -> CFStringTokenizerRef;
/* Setting the String */
pub fn CFStringTokenizerSetString(
tokenizer: CFStringTokenizerRef,
string: CFStringRef,
range: CFRange,
);
/* Changing the Location */
pub fn CFStringTokenizerAdvanceToNextToken(
tokenizer: CFStringTokenizerRef,
) -> CFStringTokenizerTokenType;
pub fn CFStringTokenizerGoToTokenAtIndex(
tokenizer: CFStringTokenizerRef,
index: CFIndex,
) -> CFStringTokenizerTokenType;
/* Getting Information About the Current Token */
pub fn CFStringTokenizerCopyCurrentTokenAttribute(
tokenizer: CFStringTokenizerRef,
attribute: CFOptionFlags,
) -> CFTypeRef;
pub fn CFStringTokenizerGetCurrentTokenRange(tokenizer: CFStringTokenizerRef) -> CFRange;
pub fn CFStringTokenizerGetCurrentSubTokens(
tokenizer: CFStringTokenizerRef,
ranges: *mut CFRange,
maxRangeLength: CFIndex,
derivedSubTokens: CFMutableArrayRef,
) -> CFIndex;
/* Identifying a Language */
pub fn CFStringTokenizerCopyBestStringLanguage(
string: CFStringRef,
range: CFRange,
) -> CFStringRef;
/* Getting the CFStringTokenizer Type ID */
pub fn CFStringTokenizerGetTypeID() -> CFTypeID;
}

@ -0,0 +1,91 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
use crate::data::CFDataRef;
use crate::date::{CFAbsoluteTime, CFTimeInterval};
use crate::dictionary::CFDictionaryRef;
use crate::locale::CFLocaleRef;
use crate::notification_center::CFNotificationName;
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFTimeZone(c_void);
pub type CFTimeZoneRef = *const __CFTimeZone;
pub type CFTimeZoneNameStyle = CFIndex;
/* Constants to specify styles for time zone names */
pub const kCFTimeZoneNameStyleStandard: CFTimeZoneNameStyle = 0;
pub const kCFTimeZoneNameStyleShortStandard: CFTimeZoneNameStyle = 1;
pub const kCFTimeZoneNameStyleDaylightSaving: CFTimeZoneNameStyle = 2;
pub const kCFTimeZoneNameStyleShortDaylightSaving: CFTimeZoneNameStyle = 3;
pub const kCFTimeZoneNameStyleGeneric: CFTimeZoneNameStyle = 4;
pub const kCFTimeZoneNameStyleShortGeneric: CFTimeZoneNameStyle = 5;
extern "C" {
/*
* CFTimeZone.h
*/
pub static kCFTimeZoneSystemTimeZoneDidChangeNotification: CFNotificationName;
/* Creating a Time Zone */
pub fn CFTimeZoneCreate(
allocator: CFAllocatorRef,
name: CFStringRef,
data: CFDataRef,
) -> CFTimeZoneRef;
pub fn CFTimeZoneCreateWithName(
allocator: CFAllocatorRef,
name: CFStringRef,
tryAbbrev: Boolean,
) -> CFTimeZoneRef;
pub fn CFTimeZoneCreateWithTimeIntervalFromGMT(
allocator: CFAllocatorRef,
interval: CFTimeInterval,
) -> CFTimeZoneRef;
/* System and Default Time Zones and Information */
pub fn CFTimeZoneCopyAbbreviationDictionary() -> CFDictionaryRef;
pub fn CFTimeZoneCopyAbbreviation(tz: CFTimeZoneRef, at: CFAbsoluteTime) -> CFStringRef;
pub fn CFTimeZoneCopyDefault() -> CFTimeZoneRef;
pub fn CFTimeZoneCopySystem() -> CFTimeZoneRef;
pub fn CFTimeZoneSetDefault(tz: CFTimeZoneRef);
pub fn CFTimeZoneCopyKnownNames() -> CFArrayRef;
pub fn CFTimeZoneResetSystem();
pub fn CFTimeZoneSetAbbreviationDictionary(dict: CFDictionaryRef);
/* Getting Information About Time Zones */
pub fn CFTimeZoneGetName(tz: CFTimeZoneRef) -> CFStringRef;
pub fn CFTimeZoneCopyLocalizedName(
tz: CFTimeZoneRef,
style: CFTimeZoneNameStyle,
locale: CFLocaleRef,
) -> CFStringRef;
pub fn CFTimeZoneGetSecondsFromGMT(tz: CFTimeZoneRef, time: CFAbsoluteTime) -> CFTimeInterval;
pub fn CFTimeZoneGetData(tz: CFTimeZoneRef) -> CFDataRef;
/* Getting Daylight Savings Time Information */
pub fn CFTimeZoneIsDaylightSavingTime(tz: CFTimeZoneRef, at: CFAbsoluteTime) -> Boolean;
pub fn CFTimeZoneGetDaylightSavingTimeOffset(
tz: CFTimeZoneRef,
at: CFAbsoluteTime,
) -> CFTimeInterval;
pub fn CFTimeZoneGetNextDaylightSavingTimeTransition(
tz: CFTimeZoneRef,
at: CFAbsoluteTime,
) -> CFAbsoluteTime;
/* Getting the CFTimeZone Type ID */
pub fn CFTimeZoneGetTypeID() -> CFTypeID;
}

@ -0,0 +1,74 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{CFAllocatorRef, CFComparatorFunction, CFIndex, CFTypeID};
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFTree(c_void);
pub type CFTreeRef = *mut __CFTree;
pub type CFTreeRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void;
pub type CFTreeReleaseCallBack = extern "C" fn(info: *const c_void);
pub type CFTreeCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFStringRef;
pub type CFTreeApplierFunction = extern "C" fn(value: *const c_void, context: *mut c_void);
#[repr(C)]
pub struct CFTreeContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: CFTreeRetainCallBack,
pub release: CFTreeReleaseCallBack,
pub copyDescription: CFTreeCopyDescriptionCallBack,
}
extern "C" {
/*
* CFTree.h
*/
/* Creating Trees */
pub fn CFTreeCreate(allocator: CFAllocatorRef, context: *const CFTreeContext) -> CFTreeRef;
/* Modifying a Tree */
pub fn CFTreeAppendChild(tree: CFTreeRef, newChild: CFTreeRef);
pub fn CFTreeInsertSibling(tree: CFTreeRef, newSibling: CFTreeRef);
pub fn CFTreeRemoveAllChildren(tree: CFTreeRef);
pub fn CFTreePrependChild(tree: CFTreeRef, newChild: CFTreeRef);
pub fn CFTreeRemove(tree: CFTreeRef);
pub fn CFTreeSetContext(tree: CFTreeRef, context: *const CFTreeContext);
/* Sorting a Tree */
pub fn CFTreeSortChildren(
tree: CFTreeRef,
comparator: CFComparatorFunction,
context: *mut c_void,
);
/* Examining a Tree */
pub fn CFTreeFindRoot(tree: CFTreeRef) -> CFTreeRef;
pub fn CFTreeGetChildAtIndex(tree: CFTreeRef, idx: CFIndex) -> CFTreeRef;
pub fn CFTreeGetChildCount(tree: CFTreeRef) -> CFIndex;
pub fn CFTreeGetChildren(tree: CFTreeRef, children: *mut CFTreeRef);
pub fn CFTreeGetContext(tree: CFTreeRef, context: *mut CFTreeContext);
pub fn CFTreeGetFirstChild(tree: CFTreeRef) -> CFTreeRef;
pub fn CFTreeGetNextSibling(tree: CFTreeRef) -> CFTreeRef;
pub fn CFTreeGetParent(tree: CFTreeRef) -> CFTreeRef;
/* Performing an Operation on Tree Elements */
pub fn CFTreeApplyFunctionToChildren(
tree: CFTreeRef,
applier: CFTreeApplierFunction,
context: *mut c_void,
);
/* Getting the Tree Type ID */
pub fn CFTreeGetTypeID() -> CFTypeID;
}

@ -0,0 +1,481 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFArrayRef;
use crate::base::{
Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFRange, CFTypeID, CFTypeRef, SInt32,
};
use crate::data::CFDataRef;
use crate::dictionary::CFDictionaryRef;
use crate::error::CFErrorRef;
use crate::string::{CFStringEncoding, CFStringRef};
#[repr(C)]
pub struct __CFURL(c_void);
pub type CFURLRef = *const __CFURL;
pub type CFURLBookmarkCreationOptions = CFOptionFlags;
pub type CFURLBookmarkResolutionOptions = CFOptionFlags;
pub type CFURLBookmarkFileCreationOptions = CFOptionFlags;
pub type CFURLPathStyle = CFIndex;
/* typedef CF_ENUM(CFIndex, CFURLPathStyle) */
pub const kCFURLPOSIXPathStyle: CFURLPathStyle = 0;
pub const kCFURLHFSPathStyle: CFURLPathStyle = 1;
pub const kCFURLWindowsPathStyle: CFURLPathStyle = 2;
/* Bookmark Data Creation Options */
pub static kCFURLBookmarkCreationMinimalBookmarkMask: CFURLBookmarkCreationOptions =
(1u32 << 9) as usize;
pub static kCFURLBookmarkCreationSuitableForBookmarkFile: CFURLBookmarkCreationOptions =
(1u32 << 10) as usize;
#[cfg(target_os = "macos")]
pub static kCFURLBookmarkCreationWithSecurityScope: CFURLBookmarkCreationOptions =
(1u32 << 11) as usize;
#[cfg(target_os = "macos")]
pub static kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess: CFURLBookmarkCreationOptions =
(1u32 << 12) as usize;
pub static kCFURLBookmarkCreationWithoutImplicitSecurityScope: CFURLBookmarkCreationOptions =
(1u32 << 29) as usize;
pub static kCFURLBookmarkCreationPreferFileIDResolutionMask: CFURLBookmarkCreationOptions =
(1u32 << 8) as usize; // deprecated
/* The types of components in a URL. */
pub type CFURLComponentType = CFIndex;
pub const kCFURLComponentScheme: CFIndex = 1;
pub const kCFURLComponentNetLocation: CFIndex = 2;
pub const kCFURLComponentPath: CFIndex = 3;
pub const kCFURLComponentResourceSpecifier: CFIndex = 4;
pub const kCFURLComponentUser: CFIndex = 5;
pub const kCFURLComponentPassword: CFIndex = 6;
pub const kCFURLComponentUserInfo: CFIndex = 7;
pub const kCFURLComponentHost: CFIndex = 8;
pub const kCFURLComponentPort: CFIndex = 9;
pub const kCFURLComponentParameterString: CFIndex = 10;
pub const kCFURLComponentQuery: CFIndex = 11;
pub const kCFURLComponentFragment: CFIndex = 12;
/* Bookmark Data Resolution Options */
pub const kCFURLBookmarkResolutionWithoutUIMask: CFURLBookmarkResolutionOptions =
(1u32 << 8) as usize;
pub const kCFURLBookmarkResolutionWithoutMountingMask: CFURLBookmarkResolutionOptions =
(1u32 << 9) as usize;
#[cfg(target_os = "macos")]
pub const kCFURLBookmarkResolutionWithSecurityScope: CFURLBookmarkResolutionOptions =
(1u32 << 10) as usize;
//pub const kCFURLBookmarkResolutionWithoutImplicitStartAccessing: CFURLBookmarkResolutionOptions = ( 1u32 << 15 ) as usize; // macos(11.2)+
pub const kCFBookmarkResolutionWithoutUIMask: CFURLBookmarkResolutionOptions = (1u32 << 8) as usize;
pub const kCFBookmarkResolutionWithoutMountingMask: CFURLBookmarkResolutionOptions =
(1u32 << 9) as usize;
extern "C" {
/*
* CFURL.h
*/
/* Common File System Resource Keys */
pub static kCFURLNameKey: CFStringRef;
pub static kCFURLLocalizedNameKey: CFStringRef;
pub static kCFURLIsRegularFileKey: CFStringRef;
pub static kCFURLIsDirectoryKey: CFStringRef;
pub static kCFURLIsSymbolicLinkKey: CFStringRef;
pub static kCFURLIsVolumeKey: CFStringRef;
pub static kCFURLIsPackageKey: CFStringRef;
pub static kCFURLIsApplicationKey: CFStringRef;
// pub static kCFURLApplicationIsScriptableKey: CFStringRef; //macos(10.11)+
pub static kCFURLIsSystemImmutableKey: CFStringRef;
pub static kCFURLIsUserImmutableKey: CFStringRef;
pub static kCFURLIsHiddenKey: CFStringRef;
pub static kCFURLHasHiddenExtensionKey: CFStringRef;
pub static kCFURLCreationDateKey: CFStringRef;
pub static kCFURLContentAccessDateKey: CFStringRef;
pub static kCFURLContentModificationDateKey: CFStringRef;
pub static kCFURLAttributeModificationDateKey: CFStringRef;
// pub static kCFURLFileIdentifierKey: CFStringRef; //macos(13.3)+
// pub static kCFURLFileContentIdentifierKey: CFStringRef; //macos(11.0)+
// pub static kCFURLMayShareFileContentKey: CFStringRef; //macos(11.0)+
// pub static kCFURLMayHaveExtendedAttributesKey: CFStringRef; //macos(11.0)+
// pub static kCFURLIsPurgeableKey: CFStringRef; //macos(11.0)+
// pub static kCFURLIsSparseKey: CFStringRef; //macos(11.0)+
pub static kCFURLLinkCountKey: CFStringRef;
pub static kCFURLParentDirectoryURLKey: CFStringRef;
pub static kCFURLVolumeURLKey: CFStringRef;
pub static kCFURLTypeIdentifierKey: CFStringRef; //deprecated
pub static kCFURLLocalizedTypeDescriptionKey: CFStringRef;
pub static kCFURLLabelNumberKey: CFStringRef;
pub static kCFURLLabelColorKey: CFStringRef; //deprecated
pub static kCFURLLocalizedLabelKey: CFStringRef;
pub static kCFURLEffectiveIconKey: CFStringRef; //deprecated
pub static kCFURLCustomIconKey: CFStringRef; //deprecated
pub static kCFURLFileResourceIdentifierKey: CFStringRef;
pub static kCFURLVolumeIdentifierKey: CFStringRef;
pub static kCFURLPreferredIOBlockSizeKey: CFStringRef;
pub static kCFURLIsReadableKey: CFStringRef;
pub static kCFURLIsWritableKey: CFStringRef;
pub static kCFURLIsExecutableKey: CFStringRef;
pub static kCFURLFileSecurityKey: CFStringRef;
#[cfg(feature = "mac_os_10_8_features")]
#[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")]
pub static kCFURLIsExcludedFromBackupKey: CFStringRef;
// pub static kCFURLTagNamesKey: CFStringRef; //macos(10.9)+
#[cfg(feature = "mac_os_10_8_features")]
#[cfg_attr(feature = "mac_os_10_7_support", linkage = "extern_weak")]
pub static kCFURLPathKey: CFStringRef; // macos(10.8)+
pub static kCFURLCanonicalPathKey: CFStringRef; // macos(10.12)+
pub static kCFURLIsMountTriggerKey: CFStringRef;
// pub static kCFURLGenerationIdentifierKey: CFStringRef; // macos(10.10)+
// pub static kCFURLDocumentIdentifierKey: CFStringRef; // macos(10.10)+
// pub static kCFURLAddedToDirectoryDateKey: CFStringRef; // macos(10.10)+
// pub static kCFURLQuarantinePropertiesKey: CFStringRef; // macos(10.10)+
pub static kCFURLFileResourceTypeKey: CFStringRef;
/* File Resource Types. The file system object type values returned for the kCFURLFileResourceTypeKey */
pub static kCFURLFileResourceTypeNamedPipe: CFStringRef;
pub static kCFURLFileResourceTypeCharacterSpecial: CFStringRef;
pub static kCFURLFileResourceTypeDirectory: CFStringRef;
pub static kCFURLFileResourceTypeBlockSpecial: CFStringRef;
pub static kCFURLFileResourceTypeRegular: CFStringRef;
pub static kCFURLFileResourceTypeSymbolicLink: CFStringRef;
pub static kCFURLFileResourceTypeSocket: CFStringRef;
pub static kCFURLFileResourceTypeUnknown: CFStringRef;
/* File Property Keys */
pub static kCFURLFileSizeKey: CFStringRef;
pub static kCFURLFileAllocatedSizeKey: CFStringRef;
pub static kCFURLTotalFileSizeKey: CFStringRef;
pub static kCFURLTotalFileAllocatedSizeKey: CFStringRef;
pub static kCFURLIsAliasFileKey: CFStringRef;
// pub static kCFURLFileProtectionKey: CFStringRef; // ios(9.0)+
/* The protection level values returned for the kCFURLFileProtectionKey */
// pub static kCFURLFileProtectionNone: CFStringRef; // ios(9.0)+
// pub static kCFURLFileProtectionComplete: CFStringRef; // ios(9.0)+
// pub static kCFURLFileProtectionCompleteUnlessOpen: CFStringRef; // ios(9.0)+
// pub static kCFURLFileProtectionCompleteUntilFirstUserAuthentication: CFStringRef; // ios(9.0)+
/* Volume Property Keys */
pub static kCFURLVolumeLocalizedFormatDescriptionKey: CFStringRef;
pub static kCFURLVolumeTotalCapacityKey: CFStringRef;
pub static kCFURLVolumeAvailableCapacityKey: CFStringRef;
//pub static kCFURLVolumeAvailableCapacityForImportantUsageKey: CFStringRef; //macos(10.13)+
//pub static kCFURLVolumeAvailableCapacityForOpportunisticUsageKey: CFStringRef; //macos(10.13)+
pub static kCFURLVolumeResourceCountKey: CFStringRef;
pub static kCFURLVolumeSupportsPersistentIDsKey: CFStringRef;
pub static kCFURLVolumeSupportsSymbolicLinksKey: CFStringRef;
pub static kCFURLVolumeSupportsHardLinksKey: CFStringRef;
pub static kCFURLVolumeSupportsJournalingKey: CFStringRef;
pub static kCFURLVolumeIsJournalingKey: CFStringRef;
pub static kCFURLVolumeSupportsSparseFilesKey: CFStringRef;
pub static kCFURLVolumeSupportsZeroRunsKey: CFStringRef;
pub static kCFURLVolumeSupportsCaseSensitiveNamesKey: CFStringRef;
pub static kCFURLVolumeSupportsCasePreservedNamesKey: CFStringRef;
pub static kCFURLVolumeSupportsRootDirectoryDatesKey: CFStringRef;
pub static kCFURLVolumeSupportsVolumeSizesKey: CFStringRef;
pub static kCFURLVolumeSupportsRenamingKey: CFStringRef;
pub static kCFURLVolumeSupportsAdvisoryFileLockingKey: CFStringRef;
pub static kCFURLVolumeSupportsExtendedSecurityKey: CFStringRef;
pub static kCFURLVolumeIsBrowsableKey: CFStringRef;
pub static kCFURLVolumeMaximumFileSizeKey: CFStringRef;
pub static kCFURLVolumeIsEjectableKey: CFStringRef;
pub static kCFURLVolumeIsRemovableKey: CFStringRef;
pub static kCFURLVolumeIsInternalKey: CFStringRef;
pub static kCFURLVolumeIsAutomountedKey: CFStringRef;
pub static kCFURLVolumeIsLocalKey: CFStringRef;
pub static kCFURLVolumeIsReadOnlyKey: CFStringRef;
pub static kCFURLVolumeCreationDateKey: CFStringRef;
pub static kCFURLVolumeURLForRemountingKey: CFStringRef;
pub static kCFURLVolumeUUIDStringKey: CFStringRef;
pub static kCFURLVolumeNameKey: CFStringRef;
pub static kCFURLVolumeLocalizedNameKey: CFStringRef;
// pub static kCFURLVolumeIsEncryptedKey: CFStringRef; //macos(10.12)+
// pub static kCFURLVolumeIsRootFileSystemKey: CFStringRef; //macos(10.12)+
// pub static kCFURLVolumeSupportsCompressionKey: CFStringRef; //macos(10.12)+
// pub static kCFURLVolumeSupportsFileCloningKey: CFStringRef; //macos(10.12)+
// pub static kCFURLVolumeSupportsSwapRenamingKey: CFStringRef; //macos(10.12)+
// pub static kCFURLVolumeSupportsExclusiveRenamingKey: CFStringRef; //macos(10.12)+
// pub static kCFURLVolumeSupportsImmutableFilesKey: CFStringRef; //macos(10.13)+
// pub static kCFURLVolumeSupportsAccessPermissionsKey: CFStringRef; //macos(10.13)+
// pub static kCFURLVolumeSupportsFileProtectionKey: CFStringRef; //macos(11.0)+
// pub static kCFURLVolumeTypeNameKey: CFStringRef; //macos(13.3)+
// pub static kCFURLVolumeSubtypeKey: CFStringRef; //macos(13.3)+
// pub static kCFURLVolumeMountFromLocationKey: CFStringRef; //macos(13.3)+
/* iCloud Constants */
pub static kCFURLIsUbiquitousItemKey: CFStringRef;
pub static kCFURLUbiquitousItemHasUnresolvedConflictsKey: CFStringRef;
pub static kCFURLUbiquitousItemIsDownloadedKey: CFStringRef; // deprecated
pub static kCFURLUbiquitousItemIsDownloadingKey: CFStringRef;
pub static kCFURLUbiquitousItemIsUploadedKey: CFStringRef;
pub static kCFURLUbiquitousItemIsUploadingKey: CFStringRef;
pub static kCFURLUbiquitousItemPercentDownloadedKey: CFStringRef; // deprecated
pub static kCFURLUbiquitousItemPercentUploadedKey: CFStringRef; // deprecated
// pub static kCFURLUbiquitousItemDownloadingStatusKey: CFStringRef; // macos(10.9)+
// pub static kCFURLUbiquitousItemDownloadingErrorKey: CFStringRef; // macos(10.9)+
// pub static kCFURLUbiquitousItemUploadingErrorKey: CFStringRef; // macos(10.9)+
// pub static kCFURLUbiquitousItemIsExcludedFromSyncKey: CFStringRef; // macos(11.3)+
/* The values returned for kCFURLUbiquitousItemDownloadingStatusKey */
// pub static kCFURLUbiquitousItemDownloadingStatusNotDownloaded: CFStringRef; // macos(10.9)+
// pub static kCFURLUbiquitousItemDownloadingStatusDownloaded: CFStringRef; // macos(10.9)+
// pub static kCFURLUbiquitousItemDownloadingStatusCurrent: CFStringRef; // macos(10.9)+
/* CFError userInfo Dictionary Keys */
pub static kCFURLKeysOfUnsetValuesKey: CFStringRef;
/* Creating a CFURL */
pub fn CFURLCopyAbsoluteURL(anURL: CFURLRef) -> CFURLRef;
pub fn CFURLCreateAbsoluteURLWithBytes(
allocator: CFAllocatorRef,
relativeURLBytes: *const u8,
length: CFIndex,
encoding: CFStringEncoding,
baseURL: CFURLRef,
useCompatibilityMode: Boolean,
) -> CFURLRef;
pub fn CFURLCreateByResolvingBookmarkData(
allocator: CFAllocatorRef,
bookmark: CFDataRef,
options: CFURLBookmarkResolutionOptions,
relativeToURL: CFURLRef,
resourcePropertiesToInclude: CFArrayRef,
isStale: *mut Boolean,
error: *mut CFErrorRef,
) -> CFURLRef;
pub fn CFURLCreateCopyAppendingPathComponent(
allocator: CFAllocatorRef,
url: CFURLRef,
pathComponent: CFStringRef,
isDirectory: Boolean,
) -> CFURLRef;
pub fn CFURLCreateCopyAppendingPathExtension(
allocator: CFAllocatorRef,
url: CFURLRef,
extension: CFStringRef,
) -> CFURLRef;
pub fn CFURLCreateCopyDeletingLastPathComponent(
allocator: CFAllocatorRef,
url: CFURLRef,
) -> CFURLRef;
pub fn CFURLCreateCopyDeletingPathExtension(
allocator: CFAllocatorRef,
url: CFURLRef,
) -> CFURLRef;
pub fn CFURLCreateFilePathURL(
allocator: CFAllocatorRef,
url: CFURLRef,
error: *mut CFErrorRef,
) -> CFURLRef;
pub fn CFURLCreateFileReferenceURL(
allocator: CFAllocatorRef,
url: CFURLRef,
error: *mut CFErrorRef,
) -> CFURLRef;
pub fn CFURLCreateFromFileSystemRepresentation(
allocator: CFAllocatorRef,
buffer: *const u8,
bufLen: CFIndex,
isDirectory: Boolean,
) -> CFURLRef;
pub fn CFURLCreateFromFileSystemRepresentationRelativeToBase(
allocator: CFAllocatorRef,
buffer: *const u8,
bufLen: CFIndex,
isDirectory: Boolean,
baseURL: CFURLRef,
) -> CFURLRef;
//pub fn CFURLCreateFromFSRef(allocator: CFAllocatorRef, fsRef: *const FSRef) -> CFURLRef
pub fn CFURLCreateWithBytes(
allocator: CFAllocatorRef,
URLBytes: *const u8,
length: CFIndex,
encoding: CFStringEncoding,
baseURL: CFURLRef,
) -> CFURLRef;
pub fn CFURLCreateWithFileSystemPath(
allocator: CFAllocatorRef,
filePath: CFStringRef,
pathStyle: CFURLPathStyle,
isDirectory: Boolean,
) -> CFURLRef;
pub fn CFURLCreateWithFileSystemPathRelativeToBase(
allocator: CFAllocatorRef,
filePath: CFStringRef,
pathStyle: CFURLPathStyle,
isDirectory: Boolean,
baseURL: CFURLRef,
) -> CFURLRef;
pub fn CFURLCreateWithString(
allocator: CFAllocatorRef,
URLString: CFStringRef,
baseURL: CFURLRef,
) -> CFURLRef;
/* Accessing the Parts of a URL */
pub fn CFURLCanBeDecomposed(anURL: CFURLRef) -> Boolean;
pub fn CFURLCopyFileSystemPath(anURL: CFURLRef, pathStyle: CFURLPathStyle) -> CFStringRef;
pub fn CFURLCopyFragment(anURL: CFURLRef, charactersToLeaveEscaped: CFStringRef)
-> CFStringRef;
pub fn CFURLCopyHostName(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyLastPathComponent(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyNetLocation(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyParameterString(
anURL: CFURLRef,
charactersToLeaveEscaped: CFStringRef,
) -> CFStringRef; // deprecated
pub fn CFURLCopyPassword(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyPath(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyPathExtension(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyQueryString(
anURL: CFURLRef,
charactersToLeaveEscaped: CFStringRef,
) -> CFStringRef;
pub fn CFURLCopyResourceSpecifier(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyScheme(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLCopyStrictPath(anURL: CFURLRef, isAbsolute: *mut Boolean) -> CFStringRef;
pub fn CFURLCopyUserName(anURL: CFURLRef) -> CFStringRef;
pub fn CFURLGetPortNumber(anURL: CFURLRef) -> SInt32;
pub fn CFURLHasDirectoryPath(anURL: CFURLRef) -> Boolean;
/* Converting URLs to Other Representations */
pub fn CFURLCreateData(
allocator: CFAllocatorRef,
url: CFURLRef,
encoding: CFStringEncoding,
escapeWhitespace: Boolean,
) -> CFDataRef;
pub fn CFURLCreateStringByAddingPercentEscapes(
allocator: CFAllocatorRef,
originalString: CFStringRef,
charactersToLeaveUnescaped: CFStringRef,
legalURLCharactersToBeEscaped: CFStringRef,
encoding: CFStringEncoding,
) -> CFStringRef; // API_DEPRECATED("Use [NSString stringByAddingPercentEncodingWithAllowedCharacters:] instead, which always uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent (since each URL component or subcomponent has different rules for what characters are valid).", macos(10.0,10.11), ios(2.0,9.0), watchos(2.0,2.0), tvos(9.0,9.0));
pub fn CFURLCreateStringByReplacingPercentEscapes(
allocator: CFAllocatorRef,
originalString: CFStringRef,
charactersToLeaveEscaped: CFStringRef,
) -> CFStringRef;
pub fn CFURLCreateStringByReplacingPercentEscapesUsingEncoding(
allocator: CFAllocatorRef,
origString: CFStringRef,
charsToLeaveEscaped: CFStringRef,
encoding: CFStringEncoding,
) -> CFStringRef; // deprecated
pub fn CFURLGetFileSystemRepresentation(
anURL: CFURLRef,
resolveAgainstBase: Boolean,
buffer: *mut u8,
maxBufLen: CFIndex,
) -> Boolean;
//pub fn CFURLIsFileReferenceURL(url: CFURLRef) -> Boolean; // macos(10.9)+
//pub fn CFURLGetFSRef(url: CFURLRef, fsRef: *mut FSRef) -> Boolean;
pub fn CFURLGetString(anURL: CFURLRef) -> CFStringRef;
/* Getting URL Properties */
pub fn CFURLGetBaseURL(anURL: CFURLRef) -> CFURLRef;
pub fn CFURLGetBytes(anURL: CFURLRef, buffer: *mut u8, bufferLength: CFIndex) -> CFIndex;
pub fn CFURLGetByteRangeForComponent(
url: CFURLRef,
component: CFURLComponentType,
rangeIncludingSeparators: *mut CFRange,
) -> CFRange;
pub fn CFURLGetTypeID() -> CFTypeID;
pub fn CFURLResourceIsReachable(url: CFURLRef, error: *mut CFErrorRef) -> Boolean;
/* Getting and Setting File System Resource Properties */
pub fn CFURLClearResourcePropertyCache(url: CFURLRef);
pub fn CFURLClearResourcePropertyCacheForKey(url: CFURLRef, key: CFStringRef);
pub fn CFURLCopyResourcePropertiesForKeys(
url: CFURLRef,
keys: CFArrayRef,
error: *mut CFErrorRef,
) -> CFDictionaryRef;
//pub fn CFURLCopyResourcePropertyForKey(url: CFURLRef, key: CFStringRef, propertyValueTypeRefPtr: *mut c_void, error: *mut CFErrorRef) -> Boolean
pub fn CFURLCreateResourcePropertiesForKeysFromBookmarkData(
allocator: CFAllocatorRef,
resourcePropertiesToReturn: CFArrayRef,
bookmark: CFDataRef,
) -> CFDictionaryRef;
pub fn CFURLCreateResourcePropertyForKeyFromBookmarkData(
allocator: CFAllocatorRef,
resourcePropertyKey: CFStringRef,
bookmark: CFDataRef,
) -> CFTypeRef;
pub fn CFURLSetResourcePropertiesForKeys(
url: CFURLRef,
keyedPropertyValues: CFDictionaryRef,
error: *mut CFErrorRef,
) -> Boolean;
pub fn CFURLSetResourcePropertyForKey(
url: CFURLRef,
key: CFStringRef,
value: CFTypeRef,
error: *mut CFErrorRef,
) -> Boolean;
pub fn CFURLSetTemporaryResourcePropertyForKey(
url: CFURLRef,
key: CFStringRef,
propertyValue: CFTypeRef,
);
/* Working with Bookmark Data */
pub fn CFURLCreateBookmarkData(
allocator: CFAllocatorRef,
url: CFURLRef,
options: CFURLBookmarkCreationOptions,
resourcePropertiesToInclude: CFArrayRef,
relativeToURL: CFURLRef,
error: *mut CFErrorRef,
) -> CFDataRef;
#[cfg(target_os = "macos")]
pub fn CFURLCreateBookmarkDataFromAliasRecord(
allocator: CFAllocatorRef,
aliasRecordDataRef: CFDataRef,
) -> CFDataRef; // deprecated
pub fn CFURLCreateBookmarkDataFromFile(
allocator: CFAllocatorRef,
fileURL: CFURLRef,
errorRef: *mut CFErrorRef,
) -> CFDataRef;
pub fn CFURLWriteBookmarkDataToFile(
bookmarkRef: CFDataRef,
fileURL: CFURLRef,
options: CFURLBookmarkFileCreationOptions,
errorRef: *mut CFErrorRef,
) -> Boolean;
pub fn CFURLStartAccessingSecurityScopedResource(url: CFURLRef) -> Boolean;
pub fn CFURLStopAccessingSecurityScopedResource(url: CFURLRef);
}
#[test]
#[cfg(feature = "mac_os_10_8_features")]
fn can_see_excluded_from_backup_key() {
let _ = unsafe { kCFURLIsExcludedFromBackupKey };
}

@ -0,0 +1,62 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID};
use crate::error::CFErrorRef;
use crate::url::CFURLRef;
#[repr(C)]
pub struct __CFURLEnumerator(c_void);
pub type CFURLEnumeratorRef = *mut __CFURLEnumerator;
pub type CFURLEnumeratorOptions = CFOptionFlags;
pub const kCFURLEnumeratorDefaultBehavior: CFURLEnumeratorOptions = 0;
pub const kCFURLEnumeratorDescendRecursively: CFURLEnumeratorOptions = 1 << 0;
pub const kCFURLEnumeratorSkipInvisibles: CFURLEnumeratorOptions = 1 << 1;
pub const kCFURLEnumeratorGenerateFileReferenceURLs: CFURLEnumeratorOptions = 1 << 2;
pub const kCFURLEnumeratorSkipPackageContents: CFURLEnumeratorOptions = 1 << 3;
pub const kCFURLEnumeratorIncludeDirectoriesPreOrder: CFURLEnumeratorOptions = 1 << 4;
pub const kCFURLEnumeratorIncludeDirectoriesPostOrder: CFURLEnumeratorOptions = 1 << 5;
//pub const kCFURLEnumeratorGenerateRelativePathURLs = 1UL << 6; // macos(10.15)+
pub type CFURLEnumeratorResult = CFIndex;
pub const kCFURLEnumeratorSuccess: CFURLEnumeratorOptions = 1;
pub const kCFURLEnumeratorEnd: CFURLEnumeratorOptions = 2;
pub const kCFURLEnumeratorError: CFURLEnumeratorOptions = 3;
pub const kCFURLEnumeratorDirectoryPostOrderSuccess: CFURLEnumeratorOptions = 4;
extern "C" {
/*
* CFURLEnumerator.h
*/
pub fn CFURLEnumeratorGetTypeID() -> CFTypeID;
pub fn CFURLEnumeratorCreateForDirectoryURL(
alloc: CFAllocatorRef,
directoryURL: CFURLRef,
option: CFURLEnumeratorOptions,
propertyKeys: CFArrayRef,
) -> CFURLEnumeratorRef;
pub fn CFURLEnumeratorCreateForMountedVolumes(
alloc: CFAllocatorRef,
option: CFURLEnumeratorOptions,
propertyKeys: CFArrayRef,
) -> CFURLEnumeratorRef;
pub fn CFURLEnumeratorGetNextURL(
enumerator: CFURLEnumeratorRef,
url: *mut CFURLRef,
error: *mut CFErrorRef,
) -> CFURLEnumeratorResult;
pub fn CFURLEnumeratorSkipDescendents(enumerator: CFURLEnumeratorRef);
pub fn CFURLEnumeratorGetDescendentLevel(enumerator: CFURLEnumeratorRef) -> CFIndex;
pub fn CFURLEnumeratorGetSourceDidChange(enumerator: CFURLEnumeratorRef) -> Boolean; // deprecated since macos 10.7
}

@ -0,0 +1,138 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, SInt32};
use crate::date::CFTimeInterval;
use crate::dictionary::CFDictionaryRef;
use crate::runloop::CFRunLoopSourceRef;
use crate::string::CFStringRef;
use crate::url::CFURLRef;
#[repr(C)]
pub struct __CFUserNotification(c_void);
pub type CFUserNotificationCallBack =
extern "C" fn(userNotification: CFUserNotificationRef, responseFlags: CFOptionFlags);
pub type CFUserNotificationRef = *mut __CFUserNotification;
/* Alert Levels */
pub const kCFUserNotificationStopAlertLevel: CFOptionFlags = 0;
pub const kCFUserNotificationNoteAlertLevel: CFOptionFlags = 1;
pub const kCFUserNotificationCautionAlertLevel: CFOptionFlags = 2;
pub const kCFUserNotificationPlainAlertLevel: CFOptionFlags = 3;
/* Response Codes */
pub const kCFUserNotificationDefaultResponse: CFOptionFlags = 0;
pub const kCFUserNotificationAlternateResponse: CFOptionFlags = 1;
pub const kCFUserNotificationOtherResponse: CFOptionFlags = 2;
pub const kCFUserNotificationCancelResponse: CFOptionFlags = 3;
/* Button Flags */
pub const kCFUserNotificationNoDefaultButtonFlag: CFOptionFlags = 1usize << 5;
pub const kCFUserNotificationUseRadioButtonsFlag: CFOptionFlags = 1usize << 6;
#[inline(always)]
pub fn CFUserNotificationCheckBoxChecked(i: CFIndex) -> CFOptionFlags {
(1u32 << (8 + i)) as CFOptionFlags
}
#[inline(always)]
pub fn CFUserNotificationSecureTextField(i: CFIndex) -> CFOptionFlags {
(1u32 << (16 + i)) as CFOptionFlags
}
#[inline(always)]
pub fn CFUserNotificationPopUpSelection(n: CFIndex) -> CFOptionFlags {
(n << 24) as CFOptionFlags
}
extern "C" {
/*
* CFUserNotification.h
*/
/* Dialog Description Keys */
pub static kCFUserNotificationIconURLKey: CFStringRef;
pub static kCFUserNotificationSoundURLKey: CFStringRef;
pub static kCFUserNotificationLocalizationURLKey: CFStringRef;
pub static kCFUserNotificationAlertHeaderKey: CFStringRef;
pub static kCFUserNotificationAlertMessageKey: CFStringRef;
pub static kCFUserNotificationDefaultButtonTitleKey: CFStringRef;
pub static kCFUserNotificationAlternateButtonTitleKey: CFStringRef;
pub static kCFUserNotificationOtherButtonTitleKey: CFStringRef;
pub static kCFUserNotificationProgressIndicatorValueKey: CFStringRef;
pub static kCFUserNotificationPopUpTitlesKey: CFStringRef;
pub static kCFUserNotificationTextFieldTitlesKey: CFStringRef;
pub static kCFUserNotificationCheckBoxTitlesKey: CFStringRef;
pub static kCFUserNotificationTextFieldValuesKey: CFStringRef;
pub static kCFUserNotificationPopUpSelectionKey: CFStringRef;
pub static kCFUserNotificationAlertTopMostKey: CFStringRef;
pub static kCFUserNotificationKeyboardTypesKey: CFStringRef;
/* CFUserNotification Miscellaneous Functions */
pub fn CFUserNotificationCancel(userNotification: CFUserNotificationRef) -> SInt32;
pub fn CFUserNotificationCreate(
allocator: CFAllocatorRef,
timeout: CFTimeInterval,
flags: CFOptionFlags,
error: *mut SInt32,
dictionary: CFDictionaryRef,
) -> CFUserNotificationRef;
pub fn CFUserNotificationCreateRunLoopSource(
allocator: CFAllocatorRef,
userNotification: CFUserNotificationRef,
callout: CFUserNotificationCallBack,
order: CFIndex,
) -> CFRunLoopSourceRef;
pub fn CFUserNotificationDisplayAlert(
timeout: CFTimeInterval,
flags: CFOptionFlags,
iconURL: CFURLRef,
soundURL: CFURLRef,
localizationURL: CFURLRef,
alertHeader: CFStringRef,
alertMessage: CFStringRef,
defaultButtonTitle: CFStringRef,
alternateButtonTitle: CFStringRef,
otherButtonTitle: CFStringRef,
responseFlags: *mut CFOptionFlags,
) -> SInt32;
pub fn CFUserNotificationDisplayNotice(
timeout: CFTimeInterval,
flags: CFOptionFlags,
iconURL: CFURLRef,
soundURL: CFURLRef,
localizationURL: CFURLRef,
alertHeader: CFStringRef,
alertMessage: CFStringRef,
defaultButtonTitle: CFStringRef,
) -> SInt32;
pub fn CFUserNotificationGetTypeID() -> CFTypeID;
pub fn CFUserNotificationGetResponseDictionary(
userNotification: CFUserNotificationRef,
) -> CFDictionaryRef;
pub fn CFUserNotificationGetResponseValue(
userNotification: CFUserNotificationRef,
key: CFStringRef,
idx: CFIndex,
) -> CFStringRef;
pub fn CFUserNotificationReceiveResponse(
userNotification: CFUserNotificationRef,
timeout: CFTimeInterval,
responseFlags: *mut CFOptionFlags,
) -> SInt32;
pub fn CFUserNotificationUpdate(
userNotification: CFUserNotificationRef,
timeout: CFTimeInterval,
flags: CFOptionFlags,
dictionary: CFDictionaryRef,
) -> SInt32;
}

@ -0,0 +1,95 @@
// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{CFAllocatorRef, CFTypeID};
use crate::string::CFStringRef;
#[repr(C)]
pub struct __CFUUID(c_void);
pub type CFUUIDRef = *const __CFUUID;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct CFUUIDBytes {
pub byte0: u8,
pub byte1: u8,
pub byte2: u8,
pub byte3: u8,
pub byte4: u8,
pub byte5: u8,
pub byte6: u8,
pub byte7: u8,
pub byte8: u8,
pub byte9: u8,
pub byte10: u8,
pub byte11: u8,
pub byte12: u8,
pub byte13: u8,
pub byte14: u8,
pub byte15: u8,
}
extern "C" {
/*
* CFUUID.h
*/
/* Creating CFUUID Objects */
pub fn CFUUIDCreate(allocator: CFAllocatorRef) -> CFUUIDRef;
pub fn CFUUIDCreateFromString(alloc: CFAllocatorRef, uuidStr: CFStringRef) -> CFUUIDRef;
pub fn CFUUIDCreateFromUUIDBytes(allocator: CFAllocatorRef, bytes: CFUUIDBytes) -> CFUUIDRef;
pub fn CFUUIDCreateWithBytes(
alloc: CFAllocatorRef,
byte0: u8,
byte1: u8,
byte2: u8,
byte3: u8,
byte4: u8,
byte5: u8,
byte6: u8,
byte7: u8,
byte8: u8,
byte9: u8,
byte10: u8,
byte11: u8,
byte12: u8,
byte13: u8,
byte14: u8,
byte15: u8,
) -> CFUUIDRef;
/* Getting Information About CFUUID Objects */
pub fn CFUUIDCreateString(allocator: CFAllocatorRef, uid: CFUUIDRef) -> CFStringRef;
pub fn CFUUIDGetConstantUUIDWithBytes(
alloc: CFAllocatorRef,
byte0: u8,
byte1: u8,
byte2: u8,
byte3: u8,
byte4: u8,
byte5: u8,
byte6: u8,
byte7: u8,
byte8: u8,
byte9: u8,
byte10: u8,
byte11: u8,
byte12: u8,
byte13: u8,
byte14: u8,
byte15: u8,
) -> CFUUIDRef;
pub fn CFUUIDGetUUIDBytes(uuid: CFUUIDRef) -> CFUUIDBytes;
/* Getting the CFUUID Type Identifier */
pub fn CFUUIDGetTypeID() -> CFTypeID;
}

@ -0,0 +1,147 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::{c_char, c_void};
use crate::array::CFArrayRef;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
use crate::dictionary::CFDictionaryRef;
use crate::string::{CFStringEncoding, CFStringRef};
use crate::tree::CFTreeRef;
use crate::url::CFURLRef;
#[repr(C)]
pub struct __CFXMLNode(c_void);
pub type CFXMLNodeRef = *mut __CFXMLNode;
pub type CFXMLTreeRef = CFTreeRef;
pub const kCFXMLNodeCurrentVersion: CFIndex = 1;
pub type CFXMLNodeTypeCode = CFIndex;
pub const kCFXMLNodeTypeDocument: CFXMLNodeTypeCode = 1;
pub const kCFXMLNodeTypeElement: CFXMLNodeTypeCode = 2;
pub const kCFXMLNodeTypeAttribute: CFXMLNodeTypeCode = 3;
pub const kCFXMLNodeTypeProcessingInstruction: CFXMLNodeTypeCode = 4;
pub const kCFXMLNodeTypeComment: CFXMLNodeTypeCode = 5;
pub const kCFXMLNodeTypeText: CFXMLNodeTypeCode = 6;
pub const kCFXMLNodeTypeCDATASection: CFXMLNodeTypeCode = 7;
pub const kCFXMLNodeTypeDocumentFragment: CFXMLNodeTypeCode = 8;
pub const kCFXMLNodeTypeEntity: CFXMLNodeTypeCode = 9;
pub const kCFXMLNodeTypeEntityReference: CFXMLNodeTypeCode = 10;
pub const kCFXMLNodeTypeDocumentType: CFXMLNodeTypeCode = 11;
pub const kCFXMLNodeTypeWhitespace: CFXMLNodeTypeCode = 12;
pub const kCFXMLNodeTypeNotation: CFXMLNodeTypeCode = 13;
pub const kCFXMLNodeTypeElementTypeDeclaration: CFXMLNodeTypeCode = 14;
pub const kCFXMLNodeTypeAttributeListDeclaration: CFXMLNodeTypeCode = 15;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLElementInfo {
pub attributes: CFDictionaryRef,
pub attributeOrder: CFArrayRef,
pub isEmpty: Boolean,
pub _reserved: [c_char; 3],
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLProcessingInstructionInfo {
pub dataString: CFStringRef,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLDocumentInfo {
pub sourceURL: CFURLRef,
pub encoding: CFStringEncoding,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLExternalID {
pub systemID: CFURLRef,
pub publicID: CFStringRef,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLDocumentTypeInfo {
pub externalID: CFXMLExternalID,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLNotationInfo {
pub externalID: CFXMLExternalID,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLElementTypeDeclarationInfo {
pub contentDescription: CFStringRef,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLAttributeDeclarationInfo {
pub attributeName: CFStringRef,
pub typeString: CFStringRef,
pub defaultString: CFStringRef,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLAttributeListDeclarationInfo {
pub numberOfAttributes: CFIndex,
pub attributes: *mut CFXMLAttributeDeclarationInfo,
}
pub type CFXMLEntityTypeCode = CFIndex;
pub const kCFXMLEntityTypeParameter: CFXMLEntityTypeCode = 0;
pub const kCFXMLEntityTypeParsedInternal: CFXMLEntityTypeCode = 1;
pub const kCFXMLEntityTypeParsedExternal: CFXMLEntityTypeCode = 2;
pub const kCFXMLEntityTypeUnparsed: CFXMLEntityTypeCode = 3;
pub const kCFXMLEntityTypeCharacter: CFXMLEntityTypeCode = 4;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLEntityInfo {
pub entityType: CFXMLEntityTypeCode,
pub replacementText: CFStringRef,
pub entityID: CFXMLExternalID,
pub notationName: CFStringRef,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLEntityReferenceInfo {
pub entityType: CFXMLEntityTypeCode,
}
extern "C" {
/*
* CFXMLNode.h
*/
pub fn CFXMLNodeGetTypeID() -> CFTypeID;
pub fn CFXMLNodeCreate(
alloc: CFAllocatorRef,
xmlType: CFXMLNodeTypeCode,
dataString: CFStringRef,
additionalInfoPtr: *const c_void,
version: CFIndex,
) -> CFXMLNodeRef;
pub fn CFXMLNodeCreateCopy(alloc: CFAllocatorRef, origNode: CFXMLNodeRef) -> CFXMLNodeRef;
pub fn CFXMLNodeGetTypeCode(node: CFXMLNodeRef) -> CFXMLNodeTypeCode;
pub fn CFXMLNodeGetString(node: CFXMLNodeRef) -> CFStringRef;
pub fn CFXMLNodeGetInfoPtr(node: CFXMLNodeRef) -> *const c_void;
pub fn CFXMLNodeGetVersion(node: CFXMLNodeRef) -> CFIndex;
pub fn CFXMLTreeCreateWithNode(alloc: CFAllocatorRef, node: CFXMLNodeRef) -> CFXMLTreeRef;
pub fn CFXMLTreeGetNode(xmlTree: CFXMLTreeRef) -> CFXMLNodeRef;
}

@ -0,0 +1,174 @@
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::os::raw::c_void;
use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID};
use crate::data::CFDataRef;
use crate::dictionary::CFDictionaryRef;
use crate::string::CFStringRef;
use crate::url::CFURLRef;
use crate::xml_node::{CFXMLExternalID, CFXMLNodeRef, CFXMLTreeRef};
#[repr(C)]
pub struct __CFXMLParser(c_void);
pub type CFXMLParserRef = *mut __CFXMLParser;
pub type CFXMLParserOptions = CFOptionFlags;
pub const kCFXMLParserValidateDocument: CFXMLParserOptions = 1 << 0;
pub const kCFXMLParserSkipMetaData: CFXMLParserOptions = 1 << 1;
pub const kCFXMLParserReplacePhysicalEntities: CFXMLParserOptions = 1 << 2;
pub const kCFXMLParserSkipWhitespace: CFXMLParserOptions = 1 << 3;
pub const kCFXMLParserResolveExternalEntities: CFXMLParserOptions = 1 << 4;
pub const kCFXMLParserAddImpliedAttributes: CFXMLParserOptions = 1 << 5;
pub const kCFXMLParserAllOptions: CFXMLParserOptions = 0x00FFFFFF;
pub const kCFXMLParserNoOptions: CFXMLParserOptions = 0;
pub type CFXMLParserStatusCode = CFIndex;
pub const kCFXMLStatusParseNotBegun: CFIndex = -2;
pub const kCFXMLStatusParseInProgress: CFIndex = -1;
pub const kCFXMLStatusParseSuccessful: CFIndex = 0;
pub const kCFXMLErrorUnexpectedEOF: CFIndex = 1;
pub const kCFXMLErrorUnknownEncoding: CFIndex = 2;
pub const kCFXMLErrorEncodingConversionFailure: CFIndex = 3;
pub const kCFXMLErrorMalformedProcessingInstruction: CFIndex = 4;
pub const kCFXMLErrorMalformedDTD: CFIndex = 5;
pub const kCFXMLErrorMalformedName: CFIndex = 6;
pub const kCFXMLErrorMalformedCDSect: CFIndex = 7;
pub const kCFXMLErrorMalformedCloseTag: CFIndex = 8;
pub const kCFXMLErrorMalformedStartTag: CFIndex = 9;
pub const kCFXMLErrorMalformedDocument: CFIndex = 10;
pub const kCFXMLErrorElementlessDocument: CFIndex = 11;
pub const kCFXMLErrorMalformedComment: CFIndex = 12;
pub const kCFXMLErrorMalformedCharacterReference: CFIndex = 13;
pub const kCFXMLErrorMalformedParsedCharacterData: CFIndex = 14;
pub const kCFXMLErrorNoData: CFIndex = 15;
pub type CFXMLParserCreateXMLStructureCallBack =
extern "C" fn(parser: CFXMLParserRef, nodeDesc: CFXMLNodeRef, info: *mut c_void) -> *mut c_void;
pub type CFXMLParserAddChildCallBack = extern "C" fn(
parser: CFXMLParserRef,
parent: *mut c_void,
child: *mut c_void,
info: *mut c_void,
);
pub type CFXMLParserEndXMLStructureCallBack =
extern "C" fn(parser: CFXMLParserRef, xmlType: *mut c_void, info: *mut c_void);
pub type CFXMLParserResolveExternalEntityCallBack = extern "C" fn(
parser: CFXMLParserRef,
extID: *mut CFXMLExternalID,
info: *mut c_void,
) -> CFDataRef;
pub type CFXMLParserHandleErrorCallBack = extern "C" fn(
parser: CFXMLParserRef,
error: CFXMLParserStatusCode,
info: *mut c_void,
) -> Boolean;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLParserCallBacks {
pub version: CFIndex,
pub createXMLStructure: CFXMLParserCreateXMLStructureCallBack,
pub addChild: CFXMLParserAddChildCallBack,
pub endXMLStructure: CFXMLParserEndXMLStructureCallBack,
pub resolveExternalEntity: CFXMLParserResolveExternalEntityCallBack,
pub handleError: CFXMLParserHandleErrorCallBack,
}
pub type CFXMLParserRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void;
pub type CFXMLParserReleaseCallBack = extern "C" fn(info: *const c_void);
pub type CFXMLParserCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFStringRef;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFXMLParserContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: CFXMLParserRetainCallBack,
pub release: CFXMLParserReleaseCallBack,
pub copyDescription: CFXMLParserCopyDescriptionCallBack,
}
extern "C" {
/*
* CFXMLParser.h
*/
pub static kCFXMLTreeErrorDescription: CFStringRef;
pub static kCFXMLTreeErrorLineNumber: CFStringRef;
pub static kCFXMLTreeErrorLocation: CFStringRef;
pub static kCFXMLTreeErrorStatusCode: CFStringRef;
pub fn CFXMLParserGetTypeID() -> CFTypeID;
pub fn CFXMLParserCreate(
allocator: CFAllocatorRef,
xmlData: CFDataRef,
dataSource: CFURLRef,
parseOptions: CFOptionFlags,
versionOfNodes: CFIndex,
callBacks: *mut CFXMLParserCallBacks,
context: *mut CFXMLParserContext,
) -> CFXMLParserRef;
pub fn CFXMLParserCreateWithDataFromURL(
allocator: CFAllocatorRef,
dataSource: CFURLRef,
parseOptions: CFOptionFlags,
versionOfNodes: CFIndex,
callBacks: *mut CFXMLParserCallBacks,
context: *mut CFXMLParserContext,
) -> CFXMLParserRef;
pub fn CFXMLParserGetContext(parser: CFXMLParserRef, context: *mut CFXMLParserContext);
pub fn CFXMLParserGetCallBacks(parser: CFXMLParserRef, callBacks: *mut CFXMLParserCallBacks);
pub fn CFXMLParserGetSourceURL(parser: CFXMLParserRef) -> CFURLRef;
pub fn CFXMLParserGetLocation(parser: CFXMLParserRef) -> CFIndex;
pub fn CFXMLParserGetLineNumber(parser: CFXMLParserRef) -> CFIndex;
pub fn CFXMLParserGetDocument(parser: CFXMLParserRef) -> *mut c_void;
pub fn CFXMLParserGetStatusCode(parser: CFXMLParserRef) -> CFXMLParserStatusCode;
pub fn CFXMLParserCopyErrorDescription(parser: CFXMLParserRef) -> CFStringRef;
pub fn CFXMLParserAbort(
parser: CFXMLParserRef,
errorCode: CFXMLParserStatusCode,
errorDescription: CFStringRef,
);
pub fn CFXMLParserParse(parser: CFXMLParserRef) -> Boolean;
pub fn CFXMLTreeCreateFromData(
allocator: CFAllocatorRef,
xmlData: CFDataRef,
dataSource: CFURLRef,
parseOptions: CFOptionFlags,
versionOfNodes: CFIndex,
) -> CFXMLTreeRef;
pub fn CFXMLTreeCreateFromDataWithError(
allocator: CFAllocatorRef,
xmlData: CFDataRef,
dataSource: CFURLRef,
parseOptions: CFOptionFlags,
versionOfNodes: CFIndex,
errorDict: *mut CFDictionaryRef,
) -> CFXMLTreeRef;
pub fn CFXMLTreeCreateWithDataFromURL(
allocator: CFAllocatorRef,
dataSource: CFURLRef,
parseOptions: CFOptionFlags,
versionOfNodes: CFIndex,
) -> CFXMLTreeRef;
pub fn CFXMLTreeCreateXMLData(allocator: CFAllocatorRef, xmlTree: CFXMLTreeRef) -> CFDataRef;
pub fn CFXMLCreateStringByEscapingEntities(
allocator: CFAllocatorRef,
string: CFStringRef,
entitiesDictionary: CFDictionaryRef,
) -> CFStringRef;
pub fn CFXMLCreateStringByUnescapingEntities(
allocator: CFAllocatorRef,
string: CFStringRef,
entitiesDictionary: CFDictionaryRef,
) -> CFStringRef;
}

@ -0,0 +1,6 @@
{
"git": {
"sha1": "665d2c8e4fa8b664ec9264b8d1c1691794affbb2"
},
"path_in_vcs": ""
}

@ -0,0 +1,9 @@
---
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100
---
Language: Cpp
SortIncludes: false
TabWidth: 4
UseTab: Never

@ -0,0 +1,3 @@
allowed-duplicate-crates = ["cfg-if"]
avoid-breaking-exported-api = true
msrv = "1.48.0"

@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "daily"

@ -0,0 +1,388 @@
name: build
on:
push:
branches:
- main
pull_request:
branches: [ '**' ]
schedule:
# At 23:25 on Thursday.
- cron: "25 23 * * 4"
jobs:
test:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-20.04, windows-2022, macos-12]
toolchain:
- "1.48"
- stable
- nightly
versions:
- ""
- "-Zminimal-versions"
exclude:
# `windows-core >= 0.51` uses `edition = "2021"`, but users of the library can can use
# `windows-core == 0.50` to be rust 1.48 compatible.
- runs-on: windows-2022
toolchain: "1.48"
versions: ""
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
if: matrix.runs-on == 'macos-12' && matrix.toolchain == '1.48'
with:
xcode-version: "13.4.1"
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update
rustup default ${{ matrix.toolchain }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
env:
RUSTC_BOOTSTRAP: 1
- run: cargo test --all-targets
- run: cargo run --example stress-test
build-wasm:
strategy:
fail-fast: false
matrix:
versions:
- ""
- "-Zminimal-versions"
toolchain:
- stable
- nightly
include:
# Without `-Zminimal-versions` a too recent bumpalo version is selected. Newer versions use `edition = "2021"`.
- versions: "-Zminimal-versions"
- toolchain: "1.48"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --target wasm32-unknown-unknown
rustup default ${{ matrix.toolchain }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
env:
RUSTC_BOOTSTRAP: 1
- run: cargo build --lib
test-wasm:
strategy:
fail-fast: false
matrix:
versions:
- ""
- "-Zminimal-versions"
toolchain:
- stable
- nightly
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --target wasm32-unknown-unknown
rustup default ${{ matrix.toolchain }}
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install "wasm-pack"
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
env:
RUSTC_BOOTSTRAP: 1
- run: wasm-pack test --node
build-cross:
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-freebsd
- x86_64-unknown-illumos
- x86_64-unknown-netbsd
- sparcv9-sun-solaris
versions:
- ""
- "-Zminimal-versions"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal --no-self-update --target ${{ matrix.target }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
env:
RUSTC_BOOTSTRAP: 1
- name: Install "cross"
uses: taiki-e/install-action@v2
with:
tool: cross
- run: cross build --target ${{ matrix.target }} --examples
build-android:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: rustup toolchain install stable --profile minimal --no-self-update
- name: Add Rust components
run: rustup component add clippy rust-src
- name: Add Rust toolchain
run: rustup target add aarch64-linux-android armv7-linux-androideabi
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25b
local-cache: true
- name: Install "cargo ndk"
uses: taiki-e/install-action@v2
with:
tool: cargo-ndk
- name: Check
run: cargo ndk check --lib
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Clippy
run: cargo ndk clippy --lib
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Build library
run: cargo ndk build --lib
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
build-ios-cross:
strategy:
fail-fast: false
matrix:
toolchain:
- "1.48"
- stable
target:
- x86_64-apple-ios
versions:
- ""
- "-Zminimal-versions"
exclude:
# Support for this target was added quite recently.
- target: aarch64-apple-ios-sim
- toolchain: "1.48"
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --target ${{ matrix.target }}
rustup default ${{ matrix.toolchain }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
env:
RUSTC_BOOTSTRAP: 1
- name: Install "cross"
run: curl --location --silent --show-error --fail https://github.com/cargo-bins/cargo-quickinstall/releases/download/cross-0.2.5-x86_64-apple-darwin/cross-0.2.5-x86_64-apple-darwin.tar.gz | tar -xzvvf - -C $HOME/.cargo/bin
- run: cross build --target ${{ matrix.target }} --examples
check:
strategy:
fail-fast: false
matrix:
toolchain:
- "1.48"
- stable
- nightly
versions:
- ""
- "-Zminimal-versions"
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --component clippy
rustup default ${{ matrix.toolchain }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
env:
RUSTC_BOOTSTRAP: 1
- run: cargo check --all-targets --workspace
- run: cargo clippy --all-targets --workspace -- -D warnings
no-docker-image-check-only:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install nightly --profile minimal --no-self-update --component rust-src
rustup default nightly
- run: cargo check --target x86_64-unknown-haiku -Z build-std --examples
doc:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install nightly --profile minimal --no-self-update
rustup default nightly
- run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features
audit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Audit
uses: rustsec/audit-check@v1.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fallback:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal --no-self-update --target x86_64-fortanix-unknown-sgx
# Should fail (outcome is negated):
- run: if cargo build --lib --target x86_64-fortanix-unknown-sgx; then exit 1; fi
# Should succeed:
- run: cargo build --lib --target x86_64-fortanix-unknown-sgx --features fallback
c:
name: Lint and format C
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js runtime
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install npm
run: npm i -f -g npm@8.16.0
- name: Lint and check formatting with clang-format
run: npx github:artichoke/clang-format --check
test-haiku:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-20.04, windows-2022, macos-12]
toolchain:
- stable
versions:
- ""
runs-on: ${{ matrix.runs-on }}
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --target x86_64-fortanix-unknown-sgx
rustup default ${{ matrix.toolchain }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
working-directory: haiku
env:
RUSTC_BOOTSTRAP: 1
- run: cargo test --all-targets
working-directory: haiku
check-haiku:
strategy:
fail-fast: false
matrix:
toolchain:
- stable
versions:
- ""
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
RUST_BACKTRACE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --no-self-update --component clippy
rustup default ${{ matrix.toolchain }}
- name: Update lockfile
run: cargo generate-lockfile ${{ matrix.versions }}
working-directory: haiku
env:
RUSTC_BOOTSTRAP: 1
- run: cargo check --all-targets
working-directory: haiku
- run: cargo clippy --all-targets -- -D warnings
working-directory: haiku
check-all-versions:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
run: |
rustup toolchain install nightly --profile minimal --no-self-update
rustup default nightly
- name: Install "cargo hack"
uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- run: cargo hack check --version-range 1.36.. --version-step 2 --clean-per-version --clean-per-run
generate-windows-bindings:
name: Generate windows-core bindings with windows-bindgen
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clean
run: rm -rf src/Windows.rs
- name: Generate
run: cargo r --manifest-path=api_gen/Cargo.toml
- name: Diff generated Rust code
run: test -z "$(git status --porcelain)" || (echo "::error::Generated files are different, please regenerate with cargo run --manifest-path=api_gen/Cargo.toml!"; git status; false)

@ -0,0 +1,2 @@
target
Cargo.lock

@ -0,0 +1,337 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.61] - 2024-09-16
### Changed
- Depend on wasm-bindgen 0.2.89 or higher ([#134](https://github.com/strawlab/iana-time-zone/pull/134))
- Do not use wasm_bindgen in wasm32-unknown-emscripten environment ([#130](https://github.com/strawlab/iana-time-zone/pull/130))
## [0.1.60] - 2024-02-03
### Changed
- correct `windows-core` dependency version ([#127](https://github.com/strawlab/iana-time-zone/pull/127))
## [0.1.59] - 2023-12-30
### Changed
- update `windows` dependency ([#125](https://github.com/strawlab/iana-time-zone/pull/125))
## [0.1.58] - 2023-10-17
### Added
- use windows-core with embedded bindings via windows-bindgen ([#117](https://github.com/strawlab/iana-time-zone/pull/117))
- implement GNU Hurd support ([#121](https://github.com/strawlab/iana-time-zone/pull/121))
- implement AIX support ([#57](https://github.com/strawlab/iana-time-zone/pull/57))
## [0.1.57] - 2023-06-07
### Added
- implement OpenWRT support ([#109](https://github.com/strawlab/iana-time-zone/pull/109))
## [0.1.56] - 2023-04-03
### Changed
- update `windows` dependency ([#102](https://github.com/strawlab/iana-time-zone/pull/102))
## [0.1.55] - 2023-03-30
### Changed
- update `windows` dependency ([#101](https://github.com/strawlab/iana-time-zone/pull/101))
## [0.1.54] - 2023-03-21
### Changed
- replace `winapi` dependency with `windows` ([#97](https://github.com/strawlab/iana-time-zone/pull/97))
- bump msrv to 1.48 ([#91](https://github.com/strawlab/iana-time-zone/pull/91))
## [0.1.53] - 2022-10-28
### Fixed
- remove lint causing breakage on rust 1.45-1.51 ([#84](https://github.com/strawlab/iana-time-zone/pull/84))
## [0.1.52] - 2022-10-28
### Fixed
- fix for NixOS ([#81](https://github.com/strawlab/iana-time-zone/pull/81))
### Changed
- allow building the haiku crate on other hosts([#75](https://github.com/strawlab/iana-time-zone/pull/75))
- various improvements in continuous integration and source quality
([#76](https://github.com/strawlab/iana-time-zone/pull/76)),
([#77](https://github.com/strawlab/iana-time-zone/pull/77)),
([#78](https://github.com/strawlab/iana-time-zone/pull/78)),
([#81](https://github.com/strawlab/iana-time-zone/pull/81))
## [0.1.51] - 2022-10-08
### Changed
- bump MSRV to 1.38 ([#70](https://github.com/strawlab/iana-time-zone/pull/70))
- Refactor Android property key CStr construction to add tests ([#69](https://github.com/strawlab/iana-time-zone/pull/69))
- Refactor MacOS implementation a lot ([#67](https://github.com/strawlab/iana-time-zone/pull/67))
### Added
- Implement for Haiku ([#66](https://github.com/strawlab/iana-time-zone/pull/66))
### Fixed
- Fix spelling of 'initialized' in sync::Once statics ([#63](https://github.com/strawlab/iana-time-zone/pull/63))
## [0.1.50] - 2022-09-23
### Fixed
- Reduce MSRV for Android again ([#62](https://github.com/strawlab/iana-time-zone/pull/62))
## [0.1.49] - 2022-09-22
### Changed
- `once_cell` dependency is not needed ([#61](https://github.com/strawlab/iana-time-zone/pull/61))
## [0.1.48] - 2022-09-12
### Changed
- Downgrade requirements for WASM dependencies ([#58](https://github.com/strawlab/iana-time-zone/pull/58))
- Reduce MSRV for Tier 1 platforms to 1.31 ([#59](https://github.com/strawlab/iana-time-zone/pull/59))
## [0.1.47] - 2022-08-30
### Changed
- Update `android_system_properties` to v0.1.5 to run 9786% faster (YMMV) ([#56](https://github.com/strawlab/iana-time-zone/pull/56))
## [0.1.46] - 2022-08-18
### Added
- Implement for Solaris ([#55](https://github.com/strawlab/iana-time-zone/pull/55))
## [0.1.45] - 2022-08-16
### Fixed
- Fix potential use after free in MacOS / iOS ([#54](https://github.com/strawlab/iana-time-zone/pull/54), [RUSTSEC-2022-0049](https://rustsec.org/advisories/RUSTSEC-2022-0049.html))
- Fix typos in README ([#53](https://github.com/strawlab/iana-time-zone/pull/53))
## [0.1.44] - 2022-08-11
### Fixed
- "/etc/localtime" may be relative link ([#49](https://github.com/strawlab/iana-time-zone/pull/49))
## [0.1.43] - 2022-08-11
### Changed
- Use `core-foundation-sys` instead of `core-foundation` ([#50](https://github.com/strawlab/iana-time-zone/pull/50))
## [0.1.42] - 2022-08-10
### Fixed
- Fix implementation for Redhat based distros ([#48](https://github.com/strawlab/iana-time-zone/pull/48))
## [0.1.41] - 2022-08-02
### Added
- Add `fallback` feature ([#46](https://github.com/strawlab/iana-time-zone/pull/46))
## [0.1.40] - 2022-07-29
### Added
- Implement for Android ([#45](https://github.com/strawlab/iana-time-zone/pull/45))
## [0.1.38] - 2022-07-27
### Added
- Implement illumos ([#44](https://github.com/strawlab/iana-time-zone/pull/44))
### Changed
- Update examples in README
## [0.1.37] - 2022-07-23
### Added
- Support iOS ([#41](https://github.com/strawlab/iana-time-zone/pull/41))
### Changed
- Implement `std::err::source()`, format `IoError` ([#42](https://github.com/strawlab/iana-time-zone/pull/42))
## [0.1.36] - 2022-07-21
### Fixed
- Fail to compile for WASI ([#40](https://github.com/strawlab/iana-time-zone/pull/40))
## [0.1.35] - 2022-06-29
### Added
- Implement for FreeBSD, NetBSD, OpenBSD and Dragonfly ([#39](https://github.com/strawlab/iana-time-zone/pull/39))
## [0.1.34] - 2022-06-29
### Added
- Implement for wasm32 ([#38](https://github.com/strawlab/iana-time-zone/pull/38))
## [0.1.33] - 2022-04-15
### Changed
- Use `winapi` crate instead of `windows` crate ([#35](https://github.com/strawlab/iana-time-zone/pull/35))
## [0.1.32] - 2022-04-06
### Changed
- Update `windows` requirement from 0.34 to 0.35 ([#34](https://github.com/strawlab/iana-time-zone/pull/34))
## [0.1.31] - 2022-03-16
### Changed
- Update `windows` requirement from 0.33 to 0.34 ([#33](https://github.com/strawlab/iana-time-zone/pull/33))
## [0.1.30] - 2022-02-28
### Changed
- Fewer string allocations ([#32](https://github.com/strawlab/iana-time-zone/pull/32))
## [0.1.29] - 2022-02-25
### Changed
- Update `windows` requirement from 0.32 to 0.33 ([#31](https://github.com/strawlab/iana-time-zone/pull/31))
## [0.1.28] - 2022-02-04
### Changed
- Update `windows` requirement from 0.30 to 0.32 ([#30](https://github.com/strawlab/iana-time-zone/pull/30))
## [0.1.27] - 2022-01-14
### Changed
- Update `windows` requirement from 0.29 to 0.30 ([#29](https://github.com/strawlab/iana-time-zone/pull/29))
## [0.1.26] - 2021-12-23
### Changed
- Update `windows` requirement from 0.28 to 0.29 ([#28](https://github.com/strawlab/iana-time-zone/pull/28))
## [0.1.25] - 2021-11-18
### Changed
- Update `windows` requirement from 0.27 to 0.28 ([#27](https://github.com/strawlab/iana-time-zone/pull/27))
## [0.1.24] - 2021-11-16
### Changed
- Update `windows` requirement from 0.26 to 0.27 ([#26](https://github.com/strawlab/iana-time-zone/pull/26))
## [0.1.23] - 2021-11-12
### Changed
- Update `windows` requirement from 0.25 to 0.26 ([#25](https://github.com/strawlab/iana-time-zone/pull/25))
## [0.1.22] - 2021-11-08
### Changed
- Update `windows` requirement from 0.24 to 0.25 ([#24](https://github.com/strawlab/iana-time-zone/pull/24))
## [0.1.21] - 2021-11-02
### Changed
- Update `windows` requirement from 0.23 to 0.24 ([#23](https://github.com/strawlab/iana-time-zone/pull/23))
## [0.1.20] - 2021-10-29
### Changed
- Update `windows` requirement from 0.21 to 0.23 ([#22](https://github.com/strawlab/iana-time-zone/pull/22))
## [0.1.19] - 2021-09-27
### Changed
- Update `windows` requirement from 0.19 to 0.21 ([#18](https://github.com/strawlab/iana-time-zone/pull/18), [#20](https://github.com/strawlab/iana-time-zone/pull/20))
- Update `chrono-tz` requirement from 0.5 to 0.6 ([#19](https://github.com/strawlab/iana-time-zone/pull/19))
## [0.1.18] - 2021-08-23
### Changed
- Update `windows` requirement from 0.18 to 0.19 ([#17](https://github.com/strawlab/iana-time-zone/pull/17))
## [0.1.16] - 2021-07-26
### Changed
- Update `windows` requirement from 0.17 to 0.18 ([#16](https://github.com/strawlab/iana-time-zone/pull/16))
## [0.1.15] - 2021-07-08
### Changed
- Update `windows` requirement from 0.14 to 0.17 ([#15](https://github.com/strawlab/iana-time-zone/pull/15))
## [0.1.14] - 2021-07-07
### Changed
- Update `windows` requirement from 0.13 to 0.14 ([#14](https://github.com/strawlab/iana-time-zone/pull/14))
## [0.1.13] - 2021-06-28
### Changed
- Update `windows` requirement from 0.12 to 0.13 ([#13](https://github.com/strawlab/iana-time-zone/pull/13))
## [0.1.12] - 2021-06-28
### Changed
- Update `windows` requirement from 0.11 to 0.12 ([#12](https://github.com/strawlab/iana-time-zone/pull/12))
## [0.1.11] - 2021-06-12
### Changed
- Update `windows` requirement from 0.10 to 0.11 ([#11](https://github.com/strawlab/iana-time-zone/pull/11))
## [0.1.10] - 2021-05-13
### Changed
- Update `windows` requirement from 0.9 to 0.10 ([#10](https://github.com/strawlab/iana-time-zone/pull/10))
## [0.1.9] - 2021-04-28
### Changed
- Update `windows` requirement from 0.8 to 0.9 ([#8](https://github.com/strawlab/iana-time-zone/pull/8))
## [0.1.8] - 2021-04-13
### Changed
- Update `windows` requirement from 0.7 to 0.8 ([#7](https://github.com/strawlab/iana-time-zone/pull/7))
## [0.1.7] - 2021-03-30
### Changed
- Update `windows` requirement from 0.6 to 0.7 ([#6](https://github.com/strawlab/iana-time-zone/pull/6))
## [0.1.6] - 2021-03-24
### Changed
- Update `windows` requirement from 0.5 to 0.6 ([#5](https://github.com/strawlab/iana-time-zone/pull/5))
## [0.1.5] - 2021-03-20
### Changed
- Update `windows` requirement from 0.4 to 0.5 ([#4](https://github.com/strawlab/iana-time-zone/pull/4))
## [0.1.4] - 2021-03-11
### Changed
- Update `windows` requirement from 0.3 to 0.4 ([#3](https://github.com/strawlab/iana-time-zone/pull/3))
## [0.1.3] - 2021-02-22
### Changed
- Use `windows` crate instead of `winrt`
## [0.1.2] - 2020-10-09
### Changed
- Update `core-foundation` requirement from 0.7 to 0.9 ([#1](https://github.com/strawlab/iana-time-zone/pull/1))
## [0.1.1] - 2020-06-27
### Changed
- Update `core-foundation` requirement from 0.5 to 0.7
## [0.1.0] - 2020-06-27
### Added
- Implement for Linux, Windows, MacOS
[0.1.61]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.61
[0.1.60]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.60
[0.1.59]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.59
[0.1.58]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.58
[0.1.57]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.57
[0.1.56]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.56
[0.1.55]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.55
[0.1.54]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.54
[0.1.53]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.53
[0.1.52]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.52
[0.1.51]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.51
[0.1.50]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.50
[0.1.49]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.49
[0.1.48]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.48
[0.1.47]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.47
[0.1.46]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.46
[0.1.45]: https://github.com/strawlab/iana-time-zone/releases/tag/v0.1.45
[0.1.44]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.44
[0.1.43]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.43
[0.1.42]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.42
[0.1.41]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.41
[0.1.40]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.40
[0.1.39]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.39
[0.1.38]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.38
[0.1.37]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.37
[0.1.36]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.36
[0.1.35]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.35
[0.1.34]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.34
[0.1.33]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.33
[0.1.32]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.32
[0.1.31]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.31
[0.1.30]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.30
[0.1.29]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.29
[0.1.28]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.28
[0.1.27]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.27
[0.1.26]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.26
[0.1.25]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.25
[0.1.24]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.24
[0.1.23]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.23
[0.1.22]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.22
[0.1.21]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.21
[0.1.20]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.20
[0.1.19]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.19
[0.1.18]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.18
[0.1.17]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.17
[0.1.16]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.16
[0.1.15]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.15
[0.1.14]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.14
[0.1.13]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.13
[0.1.12]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.12
[0.1.11]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.11
[0.1.10]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.10
[0.1.9]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.9
[0.1.8]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.8
[0.1.7]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.7
[0.1.6]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.6
[0.1.5]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.5
[0.1.4]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.4
[0.1.3]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.3
[0.1.2]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.2
[0.1.1]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.1
[0.1.0]: https://github.com/strawlab/iana-time-zone/releases/tag/0.1.0

@ -0,0 +1,74 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "iana-time-zone"
version = "0.1.61"
authors = [
"Andrew Straw <strawman@astraw.com>",
"René Kijewski <rene.kijewski@fu-berlin.de>",
"Ryan Lopopolo <rjl@hyperbo.la>",
]
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "get the IANA time zone for the current system"
readme = "README.md"
keywords = [
"IANA",
"time",
]
categories = [
"date-and-time",
"internationalization",
"os",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/strawlab/iana-time-zone"
[lib]
name = "iana_time_zone"
path = "src/lib.rs"
[[example]]
name = "get_timezone"
path = "examples/get_timezone.rs"
[[example]]
name = "stress-test"
path = "examples/stress-test.rs"
[features]
fallback = []
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies.js-sys]
version = "0.3.66"
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies.wasm-bindgen]
version = "0.2.89"
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies.wasm-bindgen-test]
version = "0.3"
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.core-foundation-sys]
version = "0.8.3"
[target.'cfg(target_os = "android")'.dependencies.android_system_properties]
version = "0.1.5"
[target.'cfg(target_os = "haiku")'.dependencies.iana-time-zone-haiku]
version = "0.1.1"
[target.'cfg(target_os = "windows")'.dependencies.windows-core]
version = ">=0.50, <=0.52"

@ -0,0 +1,42 @@
[package]
name = "iana-time-zone"
description = "get the IANA time zone for the current system"
version = "0.1.61"
authors = [
"Andrew Straw <strawman@astraw.com>",
"René Kijewski <rene.kijewski@fu-berlin.de>",
"Ryan Lopopolo <rjl@hyperbo.la>",
]
repository = "https://github.com/strawlab/iana-time-zone"
license = "MIT OR Apache-2.0"
keywords = ["IANA", "time"]
categories = ["date-and-time", "internationalization", "os"]
readme = "README.md"
edition = "2018"
[features]
# When enabled, the library will succeed to compile for unknown target platforms, and return an `Err(GetTimezoneError::OsError)` at runtime.
fallback = []
[target.'cfg(target_os = "android")'.dependencies]
android_system_properties = "0.1.5"
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
core-foundation-sys = "0.8.3"
[target.'cfg(target_os = "windows")'.dependencies]
windows-core = { version = ">=0.50, <=0.52" }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
js-sys = "0.3.66"
wasm-bindgen = "0.2.89"
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
wasm-bindgen-test = "0.3"
[target.'cfg(target_os = "haiku")'.dependencies]
iana-time-zone-haiku = { version = "0.1.1", path = "haiku" }
[workspace]
members = [".", "haiku"]
default-members = ["."]

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2020 Andrew Straw
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -0,0 +1,25 @@
Copyright (c) 2020 Andrew D. Straw
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

@ -0,0 +1,47 @@
# iana-time-zone - get the IANA time zone for the current system
[![Crates.io](https://img.shields.io/crates/v/iana-time-zone.svg)](https://crates.io/crates/iana-time-zone)
[![Documentation](https://docs.rs/iana-time-zone/badge.svg)](https://docs.rs/iana-time-zone/)
[![Crate License](https://img.shields.io/crates/l/iana-time-zone.svg)](https://crates.io/crates/iana-time-zone)
[![build](https://github.com/strawlab/iana-time-zone/actions/workflows/rust.yml/badge.svg)](https://github.com/strawlab/iana-time-zone/actions?query=branch%3Amain)
This small utility crate gets the IANA time zone for the current system.
This is also known the [tz database](https://en.wikipedia.org/wiki/Tz_database),
tzdata, the zoneinfo database, and the Olson database.
Example:
```rust
// Get the current time zone as a string.
let tz_str = iana_time_zone::get_timezone()?;
println!("The current time zone is: {}", tz_str);
```
You can test this is working on your platform with:
```
cargo run --example get_timezone
```
## Minimum supported rust version policy
This crate has a minimum supported rust version (MSRV) of 1.48
for [Tier 1](https://doc.rust-lang.org/1.63.0/rustc/platform-support.html) platforms.
Updates to the MSRV are sometimes necessary due to the MSRV of dependencies. MSRV updates will
not be indicated as a breaking change to the semver version.
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
<http://www.apache.org/licenses/LICENSE-2.0>)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
<http://opensource.org/licenses/MIT>)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

@ -0,0 +1,16 @@
--out src/Windows.rs
--filter
Windows.Globalization.Calendar
# Dependencies of the above
Windows.Foundation.Collections.IIterable
Windows.Foundation.Collections.IIterator
Windows.Foundation.Collections.IVectorView
Windows.Foundation.DateTime
Windows.Foundation.TimeSpan
Windows.Globalization.DayOfWeek
Windows.Globalization.ICalendar
Windows.Globalization.ICalendarFactory
Windows.Globalization.ICalendarFactory2
Windows.Globalization.ITimeZoneOnCalendar

@ -0,0 +1,6 @@
use iana_time_zone::{get_timezone, GetTimezoneError};
fn main() -> Result<(), GetTimezoneError> {
println!("{}", get_timezone()?);
Ok(())
}

@ -0,0 +1,25 @@
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
use iana_time_zone::get_timezone;
const THREADS: usize = 10;
const ITERATIONS: usize = 100_000;
static COUNT: AtomicUsize = AtomicUsize::new(0);
fn main() {
let mut threads = Vec::with_capacity(THREADS);
for _ in 0..THREADS {
threads.push(spawn(|| {
for _ in 0..ITERATIONS {
get_timezone().unwrap();
COUNT.fetch_add(1, Ordering::Relaxed);
}
}));
}
for thread in threads {
thread.join().unwrap();
}
assert_eq!(COUNT.load(Ordering::SeqCst), THREADS * ITERATIONS);
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,49 @@
//! Cross platform FFI helpers.
use std::ffi::CStr;
// The system property named 'persist.sys.timezone' contains the name of the
// current timezone.
//
// From https://android.googlesource.com/platform/bionic/+/gingerbread-release/libc/docs/OVERVIEW.TXT#79:
//
// > The name of the current timezone is taken from the TZ environment variable,
// > if defined. Otherwise, the system property named 'persist.sys.timezone' is
// > checked instead.
const ANDROID_TIMEZONE_PROPERTY_NAME: &[u8] = b"persist.sys.timezone\0";
/// Return a [`CStr`] to access the timezone from an Android system properties
/// environment.
pub(crate) fn android_timezone_property_name() -> &'static CStr {
// In tests or debug mode, opt into extra runtime checks.
if cfg!(any(test, debug_assertions)) {
return CStr::from_bytes_with_nul(ANDROID_TIMEZONE_PROPERTY_NAME).unwrap();
}
// SAFETY: the key is NUL-terminated and there are no other NULs, this
// invariant is checked in tests.
unsafe { CStr::from_bytes_with_nul_unchecked(ANDROID_TIMEZONE_PROPERTY_NAME) }
}
#[cfg(test)]
mod tests {
use std::ffi::CStr;
use super::{android_timezone_property_name, ANDROID_TIMEZONE_PROPERTY_NAME};
#[test]
fn test_android_timezone_property_name_is_valid_cstr() {
CStr::from_bytes_with_nul(ANDROID_TIMEZONE_PROPERTY_NAME).unwrap();
let mut invalid_property_name = ANDROID_TIMEZONE_PROPERTY_NAME.to_owned();
invalid_property_name.push(b'\0');
CStr::from_bytes_with_nul(&invalid_property_name).unwrap_err();
}
#[test]
fn test_android_timezone_property_name_getter() {
let key = android_timezone_property_name().to_bytes_with_nul();
assert_eq!(key, ANDROID_TIMEZONE_PROPERTY_NAME);
std::str::from_utf8(key).unwrap();
}
}

@ -0,0 +1,114 @@
#![warn(clippy::all)]
#![warn(clippy::cargo)]
#![warn(clippy::undocumented_unsafe_blocks)]
#![allow(unknown_lints)]
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![warn(trivial_casts, trivial_numeric_casts)]
#![warn(unused_qualifications)]
#![warn(variant_size_differences)]
//! get the IANA time zone for the current system
//!
//! This small utility crate provides the
//! [`get_timezone()`](fn.get_timezone.html) function.
//!
//! ```rust
//! // Get the current time zone as a string.
//! let tz_str = iana_time_zone::get_timezone()?;
//! println!("The current time zone is: {}", tz_str);
//! # Ok::<(), iana_time_zone::GetTimezoneError>(())
//! ```
//!
//! The resulting string can be parsed to a
//! [`chrono-tz::Tz`](https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)
//! variant like this:
//! ```ignore
//! let tz_str = iana_time_zone::get_timezone()?;
//! let tz: chrono_tz::Tz = tz_str.parse()?;
//! ```
#[allow(dead_code)]
mod ffi_utils;
#[cfg_attr(any(target_os = "linux", target_os = "hurd"), path = "tz_linux.rs")]
#[cfg_attr(target_os = "windows", path = "tz_windows.rs")]
#[cfg_attr(any(target_os = "macos", target_os = "ios"), path = "tz_macos.rs")]
#[cfg_attr(
all(target_arch = "wasm32", target_os = "unknown"),
path = "tz_wasm32_unknown.rs"
)]
#[cfg_attr(
any(target_os = "freebsd", target_os = "dragonfly"),
path = "tz_freebsd.rs"
)]
#[cfg_attr(
any(target_os = "netbsd", target_os = "openbsd"),
path = "tz_netbsd.rs"
)]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
path = "tz_illumos.rs"
)]
#[cfg_attr(target_os = "aix", path = "tz_aix.rs")]
#[cfg_attr(target_os = "android", path = "tz_android.rs")]
#[cfg_attr(target_os = "haiku", path = "tz_haiku.rs")]
mod platform;
/// Error types
#[derive(Debug)]
pub enum GetTimezoneError {
/// Failed to parse
FailedParsingString,
/// Wrapped IO error
IoError(std::io::Error),
/// Platform-specific error from the operating system
OsError,
}
impl std::error::Error for GetTimezoneError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
GetTimezoneError::FailedParsingString => None,
GetTimezoneError::IoError(err) => Some(err),
GetTimezoneError::OsError => None,
}
}
}
impl std::fmt::Display for GetTimezoneError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
f.write_str(match self {
GetTimezoneError::FailedParsingString => "GetTimezoneError::FailedParsingString",
GetTimezoneError::IoError(err) => return err.fmt(f),
GetTimezoneError::OsError => "OsError",
})
}
}
impl From<std::io::Error> for GetTimezoneError {
fn from(orig: std::io::Error) -> Self {
GetTimezoneError::IoError(orig)
}
}
/// Get the current IANA time zone as a string.
///
/// See the module-level documentation for a usage example and more details
/// about this function.
#[inline]
pub fn get_timezone() -> Result<String, GetTimezoneError> {
platform::get_timezone_inner()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn get_current() {
println!("current: {}", get_timezone().unwrap());
}
}

@ -0,0 +1,9 @@
pub fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
Err(crate::GetTimezoneError::OsError)
}
#[cfg(not(feature = "fallback"))]
compile_error!(
"iana-time-zone is currently implemented for Linux, Window, MacOS, FreeBSD, NetBSD, \
OpenBSD, Dragonfly, WebAssembly (browser), iOS, Illumos, Android, AIX, Solaris and Haiku.",
);

@ -0,0 +1,26 @@
use std::fs::OpenOptions;
use std::io::{BufRead, BufReader};
use std::env;
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
env::var("TZ").map_err(|_| crate::GetTimezoneError::OsError)
}
fn read_environment() -> Result<String, crate::GetTimezoneError> {
// https://www.ibm.com/docs/en/aix/7.2?topic=files-environment-file
let file = OpenOptions::new().read(true).open("/etc/environment")?;
let mut reader = BufReader::new(file);
let mut line = String::with_capacity(80);
loop {
line.clear();
let count = reader.read_line(&mut line)?;
if count == 0 {
return Err(crate::GetTimezoneError::FailedParsingString);
} else if line.starts_with("TZ=") {
line.truncate(line.trim_end().len());
line.replace_range(..3, "");
return Ok(line);
}
}
}

@ -0,0 +1,27 @@
use std::sync::Once;
use android_system_properties::AndroidSystemProperties;
use crate::ffi_utils::android_timezone_property_name;
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
let key = android_timezone_property_name();
get_properties()
.and_then(|properties| properties.get_from_cstr(key))
.ok_or(crate::GetTimezoneError::OsError)
}
fn get_properties() -> Option<&'static AndroidSystemProperties> {
static INITIALIZED: Once = Once::new();
static mut PROPERTIES: Option<AndroidSystemProperties> = None;
INITIALIZED.call_once(|| {
let properties = AndroidSystemProperties::new();
// SAFETY: `INITIALIZED` is synchronizing. The variable is only assigned to once.
unsafe { PROPERTIES = Some(properties) };
});
// SAFETY: `INITIALIZED` is synchronizing. The variable is only assigned to once.
unsafe { PROPERTIES.as_ref() }
}

@ -0,0 +1,7 @@
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
// see https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/19
let mut contents = std::fs::read_to_string("/var/db/zoneinfo")?;
// Trim to the correct length without allocating.
contents.truncate(contents.trim_end().len());
Ok(contents)
}

@ -0,0 +1,3 @@
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
iana_time_zone_haiku::get_timezone().ok_or(crate::GetTimezoneError::OsError)
}

@ -0,0 +1,22 @@
use std::fs::OpenOptions;
use std::io::{BufRead, BufReader};
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
// https://illumos.org/man/5/TIMEZONE
// https://docs.oracle.com/cd/E23824_01/html/821-1473/uc-timezone-4.html
let file = OpenOptions::new().read(true).open("/etc/default/init")?;
let mut reader = BufReader::with_capacity(1536, file);
let mut line = String::with_capacity(80);
loop {
line.clear();
let count = reader.read_line(&mut line)?;
if count == 0 {
return Err(crate::GetTimezoneError::FailedParsingString);
} else if line.starts_with("TZ=") {
line.truncate(line.trim_end().len());
line.replace_range(..3, "");
return Ok(line);
}
}
}

@ -0,0 +1,184 @@
use std::fs::{read_link, read_to_string};
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
etc_localtime()
.or_else(|_| etc_timezone())
.or_else(|_| openwrt::etc_config_system())
}
fn etc_timezone() -> Result<String, crate::GetTimezoneError> {
// see https://stackoverflow.com/a/12523283
let mut contents = read_to_string("/etc/timezone")?;
// Trim to the correct length without allocating.
contents.truncate(contents.trim_end().len());
Ok(contents)
}
fn etc_localtime() -> Result<String, crate::GetTimezoneError> {
// Per <https://www.man7.org/linux/man-pages/man5/localtime.5.html>:
// “ The /etc/localtime file configures the system-wide timezone of the local system that is
// used by applications for presentation to the user. It should be an absolute or relative
// symbolic link pointing to /usr/share/zoneinfo/, followed by a timezone identifier such as
// "Europe/Berlin" or "Etc/UTC". The resulting link should lead to the corresponding binary
// tzfile(5) timezone data for the configured timezone. ”
// Systemd does not canonicalize the link, but only checks if it is prefixed by
// "/usr/share/zoneinfo/" or "../usr/share/zoneinfo/". So we do the same.
// <https://github.com/systemd/systemd/blob/9102c625a673a3246d7e73d8737f3494446bad4e/src/basic/time-util.c#L1493>
const PREFIXES: &[&str] = &[
"/usr/share/zoneinfo/", // absolute path
"../usr/share/zoneinfo/", // relative path
"/etc/zoneinfo/", // absolute path for NixOS
"../etc/zoneinfo/", // relative path for NixOS
];
let mut s = read_link("/etc/localtime")?
.into_os_string()
.into_string()
.map_err(|_| crate::GetTimezoneError::FailedParsingString)?;
for &prefix in PREFIXES {
if s.starts_with(prefix) {
// Trim to the correct length without allocating.
s.replace_range(..prefix.len(), "");
return Ok(s);
}
}
Err(crate::GetTimezoneError::FailedParsingString)
}
mod openwrt {
use std::io::BufRead;
use std::{fs, io, iter};
pub(crate) fn etc_config_system() -> Result<String, crate::GetTimezoneError> {
let f = fs::OpenOptions::new()
.read(true)
.open("/etc/config/system")?;
let mut f = io::BufReader::new(f);
let mut in_system_section = false;
let mut line = String::with_capacity(80);
// prefer option "zonename" (IANA time zone) over option "timezone" (POSIX time zone)
let mut timezone = None;
loop {
line.clear();
f.read_line(&mut line)?;
if line.is_empty() {
break;
}
let mut iter = IterWords(&line);
let mut next = || iter.next().transpose();
if let Some(keyword) = next()? {
if keyword == "config" {
in_system_section = next()? == Some("system") && next()?.is_none();
} else if in_system_section && keyword == "option" {
if let Some(key) = next()? {
if key == "zonename" {
if let (Some(zonename), None) = (next()?, next()?) {
return Ok(zonename.to_owned());
}
} else if key == "timezone" {
if let (Some(value), None) = (next()?, next()?) {
timezone = Some(value.to_owned());
}
}
}
}
}
}
timezone.ok_or_else(|| crate::GetTimezoneError::OsError)
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
struct BrokenQuote;
impl From<BrokenQuote> for crate::GetTimezoneError {
fn from(_: BrokenQuote) -> Self {
crate::GetTimezoneError::FailedParsingString
}
}
/// Iterated over all words in a OpenWRT config line.
struct IterWords<'a>(&'a str);
impl<'a> Iterator for IterWords<'a> {
type Item = Result<&'a str, BrokenQuote>;
fn next(&mut self) -> Option<Self::Item> {
match read_word(self.0) {
Ok(Some((item, tail))) => {
self.0 = tail;
Some(Ok(item))
}
Ok(None) => {
self.0 = "";
None
}
Err(err) => {
self.0 = "";
Some(Err(err))
}
}
}
}
impl iter::FusedIterator for IterWords<'_> {}
/// Read the next word in a OpenWRT config line. Strip any surrounding quotation marks.
///
/// Returns
///
/// * a tuple `Some((word, remaining_line))` if found,
/// * `None` if the line is exhausted, or
/// * `Err(BrokenQuote)` if the line could not be parsed.
#[allow(clippy::manual_strip)] // needs to be compatile to 1.36
fn read_word(s: &str) -> Result<Option<(&str, &str)>, BrokenQuote> {
let s = s.trim_start();
if s.is_empty() || s.starts_with('#') {
Ok(None)
} else if s.starts_with('\'') {
let mut iter = s[1..].splitn(2, '\'');
match (iter.next(), iter.next()) {
(Some(item), Some(tail)) => Ok(Some((item, tail))),
_ => Err(BrokenQuote),
}
} else if s.starts_with('"') {
let mut iter = s[1..].splitn(2, '"');
match (iter.next(), iter.next()) {
(Some(item), Some(tail)) => Ok(Some((item, tail))),
_ => Err(BrokenQuote),
}
} else {
let mut iter = s.splitn(2, |c: char| c.is_whitespace());
match (iter.next(), iter.next()) {
(Some(item), Some(tail)) => Ok(Some((item, tail))),
_ => Ok(Some((s, ""))),
}
}
}
#[cfg(test)]
#[test]
fn test_read_word() {
assert_eq!(
read_word(" option timezone 'CST-8'\n").unwrap(),
Some(("option", "timezone 'CST-8'\n")),
);
assert_eq!(
read_word("timezone 'CST-8'\n").unwrap(),
Some(("timezone", "'CST-8'\n")),
);
assert_eq!(read_word("'CST-8'\n").unwrap(), Some(("CST-8", "\n")));
assert_eq!(read_word("\n").unwrap(), None);
assert_eq!(
read_word(r#""time 'Zone'""#).unwrap(),
Some(("time 'Zone'", "")),
);
assert_eq!(read_word("'CST-8").unwrap_err(), BrokenQuote);
}
}

@ -0,0 +1,144 @@
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
get_timezone().ok_or(crate::GetTimezoneError::OsError)
}
#[inline]
fn get_timezone() -> Option<String> {
// The longest name in the IANA time zone database is 25 ASCII characters long.
const MAX_LEN: usize = 32;
let mut buf = [0; MAX_LEN];
// Get system time zone, and borrow its name.
let tz = system_time_zone::SystemTimeZone::new()?;
let name = tz.name()?;
// If the name is encoded in UTF-8, copy it directly.
let name = if let Some(name) = name.as_utf8() {
name
} else {
// Otherwise convert the name to UTF-8.
name.to_utf8(&mut buf)?
};
if name.is_empty() || name.len() >= MAX_LEN {
// The name should not be empty, or excessively long.
None
} else {
Some(name.to_owned())
}
}
mod system_time_zone {
//! create a safe wrapper around `CFTimeZoneRef`
use core_foundation_sys::base::{CFRelease, CFTypeRef};
use core_foundation_sys::timezone::{CFTimeZoneCopySystem, CFTimeZoneGetName, CFTimeZoneRef};
pub(crate) struct SystemTimeZone(CFTimeZoneRef);
impl Drop for SystemTimeZone {
fn drop(&mut self) {
// SAFETY: `SystemTimeZone` is only ever created with a valid `CFTimeZoneRef`.
unsafe { CFRelease(self.0 as CFTypeRef) };
}
}
impl SystemTimeZone {
pub(crate) fn new() -> Option<Self> {
// SAFETY: No invariants to uphold. We'll release the pointer when we don't need it anymore.
let v: CFTimeZoneRef = unsafe { CFTimeZoneCopySystem() };
if v.is_null() {
None
} else {
Some(SystemTimeZone(v))
}
}
/// Get the time zone name as a [super::string_ref::StringRef].
///
/// The lifetime of the `StringRef` is bound to our lifetime. Mutable
/// access is also prevented by taking a reference to `self`.
pub(crate) fn name(&self) -> Option<super::string_ref::StringRef<'_, Self>> {
// SAFETY: `SystemTimeZone` is only ever created with a valid `CFTimeZoneRef`.
let string = unsafe { CFTimeZoneGetName(self.0) };
if string.is_null() {
None
} else {
// SAFETY: here we ensure that `string` is a valid pointer.
Some(unsafe { super::string_ref::StringRef::new(string, self) })
}
}
}
}
mod string_ref {
//! create safe wrapper around `CFStringRef`
use std::convert::TryInto;
use core_foundation_sys::base::{Boolean, CFRange};
use core_foundation_sys::string::{
kCFStringEncodingUTF8, CFStringGetBytes, CFStringGetCStringPtr, CFStringGetLength,
CFStringRef,
};
pub(crate) struct StringRef<'a, T> {
string: CFStringRef,
// We exclude mutable access to the parent by taking a reference to the
// parent (rather than, for example, just using a marker to enforce the
// parent's lifetime).
_parent: &'a T,
}
impl<'a, T> StringRef<'a, T> {
// SAFETY: `StringRef` must be valid pointer
pub(crate) unsafe fn new(string: CFStringRef, _parent: &'a T) -> Self {
Self { string, _parent }
}
pub(crate) fn as_utf8(&self) -> Option<&'a str> {
// SAFETY: `StringRef` is only ever created with a valid `CFStringRef`.
let v = unsafe { CFStringGetCStringPtr(self.string, kCFStringEncodingUTF8) };
if !v.is_null() {
// SAFETY: `CFStringGetCStringPtr()` returns NUL-terminated strings.
let v = unsafe { std::ffi::CStr::from_ptr(v) };
if let Ok(v) = v.to_str() {
return Some(v);
}
}
None
}
pub(crate) fn to_utf8<'b>(&self, buf: &'b mut [u8]) -> Option<&'b str> {
// SAFETY: `StringRef` is only ever created with a valid `CFStringRef`.
let length = unsafe { CFStringGetLength(self.string) };
let mut buf_bytes = 0;
let range = CFRange {
location: 0,
length,
};
let converted_bytes = unsafe {
// SAFETY: `StringRef` is only ever created with a valid `CFStringRef`.
CFStringGetBytes(
self.string,
range,
kCFStringEncodingUTF8,
b'\0',
false as Boolean,
buf.as_mut_ptr(),
buf.len() as isize,
&mut buf_bytes,
)
};
if converted_bytes != length {
return None;
}
let len = buf_bytes.try_into().ok()?;
let s = buf.get(..len)?;
std::str::from_utf8(s).ok()
}
}
}

@ -0,0 +1,25 @@
use std::fs::read_link;
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
// see https://www.cyberciti.biz/faq/openbsd-time-zone-howto/
// This is a backport of the Linux implementation.
// NetBSDs is less than thorough how the softlink should be set up.
const PREFIXES: &[&str] = &[
"/usr/share/zoneinfo/", // absolute path
"../usr/share/zoneinfo/", // relative path
];
let mut s = read_link("/etc/localtime")?
.into_os_string()
.into_string()
.map_err(|_| crate::GetTimezoneError::FailedParsingString)?;
for &prefix in PREFIXES {
if s.starts_with(prefix) {
// Trim to the correct length without allocating.
s.replace_range(..prefix.len(), "");
return Ok(s);
}
}
Err(crate::GetTimezoneError::FailedParsingString)
}

@ -0,0 +1,21 @@
use js_sys::{Array, Intl, Object, Reflect};
use wasm_bindgen::JsValue;
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
let intl = Intl::DateTimeFormat::new(&Array::new(), &Object::new()).resolved_options();
Reflect::get(&intl, &JsValue::from_str("timeZone"))
.ok()
.and_then(|tz| tz.as_string())
.ok_or(crate::GetTimezoneError::OsError)
}
#[cfg(test)]
mod tests {
use wasm_bindgen_test::*;
#[wasm_bindgen_test]
fn pass() {
let tz = super::get_timezone_inner().unwrap();
console_log!("tz={:?}", tz);
}
}

@ -0,0 +1,17 @@
#[path = "Windows.rs"]
#[allow(missing_debug_implementations, clippy::undocumented_unsafe_blocks)]
mod windows;
use windows::Globalization::Calendar;
impl From<windows_core::Error> for crate::GetTimezoneError {
fn from(orig: windows_core::Error) -> Self {
crate::GetTimezoneError::IoError(std::io::Error::new(std::io::ErrorKind::Other, orig))
}
}
pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
let cal = Calendar::new()?;
let tz_hstring = cal.GetTimeZone()?;
Ok(tz_hstring.to_string())
}

Some files were not shown because too many files have changed in this diff Show More