wasmer/src/apis/emscripten/env.rs

23 lines
676 B
Rust
Raw Normal View History

2018-11-22 04:59:23 +00:00
use super::super::host;
2018-11-21 23:10:03 +00:00
/// NOTE: These syscalls only support wasm_32 for now because they take u32 offset
2018-11-22 05:07:01 +00:00
use libc::{c_int};
2018-11-21 23:10:03 +00:00
use std::ffi::CStr;
2018-11-22 04:59:23 +00:00
use std::os::raw::c_char;
2018-11-21 23:10:03 +00:00
2018-11-22 04:59:23 +00:00
use crate::webassembly::Instance;
2018-11-21 23:10:03 +00:00
/// emscripten: _getenv
pub extern "C" fn _getenv(name_ptr: c_int, instance: &mut Instance) -> c_int {
debug!("emscripten::_getenv {}", name_ptr);
let name = unsafe {
let memory_name_ptr = instance.memory_offset_addr(0, name_ptr as usize) as *const c_char;
CStr::from_ptr(memory_name_ptr).to_str().unwrap()
};
match host::get_env(name, instance) {
Ok(_) => {
unimplemented!();
}
2018-11-22 04:59:23 +00:00
Err(_) => 0,
2018-11-21 23:10:03 +00:00
}
}