blob: cade64df5228cb22e7059ac6920124e028c6cef9 [file] [log] [blame]
Alex Crichtond3d77922015-09-11 17:03:39 -07001//! Windows CRT definitions
2
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -07003pub type c_char = i8;
4pub type c_schar = i8;
5pub type c_uchar = u8;
6pub type c_short = i16;
7pub type c_ushort = u16;
8pub type c_int = i32;
9pub type c_uint = u32;
10pub type c_long = i32;
11pub type c_ulong = u32;
12pub type c_float = f32;
13pub type c_double = f64;
14pub type wchar_t = u16;
15pub type c_longlong = i64;
16pub type c_ulonglong = u64;
17pub type intmax_t = i64;
18pub type uintmax_t = u64;
Alex Crichton5d6cf052015-09-11 14:52:34 -070019
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070020cfg_if! {
21 if #[cfg(target_arch = "x86")] {
22 pub type intptr_t = i32;
23 pub type ptrdiff_t = i32;
24 pub type size_t = u32;
25 pub type ssize_t = i32;
26 pub type uintptr_t = u32;
27 pub type LONG_PTR = c_long;
28 } else if #[cfg(target_arch = "x86_64")] {
29 pub type intptr_t = i64;
30 pub type ptrdiff_t = i64;
31 pub type size_t = u64;
32 pub type ssize_t = i64;
33 pub type uintptr_t = u64;
34 pub type LONG_PTR = i64;
35 } else {
36 // unknown arch
Alex Crichton5d6cf052015-09-11 14:52:34 -070037 }
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070038}
Alex Crichton5d6cf052015-09-11 14:52:34 -070039
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070040pub type clock_t = i32;
Alex Crichton5d6cf052015-09-11 14:52:34 -070041
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070042cfg_if! {
43 if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
44 pub type time_t = i32;
45 } else {
46 pub type time_t = i64;
47 }
48}
Alex Crichton5d6cf052015-09-11 14:52:34 -070049
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070050pub type off_t = i32;
51pub type dev_t = u32;
52pub type ino_t = u16;
53pub enum timezone {}
54pub type time64_t = i64;
Alex Crichton5d6cf052015-09-11 14:52:34 -070055
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -070056pub type BOOL = c_int;
57pub type BYTE = u8;
58pub type BOOLEAN = BYTE;
59pub type CCHAR = c_char;
60pub type CHAR = c_char;
61pub type DWORD = c_ulong;
62pub type DWORDLONG = c_ulonglong;
63pub type HANDLE = LPVOID;
64pub type HINSTANCE = HANDLE;
65pub type HMODULE = HINSTANCE;
66pub type LONG = c_long;
67pub type PLONG = *mut c_long;
68pub type LARGE_INTEGER = c_longlong;
69pub type PLARGE_INTEGER = *mut c_longlong;
70pub type LPCWSTR = *const WCHAR;
71pub type LPCSTR = *const CHAR;
72pub type LPWSTR = *mut WCHAR;
73pub type LPSTR = *mut CHAR;
74pub type LPWCH = *mut WCHAR;
75pub type LPCH = *mut CHAR;
76pub type SOCKET = uintptr_t;
77pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
78pub type LPVOID = *mut ::c_void;
79pub type LPCVOID = *const ::c_void;
80pub type LPBYTE = *mut BYTE;
81pub type LPWORD = *mut WORD;
82pub type LPDWORD = *mut DWORD;
83pub type LPHANDLE = *mut HANDLE;
84pub type LRESULT = LONG_PTR;
85pub type PBOOL = *mut BOOL;
86pub type WCHAR = wchar_t;
87pub type WORD = u16;
88pub type SIZE_T = size_t;
89pub type GROUP = c_uint;
90pub type LPSTARTUPINFOW = *mut STARTUPINFOW;
91pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
92pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
93pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
94pub type LPOVERLAPPED = *mut OVERLAPPED;
95pub type LPFILETIME = *mut FILETIME;
96pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
97pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
98pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
Alex Crichton5d6cf052015-09-11 14:52:34 -070099
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700100s! {
101 // note this is the struct called stat64 in Windows. Not stat, nor stati64.
102 pub struct stat {
103 pub st_dev: dev_t,
104 pub st_ino: ino_t,
105 pub st_mode: u16,
106 pub st_nlink: c_short,
107 pub st_uid: c_short,
108 pub st_gid: c_short,
109 pub st_rdev: dev_t,
110 pub st_size: i64,
111 pub st_atime: time64_t,
112 pub st_mtime: time64_t,
113 pub st_ctime: time64_t,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700114 }
115
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700116 // note that this is called utimbuf64 in Windows
117 pub struct utimbuf {
118 pub actime: time64_t,
119 pub modtime: time64_t,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700120 }
121
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700122 pub struct timeval {
123 pub tv_sec: c_long,
124 pub tv_usec: c_long,
125 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700126
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700127 pub struct timespec {
128 pub tv_sec: time_t,
129 pub tv_nsec: c_long,
130 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700131
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700132 pub struct sockaddr {
133 pub sa_family: u16,
134 pub sa_data: [u8; 14],
135 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700136
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700137 pub struct sockaddr_storage {
138 pub ss_family: u16,
139 __ss_pad1: [u8; 6],
140 __ss_align: i64,
141 __ss_pad2: [u8; 112],
142 }
143
144 pub struct sockaddr_in {
145 pub sin_family: u16,
146 pub sin_port: u16,
147 pub sin_addr: in_addr,
148 pub sin_zero: [u8; 8],
149 }
150
151 pub struct in_addr {
152 pub s_addr: u32,
153 }
154
155 pub struct sockaddr_in6 {
156 pub sin6_family: u16,
157 pub sin6_port: u16,
158 pub sin6_flowinfo: u32,
159 pub sin6_addr: in6_addr,
160 pub sin6_scope_id: u32,
161 }
162
163 pub struct in6_addr {
164 pub s6_addr: [u16; 8],
165 }
166
167 pub struct ip_mreq {
168 pub imr_multiaddr: in_addr,
169 pub imr_interface: in_addr,
170 }
171
172 pub struct ipv6_mreq {
173 pub ipv6mr_multiaddr: in6_addr,
174 pub ipv6mr_interface: c_uint,
175 }
176
177 pub struct addrinfo {
178 pub ai_flags: c_int,
179 pub ai_family: c_int,
180 pub ai_socktype: c_int,
181 pub ai_protocol: c_int,
182 pub ai_addrlen: size_t,
183 pub ai_canonname: *mut c_char,
184 pub ai_addr: *mut sockaddr,
185 pub ai_next: *mut addrinfo,
186 }
187
188 pub struct SECURITY_ATTRIBUTES {
189 pub nLength: DWORD,
190 pub lpSecurityDescriptor: LPVOID,
191 pub bInheritHandle: BOOL,
192 }
193
194 pub struct STARTUPINFOW {
195 pub cb: DWORD,
196 pub lpReserved: LPWSTR,
197 pub lpDesktop: LPWSTR,
198 pub lpTitle: LPWSTR,
199 pub dwX: DWORD,
200 pub dwY: DWORD,
201 pub dwXSize: DWORD,
202 pub dwYSize: DWORD,
203 pub dwXCountChars: DWORD,
204 pub dwYCountChars: DWORD,
205 pub dwFillAttribute: DWORD,
206 pub dwFlags: DWORD,
207 pub wShowWindow: WORD,
208 pub cbReserved2: WORD,
209 pub lpReserved2: LPBYTE,
210 pub hStdInput: HANDLE,
211 pub hStdOutput: HANDLE,
212 pub hStdError: HANDLE,
213 }
214
215 pub struct PROCESS_INFORMATION {
216 pub hProcess: HANDLE,
217 pub hThread: HANDLE,
218 pub dwProcessId: DWORD,
219 pub dwThreadId: DWORD,
220 }
221
222 pub struct SYSTEM_INFO {
223 pub wProcessorArchitecture: WORD,
224 pub wReserved: WORD,
225 pub dwPageSize: DWORD,
226 pub lpMinimumApplicationAddress: LPVOID,
227 pub lpMaximumApplicationAddress: LPVOID,
228 pub dwActiveProcessorMask: uintptr_t,
229 pub dwNumberOfProcessors: DWORD,
230 pub dwProcessorType: DWORD,
231 pub dwAllocationGranularity: DWORD,
232 pub wProcessorLevel: WORD,
233 pub wProcessorRevision: WORD,
234 }
235
236 pub struct MEMORY_BASIC_INFORMATION {
237 pub BaseAddress: LPVOID,
238 pub AllocationBase: LPVOID,
239 pub AllocationProtect: DWORD,
240 pub RegionSize: SIZE_T,
241 pub State: DWORD,
242 pub Protect: DWORD,
243 pub Type: DWORD,
244 }
245
246 pub struct OVERLAPPED {
247 pub Internal: *mut c_ulong,
248 pub InternalHigh: *mut c_ulong,
249 pub Offset: DWORD,
250 pub OffsetHigh: DWORD,
251 pub hEvent: HANDLE,
252 }
253
254 pub struct FILETIME {
255 pub dwLowDateTime: DWORD,
256 pub dwHighDateTime: DWORD,
257 }
258
259 pub struct GUID {
260 pub Data1: DWORD,
261 pub Data2: WORD,
262 pub Data3: WORD,
263 pub Data4: [BYTE; 8],
264 }
265
266 pub struct WSAPROTOCOLCHAIN {
267 pub ChainLen: c_int,
268 pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
269 }
270
271 pub struct WSAPROTOCOL_INFO {
272 pub dwServiceFlags1: DWORD,
273 pub dwServiceFlags2: DWORD,
274 pub dwServiceFlags3: DWORD,
275 pub dwServiceFlags4: DWORD,
276 pub dwProviderFlags: DWORD,
277 pub ProviderId: GUID,
278 pub dwCatalogEntryId: DWORD,
279 pub ProtocolChain: WSAPROTOCOLCHAIN,
280 pub iVersion: c_int,
281 pub iAddressFamily: c_int,
282 pub iMaxSockAddr: c_int,
283 pub iMinSockAddr: c_int,
284 pub iSocketType: c_int,
285 pub iProtocol: c_int,
286 pub iProtocolMaxOffset: c_int,
287 pub iNetworkByteOrder: c_int,
288 pub iSecurityScheme: c_int,
289 pub dwMessageSize: DWORD,
290 pub dwProviderReserved: DWORD,
291 pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1],
292 }
293
294 pub struct WIN32_FIND_DATAW {
295 pub dwFileAttributes: DWORD,
296 pub ftCreationTime: FILETIME,
297 pub ftLastAccessTime: FILETIME,
298 pub ftLastWriteTime: FILETIME,
299 pub nFileSizeHigh: DWORD,
300 pub nFileSizeLow: DWORD,
301 pub dwReserved0: DWORD,
302 pub dwReserved1: DWORD,
303 pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
304 pub cAlternateFileName: [wchar_t; 14],
305 }
306}
307
308pub const EXIT_FAILURE: c_int = 1;
309pub const EXIT_SUCCESS: c_int = 0;
310pub const RAND_MAX: c_int = 32767;
311pub const EOF: c_int = -1;
312pub const SEEK_SET: c_int = 0;
313pub const SEEK_CUR: c_int = 1;
314pub const SEEK_END: c_int = 2;
315pub const _IOFBF: c_int = 0;
316pub const _IONBF: c_int = 4;
317pub const _IOLBF: c_int = 64;
318pub const BUFSIZ: c_uint = 512;
319pub const FOPEN_MAX: c_uint = 20;
320pub const FILENAME_MAX: c_uint = 260;
321
322pub const WSAEINTR: c_int = 10004;
323pub const WSAEBADF: c_int = 10009;
324pub const WSAEACCES: c_int = 10013;
325pub const WSAEFAULT: c_int = 10014;
326pub const WSAEINVAL: c_int = 10022;
327pub const WSAEMFILE: c_int = 10024;
328pub const WSAEWOULDBLOCK: c_int = 10035;
329pub const WSAEINPROGRESS: c_int = 10036;
330pub const WSAEALREADY: c_int = 10037;
331pub const WSAENOTSOCK: c_int = 10038;
332pub const WSAEDESTADDRREQ: c_int = 10039;
333pub const WSAEMSGSIZE: c_int = 10040;
334pub const WSAEPROTOTYPE: c_int = 10041;
335pub const WSAENOPROTOOPT: c_int = 10042;
336pub const WSAEPROTONOSUPPORT: c_int = 10043;
337pub const WSAESOCKTNOSUPPORT: c_int = 10044;
338pub const WSAEOPNOTSUPP: c_int = 10045;
339pub const WSAEPFNOSUPPORT: c_int = 10046;
340pub const WSAEAFNOSUPPORT: c_int = 10047;
341pub const WSAEADDRINUSE: c_int = 10048;
342pub const WSAEADDRNOTAVAIL: c_int = 10049;
343pub const WSAENETDOWN: c_int = 10050;
344pub const WSAENETUNREACH: c_int = 10051;
345pub const WSAENETRESET: c_int = 10052;
346pub const WSAECONNABORTED: c_int = 10053;
347pub const WSAECONNRESET: c_int = 10054;
348pub const WSAENOBUFS: c_int = 10055;
349pub const WSAEISCONN: c_int = 10056;
350pub const WSAENOTCONN: c_int = 10057;
351pub const WSAESHUTDOWN: c_int = 10058;
352pub const WSAETOOMANYREFS: c_int = 10059;
353pub const WSAETIMEDOUT: c_int = 10060;
354pub const WSAECONNREFUSED: c_int = 10061;
355pub const WSAELOOP: c_int = 10062;
356pub const WSAENAMETOOLONG: c_int = 10063;
357pub const WSAEHOSTDOWN: c_int = 10064;
358pub const WSAEHOSTUNREACH: c_int = 10065;
359pub const WSAENOTEMPTY: c_int = 10066;
360pub const WSAEPROCLIM: c_int = 10067;
361pub const WSAEUSERS: c_int = 10068;
362pub const WSAEDQUOT: c_int = 10069;
363pub const WSAESTALE: c_int = 10070;
364pub const WSAEREMOTE: c_int = 10071;
365pub const WSASYSNOTREADY: c_int = 10091;
366pub const WSAVERNOTSUPPORTED: c_int = 10092;
367pub const WSANOTINITIALISED: c_int = 10093;
368pub const WSAEDISCON: c_int = 10101;
369pub const WSAENOMORE: c_int = 10102;
370pub const WSAECANCELLED: c_int = 10103;
371pub const WSAEINVALIDPROCTABLE: c_int = 10104;
372pub const WSAEINVALIDPROVIDER: c_int = 10105;
373pub const WSAEPROVIDERFAILEDINIT: c_int = 10106;
374
375cfg_if! {
376 if #[cfg(all(target_env = "gnu"))] {
377 pub const L_tmpnam: c_uint = 14;
378 pub const TMP_MAX: c_uint = 0x7fff;
379 } else {
380 pub const L_tmpnam: c_uint = 260;
381 pub const TMP_MAX: c_uint = 0x7fff_ffff;
382 }
383}
384
385pub const O_RDONLY: c_int = 0;
386pub const O_WRONLY: c_int = 1;
387pub const O_RDWR: c_int = 2;
388pub const O_APPEND: c_int = 8;
389pub const O_CREAT: c_int = 256;
390pub const O_EXCL: c_int = 1024;
391pub const O_TRUNC: c_int = 512;
392pub const S_IFCHR: c_int = 8192;
393pub const S_IFDIR: c_int = 16384;
394pub const S_IFREG: c_int = 32768;
395pub const S_IFMT: c_int = 61440;
396pub const S_IEXEC: c_int = 64;
397pub const S_IWRITE: c_int = 128;
398pub const S_IREAD: c_int = 256;
399
400pub const AF_INET: c_int = 2;
401pub const AF_INET6: c_int = 23;
402pub const SOCK_STREAM: c_int = 1;
403pub const SOCK_DGRAM: c_int = 2;
404pub const SOCK_RAW: c_int = 3;
405pub const IPPROTO_TCP: c_int = 6;
406pub const IPPROTO_IP: c_int = 0;
407pub const IPPROTO_IPV6: c_int = 41;
408pub const IP_MULTICAST_TTL: c_int = 10;
409pub const IP_MULTICAST_LOOP: c_int = 11;
410pub const IP_ADD_MEMBERSHIP: c_int = 12;
411pub const IP_DROP_MEMBERSHIP: c_int = 13;
412pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
413pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
414pub const IP_TTL: c_int = 4;
415pub const IP_HDRINCL: c_int = 2;
416
417pub const TCP_NODELAY: c_int = 0x0001;
418pub const SOL_SOCKET: c_int = 0xffff;
419
420pub const SO_DEBUG: c_int = 0x0001;
421pub const SO_ACCEPTCONN: c_int = 0x0002;
422pub const SO_REUSEADDR: c_int = 0x0004;
423pub const SO_KEEPALIVE: c_int = 0x0008;
424pub const SO_DONTROUTE: c_int = 0x0010;
425pub const SO_BROADCAST: c_int = 0x0020;
426pub const SO_USELOOPBACK: c_int = 0x0040;
427pub const SO_LINGER: c_int = 0x0080;
428pub const SO_OOBINLINE: c_int = 0x0100;
429pub const SO_SNDBUF: c_int = 0x1001;
430pub const SO_RCVBUF: c_int = 0x1002;
431pub const SO_SNDLOWAT: c_int = 0x1003;
432pub const SO_RCVLOWAT: c_int = 0x1004;
433pub const SO_SNDTIMEO: c_int = 0x1005;
434pub const SO_RCVTIMEO: c_int = 0x1006;
435pub const SO_ERROR: c_int = 0x1007;
436pub const SO_TYPE: c_int = 0x1008;
437
438pub const IFF_LOOPBACK: c_int = 4;
439
440pub const SD_RECEIVE: c_int = 0;
441pub const SD_SEND: c_int = 1;
442pub const SD_BOTH: c_int = 2;
443
444pub const TRUE: BOOL = 1;
445pub const FALSE: BOOL = 0;
446
447pub const O_TEXT: c_int = 16384;
448pub const O_BINARY: c_int = 32768;
449pub const O_NOINHERIT: c_int = 128;
450
451pub const ERROR_SUCCESS: c_int = 0;
452pub const ERROR_INVALID_FUNCTION: c_int = 1;
453pub const ERROR_FILE_NOT_FOUND: c_int = 2;
454pub const ERROR_ACCESS_DENIED: c_int = 5;
455pub const ERROR_INVALID_HANDLE: c_int = 6;
456pub const ERROR_BROKEN_PIPE: c_int = 109;
457pub const ERROR_DISK_FULL: c_int = 112;
458pub const ERROR_CALL_NOT_IMPLEMENTED: c_int = 120;
459pub const ERROR_INSUFFICIENT_BUFFER: c_int = 122;
460pub const ERROR_INVALID_NAME: c_int = 123;
461pub const ERROR_ALREADY_EXISTS: c_int = 183;
462pub const ERROR_PIPE_BUSY: c_int = 231;
463pub const ERROR_NO_DATA: c_int = 232;
464pub const ERROR_INVALID_ADDRESS: c_int = 487;
465pub const ERROR_PIPE_CONNECTED: c_int = 535;
466pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758;
467pub const ERROR_OPERATION_ABORTED: c_int = 995;
468pub const ERROR_IO_PENDING: c_int = 997;
469pub const ERROR_FILE_INVALID: c_int = 1006;
470pub const ERROR_NOT_FOUND: c_int = 1168;
471pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
472
473pub const DELETE: DWORD = 0x00010000;
474pub const READ_CONTROL: DWORD = 0x00020000;
475pub const SYNCHRONIZE: DWORD = 0x00100000;
476pub const WRITE_DAC: DWORD = 0x00040000;
477pub const WRITE_OWNER: DWORD = 0x00080000;
478
479pub const PROCESS_CREATE_PROCESS: DWORD = 0x0080;
480pub const PROCESS_CREATE_THREAD: DWORD = 0x0002;
481pub const PROCESS_DUP_HANDLE: DWORD = 0x0040;
482pub const PROCESS_QUERY_INFORMATION: DWORD = 0x0400;
483pub const PROCESS_QUERY_LIMITED_INFORMATION: DWORD = 0x1000;
484pub const PROCESS_SET_INFORMATION: DWORD = 0x0200;
485pub const PROCESS_SET_QUOTA: DWORD = 0x0100;
486pub const PROCESS_SUSPEND_RESUME: DWORD = 0x0800;
487pub const PROCESS_TERMINATE: DWORD = 0x0001;
488pub const PROCESS_VM_OPERATION: DWORD = 0x0008;
489pub const PROCESS_VM_READ: DWORD = 0x0010;
490pub const PROCESS_VM_WRITE: DWORD = 0x0020;
491
492pub const STARTF_FORCEONFEEDBACK: DWORD = 0x00000040;
493pub const STARTF_FORCEOFFFEEDBACK: DWORD = 0x00000080;
494pub const STARTF_PREVENTPINNING: DWORD = 0x00002000;
495pub const STARTF_RUNFULLSCREEN: DWORD = 0x00000020;
496pub const STARTF_TITLEISAPPID: DWORD = 0x00001000;
497pub const STARTF_TITLEISLINKNAME: DWORD = 0x00000800;
498pub const STARTF_USECOUNTCHARS: DWORD = 0x00000008;
499pub const STARTF_USEFILLATTRIBUTE: DWORD = 0x00000010;
500pub const STARTF_USEHOTKEY: DWORD = 0x00000200;
501pub const STARTF_USEPOSITION: DWORD = 0x00000004;
502pub const STARTF_USESHOWWINDOW: DWORD = 0x00000001;
503pub const STARTF_USESIZE: DWORD = 0x00000002;
504pub const STARTF_USESTDHANDLES: DWORD = 0x00000100;
505
506pub const WAIT_ABANDONED: DWORD = 0x00000080;
507pub const WAIT_OBJECT_0: DWORD = 0x00000000;
508pub const WAIT_TIMEOUT: DWORD = 0x00000102;
509pub const WAIT_FAILED: DWORD = !0;
510
511pub const DUPLICATE_CLOSE_SOURCE: DWORD = 0x00000001;
512pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002;
513
514pub const INFINITE: DWORD = !0;
515pub const STILL_ACTIVE: DWORD = 259;
516
517pub const MEM_COMMIT: DWORD = 0x00001000;
518pub const MEM_RESERVE: DWORD = 0x00002000;
519pub const MEM_DECOMMIT: DWORD = 0x00004000;
520pub const MEM_RELEASE: DWORD = 0x00008000;
521pub const MEM_RESET: DWORD = 0x00080000;
522pub const MEM_RESET_UNDO: DWORD = 0x1000000;
523pub const MEM_LARGE_PAGES: DWORD = 0x20000000;
524pub const MEM_PHYSICAL: DWORD = 0x00400000;
525pub const MEM_TOP_DOWN: DWORD = 0x00100000;
526pub const MEM_WRITE_WATCH: DWORD = 0x00200000;
527
528pub const PAGE_EXECUTE: DWORD = 0x10;
529pub const PAGE_EXECUTE_READ: DWORD = 0x20;
530pub const PAGE_EXECUTE_READWRITE: DWORD = 0x40;
531pub const PAGE_EXECUTE_WRITECOPY: DWORD = 0x80;
532pub const PAGE_NOACCESS: DWORD = 0x01;
533pub const PAGE_READONLY: DWORD = 0x02;
534pub const PAGE_READWRITE: DWORD = 0x04;
535pub const PAGE_WRITECOPY: DWORD = 0x08;
536pub const PAGE_GUARD: DWORD = 0x100;
537pub const PAGE_NOCACHE: DWORD = 0x200;
538pub const PAGE_WRITECOMBINE: DWORD = 0x400;
539
540pub const SEC_COMMIT: DWORD = 0x8000000;
541pub const SEC_IMAGE: DWORD = 0x1000000;
542pub const SEC_IMAGE_NO_EXECUTE: DWORD = 0x11000000;
543pub const SEC_LARGE_PAGES: DWORD = 0x80000000;
544pub const SEC_NOCACHE: DWORD = 0x10000000;
545pub const SEC_RESERVE: DWORD = 0x4000000;
546pub const SEC_WRITECOMBINE: DWORD = 0x40000000;
547
548pub const FILE_MAP_ALL_ACCESS: DWORD = 0xf001f;
549pub const FILE_MAP_READ: DWORD = 0x4;
550pub const FILE_MAP_WRITE: DWORD = 0x2;
551pub const FILE_MAP_COPY: DWORD = 0x1;
552pub const FILE_MAP_EXECUTE: DWORD = 0x20;
553
554pub const PROCESSOR_ARCHITECTURE_INTEL: WORD = 0;
555pub const PROCESSOR_ARCHITECTURE_ARM: WORD = 5;
556pub const PROCESSOR_ARCHITECTURE_IA64: WORD = 6;
557pub const PROCESSOR_ARCHITECTURE_AMD64: WORD = 9;
558pub const PROCESSOR_ARCHITECTURE_UNKNOWN: WORD = 0xffff;
559
560pub const MOVEFILE_COPY_ALLOWED: DWORD = 2;
561pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16;
562pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4;
563pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32;
564pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
565pub const MOVEFILE_WRITE_THROUGH: DWORD = 8;
566
567pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1;
568
569pub const FILE_SHARE_DELETE: DWORD = 0x4;
570pub const FILE_SHARE_READ: DWORD = 0x1;
571pub const FILE_SHARE_WRITE: DWORD = 0x2;
572
573pub const CREATE_ALWAYS: DWORD = 2;
574pub const CREATE_NEW: DWORD = 1;
575pub const OPEN_ALWAYS: DWORD = 4;
576pub const OPEN_EXISTING: DWORD = 3;
577pub const TRUNCATE_EXISTING: DWORD = 5;
578
579pub const FILE_APPEND_DATA: DWORD = 0x00000004;
580pub const FILE_READ_DATA: DWORD = 0x00000001;
581pub const FILE_WRITE_DATA: DWORD = 0x00000002;
582
583pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20;
584pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800;
585pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40;
586pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
587pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000;
588pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2;
589pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000;
590pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80;
591pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000;
592pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000;
593pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000;
594pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
595pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
596pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200;
597pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4;
598pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100;
599pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000;
600
601pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
602pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000;
603pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000;
604pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000;
605pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
606pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
607pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000;
608pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000;
609pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000;
610pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000;
611pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000;
612pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
613
614pub const FILE_NAME_NORMALIZED: DWORD = 0x0;
615pub const FILE_NAME_OPENED: DWORD = 0x8;
616
617pub const VOLUME_NAME_DOS: DWORD = 0x0;
618pub const VOLUME_NAME_GUID: DWORD = 0x1;
619pub const VOLUME_NAME_NONE: DWORD = 0x4;
620pub const VOLUME_NAME_NT: DWORD = 0x2;
621
622pub const GENERIC_READ: DWORD = 0x80000000;
623pub const GENERIC_WRITE: DWORD = 0x40000000;
624pub const GENERIC_EXECUTE: DWORD = 0x20000000;
625pub const GENERIC_ALL: DWORD = 0x10000000;
626pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
627pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080;
628
629pub const STANDARD_RIGHTS_READ: DWORD = 0x20000;
630pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000;
631pub const FILE_WRITE_EA: DWORD = 0x00000010;
632pub const FILE_READ_EA: DWORD = 0x00000008;
633pub const FILE_GENERIC_READ: DWORD =
634 STANDARD_RIGHTS_READ | FILE_READ_DATA |
635 FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE;
636pub const FILE_GENERIC_WRITE: DWORD =
637 STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
638 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA |
639 SYNCHRONIZE;
640
641pub const FILE_BEGIN: DWORD = 0;
642pub const FILE_CURRENT: DWORD = 1;
643pub const FILE_END: DWORD = 2;
644
645pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
646pub const WSAPROTOCOL_LEN: DWORD = 255;
647pub const INVALID_SOCKET: SOCKET = !0;
648
649pub const DETACHED_PROCESS: DWORD = 0x00000008;
650pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
651pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
652
653pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003;
654pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
655pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
656pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
657pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004;
658pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
659pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002;
660pub const PIPE_WAIT: DWORD = 0x00000000;
661pub const PIPE_NOWAIT: DWORD = 0x00000001;
662pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000;
663pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
664pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255;
665
666pub const IPPROTO_RAW: c_int = 255;
667
668pub const FIONBIO: c_long = -0x7FFB9982;
669
Alex Crichton2c57e362015-09-15 17:30:53 -0700670#[cfg(target_env = "msvc")]
671#[link(name = "kernel32")]
672#[link(name = "shell32")]
673#[link(name = "msvcrt")]
674extern {}
675
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700676extern {
677 #[link_name = "_chmod"]
678 pub fn chmod(path: *const c_char, mode: c_int) -> c_int;
679 #[link_name = "_wchmod"]
680 pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int;
681 #[link_name = "_mkdir"]
682 pub fn mkdir(path: *const c_char) -> c_int;
683 #[link_name = "_wrmdir"]
684 pub fn wrmdir(path: *const wchar_t) -> c_int;
685 #[link_name = "_fstat64"]
686 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
687 #[link_name = "_stat64"]
688 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
689 #[link_name = "_wstat64"]
690 pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int;
691 #[link_name = "_wutime64"]
692 pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int;
693 #[link_name = "_popen"]
694 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
695 #[link_name = "_pclose"]
696 pub fn pclose(stream: *mut ::FILE) -> c_int;
697 #[link_name = "_fdopen"]
698 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE;
699 #[link_name = "_fileno"]
700 pub fn fileno(stream: *mut ::FILE) -> c_int;
701 #[link_name = "_open"]
702 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
703 #[link_name = "_wopen"]
704 pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int;
705 #[link_name = "_creat"]
706 pub fn creat(path: *const c_char, mode: c_int) -> c_int;
707 #[link_name = "_access"]
708 pub fn access(path: *const c_char, amode: c_int) -> c_int;
709 #[link_name = "_chdir"]
710 pub fn chdir(dir: *const c_char) -> c_int;
711 #[link_name = "_close"]
712 pub fn close(fd: c_int) -> c_int;
713 #[link_name = "_dup"]
714 pub fn dup(fd: c_int) -> c_int;
715 #[link_name = "_dup2"]
716 pub fn dup2(src: c_int, dst: c_int) -> c_int;
717 #[link_name = "_execv"]
718 pub fn execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t;
719 #[link_name = "_execve"]
720 pub fn execve(prog: *const c_char, argv: *const *const c_char,
721 envp: *const *const c_char) -> c_int;
722 #[link_name = "_execvp"]
723 pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int;
724 #[link_name = "_execvpe"]
725 pub fn execvpe(c: *const c_char, argv: *const *const c_char,
726 envp: *const *const c_char) -> c_int;
727 #[link_name = "_getcwd"]
728 pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char;
729 #[link_name = "_getpid"]
730 pub fn getpid() -> c_int;
731 #[link_name = "_isatty"]
732 pub fn isatty(fd: c_int) -> c_int;
733 #[link_name = "_lseek"]
734 pub fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long;
735 #[link_name = "_pipe"]
736 pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int;
737 #[link_name = "_read"]
738 pub fn read(fd: c_int, buf: *mut ::c_void, count: c_uint) -> c_int;
739 #[link_name = "_rmdir"]
740 pub fn rmdir(path: *const c_char) -> c_int;
741 #[link_name = "_unlink"]
742 pub fn unlink(c: *const c_char) -> c_int;
743 #[link_name = "_write"]
744 pub fn write(fd: c_int, buf: *const ::c_void, count: c_uint) -> c_int;
745 #[link_name = "_commit"]
746 pub fn commit(fd: c_int) -> c_int;
747 #[link_name = "_get_osfhandle"]
748 pub fn get_osfhandle(fd: c_int) -> intptr_t;
749 #[link_name = "_open_osfhandle"]
750 pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int;
751}
752
753extern "system" {
754 pub fn GetEnvironmentVariableW(n: LPCWSTR,
755 v: LPWSTR,
756 nsize: DWORD)
757 -> DWORD;
758 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700759 -> BOOL;
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700760 pub fn GetEnvironmentStringsW() -> LPWCH;
761 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
762 pub fn GetModuleFileNameW(hModule: HMODULE,
763 lpFilename: LPWSTR,
764 nSize: DWORD)
765 -> DWORD;
766 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
767 lpSecurityAttributes:
768 LPSECURITY_ATTRIBUTES)
769 -> BOOL;
770 pub fn CopyFileW(lpExistingFileName: LPCWSTR,
771 lpNewFileName: LPCWSTR,
772 bFailIfExists: BOOL)
773 -> BOOL;
774 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
775 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
776 pub fn GetCurrentDirectoryW(nBufferLength: DWORD,
777 lpBuffer: LPWSTR)
778 -> DWORD;
779 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
780 pub fn GetLastError() -> DWORD;
781 pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW)
782 -> HANDLE;
783 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
784 -> BOOL;
785 pub fn FindClose(findFile: HANDLE) -> BOOL;
786 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
787 hSourceHandle: HANDLE,
788 hTargetProcessHandle: HANDLE,
789 lpTargetHandle: LPHANDLE,
790 dwDesiredAccess: DWORD,
791 bInheritHandle: BOOL,
792 dwOptions: DWORD)
793 -> BOOL;
794 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
795 pub fn OpenProcess(dwDesiredAccess: DWORD,
796 bInheritHandle: BOOL,
797 dwProcessId: DWORD)
798 -> HANDLE;
799 pub fn GetCurrentProcess() -> HANDLE;
800 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
801 lpCommandLine: LPWSTR,
802 lpProcessAttributes:
803 LPSECURITY_ATTRIBUTES,
804 lpThreadAttributes:
805 LPSECURITY_ATTRIBUTES,
806 bInheritHandles: BOOL,
807 dwCreationFlags: DWORD,
808 lpEnvironment: LPVOID,
809 lpCurrentDirectory: LPCWSTR,
810 lpStartupInfo: LPSTARTUPINFOW,
811 lpProcessInformation:
812 LPPROCESS_INFORMATION)
813 -> BOOL;
814 pub fn WaitForSingleObject(hHandle: HANDLE,
815 dwMilliseconds: DWORD)
816 -> DWORD;
817 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint)
818 -> BOOL;
819 pub fn GetExitCodeProcess(hProcess: HANDLE,
820 lpExitCode: LPDWORD)
821 -> BOOL;
822 pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
823 pub fn VirtualAlloc(lpAddress: LPVOID,
824 dwSize: SIZE_T,
825 flAllocationType: DWORD,
826 flProtect: DWORD)
827 -> LPVOID;
828 pub fn VirtualFree(lpAddress: LPVOID,
829 dwSize: SIZE_T,
830 dwFreeType: DWORD)
831 -> BOOL;
832 pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL;
833 pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T)
834 -> BOOL;
835 pub fn VirtualProtect(lpAddress: LPVOID,
836 dwSize: SIZE_T,
837 flNewProtect: DWORD,
838 lpflOldProtect: LPDWORD)
839 -> BOOL;
840 pub fn VirtualQuery(lpAddress: LPCVOID,
841 lpBuffer: PMEMORY_BASIC_INFORMATION,
842 dwLength: SIZE_T)
843 -> SIZE_T;
844 pub fn CreateFileMappingW(hFile: HANDLE,
845 lpAttributes: LPSECURITY_ATTRIBUTES,
846 flProtect: DWORD,
847 dwMaximumSizeHigh: DWORD,
848 dwMaximumSizeLow: DWORD,
849 lpName: LPCWSTR)
850 -> HANDLE;
851 pub fn MapViewOfFile(hFileMappingObject: HANDLE,
852 dwDesiredAccess: DWORD,
853 dwFileOffsetHigh: DWORD,
854 dwFileOffsetLow: DWORD,
855 dwNumberOfBytesToMap: SIZE_T)
856 -> LPVOID;
857 pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
858 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
859 lpNewFileName: LPCWSTR,
860 dwFlags: DWORD) -> BOOL;
861 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
862 lpTargetFileName: LPCWSTR,
863 lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
864 -> BOOL;
865 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
866 pub fn CreateFileW(lpFileName: LPCWSTR,
867 dwDesiredAccess: DWORD,
868 dwShareMode: DWORD,
869 lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
870 dwCreationDisposition: DWORD,
871 dwFlagsAndAttributes: DWORD,
872 hTemplateFile: HANDLE) -> HANDLE;
873 pub fn ReadFile(hFile: HANDLE,
874 lpBuffer: LPVOID,
875 nNumberOfBytesToRead: DWORD,
876 lpNumberOfBytesRead: LPDWORD,
877 lpOverlapped: LPOVERLAPPED) -> BOOL;
878 pub fn WriteFile(hFile: HANDLE,
879 lpBuffer: LPCVOID,
880 nNumberOfBytesToWrite: DWORD,
881 lpNumberOfBytesWritten: LPDWORD,
882 lpOverlapped: LPOVERLAPPED) -> BOOL;
883 pub fn SetFilePointerEx(hFile: HANDLE,
884 liDistanceToMove: LARGE_INTEGER,
885 lpNewFilePointer: PLARGE_INTEGER,
886 dwMoveMethod: DWORD) -> BOOL;
887 pub fn SetEndOfFile(hFile: HANDLE) -> BOOL;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700888
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700889 pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700890
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700891 pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL;
892 pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER)
893 -> BOOL;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700894
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700895 pub fn GetCurrentProcessId() -> DWORD;
896 pub fn CreateNamedPipeW(
897 lpName: LPCWSTR,
898 dwOpenMode: DWORD,
899 dwPipeMode: DWORD,
900 nMaxInstances: DWORD,
901 nOutBufferSize: DWORD,
902 nInBufferSize: DWORD,
903 nDefaultTimeOut: DWORD,
904 lpSecurityAttributes: LPSECURITY_ATTRIBUTES
905 ) -> HANDLE;
906 pub fn ConnectNamedPipe(hNamedPipe: HANDLE,
907 lpOverlapped: LPOVERLAPPED) -> BOOL;
908 pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR,
909 nTimeOut: DWORD) -> BOOL;
910 pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE,
911 lpMode: LPDWORD,
912 lpMaxCollectionCount: LPDWORD,
913 lpCollectDataTimeout: LPDWORD)
914 -> BOOL;
915 pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
916 bManualReset: BOOL,
917 bInitialState: BOOL,
918 lpName: LPCWSTR) -> HANDLE;
919 pub fn GetOverlappedResult(hFile: HANDLE,
920 lpOverlapped: LPOVERLAPPED,
921 lpNumberOfBytesTransferred: LPDWORD,
922 bWait: BOOL) -> BOOL;
923 pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700924
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700925 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
926 pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET;
927 pub fn connect(socket: SOCKET, address: *const sockaddr,
928 len: c_int) -> c_int;
929 pub fn bind(socket: SOCKET, address: *const sockaddr,
930 address_len: c_int) -> c_int;
931 pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
932 pub fn accept(socket: SOCKET, address: *mut sockaddr,
933 address_len: *mut c_int) -> SOCKET;
934 pub fn getpeername(socket: SOCKET, address: *mut sockaddr,
935 address_len: *mut c_int) -> c_int;
936 pub fn getsockname(socket: SOCKET, address: *mut sockaddr,
937 address_len: *mut c_int) -> c_int;
938 pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int,
939 value: *const c_char,
940 option_len: c_int) -> c_int;
941 pub fn closesocket(socket: SOCKET) -> c_int;
942 pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int,
943 flags: c_int) -> c_int;
944 pub fn send(socket: SOCKET, buf: *const c_char, len: c_int,
945 flags: c_int) -> c_int;
946 pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int,
947 flags: c_int, addr: *mut sockaddr,
948 addrlen: *mut c_int) -> c_int;
949 pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int,
950 flags: c_int, addr: *const sockaddr,
951 addrlen: c_int) -> c_int;
952 pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
953}