diff --git a/src/header/netdb/mod.rs b/src/header/netdb/mod.rs index aac67e1ee5b5dbd6c1cf9d85fb5db6f355af37fa..2e82d415f97a6ef43bed3c04bb6e3d49a47b0084 100644 --- a/src/header/netdb/mod.rs +++ b/src/header/netdb/mod.rs @@ -1014,6 +1014,21 @@ pub extern "C" fn freeaddrinfo(res: *mut addrinfo) { unimplemented!(); } +#[no_mangle] pub extern "C" fn gai_strerror(errcode: c_int) -> *const c_char { - unimplemented!(); + match errcode { + EAI_BADFLAGS => c_str!("Invalid flags"), + EAI_NONAME => c_str!("Name does not resolve"), + EAI_AGAIN => c_str!("Try again"), + EAI_FAIL => c_str!("Non-recoverable error"), + EAI_NODATA => c_str!("Unknown error"), + EAI_FAMILY => c_str!("Unrecognized address family or invalid length"), + EAI_SOCKTYPE => c_str!("Unrecognized socket type"), + EAI_SERVICE => c_str!("Unrecognized service"), + EAI_ADDRFAMILY => c_str!("Address family for name not supported"), + EAI_MEMORY => c_str!("Out of memory"), + EAI_SYSTEM => c_str!("System error"), + EAI_OVERFLOW => c_str!("Overflow"), + _ => c_str!("Unknown error"), + }.as_ptr() }