src/win32/libc_interface.h

changeset 3776
4372bb2cc50f
child 4193
0f6072a0ffa4
equal deleted inserted replaced
3775:185cc5cacd3c 3776:4372bb2cc50f
1 /*
2 * libc_interface.h
3 */
4
5 #ifndef _LIBC_INTERFACE_H_
6 #define _LIBC_INTERFACE_H_
7 #include <winsock.h>
8 #include <errno.h>
9 #include "libc_internal.h"
10
11 /* sys/socket.h */
12 extern int wgaim_socket(int namespace, int style, int protocol);
13 #define socket( namespace, style, protocol ) \
14 wgaim_socket( ## namespace ##, ## style ##, ## protocol ## )
15
16 extern int wgaim_connect(int socket, struct sockaddr *addr, u_long length);
17 #define connect( socket, addr, length ) \
18 wgaim_connect( ## socket ##, ## addr ##, ## length ## )
19
20 extern int wgaim_getsockopt(int socket, int level, int optname, void *optval, unsigned int *optlenptr);
21 #define getsockopt( args... ) \
22 wgaim_getsockopt( ## args )
23
24 /* sys/ioctl.h */
25 extern int wgaim_ioctl(int fd, int command, void* opt);
26 #define ioctl( fd, command, val ) \
27 wgaim_ioctl( ## fd ##, ## command ##, ## val ## )
28
29 /* fcntl.h */
30 extern int wgaim_fcntl(int socket, int command, int val);
31 #define fcntl( fd, command, val ) \
32 wgaim_fcntl( ## fd ##, ## command ##, ## val ## )
33
34 #define open( args... ) _open( ## args )
35
36 /* arpa/inet.h */
37 extern int wgaim_inet_aton(const char *name, struct in_addr *addr);
38 #define inet_aton( name, addr ) \
39 wgaim_inet_aton( ## name ##, ## addr ## )
40
41 /* netdb.h */
42 extern struct hostent* wgaim_gethostbyname(const char *name);
43 #define gethostbyname( name ) \
44 wgaim_gethostbyname( ## name ## )
45
46 /* string.h */
47 extern char* wgaim_strerror( int errornum );
48 #define hstrerror( herror ) \
49 wgaim_strerror( errno )
50 #define strerror( errornum ) \
51 wgaim_strerror( ## errornum ## )
52
53 #define bzero( dest, size ) memset( ## dest ##, 0, ## size ## )
54
55 /* unistd.h */
56 extern int wgaim_read(int fd, void *buf, unsigned int size);
57 #define read( fd, buf, buflen ) \
58 wgaim_read( ## fd ##, ## buf ##, ## buflen ## )
59
60 extern int wgaim_write(int fd, const void *buf, unsigned int size);
61 #define write( socket, buf, buflen ) \
62 wgaim_write( ## socket ##, ## buf ##, ## buflen ## )
63
64 extern int wgaim_close(int fd);
65 #define close( fd ) \
66 wgaim_close( ## fd ## )
67
68 #define sleep(x) Sleep((x)*1000)
69
70 /* sys/time.h */
71 extern int wgaim_gettimeofday(struct timeval *p, struct timezone *z);
72 #define gettimeofday( timeval, timezone ) \
73 wgaim_gettimeofday( ## timeval ##, ## timezone ## )
74
75 /* stdio.h */
76 #define snprintf _snprintf
77 #define vsnprintf _vsnprintf
78
79 /* sys/stat.h */
80 #define mkdir(a,b) _mkdir((a))
81
82 #endif /* _LIBC_INTERFACE_H_ */

mercurial