/pidgin/main: e83a87761544: Gadu-Gadu: update internal libgadu t...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Feb 13 12:29:22 EST 2014


Changeset: e83a877615441d3916acc1d0d90ff4e152949c3b
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-02-13 18:29 +0100
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/e83a87761544

Description:

Gadu-Gadu: update internal libgadu to 1.12.0-rc2

diffstat:

 configure.ac                              |     7 +-
 libpurple/protocols/gg/Makefile.am        |    19 +-
 libpurple/protocols/gg/lib/common.c       |   286 ++-
 libpurple/protocols/gg/lib/compat.h       |    50 -
 libpurple/protocols/gg/lib/config.h       |    18 +-
 libpurple/protocols/gg/lib/dcc.c          |   221 +-
 libpurple/protocols/gg/lib/dcc7.c         |   130 +-
 libpurple/protocols/gg/lib/debug.c        |    37 +-
 libpurple/protocols/gg/lib/debug.h        |     2 -
 libpurple/protocols/gg/lib/encoding.c     |     8 +-
 libpurple/protocols/gg/lib/endian.c       |   110 +
 libpurple/protocols/gg/lib/events.c       |  2302 ++++++++++++++++--------
 libpurple/protocols/gg/lib/fileio.h       |    54 +
 libpurple/protocols/gg/lib/handlers.c     |  1141 ++++++++++-
 libpurple/protocols/gg/lib/http.c         |   105 +-
 libpurple/protocols/gg/lib/internal.h     |    94 +-
 libpurple/protocols/gg/lib/libgadu.c      |  2016 ++++++++++++++-------
 libpurple/protocols/gg/lib/libgadu.h      |   392 +++-
 libpurple/protocols/gg/lib/message.c      |   507 ++++-
 libpurple/protocols/gg/lib/message.h      |     8 +-
 libpurple/protocols/gg/lib/network.c      |   307 +++
 libpurple/protocols/gg/lib/network.h      |    95 +
 libpurple/protocols/gg/lib/obsolete.c     |     9 +-
 libpurple/protocols/gg/lib/packets.pb-c.c |  2370 +++++++++++++++++++++++++
 libpurple/protocols/gg/lib/packets.pb-c.h |   682 +++++++
 libpurple/protocols/gg/lib/protobuf-c.c   |  2673 +++++++++++++++++++++++++++++
 libpurple/protocols/gg/lib/protobuf-c.h   |   552 +++++
 libpurple/protocols/gg/lib/protobuf.c     |   153 +
 libpurple/protocols/gg/lib/protobuf.h     |    70 +
 libpurple/protocols/gg/lib/protocol.h     |    85 +
 libpurple/protocols/gg/lib/pubdir.c       |    23 +-
 libpurple/protocols/gg/lib/pubdir50.c     |    12 +-
 libpurple/protocols/gg/lib/resolver.c     |   350 +++-
 libpurple/protocols/gg/lib/resolver.h     |     5 +-
 libpurple/protocols/gg/lib/session.h      |     3 -
 libpurple/protocols/gg/lib/sha1.c         |   161 +-
 libpurple/protocols/gg/lib/strman.h       |    43 +
 libpurple/protocols/gg/lib/tvbuff.c       |   601 ++++++
 libpurple/protocols/gg/lib/tvbuff.h       |    59 +
 libpurple/protocols/gg/lib/tvbuilder.c    |   424 ++++
 libpurple/protocols/gg/lib/tvbuilder.h    |    50 +
 41 files changed, 13985 insertions(+), 2249 deletions(-)

