wasmer/src/apis/emscripten/env.rs

35 lines
787 B
Rust
Raw Normal View History

2018-11-21 23:10:03 +00:00
/// NOTE: These syscalls only support wasm_32 for now because they take u32 offset
use libc::{
c_int,
c_void,
size_t,
ssize_t,
exit,
read,
open,
close,
};
use std::os::raw::c_char;
use std::ffi::CStr;
use super::super::host;
use crate::webassembly::{Instance};
/// 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!();
}
Err(_) => {
0
}
}
}