]> git.lizzy.rs Git - rust.git/blob - src/libnative/io/c_win32.rs
Honor hidden doc attribute of derivable trait methods
[rust.git] / src / libnative / io / c_win32.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! C definitions used by libnative that don't belong in liblibc
12
13 #![allow(type_overflow)]
14
15 use libc;
16
17 pub static WSADESCRIPTION_LEN: uint = 256;
18 pub static WSASYS_STATUS_LEN: uint = 128;
19 pub static FIONBIO: libc::c_long = 0x8004667e;
20 static FD_SETSIZE: uint = 64;
21
22 pub struct WSADATA {
23     pub wVersion: libc::WORD,
24     pub wHighVersion: libc::WORD,
25     pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1],
26     pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
27     pub iMaxSockets: u16,
28     pub iMaxUdpDg: u16,
29     pub lpVendorInfo: *u8,
30 }
31
32 pub type LPWSADATA = *mut WSADATA;
33
34 pub struct fd_set {
35     fd_count: libc::c_uint,
36     fd_array: [libc::SOCKET, ..FD_SETSIZE],
37 }
38
39 pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) {
40     set.fd_array[set.fd_count as uint] = s;
41     set.fd_count += 1;
42 }
43
44 #[link(name = "ws2_32")]
45 extern "system" {
46     pub fn WSAStartup(wVersionRequested: libc::WORD,
47                       lpWSAData: LPWSADATA) -> libc::c_int;
48     pub fn WSAGetLastError() -> libc::c_int;
49
50     pub fn ioctlsocket(s: libc::SOCKET, cmd: libc::c_long,
51                        argp: *mut libc::c_ulong) -> libc::c_int;
52     pub fn select(nfds: libc::c_int,
53                   readfds: *mut fd_set,
54                   writefds: *mut fd_set,
55                   exceptfds: *mut fd_set,
56                   timeout: *libc::timeval) -> libc::c_int;
57     pub fn getsockopt(sockfd: libc::SOCKET,
58                       level: libc::c_int,
59                       optname: libc::c_int,
60                       optval: *mut libc::c_char,
61                       optlen: *mut libc::c_int) -> libc::c_int;
62 }