diffs (truncated from 19536 to 300 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1177,14 +1177,14 @@ AC_ARG_WITH(gadu-includes, [AS_HELP_STRI
 AC_ARG_WITH(gadu-libs, [AS_HELP_STRING([--with-gadu-libs=DIR], [compile the Gadu-Gadu plugin against the libs in DIR])], [ac_gadu_libs="$withval"], [ac_gadu_libs="no"])
 GADU_CFLAGS=""
 GADU_LIBS=""
-GADU_LIBGADU_VERSION=1.11.2
+GADU_LIBGADU_MIN_VERSION=1.11.2
 if test -n "$with_gadu_includes" || test -n "$with_gadu_libs"; then
 	gadu_manual_check="yes"
 else
 	gadu_manual_check="no"
 fi
 if test "x$gadu_manual_check" = "xno"; then
-	PKG_CHECK_MODULES(GADU, [libgadu >= $GADU_LIBGADU_VERSION], [
+	PKG_CHECK_MODULES(GADU, [libgadu >= $GADU_LIBGADU_MIN_VERSION], [
 		gadu_includes="yes"
 		gadu_libs="yes"
 	], [
@@ -1253,7 +1253,7 @@ if test "x$gadu_libs" = "xyes" -a "x$gad
 		AC_MSG_RESULT(no)
 		echo
 		echo "Your supplied copy of libgadu is too old."
-		echo "Install version $GADU_LIBGADU_VERSION or newer."
+		echo "Install version $GADU_LIBGADU_MIN_VERSION or newer."
 		echo "Then rerun this ./configure"
 		echo
 		echo "Falling back to using our own copy of libgadu"
@@ -1283,7 +1283,6 @@ fi
 
 AC_SUBST(GADU_LIBS)
 AC_SUBST(GADU_CFLAGS)
-AC_SUBST(GADU_LIBGADU_VERSION)
 
 AC_ARG_ENABLE(distrib,,,enable_distrib=no)
 AM_CONDITIONAL(DISTRIB, test "x$enable_distrib" = "xyes")
diff --git a/libpurple/protocols/gg/Makefile.am b/libpurple/protocols/gg/Makefile.am
--- a/libpurple/protocols/gg/Makefile.am
+++ b/libpurple/protocols/gg/Makefile.am
@@ -12,7 +12,6 @@ EXTRA_DIST = \
 if USE_INTERNAL_LIBGADU
 INTGGSOURCES = \
 	lib/common.c \
-	lib/compat.h \
 	lib/config.h \
 	lib/dcc.c \
 	lib/dcc7.c \
@@ -22,7 +21,9 @@ INTGGSOURCES = \
 	lib/deflate.h \
 	lib/encoding.c \
 	lib/encoding.h \
+	lib/endian.c \
 	lib/events.c \
+	lib/fileio.h \
 	lib/handlers.c \
 	lib/http.c \
 	lib/internal.h \
@@ -30,14 +31,28 @@ INTGGSOURCES = \
 	lib/libgadu.h \
 	lib/message.c \
 	lib/message.h \
+	lib/network.c \
+	lib/network.h \
 	lib/obsolete.c \
+	lib/packets.pb-c.c \
+	lib/packets.pb-c.h \
+	lib/protobuf-c.c \
+	lib/protobuf-c.h \
+	lib/protobuf.c \
+	lib/protobuf.h \
 	lib/protocol.h \
 	lib/pubdir.c \
 	lib/pubdir50.c \
 	lib/resolver.c \
 	lib/resolver.h \
 	lib/session.h \
-	lib/sha1.c
+	lib/strman.h \
+	lib/sha1.c \
+	lib/tvbuff.c \
+	lib/tvbuff.h \
+	lib/tvbuilder.c \
+	lib/tvbuilder.h
+
 
 INTGG_CFLAGS = -I$(top_srcdir)/libpurple/protocols/gg/lib \
 	$(ZLIB_CFLAGS) \
diff --git a/libpurple/protocols/gg/lib/common.c b/libpurple/protocols/gg/lib/common.c
--- a/libpurple/protocols/gg/lib/common.c
+++ b/libpurple/protocols/gg/lib/common.c
@@ -1,4 +1,4 @@
-/* $Id: common.c 1101 2011-05-05 21:17:28Z wojtekka $ */
+/* $Id$ */
 
 /*
  *  (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka at irc.pl>
@@ -24,21 +24,34 @@
  *
  * \brief Funkcje wykorzystywane przez różne moduły biblioteki
  */
-#include "compat.h"
-#include <sys/types.h>
+
+#include "network.h"
+#include "strman.h"
 #ifdef sun
 #  include <sys/filio.h>
 #endif
 
 #include <errno.h>
-#include <fcntl.h>
 #include <stdarg.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
+#include <ctype.h>
+#include <time.h>
 
+#include "config.h"
 #include "libgadu.h"
+#include "internal.h"
+
+#ifndef GG_CONFIG_HAVE_VA_COPY
+#  ifdef GG_CONFIG_HAVE___VA_COPY
+#    define va_copy(dest, src) __va_copy((dest), (src))
+#  else
+/* Taka wersja va_copy() działa poprawnie tylko na platformach, które
+ * va_copy() de facto wcale nie potrzebujÄ
, np. MSVC. Definicja tylko dla
+ * przejrzystości kodu. */
+#    define va_copy(dest, src) (dest) = (src)
+#  endif
+#endif
 
 /**
  * \internal Odpowiednik funkcji \c vsprintf alokujÄ
cy miejsce na wynik.
@@ -55,59 +68,54 @@
  */
 char *gg_vsaprintf(const char *format, va_list ap)
 {
-	int size = 0;
+	int size;
 	char *buf = NULL;
-
-#ifdef GG_CONFIG_HAVE_VA_COPY
 	va_list aq;
 
-	va_copy(aq, ap);
-#else
-#  ifdef GG_CONFIG_HAVE___VA_COPY
-	va_list aq;
-
-	__va_copy(aq, ap);
-#  endif
-#endif
-
-#ifndef GG_CONFIG_HAVE_C99_VSNPRINTF
+#if !defined(GG_CONFIG_HAVE_C99_VSNPRINTF) && !defined(HAVE__VSCPRINTF)
 	{
-		int res;
+		int res = 0;
 		char *tmp;
 
 		size = 128;
 		do {
-			size *= 2;
-			if (!(tmp = realloc(buf, size + 1))) {
+			if (res > size) {
+				/* Jednak zachowanie zgodne z C99. */
+				size = res + 1;
+			} else {
+				size *= 2;
+			}
+
+			if (!(tmp = realloc(buf, size))) {
 				free(buf);
 				return NULL;
 			}
+
 			buf = tmp;
-			res = vsnprintf(buf, size, format, ap);
-		} while (res >= size - 1 || res == -1);
+			va_copy(aq, ap);
+			res = vsnprintf(buf, size, format, aq);
+			va_end(aq);
+		} while (res >= size || res < 0);
 	}
 #else
+	va_copy(aq, ap);
+
+#  ifdef HAVE__VSCPRINTF
+	size = _vscprintf(format, aq) + 1;
+#  else
 	{
 		char tmp[2];
 
 		/* libce Solarisa przy buforze NULL zawsze zwracajÄ
 -1, więc
 		 * musimy podać coÅ› istniejÄ
cego jako cel printf()owania. */
-		size = vsnprintf(tmp, sizeof(tmp), format, ap);
-		if (!(buf = malloc(size + 1)))
-			return NULL;
+		size = vsnprintf(tmp, sizeof(tmp), format, aq) + 1;
 	}
-#endif
+#  endif
+	va_end(aq);
+	if (!(buf = malloc(size)))
+		return NULL;
 
-#ifdef GG_CONFIG_HAVE_VA_COPY
-	vsnprintf(buf, size + 1, format, aq);
-	va_end(aq);
-#else
-#  ifdef GG_CONFIG_HAVE___VA_COPY
-	vsnprintf(buf, size + 1, format, aq);
-	va_end(aq);
-#  else
-	vsnprintf(buf, size + 1, format, ap);
-#  endif
+	vsnprintf(buf, size, format, ap);
 #endif
 
 	return buf;
@@ -146,6 +154,8 @@ char *gg_saprintf(const char *format, ..
  * \param ptr Wskaźnik do zmiennej, która przechowuje aktualne położenie
  *            w analizowanym buforze
  *
+ * \note Funkcja nie jest już używana. Pozostała dla zachowania ABI.
+ *
  * \return Wskaźnik do kolejnej linii tekstu lub NULL, jeśli to już koniec
  *         bufora.
  */
@@ -180,11 +190,15 @@ char *gg_get_line(char **ptr)
  * Funkcja czyta tekst znak po znaku, więc nie jest efektywna, ale dzięki
  * brakowi buforowania, nie koliduje z innymi funkcjami odczytu.
  *
+ * \note W przypadku zakoÅ„czenia poÅ‚Ä
czenia przez drugÄ
 stronÄ™, ostatnia
+ * linia nie jest zwracana.
+ *
  * \param sock Deskryptor gniazda
  * \param buf Wskaźnik do bufora
  * \param length Długość bufora
  *
- * \return Zwraca \c buf jeśli się powiodło, lub \c NULL w przypadku błędu.
+ * \return Zwraca wskaźnik na koniec odebranej linii jeśli się powiodło,
+ * lub \c NULL w przypadku błędu.
  */
 char *gg_read_line(int sock, char *buf, int length)
 {
@@ -195,7 +209,7 @@ char *gg_read_line(int sock, char *buf, 
 
 	for (; length > 1; buf++, length--) {
 		do {
-			if ((ret = read(sock, buf, 1)) == -1 && errno != EINTR && errno != EAGAIN) {
+			if ((ret = recv(sock, buf, 1, 0)) == -1 && errno != EINTR && errno != EAGAIN) {
 				gg_debug(GG_DEBUG_MISC, "// gg_read_line() error on read (errno=%d, %s)\n", errno, strerror(errno));
 				*buf = 0;
 				return NULL;
@@ -229,7 +243,7 @@ char *gg_read_line(int sock, char *buf, 
  */
 int gg_connect(void *addr, int port, int async)
 {
-	int sock, one = 1, errno2;
+	int sock, errno2;
 	struct sockaddr_in sin;
 	struct in_addr *a = addr;
 	struct sockaddr_in myaddr;
@@ -256,11 +270,13 @@ int gg_connect(void *addr, int port, int
 
 	if (async) {
 #ifdef FIONBIO
+		int one = 1;
+
 		if (ioctl(sock, FIONBIO, &one) == -1) {
 #else
 		if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1) {
 #endif
-			gg_debug(GG_DEBUG_MISC, "// gg_connect() ioctl() failed (errno=%d, %s)\n", errno, strerror(errno));
+			gg_debug(GG_DEBUG_MISC, "// gg_connect() can't set nonblocking (errno=%d, %s)\n", errno, strerror(errno));
 			errno2 = errno;
 			close(sock);
 			errno = errno2;
@@ -384,7 +400,8 @@ int gg_http_hash(const char *format, ...
 	va_start(ap, format);
 
 	for (j = 0; j < strlen(format); j++) {
-		char *arg, buf[16];
+		const char *arg;
+		char buf[16];
 
 		if (format[j] == 'u') {
 			snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t));
@@ -486,7 +503,7 @@ char *gg_base64_decode(const char *buf)
 {
 	char *res, *save, *foo, val;
 	const char *end;
-	unsigned int index = 0;
+	unsigned int idx = 0;
 



More information about the Commits mailing list