Mercurial > pidgin
comparison src/win32/libc_interface.c @ 8244:5e7ffea3f76a
[gaim-migrate @ 8967]
Now using winsock2.h, included in libc_interface.h. Some more functions added to libc_interface.c
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Thu, 12 Feb 2004 19:54:18 +0000 |
parents | 26b739bc9f1a |
children | 5e78d07f6b36 |
comparison
equal
deleted
inserted
replaced
8243:217643616a74 | 8244:5e7ffea3f76a |
---|---|
20 * You should have received a copy of the GNU General Public License | 20 * You should have received a copy of the GNU General Public License |
21 * along with this program; if not, write to the Free Software | 21 * along with this program; if not, write to the Free Software |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 * | 23 * |
24 */ | 24 */ |
25 #include <winsock.h> | 25 #include <winsock2.h> |
26 #include <ws2tcpip.h> | |
26 #include <io.h> | 27 #include <io.h> |
27 #include <stdlib.h> | 28 #include <stdlib.h> |
28 #include <stdio.h> | 29 #include <stdio.h> |
29 #include <errno.h> | 30 #include <errno.h> |
30 #include <sys/timeb.h> | 31 #include <sys/timeb.h> |
89 return -1; | 90 return -1; |
90 } | 91 } |
91 return 0; | 92 return 0; |
92 } | 93 } |
93 | 94 |
94 int wgaim_getsockopt(int socket, int level, int optname, void *optval, unsigned int *optlenptr) { | 95 int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { |
95 int ret; | 96 if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { |
96 | |
97 ret = getsockopt( socket, level, optname, optval, optlenptr ); | |
98 if( ret == SOCKET_ERROR ) { | |
99 errno = WSAGetLastError(); | 97 errno = WSAGetLastError(); |
100 return -1; | 98 return -1; |
101 } | 99 } |
102 | |
103 return 0; | 100 return 0; |
101 } | |
102 | |
103 int wgaim_setsockopt(int socket, int level, int optname, void *optval, socklen_t optlen) { | |
104 if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { | |
105 errno = WSAGetLastError(); | |
106 return -1; | |
107 } | |
108 return 0; | |
109 } | |
110 | |
111 int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { | |
112 if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { | |
113 errno = WSAGetLastError(); | |
114 return -1; | |
115 } | |
116 return 0; | |
117 } | |
118 | |
119 int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) { | |
120 if(bind(socket, addr, length) == SOCKET_ERROR) { | |
121 errno = WSAGetLastError(); | |
122 return -1; | |
123 } | |
124 return 0; | |
125 } | |
126 | |
127 int wgaim_listen(int socket, unsigned int n) { | |
128 if(listen(socket, n) == SOCKET_ERROR) { | |
129 errno = WSAGetLastError(); | |
130 return -1; | |
131 } | |
132 return 0; | |
104 } | 133 } |
105 | 134 |
106 /* fcntl.h */ | 135 /* fcntl.h */ |
107 /* This is not a full implementation of fcntl. Update as needed.. */ | 136 /* This is not a full implementation of fcntl. Update as needed.. */ |
108 int wgaim_fcntl(int socket, int command, int val) { | 137 int wgaim_fcntl(int socket, int command, int val) { |
285 else | 314 else |
286 return 0; | 315 return 0; |
287 } | 316 } |
288 else | 317 else |
289 return close(fd); | 318 return close(fd); |
319 } | |
320 | |
321 int wgaim_gethostname(char *name, size_t size) { | |
322 if(gethostname(name, size) == SOCKET_ERROR) { | |
323 errno = WSAGetLastError(); | |
324 return -1; | |
325 } | |
326 return 0; | |
290 } | 327 } |
291 | 328 |
292 /* sys/time.h */ | 329 /* sys/time.h */ |
293 | 330 |
294 int wgaim_gettimeofday(struct timeval *p, struct timezone *z) { | 331 int wgaim_gettimeofday(struct timeval *p, struct timezone *z) { |