# HG changeset patch # User Herman Bloggs # Date 1076615658 0 # Node ID 5e7ffea3f76a7bf6af01b15ff7761d6d5a477d21 # Parent 217643616a74076a50deb42d0a63e9e4f4dda1e3 [gaim-migrate @ 8967] Now using winsock2.h, included in libc_interface.h. Some more functions added to libc_interface.c committer: Tailor Script diff -r 217643616a74 -r 5e7ffea3f76a src/protocols/icq/icq.h --- 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 and * Bill Soudan @@ -34,7 +34,7 @@ #include #include #else -#include +#include "libc_interface.h" #endif /* _WIN32 */ #ifdef __BEOS__ diff -r 217643616a74 -r 5e7ffea3f76a src/protocols/icq/socketmanager.h --- 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 and * Bill Soudan @@ -34,7 +34,7 @@ #ifndef _WIN32 #include #else -#include +#include "libc_interface.h" #endif #include "icq.h" diff -r 217643616a74 -r 5e7ffea3f76a src/protocols/icq/tcplink.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 and * Bill Soudan @@ -29,11 +29,11 @@ #include #endif -#ifdef _WIN32 -#include -#else +#ifndef _WIN32 #include #include +#else +#include "libc_interface.h" #endif #include "icq.h" diff -r 217643616a74 -r 5e7ffea3f76a src/protocols/icq/util.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 and * Bill Soudan @@ -31,10 +31,10 @@ #include -#ifdef _WIN32 -#include +#ifndef _WIN32 +#include #else -#include +#include "libc_interface.h" #endif #include "icqtypes.h" diff -r 217643616a74 -r 5e7ffea3f76a src/protocols/oscar/aim.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 #include #else -#include +#include "libc_interface.h" #endif #ifdef __cplusplus diff -r 217643616a74 -r 5e7ffea3f76a src/win32/libc_interface.c --- 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 +#include +#include #include #include #include @@ -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) { diff -r 217643616a74 -r 5e7ffea3f76a src/win32/libc_interface.h --- 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 +#include +#include #include #include #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 ) \ diff -r 217643616a74 -r 5e7ffea3f76a src/win32/win32dep.h --- a/src/win32/win32dep.h Thu Feb 12 19:17:54 2004 +0000 +++ b/src/win32/win32dep.h Thu Feb 12 19:54:18 2004 +0000 @@ -22,7 +22,7 @@ */ #ifndef _WIN32DEP_H_ #define _WIN32DEP_H_ -#include +#include #include #include #include