Merged pidgin/main into default
[pidgin-git.git] / libpurple / win32 / libc_interface.h
blob011d178d519600c4afa47bf692253aad8cee2791
1 /*
2 * purple
4 * File: libc_interface.h
6 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
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.
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.
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
23 #ifndef _LIBC_INTERFACE_H_
24 #define _LIBC_INTERFACE_H_
26 #include <config.h>
28 #include <winsock2.h>
29 #include <ws2tcpip.h>
30 #include <io.h>
31 #include <errno.h>
32 #include "libc_internal.h"
33 #include <glib.h>
34 #include "glibcompat.h"
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
40 #ifdef _MSC_VER
41 #define S_IRUSR S_IREAD
42 #define S_IWUSR S_IWRITE
43 #define S_IXUSR S_IEXEC
45 #define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
47 #define F_OK 0
48 #endif
50 /* sys/socket.h */
51 #define socket( domain, style, protocol ) \
52 wpurple_socket( domain, style, protocol )
54 #define connect( socket, addr, length ) \
55 wpurple_connect( socket, addr, length )
57 #define getsockopt( socket, level, optname, optval, optlenptr ) \
58 wpurple_getsockopt( socket, level, optname, optval, optlenptr )
60 #define setsockopt( socket, level, optname, optval, optlen ) \
61 wpurple_setsockopt( socket, level, optname, optval, optlen )
63 #define getsockname( socket, addr, lenptr ) \
64 wpurple_getsockname( socket, addr, lenptr )
66 #define bind( socket, addr, length ) \
67 wpurple_bind( socket, addr, length )
69 #define listen( socket, n ) \
70 wpurple_listen( socket, n )
72 #define sendto(socket, buf, len, flags, to, tolen) \
73 wpurple_sendto(socket, buf, len, flags, to, tolen)
75 #define recv(fd, buf, len, flags) \
76 wpurple_recv(fd, buf, len, flags)
78 #define send(socket, buf, buflen, flags) \
79 wpurple_send(socket, buf, buflen, flags)
81 /* sys/ioctl.h */
82 #define ioctl( fd, command, val ) \
83 wpurple_ioctl( fd, command, val )
85 /* fcntl.h */
86 #define fcntl( fd, command, ... ) \
87 wpurple_fcntl( fd, command, ##__VA_ARGS__ )
89 /* arpa/inet.h */
90 #define inet_aton( name, addr ) \
91 wpurple_inet_aton( name, addr )
93 #define inet_ntop( af, src, dst, cnt ) \
94 wpurple_inet_ntop( af, src, dst, cnt )
96 #define inet_pton( af, src, dst ) \
97 wpurple_inet_pton( af, src, dst )
99 /* netdb.h */
100 #define gethostbyname( name ) \
101 wpurple_gethostbyname( name )
103 /* netinet/in.h */
104 #define ntohl( netlong ) \
105 (unsigned int)ntohl( netlong )
107 /* string.h */
108 #define hstrerror( herror ) \
109 wpurple_strerror( errno )
110 #define strerror( errornum ) \
111 wpurple_strerror( errornum )
112 #define g_strerror( errornum ) \
113 wpurple_strerror( errornum )
115 /* unistd.h */
116 #define read( fd, buf, buflen ) \
117 wpurple_read( fd, buf, buflen )
119 #define write( socket, buf, buflen ) \
120 wpurple_write( socket, buf, buflen )
122 #define close( fd ) \
123 wpurple_close( fd )
125 #ifndef sleep
126 #define sleep(x) Sleep((x)*1000)
127 #endif
129 #define gethostname( name, size ) \
130 wpurple_gethostname( name, size )
132 #define fsync(fd) _commit(fd)
134 /* sys/time.h */
135 #define gettimeofday( timeval, timezone ) \
136 wpurple_gettimeofday( timeval, timezone )
138 /* stdio.h */
139 #if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3 || \
140 !defined(IS_WIN32_CROSS_COMPILED)
141 # undef snprintf
142 # define snprintf _snprintf
143 # undef vsnprintf
144 # define vsnprintf _vsnprintf
145 #endif
147 #define rename( oldname, newname ) \
148 g_rename( oldname, newname )
150 /* sys/stat.h */
151 #define fchmod(a,b)
153 /* time.h */
154 /* XXX: it may be also defined by pthread.h */
155 #undef localtime_r
156 #define localtime_r( time, resultp ) \
157 wpurple_localtime_r( time, resultp )
159 #ifdef __cplusplus
161 #endif /* __cplusplus */
163 #endif /* _LIBC_INTERFACE_H_ */