W dniu 18 października 2011 16:41 użytkownik Tomasz Wasilczyk <tomkiewicz.gro...@gmail.com> napisał: > Zmiana, do której nie jestem całkowicie przekonany: implementacja > getsockopt i ioctl wyciągnięta z libpurple. To chyba wymaga > dopracowania.
Po przemyśleniu, jednak wywaliłem to całkiem z patcha, jako że nie mam tego nawet jak przetestować. > - dlaczego #pragma pack jest używana tylko w C++? Jak przeniosłem w > libpurple ifdefy tak, żeby odpowiadały tym z upstream-libgadu, to > niektóre funkcje (np. katalog publiczny) przestały działać pod > Windowsem. Po obejrzeniu kodu forka libgadu dla kadu, zrozumiałem w czym problem i też to poprawiłem w patchu. > - wie ktokolwiek, po co jest ten wyjątek dla cygwina? Bo wypadało by > przenieść to do configure, tak jak było to wspomniane parę miesięcy > temu Trochę tu pogrzebałem i znalazłem commity i tickety, w których ten warunek został rozszerzony. Może to komuś pomoże w ustaleniu, po co to jest. Poza tym z tego, co widzę, to libgadu nawet nie używa typów intX_t, więc można by to było bezpiecznie zakomentować (niekoniecznie wywalać, bo może ktoś kiedyś będzie potrzebował tych typów). SunOS: http://developer.pidgin.im/ticket/11841 SunOS: http://developer.pidgin.im/viewmtn/revision/info/cfa223b3386ae5aea84acf03fb9eb9b741364d29 HP-UX: http://developer.pidgin.im/viewmtn/revision/info/1ce90eeff222690b47ecfe394e118403b2782a2f --- W załączniku przesyłam poprawiony patch. Proszę o feedback i/lub ewentualnego commita - zsynchronizowanie się z upstream bardzo ułatwi zarządzanie wtyczką gg w Pidginie. A jako, że zmiany (z tego, co widzę) częściowo pokrywają się z tymi z forka dla Kadu, to nie tylko ja tu będę miał łatwiej ;). Pozdrawiam, Tomek
Index: include/libgadu.h.in =================================================================== --- include/libgadu.h.in (wersja 1185) +++ include/libgadu.h.in (kopia robocza) @@ -33,10 +33,11 @@ #ifndef __GG_LIBGADU_H #define __GG_LIBGADU_H -#ifdef __cplusplus -#ifdef _WIN32 +#if defined(__cplusplus) || defined(_WIN32) #pragma pack(push, 1) #endif + +#ifdef __cplusplus extern "C" { #endif @@ -52,6 +53,13 @@ /* Defined if this machine has gethostbyname_r(). */ #undef GG_CONFIG_HAVE_GETHOSTBYNAME_R +/* Defined if libgadu was compiled for system with fork support. */ +#ifdef _WIN32 +# undef GG_CONFIG_HAVE_FORK +#else +# define GG_CONFIG_HAVE_FORK +#endif + /* Defined if libgadu was compiled and linked with pthread support. */ #undef GG_CONFIG_HAVE_PTHREAD @@ -2337,10 +2345,11 @@ #ifdef __cplusplus } -#ifdef _WIN32 +#endif + +#if defined(__cplusplus) || defined(_WIN32) #pragma pack(pop) #endif -#endif #endif /* __GG_LIBGADU_H */ Index: include/resolver.h =================================================================== --- include/resolver.h (wersja 1185) +++ include/resolver.h (kopia robocza) @@ -19,7 +19,7 @@ #ifndef LIBGADU_RESOLVER_H #define LIBGADU_RESOLVER_H -#include <arpa/inet.h> +#include "compat.h" int gg_gethostbyname_real(const char *hostname, struct in_addr **result, unsigned int *count, int pthread); Index: include/compat.h =================================================================== --- include/compat.h (wersja 1185) +++ include/compat.h (kopia robocza) @@ -29,10 +29,28 @@ #define __COMPAT_H #include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> +#ifdef _WIN32 +# include <ws2tcpip.h> +# include <winsock2.h> +# define EINPROGRESS WSAEINPROGRESS +# define ETIMEDOUT WSAETIMEDOUT +# define ENOTCONN WSAENOTCONN +# define ECONNRESET WSAECONNRESET +# define SHUT_RDWR SD_BOTH +# define SIOCGIFCONF 0x8912 +# undef small +# define random (long)rand +#else +# include <sys/wait.h> +# include <sys/ioctl.h> +# include <netdb.h> +# include <sys/socket.h> +# include <netinet/in.h> +# include <arpa/inet.h> +# include <signal.h> +#endif + #ifdef sun # define INADDR_NONE ((in_addr_t) 0xffffffff) #endif Index: src/handlers.c =================================================================== --- src/handlers.c (wersja 1185) +++ src/handlers.c (kopia robocza) @@ -27,9 +27,6 @@ */ #include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> #include <ctype.h> #ifdef sun # include <sys/filio.h> @@ -46,7 +43,6 @@ #include "deflate.h" #include <errno.h> -#include <netdb.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> Index: src/resolver.c =================================================================== --- src/resolver.c (wersja 1185) +++ src/resolver.c (kopia robocza) @@ -26,13 +26,10 @@ * \brief Funkcje rozwiązywania nazw */ -#include <sys/wait.h> -#include <netdb.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <signal.h> #include "compat.h" #include "libgadu.h" @@ -242,6 +239,7 @@ #endif /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */ } +#if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_HAVE_FORK) /** * \internal Rozwiązuje nazwę i zapisuje wynik do podanego desktyptora. * @@ -280,6 +278,7 @@ return res; } +#endif /** * \internal Odpowiednik \c gethostbyname zapewniający współbieżność. @@ -311,6 +310,7 @@ int pid; /*< Identyfikator procesu */ }; +#ifdef GG_CONFIG_HAVE_FORK /** * \internal Rozwiązuje nazwę serwera w osobnym procesie. * @@ -365,9 +365,9 @@ close(pipes[0]); if (gg_resolver_run(pipes[1], hostname) == -1) - exit(1); + _Exit(1); else - exit(0); + _Exit(0); } close(pipes[1]); @@ -416,6 +416,7 @@ free(data); } +#endif #ifdef GG_CONFIG_HAVE_PTHREAD @@ -593,11 +594,13 @@ } switch (type) { +#ifdef GG_CONFIG_HAVE_FORK case GG_RESOLVER_FORK: gs->resolver_type = type; gs->resolver_start = gg_resolver_fork_start; gs->resolver_cleanup = gg_resolver_fork_cleanup; return 0; +#endif #ifdef GG_CONFIG_HAVE_PTHREAD case GG_RESOLVER_PTHREAD: @@ -702,11 +705,13 @@ } switch (type) { +#ifdef GG_CONFIG_HAVE_FORK case GG_RESOLVER_FORK: gh->resolver_type = type; gh->resolver_start = gg_resolver_fork_start; gh->resolver_cleanup = gg_resolver_fork_cleanup; return 0; +#endif #ifdef GG_CONFIG_HAVE_PTHREAD case GG_RESOLVER_PTHREAD: @@ -778,11 +783,13 @@ gg_global_resolver_cleanup = NULL; return 0; +#ifdef GG_CONFIG_HAVE_FORK case GG_RESOLVER_FORK: gg_global_resolver_type = type; gg_global_resolver_start = gg_resolver_fork_start; gg_global_resolver_cleanup = gg_resolver_fork_cleanup; return 0; +#endif #ifdef GG_CONFIG_HAVE_PTHREAD case GG_RESOLVER_PTHREAD: Index: src/events.c =================================================================== --- src/events.c (wersja 1185) +++ src/events.c (kopia robocza) @@ -30,7 +30,6 @@ */ #include "compat.h" -#include <sys/ioctl.h> #include <ctype.h> #include "libgadu.h" @@ -353,7 +352,7 @@ static int gg_async_connect_failed(struct gg_session *gs, int *res_ptr) { int res = 0; - unsigned int res_size = sizeof(res); + socklen_t res_size = sizeof(res); if (!gs->async) return 0; Index: src/libgadu.c =================================================================== --- src/libgadu.c (wersja 1185) +++ src/libgadu.c (kopia robocza) @@ -44,7 +44,6 @@ #include "deflate.h" #include <errno.h> -#include <netdb.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> Index: src/http.c =================================================================== --- src/http.c (wersja 1185) +++ src/http.c (kopia robocza) @@ -30,7 +30,6 @@ #include <ctype.h> #include <errno.h> -#include <netdb.h> #include <signal.h> #include <stdarg.h> #include <stdio.h> @@ -251,7 +250,7 @@ } if (h->state == GG_STATE_SENDING_QUERY) { - int res; + ssize_t res; res = write(h->fd, h->query, strlen(h->query)); Index: src/dcc7.c =================================================================== --- src/dcc7.c (wersja 1185) +++ src/dcc7.c (kopia robocza) @@ -31,7 +31,6 @@ #include "compat.h" #include <sys/stat.h> -#include <sys/ioctl.h> #ifdef sun # include <sys/filio.h> #endif Index: src/pubdir.c =================================================================== --- src/pubdir.c (wersja 1185) +++ src/pubdir.c (kopia robocza) @@ -26,6 +26,7 @@ * \brief Obsługa katalogu publicznego */ +#include "compat.h" #include <ctype.h> #include <errno.h> #include <stdarg.h> @@ -167,6 +168,7 @@ #endif /* DOXYGEN */ + /** * Usuwa użytkownika. * Index: src/common.c =================================================================== --- src/common.c (wersja 1185) +++ src/common.c (kopia robocza) @@ -24,18 +24,14 @@ * * \brief Funkcje wykorzystywane przez różne moduły biblioteki */ +#include "compat.h" #include <sys/types.h> -#include <sys/ioctl.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> #ifdef sun # include <sys/filio.h> #endif #include <errno.h> #include <fcntl.h> -#include <netdb.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> Index: src/dcc.c =================================================================== --- src/dcc.c (wersja 1185) +++ src/dcc.c (kopia robocza) @@ -28,7 +28,6 @@ #include "compat.h" #include <sys/stat.h> -#include <sys/ioctl.h> #ifdef sun # include <sys/filio.h> #endif Index: src/pubdir50.c =================================================================== --- src/pubdir50.c (wersja 1185) +++ src/pubdir50.c (kopia robocza) @@ -25,6 +25,7 @@ * testowa konwersja, żeby poznać długość tekstu wynikowego. */ +#include "compat.h" #include <errno.h> #include <stdlib.h> #include <string.h>
_______________________________________________ libgadu-devel mailing list libgadu-devel@lists.ziew.org http://lists.ziew.org/mailman/listinfo/libgadu-devel