Mercurial > pidgin
changeset 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 | 217643616a74 |
children | 91c6629b1ee8 |
files | src/protocols/icq/icq.h src/protocols/icq/socketmanager.h src/protocols/icq/tcplink.h src/protocols/icq/util.h src/protocols/oscar/aim.h src/win32/libc_interface.c src/win32/libc_interface.h src/win32/win32dep.h |
diffstat | 8 files changed, 79 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/icq/icq.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/protocols/icq/icq.h Thu Feb 12 19:54:18 2004 +0000 @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* - * $Id: icq.h 2096 2001-07-31 01:00:39Z warmenhoven $ + * $Id: icq.h 8967 2004-02-12 19:54:18Z hermanator $ * * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and * Bill Soudan <soudan@kde.org> @@ -34,7 +34,7 @@ #include <sys/types.h> #include <unistd.h> #else -#include <winsock.h> +#include "libc_interface.h" #endif /* _WIN32 */ #ifdef __BEOS__
--- a/src/protocols/icq/socketmanager.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/protocols/icq/socketmanager.h Thu Feb 12 19:54:18 2004 +0000 @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* - * $Id: socketmanager.h 2405 2001-09-29 02:08:00Z warmenhoven $ + * $Id: socketmanager.h 8967 2004-02-12 19:54:18Z hermanator $ * * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and * Bill Soudan <soudan@kde.org> @@ -34,7 +34,7 @@ #ifndef _WIN32 #include <sys/socket.h> #else -#include <winsock.h> +#include "libc_interface.h" #endif #include "icq.h"
--- a/src/protocols/icq/tcplink.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/protocols/icq/tcplink.h Thu Feb 12 19:54:18 2004 +0000 @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* - * $Id: tcplink.h 2096 2001-07-31 01:00:39Z warmenhoven $ + * $Id: tcplink.h 8967 2004-02-12 19:54:18Z hermanator $ * * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and * Bill Soudan <soudan@kde.org> @@ -29,11 +29,11 @@ #include <config.h> #endif -#ifdef _WIN32 -#include <winsock.h> -#else +#ifndef _WIN32 #include <sys/socket.h> #include <netinet/in.h> +#else +#include "libc_interface.h" #endif #include "icq.h"
--- a/src/protocols/icq/util.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/protocols/icq/util.h Thu Feb 12 19:54:18 2004 +0000 @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* - * $Id: util.h 2096 2001-07-31 01:00:39Z warmenhoven $ + * $Id: util.h 8967 2004-02-12 19:54:18Z hermanator $ * * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and * Bill Soudan <soudan@kde.org> @@ -31,10 +31,10 @@ #include <sys/types.h> -#ifdef _WIN32 -#include <winsock.h> +#ifndef _WIN32 +#include <netinet/in.h> #else -#include <netinet/in.h> +#include "libc_interface.h" #endif #include "icqtypes.h"
--- a/src/protocols/oscar/aim.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/protocols/oscar/aim.h Thu Feb 12 19:54:18 2004 +0000 @@ -32,7 +32,7 @@ #include <netinet/in.h> #include <sys/socket.h> #else -#include <winsock.h> +#include "libc_interface.h" #endif #ifdef __cplusplus
--- 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) {
--- a/src/win32/libc_interface.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/win32/libc_interface.h Thu Feb 12 19:54:18 2004 +0000 @@ -22,7 +22,8 @@ */ #ifndef _LIBC_INTERFACE_H_ #define _LIBC_INTERFACE_H_ -#include <winsock.h> +#include <winsock2.h> +#include <ws2tcpip.h> #include <io.h> #include <errno.h> #include "libc_internal.h" @@ -40,6 +41,22 @@ #define getsockopt( args... ) \ wgaim_getsockopt( args ) +extern int wgaim_setsockopt(int socket, int level, int optname, void *optval, unsigned int *optlenptr); +#define setsockopt( args... ) \ +wgaim_setsockopt( args ) + +extern int wgaim_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr); +#define getsockname( socket, addr, lenptr ) \ +wgaim_getsockname( socket, addr, lenptr ) + +extern int wgaim_bind(int socket, struct sockaddr *addr, socklen_t length); +#define bind( socket, addr, length ) \ +wgaim_bind( socket, addr, length ) + +extern int wgaim_listen(int socket, unsigned int n); +#define listen( socket, n ) \ +wgaim_listen( socket, n ) + /* sys/ioctl.h */ extern int wgaim_ioctl(int fd, int command, void* opt); #define ioctl( fd, command, val ) \ @@ -94,6 +111,10 @@ #define sleep(x) Sleep((x)*1000) +extern int wgaim_gethostname(char *name, size_t size); +#define gethostname( name, size ) \ +wgaim_gethostname( name, size ) + /* sys/time.h */ extern int wgaim_gettimeofday(struct timeval *p, struct timezone *z); #define gettimeofday( timeval, timezone ) \