1 /*
2  * purple
3  *
4  * File: libc_interface.h
5  *
6  * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
21  *
22  */
23 #ifndef _LIBC_INTERFACE_H_
24 #define _LIBC_INTERFACE_H_
25 #include <winsock2.h>
26 #include <ws2tcpip.h>
27 #include <io.h>
28 #include <errno.h>
29 #include "libc_internal.h"
30 #include <glib.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35 
36 #ifdef _MSC_VER
37 #define S_IRUSR S_IREAD
38 #define S_IWUSR S_IWRITE
39 #define S_IXUSR S_IEXEC
40 
41 #define S_ISDIR(m)	 (((m)&S_IFDIR)==S_IFDIR)
42 
43 #define F_OK 0
44 #endif
45 
46 /* sys/socket.h */
47 #define socket( domain, style, protocol ) \
48 wpurple_socket( domain, style, protocol )
49 
50 #define connect( socket, addr, length ) \
51 wpurple_connect( socket, addr, length )
52 
53 #define getsockopt( socket, level, optname, optval, optlenptr ) \
54 wpurple_getsockopt( socket, level, optname, optval, optlenptr )
55 
56 #define setsockopt( socket, level, optname, optval, optlen ) \
57 wpurple_setsockopt( socket, level, optname, optval, optlen )
58 
59 #define getsockname( socket, addr, lenptr ) \
60 wpurple_getsockname( socket, addr, lenptr )
61 
62 #define bind( socket, addr, length ) \
63 wpurple_bind( socket, addr, length )
64 
65 #define listen( socket, n ) \
66 wpurple_listen( socket, n )
67 
68 #define sendto(socket, buf, len, flags, to, tolen) \
69 wpurple_sendto(socket, buf, len, flags, to, tolen)
70 
71 #define recv(fd, buf, len, flags) \
72 wpurple_recv(fd, buf, len, flags)
73 
74 #define send(socket, buf, buflen, flags) \
75 wpurple_send(socket, buf, buflen, flags)
76 
77 /* sys/ioctl.h */
78 #define ioctl( fd, command, val ) \
79 wpurple_ioctl( fd, command, val )
80 
81 /* fcntl.h */
82 #define fcntl( fd, command, ... ) \
83 wpurple_fcntl( fd, command, ##__VA_ARGS__ )
84 
85 /* arpa/inet.h */
86 #define inet_aton( name, addr ) \
87 wpurple_inet_aton( name, addr )
88 
89 #define inet_ntop( af, src, dst, cnt ) \
90 wpurple_inet_ntop( af, src, dst, cnt )
91 
92 #define inet_pton( af, src, dst ) \
93 wpurple_inet_pton( af, src, dst )
94 
95 /* netdb.h */
96 #define gethostbyname( name ) \
97 wpurple_gethostbyname( name )
98 
99 /* netinet/in.h */
100 #define ntohl( netlong ) \
101 (unsigned int)ntohl( netlong )
102 
103 /* string.h */
104 #define hstrerror( herror ) \
105 wpurple_strerror( errno )
106 #define strerror( errornum ) \
107 wpurple_strerror( errornum )
108 #define g_strerror( errornum ) \
109 wpurple_strerror( errornum )
110 
111 /* unistd.h */
112 #define read( fd, buf, buflen ) \
113 wpurple_read( fd, buf, buflen )
114 
115 #define write( socket, buf, buflen ) \
116 wpurple_write( socket, buf, buflen )
117 
118 #define close( fd ) \
119 wpurple_close( fd )
120 
121 #ifndef sleep
122 #define sleep(x) Sleep((x)*1000)
123 #endif
124 
125 #define gethostname( name, size ) \
126 wpurple_gethostname( name, size )
127 
128 #define fsync(fd) _commit(fd)
129 
130 /* sys/time.h */
131 #define gettimeofday( timeval, timezone ) \
132 wpurple_gettimeofday( timeval, timezone )
133 
134 /* stdio.h */
135 #undef snprintf
136 #define snprintf _snprintf
137 #undef vsnprintf
138 #define vsnprintf _vsnprintf
139 
140 #define rename( oldname, newname ) \
141 wpurple_rename( oldname, newname )
142 
143 /* sys/stat.h */
144 #define fchmod(a,b)
145 
146 /* time.h */
147 #define localtime_r( time, resultp ) \
148 wpurple_localtime_r( time, resultp )
149 
150 #ifdef __cplusplus
151 }
152 #endif /* __cplusplus */
153 
154 #endif /* _LIBC_INTERFACE_H_ */
155