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