Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
oligamiq committed Dec 22, 2023
1 parent c133928 commit 2ebcd68
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
21 changes: 11 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
// "rust-analyzer.cargo.target": "wasm32-wasi",
"rust-analyzer.cargo.target": "x86_64-apple-darwin",
"cSpell.words": [
"binstall",
"COMPUTERNAME",
"gethostname",
"libc",
"objc",
"sysinfoapi",
"thiserror",
"wasi",
"winapi",
"winbase"
"binstall",
"COMPUTERNAME",
"gethostname",
"libc",
"objc",
"sysctlbyname",
"sysinfoapi",
"thiserror",
"wasi",
"winapi",
"winbase"
],
"java.configuration.updateBuildConfiguration": "interactive"
}
11 changes: 9 additions & 2 deletions rust/macos/objc/nick_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ impl NickName {

if NSImageNameComputer.is_null() {
println!("NSImageNameComputer is null");
} else {
println!("NSImageNameComputer is not null");
// https://github.com/servo/core-foundation-rs/blob/d4ce710182f1756c9d874ab917283fe1a1b7a011/cocoa-foundation/src/foundation.rs#L632
let rust_string: *const libc::c_char = unsafe { msg_send![ns_string, UTF8String] };

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, beta, pc_test_target_tier2)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, 1.68.0, pc_test_target_tier2)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, nightly, pc_test_target_tier2)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_and_clippy_target_tier2 (macos-latest, stable, pc_test_target_tier2)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, 1.68.0, pc_test_target_tier1)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, beta, pc_test_target_tier1)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, nightly, pc_test_target_tier1)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / run_pc (macos-latest, 1.68.0, pc_run)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / build_cache_pc_tier1 (macos-latest, stable, pc_test_target_tier1)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / run_pc (macos-latest, stable, pc_run)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / run_pc (macos-latest, beta, pc_run)

cannot find value `ns_string` in this scope

Check failure on line 43 in rust/macos/objc/nick_name.rs

View workflow job for this annotation

GitHub Actions / run_pc (macos-latest, nightly, pc_run)

cannot find value `ns_string` in this scope
let rust_string = unsafe { CStr::from_ptr(rust_string) };
let rust_string = rust_string.to_str().unwrap();
println!("rust_string: {}", rust_string);
}

println!("NSImageNameComputer: {:?}", NSImageNameComputer);
Expand Down Expand Up @@ -77,7 +84,7 @@ impl NickName {
Ok(hostname)
}

pub fn get_hostname(&self) -> crate::Result<String> {
pub fn get_by_gethostname(&self) -> crate::Result<String> {
// ホスト名を格納するバッファのサイズを指定
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
let limit = unsafe { libc::sysconf(libc::_SC_HOST_NAME_MAX) };
Expand All @@ -101,7 +108,7 @@ impl NickName {
}
}

fn get_name(&self) -> crate::Result<String> {
fn get_by_sysctlbyname(&self) -> crate::Result<String> {
let mut mib: [libc::c_int; 2] = [0, 0];
let mut len: libc::size_t = 0;

Expand Down

0 comments on commit 2ebcd68

Please sign in to comment.