Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: include/libgadu.h.in
- ===================================================================
- --- include/libgadu.h.in (wersja 1185)
- +++ include/libgadu.h.in (kopia robocza)
- @@ -98,6 +98,12 @@
- #include <openssl/ssl.h>
- #endif
- +#ifdef _WIN32
- +# undef GG_CONFIG_HAVE_FORK
- +#else
- +# define GG_CONFIG_HAVE_FORK
- +#endif
- +
- #ifdef GG_CONFIG_HAVE_STDINT_H
- #include <stdint.h>
- #else
- 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,36 @@
- #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
- +# define getsockopt( socket, level, optname, optval, optlenptr ) \
- + gg_win32_getsockopt( socket, level, optname, optval, optlenptr )
- +# define ioctl( fd, command, val ) \
- + gg_win32_ioctl( fd, command, val )
- +
- +int gg_win32_getsockopt(int socket, int level, int optname, void *optval,
- + socklen_t *optlenptr);
- +int gg_win32_ioctl(int fd, int command, void* val);
- +#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/compat.c
- ===================================================================
- --- src/compat.c (wersja 0)
- +++ src/compat.c (wersja 0)
- @@ -0,0 +1,106 @@
- +#include <errno.h>
- +
- +#include "compat.h"
- +
- +#ifdef _WIN32
- +#undef getsockopt
- +
- +struct ifconf
- +{
- + int ifc_len;
- + union
- + {
- + char *ifcu_buf;
- + struct ifreq *ifcu_req;
- + } ifc_ifcu;
- +};
- +#define ifc_buf ifc_ifcu.ifcu_buf
- +#define ifc_req ifc_ifcu.ifcu_req
- +
- +struct ifreq
- +{
- + union
- + {
- + char ifrn_name[6];
- + } ifr_ifrn;
- +
- + union
- + {
- + struct sockaddr ifru_addr;
- + char *ifru_data;
- + } ifr_ifru;
- +};
- +#define ifr_name ifr_ifrn.ifrn_name
- +#define ifr_addr ifr_ifru.ifru_addr
- +
- +int gg_win32_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;
- +}
- +
- +/* sys/ioctl.h */
- +int gg_win32_ioctl(int fd, int command, void* val) {
- + switch( command ) {
- + case FIONBIO:
- + {
- + if (ioctlsocket(fd, FIONBIO, (unsigned long *)val) ==
- + SOCKET_ERROR) {
- + errno = WSAGetLastError();
- + return -1;
- + }
- + return 0;
- + }
- + case SIOCGIFCONF:
- + {
- + INTERFACE_INFO InterfaceList[20];
- + unsigned long nBytesReturned;
- + if (WSAIoctl(fd, SIO_GET_INTERFACE_LIST,
- + 0, 0, &InterfaceList,
- + sizeof(InterfaceList), &nBytesReturned,
- + 0, 0) == SOCKET_ERROR) {
- + errno = WSAGetLastError();
- + return -1;
- + } else {
- + int i;
- + struct ifconf *ifc = val;
- + char *tmp = ifc->ifc_buf;
- + int nNumInterfaces =
- + nBytesReturned / sizeof(INTERFACE_INFO);
- + for (i = 0; i < nNumInterfaces; i++) {
- + INTERFACE_INFO ii = InterfaceList[i];
- + struct ifreq *ifr = (struct ifreq *) tmp;
- + struct sockaddr_in *sa =
- + (struct sockaddr_in *) &ifr->ifr_addr;
- +
- + sa->sin_family =
- + ii.iiAddress.AddressIn.sin_family;
- + sa->sin_port =
- + ii.iiAddress.AddressIn.sin_port;
- + sa->sin_addr.s_addr =
- + ii.iiAddress.AddressIn.sin_addr.s_addr;
- + tmp += sizeof(struct ifreq);
- +
- + /* Make sure that we can fit in the original
- + * buffer */
- + if (tmp >= (ifc->ifc_buf + ifc->ifc_len +
- + sizeof(struct ifreq))) {
- + break;
- + }
- + }
- + /* Replace the length with the actually used length */
- + ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp);
- + return 0;
- + }
- + }
- + default:
- + errno = EINVAL;
- + return -1;
- + }/*end switch*/
- +}
- +
- +#endif /* _WIN32 */
- 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/Makefile.am
- ===================================================================
- --- src/Makefile.am (wersja 1185)
- +++ src/Makefile.am (kopia robocza)
- @@ -1,5 +1,5 @@
- lib_LTLIBRARIES = libgadu.la
- -libgadu_la_SOURCES = common.c dcc.c dcc7.c debug.c deflate.c encoding.c endian.c events.c handlers.c http.c libgadu.c message.c obsolete.c pubdir.c pubdir50.c resolver.c sha1.c
- +libgadu_la_SOURCES = common.c compat.c dcc.c dcc7.c debug.c deflate.c encoding.c endian.c events.c handlers.c http.c libgadu.c message.c obsolete.c pubdir.c pubdir50.c resolver.c sha1.c
- libgadu_la_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/include -DGG_IGNORE_DEPRECATED
- libgadu_la_LDFLAGS = -version-number 3:13 -export-symbols libgadu.sym
- EXTRA_DIST = libgadu.sym
- 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>
Add Comment
Please, Sign In to add comment