# HG changeset patch # User tomkiewicz@cpw.pidgin.im # Date 1319201310 0 # Node ID e2ff2ac0e022a997ae90df67c13088cac23b1263 # Parent 8c71a7e95f16280981cee19ae7e5922c29cb94fd Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343 diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/common.c --- a/libpurple/protocols/gg/lib/common.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/common.c Fri Oct 21 12:48:30 2011 +0000 @@ -24,13 +24,8 @@ * * \brief Funkcje wykorzystywane przez różne moduły biblioteki */ -#ifndef _WIN32 -# include -# include -# include -# include -# include -#endif +#include "compat.h" +#include #ifdef sun # include #endif diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/compat.h --- a/libpurple/protocols/gg/lib/compat.h Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/compat.h Fri Oct 21 12:48:30 2011 +0000 @@ -28,6 +28,21 @@ #ifndef __COMPAT_H #define __COMPAT_H +#ifdef _WIN32 +# include +# include +# define EINPROGRESS WSAEINPROGRESS +# define ETIMEDOUT WSAETIMEDOUT +# define ENOTCONN WSAENOTCONN +# define ECONNRESET WSAECONNRESET +#else +# include +# include +# include +# include +# include +#endif + #ifdef sun # define INADDR_NONE ((in_addr_t) 0xffffffff) #endif diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/dcc.c --- a/libpurple/protocols/gg/lib/dcc.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/dcc.c Fri Oct 21 12:48:30 2011 +0000 @@ -26,14 +26,9 @@ * \brief Obsługa połączeń bezpośrednich do wersji Gadu-Gadu 6.x */ +#include "compat.h" #include #include -#ifndef _WIN32 -# include -# include -# include -# include -#endif #ifdef sun # include #endif diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/dcc7.c --- a/libpurple/protocols/gg/lib/dcc7.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/dcc7.c Fri Oct 21 12:48:30 2011 +0000 @@ -31,12 +31,6 @@ #include #include -#ifndef _WIN32 -# include -# include -# include -# include -#endif #ifdef sun # include #endif diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/events.c --- a/libpurple/protocols/gg/lib/events.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/events.c Fri Oct 21 12:48:30 2011 +0000 @@ -28,12 +28,6 @@ */ #include -#ifndef _WIN32 -# include -# include -# include -# include -#endif #include #include "compat.h" diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/handlers.c --- a/libpurple/protocols/gg/lib/handlers.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/handlers.c Fri Oct 21 12:48:30 2011 +0000 @@ -27,11 +27,6 @@ */ #include -#ifndef _WIN32 -# include -# include -# include -#endif #include #ifdef sun # include @@ -48,9 +43,6 @@ #include "deflate.h" #include -#ifndef _WIN32 -# include -#endif #include #include #include diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/http.c --- a/libpurple/protocols/gg/lib/http.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/http.c Fri Oct 21 12:48:30 2011 +0000 @@ -25,11 +25,6 @@ */ #include -#ifndef _WIN32 -# include -# include -# include -#endif #include "compat.h" #include "libgadu.h" @@ -37,9 +32,6 @@ #include #include -#ifndef _WIN32 -# include -#endif #include #include #include diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/libgadu-config.h --- a/libpurple/protocols/gg/lib/libgadu-config.h Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/libgadu-config.h Fri Oct 21 12:48:30 2011 +0000 @@ -5,13 +5,33 @@ #ifndef __GG_LIBGADU_CONFIG_H #define __GG_LIBGADU_CONFIG_H -#define GG_LIBGADU_VERSION "1.11.0" - /* Defined if libgadu was compiled for bigendian machine. */ #undef __GG_LIBGADU_BIGENDIAN #ifdef WORDS_BIGENDIAN -#define __GG_LIBGADU_BIGENDIAN -#endif /* WORDS_BIGENDIAN */ +# define __GG_LIBGADU_BIGENDIAN +#endif + +/* Defined if this machine has gethostbyname_r(). */ +#undef GG_CONFIG_HAVE_GETHOSTBYNAME_R + +/* Defined if this machine has _exit(). */ +#define GG_CONFIG_HAVE__EXIT + +/* Defined if libgadu was compiled and linked with fork support. */ +#undef GG_CONFIG_HAVE_FORK +#ifndef _WIN32 +# define GG_CONFIG_HAVE_FORK +#endif + +/* Defined if libgadu was compiled and linked with pthread support. */ +/* We don't like pthreads. */ +#undef __GG_LIBGADU_HAVE_PTHREAD + +/* Defined if this machine has C99-compiliant vsnprintf(). */ +#undef __GG_LIBGADU_HAVE_C99_VSNPRINTF +#ifndef _WIN32 +# define __GG_LIBGADU_HAVE_C99_VSNPRINTF +#endif /* Defined if this machine has va_copy(). */ #define __GG_LIBGADU_HAVE_VA_COPY @@ -22,40 +42,29 @@ /* Defined if this machine supports long long. */ #undef __GG_LIBGADU_HAVE_LONG_LONG #ifdef HAVE_LONG_LONG -#define __GG_LIBGADU_HAVE_LONG_LONG -#endif /* HAVE_LONG_LONG */ +# define __GG_LIBGADU_HAVE_LONG_LONG +#endif -/* Defined if libgadu was compiled and linked with pthread support. */ -/* We don't like pthreads. */ -#undef __GG_LIBGADU_HAVE_PTHREAD - -/* Defined if libgadu was compiled and linked with GnuTLS encryption support. */ +/* Defined if libgadu was compiled and linked with GnuTLS support. */ +#undef GG_CONFIG_HAVE_GNUTLS #ifdef HAVE_GNUTLS # define GG_CONFIG_HAVE_GNUTLS -#else -# undef GG_CONFIG_HAVE_GNUTLS #endif -/* Defined if libgadu was compiled and linked with TLS support. */ +/* Defined if libgadu was compiled and linked with OpenSSL support. */ /* Always undefined in Purple. */ #undef __GG_LIBGADU_HAVE_OPENSSL -/* Include file containing uintXX_t declarations. */ +/* Defined if libgadu was compiled and linked with zlib support. */ +#undef GG_CONFIG_HAVE_ZLIB + +/* Defined if uintX_t types are defined in . */ +#undef GG_CONFIG_HAVE_STDINT_H #if HAVE_STDINT_H -#include +# define GG_CONFIG_HAVE_STDINT_H #endif -/* Defined if this machine has C99-compiliant vsnprintf(). */ -#ifndef _WIN32 -#define __GG_LIBGADU_HAVE_C99_VSNPRINTF -#else -#undef __GG_LIBGADU_HAVE_C99_VSNPRINTF -#endif #define vnsprintf g_vnsprintf -#ifdef _WIN32 -#define random (long) rand #endif - -#endif /* __GG_LIBGADU_CONFIG_H */ diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/libgadu.c --- a/libpurple/protocols/gg/lib/libgadu.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/libgadu.c Fri Oct 21 12:48:30 2011 +0000 @@ -29,16 +29,6 @@ */ #include -#ifdef _WIN32 -# include -# include -# include -# define SHUT_RDWR SD_BOTH -#else -# include -# include -# include -#endif #ifdef sun # include #endif @@ -54,10 +44,7 @@ #include "message.h" #include "deflate.h" -#ifndef _WIN32 -# include /* on Win32 this is included above */ -# include -#endif +#include #include #include #include @@ -73,6 +60,8 @@ # include #endif +#define GG_LIBGADU_VERSION "1.11.0" + /** * Port gniazda nasłuchującego dla połączeń bezpośrednich. * @@ -1119,7 +1108,6 @@ sess->resolver_cleanup(&sess->resolver, 1); if (sess->fd != -1) { - shutdown(sess->fd, SHUT_RDWR); close(sess->fd); sess->fd = -1; } diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/libgadu.h --- a/libpurple/protocols/gg/lib/libgadu.h Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/libgadu.h Fri Oct 21 12:48:30 2011 +0000 @@ -33,7 +33,7 @@ #ifndef __GG_LIBGADU_H #define __GG_LIBGADU_H -#ifdef _WIN32 +#if defined(__cplusplus) || defined(_WIN32) #pragma pack(push, 1) #endif @@ -53,6 +53,12 @@ /* Defined if this machine has gethostbyname_r(). */ #undef GG_CONFIG_HAVE_GETHOSTBYNAME_R +/* Defined if this machine has _exit(). */ +#undef GG_CONFIG_HAVE__EXIT + +/* Defined if libgadu was compiled and linked with fork support. */ +#undef GG_CONFIG_HAVE_FORK + /* Defined if libgadu was compiled and linked with pthread support. */ #undef GG_CONFIG_HAVE_PTHREAD @@ -95,11 +101,7 @@ /* Defined if uintX_t types are defined in . */ #undef GG_CONFIG_HAVE_SYS_TYPES_H -#ifdef _WIN32 -# undef GG_CONFIG_HAVE_FORK -#else -# define GG_CONFIG_HAVE_FORK -#endif +#include "libgadu-config.h" #ifdef GG_CONFIG_HAVE_OPENSSL #include @@ -121,24 +123,12 @@ # include # else -#ifndef __AC_STDINT_H -#define __AC_STDINT_H - /* ISO C 9X: 7.18 Integer types */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; -#if !defined(__CYGWIN__) && !defined(__SunOS) && !defined(_INCLUDE_HPUX_SOURCE) -#define __int8_t_defined -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -#endif - -#endif /* __AC_STDINT_H */ - # endif # endif # endif @@ -2302,17 +2292,15 @@ #define GG_DCC7_TIMEOUT_FILE_ACK 300 /* 5 minut */ #define GG_DCC7_TIMEOUT_VOICE_ACK 300 /* 5 minut */ -#ifdef _WIN32 -#pragma pack(pop) -#endif - #ifdef __cplusplus } #endif -#endif /* __GG_LIBGADU_H */ +#if defined(__cplusplus) || defined(_WIN32) +#pragma pack(pop) +#endif -#include "libgadu-config.h" +#endif /* __GG_LIBGADU_H */ /* * Local variables: diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/pubdir.c --- a/libpurple/protocols/gg/lib/pubdir.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/pubdir.c Fri Oct 21 12:48:30 2011 +0000 @@ -193,7 +193,7 @@ return NULL; } - __pwd = gg_saprintf("%ld", random()); + __pwd = gg_saprintf("%d", rand()); __fmpwd = gg_urlencode(password); __tokenid = gg_urlencode(tokenid); __tokenval = gg_urlencode(tokenval); diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/resolver.c --- a/libpurple/protocols/gg/lib/resolver.c Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/resolver.c Fri Oct 21 12:48:30 2011 +0000 @@ -26,25 +26,21 @@ * \brief Funkcje rozwiązywania nazw */ -#ifndef _WIN32 -# include -# include -#endif #include #include #include #include -#ifndef _WIN32 -# include -# include -# include -#endif #include "libgadu.h" #include "resolver.h" #include "compat.h" #include "session.h" +#ifdef GG_CONFIG_HAVE_FORK +#include +#include +#endif + /** Sposób rozwiązywania nazw serwerów */ static gg_resolver_t gg_global_resolver_type = GG_RESOLVER_DEFAULT; @@ -249,6 +245,7 @@ } #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_HAVE_FORK) + /** * \internal Rozwiązuje nazwę i zapisuje wynik do podanego desktyptora. * @@ -286,7 +283,8 @@ return res; } -#endif + +#endif /* GG_CONFIG_HAVE_PTHREAD || GG_CONFIG_HAVE_FORK */ /** * \internal Odpowiednik \c gethostbyname zapewniający współbieżność. @@ -311,6 +309,8 @@ return result; } +#ifdef GG_CONFIG_HAVE_FORK + /** * \internal Struktura przekazywana do wątku rozwiązującego nazwę. */ @@ -318,7 +318,6 @@ int pid; /*< Identyfikator procesu */ }; -#ifdef GG_CONFIG_HAVE_FORK /** * \internal Rozwiązuje nazwę serwera w osobnym procesie. * @@ -370,12 +369,17 @@ } if (data->pid == 0) { + int status; + close(pipes[0]); - if (gg_resolver_run(pipes[1], hostname) == -1) - _exit(1); - else - _exit(0); + status = (gg_resolver_run(pipes[1], hostname) == -1) ? 1 : 0; + +#ifdef GG_CONFIG_HAVE__EXIT + _exit(status); +#else + exit(status); +#endif } close(pipes[1]); @@ -424,7 +428,8 @@ free(data); } -#endif + +#endif /* GG_CONFIG_HAVE_FORK */ #ifdef GG_CONFIG_HAVE_PTHREAD @@ -594,10 +599,10 @@ return 0; } -#if !defined(GG_CONFIG_HAVE_PTHREAD) || !defined(GG_CONFIG_PTHREAD_DEFAULT) +#if defined(GG_CONFIG_HAVE_PTHREAD) && defined(GG_CONFIG_PTHREAD_DEFAULT) + type = GG_RESOLVER_PTHREAD; +#elif defined(GG_CONFIG_HAVE_FORK) type = GG_RESOLVER_FORK; -#else - type = GG_RESOLVER_PTHREAD; #endif } @@ -705,10 +710,10 @@ return 0; } -#if !defined(GG_CONFIG_HAVE_PTHREAD) || !defined(GG_CONFIG_PTHREAD_DEFAULT) +#if defined(GG_CONFIG_HAVE_PTHREAD) && defined(GG_CONFIG_PTHREAD_DEFAULT) + type = GG_RESOLVER_PTHREAD; +#elif defined(GG_CONFIG_HAVE_FORK) type = GG_RESOLVER_FORK; -#else - type = GG_RESOLVER_PTHREAD; #endif } diff -r 8c71a7e95f16 -r e2ff2ac0e022 libpurple/protocols/gg/lib/resolver.h --- a/libpurple/protocols/gg/lib/resolver.h Tue Oct 18 21:44:25 2011 +0000 +++ b/libpurple/protocols/gg/lib/resolver.h Fri Oct 21 12:48:30 2011 +0000 @@ -19,9 +19,7 @@ #ifndef LIBGADU_RESOLVER_H #define LIBGADU_RESOLVER_H -#ifndef _WIN32 -# include -#endif +#include "compat.h" int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *count, int pthread);