Mercurial > pidgin
diff 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 |
line wrap: on
line diff
--- a/src/win32/libc_interface.c Thu Feb 12 19:17:54 2004 +0000 +++ b/src/win32/libc_interface.c Thu Feb 12 19:54:18 2004 +0000 @@ -22,7 +22,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -#include <winsock.h> +#include <winsock2.h> +#include <ws2tcpip.h> #include <io.h> #include <stdlib.h> #include <stdio.h> @@ -91,16 +92,44 @@ return 0; } -int wgaim_getsockopt(int socket, int level, int optname, void *optval, unsigned int *optlenptr) { - int ret; +int wgaim_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) { + if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} - ret = getsockopt( socket, level, optname, optval, optlenptr ); - if( ret == SOCKET_ERROR ) { +int wgaim_setsockopt(int socket, int level, int optname, void *optval, socklen_t optlen) { + if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) { errno = WSAGetLastError(); return -1; } + return 0; +} - return 0; +int wgaim_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) { + if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length) { + if(bind(socket, addr, length) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + +int wgaim_listen(int socket, unsigned int n) { + if(listen(socket, n) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; } /* fcntl.h */ @@ -289,6 +318,14 @@ return close(fd); } +int wgaim_gethostname(char *name, size_t size) { + if(gethostname(name, size) == SOCKET_ERROR) { + errno = WSAGetLastError(); + return -1; + } + return 0; +} + /* sys/time.h */ int wgaim_gettimeofday(struct timeval *p, struct timezone *z) {
