annotate libpurple/protocols/gg/lib/resolver.c @ 31609:f2a2290dfc19

German translation update - one new string ("Croatian") translated
author Bj?rn Voigt <bjoern@cs.tu-berlin.de>
date Thu, 12 May 2011 07:39:19 +0000
parents 93b08d43f684
children 3a90a59ddea2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * (C) Copyright 2001-2009 Wojtek Kaniewski <wojtekka@irc.pl>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 * Robert J. Woźny <speedy@ziew.org>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4 * Arkadiusz Miśkiewicz <arekm@pld-linux.org>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 * Tomasz Chiliński <chilek@chilan.com>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * Adam Wysocki <gophi@ekg.chmurka.net>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * it under the terms of the GNU Lesser General Public License Version
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 * 2.1 as published by the Free Software Foundation.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 * GNU Lesser General Public License for more details.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * License along with this program; if not, write to the Free Software
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 * USA.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 * \file resolver.c
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
26 * \brief Funkcje rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
27 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28
29539
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
29 #ifndef _WIN32
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
30 # include <sys/wait.h>
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
31 # include <netdb.h>
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
32 # include <signal.h>
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
33 # include <netinet/in.h>
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
34 # include <arpa/inet.h>
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
35 #endif
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29538
diff changeset
36
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
37 #include <errno.h>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38 #include <stdlib.h>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
39 #include <string.h>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
40 #include <unistd.h>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 #include "libgadu.h"
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
43 #include "resolver.h"
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 #include "compat.h"
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
45 #include "session.h"
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
47 /** Sposób rozwiązywania nazw serwerów */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 static gg_resolver_t gg_global_resolver_type = GG_RESOLVER_DEFAULT;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50 /** Funkcja rozpoczynająca rozwiązywanie nazwy */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 static int (*gg_global_resolver_start)(int *fd, void **private_data, const char *hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
52
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
53 /** Funkcja zwalniająca zasoby po rozwiązaniu nazwy */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
54 static void (*gg_global_resolver_cleanup)(void **private_data, int force);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
56 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
57
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 #include <pthread.h>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
60 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61 * \internal Funkcja pomocnicza zwalniająca zasoby po rozwiązywaniu nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
62 * w wątku.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
64 * \param data Wskaźnik na wskaźnik bufora zaalokowanego w wątku
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
65 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66 static void gg_gethostbyname_cleaner(void *data)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
67 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 char **buf_ptr = (char**) data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 if (buf_ptr != NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71 free(*buf_ptr);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72 *buf_ptr = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
73 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
74 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
76 #endif /* GG_CONFIG_HAVE_PTHREAD */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
77
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
78 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
79 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
80 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
81 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
82 * nie, to zwykłej \c gethostbyname. Wynikiem jest tablica adresów zakończona
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
83 * wartością INADDR_NONE, którą należy zwolnić po użyciu.
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
84 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
85 * \param hostname Nazwa serwera
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
86 * \param result Wskaźnik na wskaźnik z tablicą adresów zakończoną INADDR_NONE
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
87 * \param count Wskaźnik na zmienną, do ktorej zapisze się liczbę wyników
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
88 * \param pthread Flaga blokowania unicestwiania wątku podczas alokacji pamięci
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
89 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
90 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
91 */
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
92 int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *count, int pthread)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 #ifdef GG_CONFIG_HAVE_GETHOSTBYNAME_R
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
95 char *buf = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96 char *new_buf = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
97 struct hostent he;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 struct hostent *he_ptr = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 size_t buf_len = 1024;
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
100 int res = -1;
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 int h_errnop;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 int ret = 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
104 int old_state;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
105 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
106
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
107 if (result == NULL) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
108 errno = EINVAL;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
109 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
110 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
111
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 pthread_cleanup_push(gg_gethostbyname_cleaner, &buf);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
114
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
116 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
117 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
119 buf = malloc(buf_len);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
120
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123 pthread_setcancelstate(old_state, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
124 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
125
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
126 if (buf != NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
127 #ifndef sun
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 while ((ret = gethostbyname_r(hostname, &he, buf, buf_len, &he_ptr, &h_errnop)) == ERANGE) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 #else
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
130 while (((he_ptr = gethostbyname_r(hostname, &he, buf, buf_len, &h_errnop)) == NULL) && (errno == ERANGE)) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
131 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132 buf_len *= 2;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
136 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
137 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
138
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
139 new_buf = realloc(buf, buf_len);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
140
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
141 if (new_buf != NULL)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
142 buf = new_buf;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
143
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
144 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
145 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
146 pthread_setcancelstate(old_state, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
147 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
148
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
149 if (new_buf == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
150 ret = ENOMEM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
151 break;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
152 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
153 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
154
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
155 if (ret == 0 && he_ptr != NULL && he_ptr->h_addr_list[0] != NULL) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
156 int i;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
157
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
158 /* Policz liczbę adresów */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
159
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
160 for (i = 0; he_ptr->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
161 ;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
162
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
163 /* Zaalokuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
164
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
165 #ifdef GG_CONFIG_HAVE_PTHREAD
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
166 if (pthread)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
167 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
168 #endif
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
169
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
170 *result = malloc((i + 1) * sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
171
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
172 #ifdef GG_CONFIG_HAVE_PTHREAD
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
173 if (pthread)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
174 pthread_setcancelstate(old_state, NULL);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
175 #endif
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
176
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
177 if (*result == NULL)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
178 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
179
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
180 /* Kopiuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
181
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
182 for (i = 0; he_ptr->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
183 memcpy(&((*result)[i]), he_ptr->h_addr_list[i], sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
184
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
185 (*result)[i].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
186
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
187 *count = i;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
188
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
189 res = 0;
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
190 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
191
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
192 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
193 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
195 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
197 free(buf);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
198 buf = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
200 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202 pthread_setcancelstate(old_state, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
203 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
207 pthread_cleanup_pop(1);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
208 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
210 return res;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
211 #else /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
212 struct hostent *he;
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
213 int i;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
214
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
215
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
216 if (result == NULL || count == NULL) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
217 errno = EINVAL;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
218 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
219 }
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221 he = gethostbyname(hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
222
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
223 if (he == NULL || he->h_addr_list[0] == NULL)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
224 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
225
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
226 /* Policz liczbę adresów */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
227
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
228 for (i = 0; he->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
229 ;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
230
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
231 /* Zaalokuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
232
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
233 *result = malloc((i + 1) * sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
234
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
235 if (*result == NULL)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
236 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
237
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
238 /* Kopiuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
239
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
240 for (i = 0; he->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
241 memcpy(&((*result)[i]), he->h_addr_list[0], sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
242
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
243 (*result)[i].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
244
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
245 *count = i;
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
246
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
247 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
248 #endif /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
249 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
250
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
251 /**
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
252 * \internal Rozwiązuje nazwę i zapisuje wynik do podanego desktyptora.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
253 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
254 * \param fd Deskryptor
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
255 * \param hostname Nazwa serwera
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
256 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
257 * \return 0 jeśli się powiodło, -1 w przypadku błędu
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
258 */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
259 int gg_resolver_run(int fd, const char *hostname)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
260 {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
261 struct in_addr addr_ip[2], *addr_list;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
262 int addr_count;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
263 int res = 0;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
264
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
265 gg_debug(GG_DEBUG_MISC, "// gg_resolver_run(%d, %s)\n", fd, hostname);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
266
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
267 if ((addr_ip[0].s_addr = inet_addr(hostname)) == INADDR_NONE) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
268 if (gg_gethostbyname_real(hostname, &addr_list, &addr_count, 1) == -1) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
269 addr_list = addr_ip;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
270 /* addr_ip[0] już zawiera INADDR_NONE */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
271 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
272 } else {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
273 addr_list = addr_ip;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
274 addr_ip[1].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
275 addr_count = 1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
276 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
277
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
278 gg_debug(GG_DEBUG_MISC, "// gg_resolver_run() count = %d\n", addr_count);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
279
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
280 if (write(fd, addr_list, (addr_count + 1) * sizeof(struct in_addr)) != (addr_count + 1) * sizeof(struct in_addr))
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
281 res = -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
282
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
283 if (addr_list != addr_ip)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
284 free(addr_list);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
285
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
286 return res;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
287 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
288
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
289 /**
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
290 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
291 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
293 * nie, to zwykłej \c gethostbyname. Funkcja służy do zachowania zgodności
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
294 * ABI i służy do pobierania tylko pierwszego adresu -- pozostałe mogą
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
295 * zostać zignorowane przez aplikację.
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
297 * \param hostname Nazwa serwera
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299 * \return Zaalokowana struktura \c in_addr lub NULL w przypadku błędu.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
301 struct in_addr *gg_gethostbyname(const char *hostname)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
302 {
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
303 struct in_addr *result;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
304 int count;
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
305
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
306 if (gg_gethostbyname_real(hostname, &result, &count, 0) == -1)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307 return NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
308
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
309 return result;
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
310 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
311
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
312 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
313 * \internal Struktura przekazywana do wątku rozwiązującego nazwę.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
314 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315 struct gg_resolver_fork_data {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
316 int pid; /*< Identyfikator procesu */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
317 };
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
318
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
319 #ifdef _WIN32
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
320 /**
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
321 * Deal with the fact that you can't select() on a win32 file fd.
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
322 * This makes it practically impossible to tie into purple's event loop.
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
323 *
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
324 * -This is thanks to Tor Lillqvist.
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
325 * XXX - Move this to where the rest of the the win32 compatiblity stuff goes when we push the changes back to libgadu.
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
326 */
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
327 static int
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
328 socket_pipe (int *fds)
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
329 {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
330 SOCKET temp, socket1 = -1, socket2 = -1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
331 struct sockaddr_in saddr;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
332 int len;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
333 u_long arg;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
334 fd_set read_set, write_set;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
335 struct timeval tv;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
336
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
337 temp = socket(AF_INET, SOCK_STREAM, 0);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
338
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
339 if (temp == INVALID_SOCKET) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
340 goto out0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
341 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
342
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
343 arg = 1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
344 if (ioctlsocket(temp, FIONBIO, &arg) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
345 goto out0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
346 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
347
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
348 memset(&saddr, 0, sizeof(saddr));
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
349 saddr.sin_family = AF_INET;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
350 saddr.sin_port = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
351 saddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
352
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
353 if (bind(temp, (struct sockaddr *)&saddr, sizeof (saddr))) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
354 goto out0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
355 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
356
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
357 if (listen(temp, 1) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
358 goto out0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
359 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
360
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
361 len = sizeof(saddr);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
362 if (getsockname(temp, (struct sockaddr *)&saddr, &len)) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
363 goto out0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
364 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
365
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
366 socket1 = socket(AF_INET, SOCK_STREAM, 0);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
367
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
368 if (socket1 == INVALID_SOCKET) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
369 goto out0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
370 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
371
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
372 arg = 1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
373 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
374 goto out1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
375 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
376
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
377 if (connect(socket1, (struct sockaddr *)&saddr, len) != SOCKET_ERROR ||
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
378 WSAGetLastError() != WSAEWOULDBLOCK) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
379 goto out1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
380 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
381
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
382 FD_ZERO(&read_set);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
383 FD_SET(temp, &read_set);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
384
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
385 tv.tv_sec = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
386 tv.tv_usec = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
387
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
388 if (select(0, &read_set, NULL, NULL, NULL) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
389 goto out1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
390 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
391
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
392 if (!FD_ISSET(temp, &read_set)) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
393 goto out1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
394 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
395
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
396 socket2 = accept(temp, (struct sockaddr *) &saddr, &len);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
397 if (socket2 == INVALID_SOCKET) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
398 goto out1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
399 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
400
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
401 FD_ZERO(&write_set);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
402 FD_SET(socket1, &write_set);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
403
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
404 tv.tv_sec = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
405 tv.tv_usec = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
406
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
407 if (select(0, NULL, &write_set, NULL, NULL) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
408 goto out2;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
409 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
410
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
411 if (!FD_ISSET(socket1, &write_set)) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
412 goto out2;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
413 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
414
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
415 arg = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
416 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
417 goto out2;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
418 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
419
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
420 arg = 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
421 if (ioctlsocket(socket2, FIONBIO, &arg) == SOCKET_ERROR) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
422 goto out2;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
423 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
424
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
425 fds[0] = socket1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
426 fds[1] = socket2;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
427
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
428 closesocket (temp);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
429
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
430 return 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
431
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
432 out2:
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
433 closesocket (socket2);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
434 out1:
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
435 closesocket (socket1);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
436 out0:
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
437 closesocket (temp);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
438 errno = EIO; /* XXX */
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
439
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
440 return -1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
441 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
442 #endif
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
443
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
444
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
445
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
446 #ifdef _WIN32
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
447 struct gg_resolve_win32thread_data {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
448 char *hostname;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
449 int fd;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
450 };
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
451
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
452 static DWORD WINAPI gg_resolve_win32thread_thread(LPVOID arg)
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
453 {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
454 struct gg_resolve_win32thread_data *d = arg;
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
455 struct in_addr addr_ip[2], *addr_list;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
456 int addr_count;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
457
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
458 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() host: %s, fd: %i called\n", d->hostname, d->fd);
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
459
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
460 if ((addr_ip[0].s_addr = inet_addr(d->hostname)) == INADDR_NONE) {
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
461 /* W przypadku błędu gg_gethostbyname_real() zwróci -1
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
462 * i nie zmieni &addr. Tam jest już INADDR_NONE,
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
463 * więc nie musimy robić nic więcej. */
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
464 if (gg_gethostbyname_real(d->hostname, &addr_list, &addr_count, 0) == -1)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
465 {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
466 addr_list = addr_ip;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
467 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
468 } else {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
469 addr_list = addr_ip;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
470 addr_ip[1].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
471 addr_count = 1;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
472 }
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
473
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
474 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() count = %d\n", addr_count);
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
475
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
476 write(d->fd, addr_list, (addr_count+1) * sizeof(struct in_addr));
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
477 close(d->fd);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
478
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
479 free(d->hostname);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
480 d->hostname = NULL;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
481
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
482 free(d);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
483
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
484 if (addr_list != addr_ip)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
485 free(addr_list);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
486
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
487 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() done\n");
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
488
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
489 return 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
490 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
491
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
492
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
493 static int gg_resolve_win32thread(int *fd, void **resolver, const char *hostname)
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
494 {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
495 struct gg_resolve_win32thread_data *d = NULL;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
496 HANDLE h;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
497 DWORD dwTId;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
498 int pipes[2], new_errno;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
499
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
500 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolve_win32thread(%p, %p, \"%s\");\n", fd, resolver, hostname);
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
501
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
502 if (!resolver || !fd || !hostname) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
503 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() invalid arguments\n");
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
504 errno = EFAULT;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
505 return -1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
506 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
507
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
508 if (socket_pipe(pipes) == -1) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
509 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
510 return -1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
511 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
512
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
513 if (!(d = malloc(sizeof(*d)))) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
514 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() out of memory\n");
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
515 new_errno = errno;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
516 goto cleanup;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
517 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
518
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
519 d->hostname = NULL;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
520
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
521 if (!(d->hostname = strdup(hostname))) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
522 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() out of memory\n");
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
523 new_errno = errno;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
524 goto cleanup;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
525 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
526
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
527 d->fd = pipes[1];
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
528
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
529 h = CreateThread(NULL, 0, gg_resolve_win32thread_thread,
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
530 d, 0, &dwTId);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
531
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
532 if (h == NULL) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
533 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() unable to create thread\n");
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
534 new_errno = errno;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
535 goto cleanup;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
536 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
537
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
538 *resolver = h;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
539 *fd = pipes[0];
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
540
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
541 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() done\n");
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
542
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
543 return 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
545 cleanup:
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
546 if (d) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
547 free(d->hostname);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
548 free(d);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
549 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
550
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
551 close(pipes[0]);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
552 close(pipes[1]);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
553
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
554 errno = new_errno;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
555
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
556 return -1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
557
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
558 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
559
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
560 static void gg_resolve_win32thread_cleanup(void **priv_data, int force)
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
561 {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
562 struct gg_resolve_win32thread_data *data;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
563
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
564 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() force: %i called\n", force);
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
565
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
566 if (priv_data == NULL || *priv_data == NULL)
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
567 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() priv_data: NULL\n");
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
568 return;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
569
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
570 data = (struct gg_resolve_win32thread_data*) *priv_data;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
571 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() data: %s called\n", data->hostname);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
572 *priv_data = NULL;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
573
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
574 if (force) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
575 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() force called\n", force);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
576 //pthread_cancel(data->thread);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
577 //pthread_join(data->thread, NULL);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
578 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
579
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
580 free(data->hostname);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
581 data->hostname = NULL;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
582
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
583 if (data->fd != -1) {
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
584 close(data->fd);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
585 data->fd = -1;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
586 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
587 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() done\n");
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
588 free(data);
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
589 }
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
590 #endif
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
591
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
592 #ifndef _WIN32
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
593 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
594 * \internal Rozwiązuje nazwę serwera w osobnym procesie.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
595 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
596 * Połączenia asynchroniczne nie mogą blokować procesu w trakcie rozwiązywania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
597 * nazwy serwera. W tym celu tworzony jest potok, nowy proces i dopiero w nim
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
598 * przeprowadzane jest rozwiązywanie nazwy. Deskryptor strony do odczytu
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
599 * zapisuje się w strukturze sieci i czeka na dane w postaci struktury
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
600 * \c in_addr. Jeśli nie znaleziono nazwy, zwracana jest \c INADDR_NONE.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
601 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
602 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
603 * potoku
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
604 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 * do numeru procesu potomnego rozwiązującego nazwę
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
606 * \param hostname Nazwa serwera do rozwiązania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
607 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
608 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
609 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
610 static int gg_resolver_fork_start(int *fd, void **priv_data, const char *hostname)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
611 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
612 struct gg_resolver_fork_data *data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613 int pipes[2], new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
614
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
615 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_fork_start(%p, %p, \"%s\");\n", fd, priv_data, hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
616
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
617 if (fd == NULL || priv_data == NULL || hostname == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
618 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() invalid arguments\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
619 errno = EFAULT;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
620 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
621 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
622
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
623 data = malloc(sizeof(struct gg_resolver_fork_data));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
624
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
625 if (data == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
626 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() out of memory for resolver data\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
627 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
628 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
629
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
630 if (pipe(pipes) == -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
631 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
632 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
633 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
634 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
635
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
636 data->pid = fork();
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
637
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
638 if (data->pid == -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
639 new_errno = errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
640 goto cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
641 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
642
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
643 if (data->pid == 0) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
644 close(pipes[0]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
645
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
646 if (gg_resolver_run(pipes[1], hostname) == -1)
30190
e4c57ecc54ee gg: s/exit/_exit/ in the resolver fork() code
Paul Aurich <paul@darkrain42.org>
parents: 29691
diff changeset
647 _exit(1);
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
648 else
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
649 _exit(0);
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
650 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
651
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
652 close(pipes[1]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
653
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
654 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() %p\n", data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
655
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
656 *fd = pipes[0];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
657 *priv_data = data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
658
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
659 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
660
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
661 cleanup:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
662 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
663 close(pipes[0]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
664 close(pipes[1]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
665
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
666 errno = new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
667
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
668 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
669 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
670
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
671 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
672 * \internal Usuwanie zasobów po procesie rozwiązywaniu nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
673 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
674 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
675 * zasobów sesji podczas rozwiązywania nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
676 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
677 * \param priv_data Wskaźnik na zmienną przechowującą wskaźnik do prywatnych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
678 * danych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
679 * \param force Flaga usuwania zasobów przed zakończeniem działania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
680 */
29691
eb8b1cfd3349 Silence some gadu-gadu warnings
Paul Aurich <paul@darkrain42.org>
parents: 29544
diff changeset
681 static void gg_resolver_fork_cleanup(void **priv_data, int force)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
682 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
683 struct gg_resolver_fork_data *data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
684
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
685 if (priv_data == NULL || *priv_data == NULL)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
686 return;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
687
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
688 data = (struct gg_resolver_fork_data*) *priv_data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
689 *priv_data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
690
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
691 if (force)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
692 kill(data->pid, SIGKILL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
693
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
694 waitpid(data->pid, NULL, WNOHANG);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
695
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
696 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
697 }
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
698 #endif
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
699
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
700 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
701
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
702 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
703 * \internal Struktura przekazywana do wątku rozwiązującego nazwę.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
704 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
705 struct gg_resolver_pthread_data {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
706 pthread_t thread; /*< Identyfikator wątku */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
707 char *hostname; /*< Nazwa serwera */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
708 int rfd; /*< Deskryptor do odczytu */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
709 int wfd; /*< Deskryptor do zapisu */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
710 };
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
711
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
712 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
713 * \internal Usuwanie zasobów po wątku rozwiązywaniu nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
714 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
715 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
716 * zasobów sesji podczas rozwiązywania nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
717 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
718 * \param priv_data Wskaźnik na zmienną przechowującą wskaźnik do prywatnych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
719 * danych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
720 * \param force Flaga usuwania zasobów przed zakończeniem działania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
721 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
722 static void gg_resolver_pthread_cleanup(void **priv_data, int force)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
723 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
724 struct gg_resolver_pthread_data *data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
725
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
726 if (priv_data == NULL || *priv_data == NULL)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
727 return;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
728
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
729 data = (struct gg_resolver_pthread_data *) *priv_data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
730 *priv_data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
731
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
732 if (force) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
733 pthread_cancel(data->thread);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
734 pthread_join(data->thread, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
735 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
736
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
737 free(data->hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
738 data->hostname = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
739
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
740 if (data->wfd != -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
741 close(data->wfd);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
742 data->wfd = -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
743 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
744
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
745 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
746 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
747
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
748 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
749 * \internal Wątek rozwiązujący nazwę.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
750 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
751 * \param arg Wskaźnik na strukturę \c gg_resolver_pthread_data
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
752 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
753 static void *gg_resolver_pthread_thread(void *arg)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
754 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
755 struct gg_resolver_pthread_data *data = arg;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
756
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
757 pthread_detach(pthread_self());
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
758
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
759 if (gg_resolver_run(data->wfd, data->hostname) == -1)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
760 pthread_exit((void*) -1);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
761 else
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
762 pthread_exit(NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
763
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
764 return NULL; /* żeby kompilator nie marudził */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
765 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
766
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
767 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
768 * \internal Rozwiązuje nazwę serwera w osobnym wątku.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
769 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
770 * Funkcja działa analogicznie do \c gg_resolver_fork_start(), z tą różnicą,
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
771 * że działa na wątkach, nie procesach. Jest dostępna wyłącznie gdy podczas
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
772 * kompilacji włączono odpowiednią opcję.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
773 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
774 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
775 * potoku
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
776 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
777 * do prywatnych danych wątku rozwiązującego nazwę
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
778 * \param hostname Nazwa serwera do rozwiązania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
779 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
780 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
781 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
782 static int gg_resolver_pthread_start(int *fd, void **priv_data, const char *hostname)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
783 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
784 struct gg_resolver_pthread_data *data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
785 int pipes[2], new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
786
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
787 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_pthread_start(%p, %p, \"%s\");\n", fd, priv_data, hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
788
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
789 if (fd == NULL || priv_data == NULL || hostname == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
790 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() invalid arguments\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
791 errno = EFAULT;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
792 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
793 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
794
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
795 data = malloc(sizeof(struct gg_resolver_pthread_data));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
796
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
797 if (data == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
798 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory for resolver data\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
799 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
800 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
801
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
802 if (pipe(pipes) == -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
803 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
804 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
805 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
806 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
807
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
808 data->hostname = strdup(hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
809
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
810 if (data->hostname == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
811 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
812 new_errno = errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
813 goto cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
814 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
815
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
816 data->rfd = pipes[0];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
817 data->wfd = pipes[1];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
818
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
819 if (pthread_create(&data->thread, NULL, gg_resolver_pthread_thread, data)) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
820 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() unable to create thread\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
821 new_errno = errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
822 goto cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
823 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
824
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
825 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() %p\n", data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
826
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
827 *fd = pipes[0];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
828 *priv_data = data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
829
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
830 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
831
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
832 cleanup:
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
833 if (data != NULL)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
834 free(data->hostname);
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
835
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
836 free(data);
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
837
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
838 close(pipes[0]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
839 close(pipes[1]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
840
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
841 errno = new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
842
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
843 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
844 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
845
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
846 #endif /* GG_CONFIG_HAVE_PTHREAD */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
847
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
848 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
849 * Ustawia sposób rozwiązywania nazw w sesji.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
850 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
851 * \param gs Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
852 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
853 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
854 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
855 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
856 int gg_session_set_resolver(struct gg_session *gs, gg_resolver_t type)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
857 {
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
858 GG_SESSION_CHECK(gs, -1);
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
859
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
860 if (type == GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
861 if (gg_global_resolver_type != GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
862 gs->resolver_type = gg_global_resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
863 gs->resolver_start = gg_global_resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
864 gs->resolver_cleanup = gg_global_resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
865 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
866 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
867
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
868 #ifdef _WIN32
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
869 type = GG_RESOLVER_WIN32;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
870 #else
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
871 type = GG_RESOLVER_FORK;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
872 #endif
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
873
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
874 #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_PTHREAD_DEFAULT)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
875 type = GG_RESOLVER_PTHREAD;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
876 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
877 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
878
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
879 switch (type) {
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
880 #ifdef _WIN32
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
881 case GG_RESOLVER_WIN32:
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
882 gs->resolver_type = type;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
883 gs->resolver_start = gg_resolve_win32thread;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
884 gs->resolver_cleanup = gg_resolve_win32thread_cleanup;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
885 return 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
886 #else
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
887 case GG_RESOLVER_FORK:
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
888 gs->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
889 gs->resolver_start = gg_resolver_fork_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
890 gs->resolver_cleanup = gg_resolver_fork_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
891 return 0;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
892 #endif
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
893
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
894 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
895 case GG_RESOLVER_PTHREAD:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
896 gs->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
897 gs->resolver_start = gg_resolver_pthread_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
898 gs->resolver_cleanup = gg_resolver_pthread_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
899 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
900 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
901
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
902 default:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
903 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
904 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
905 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
906 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
907
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
908 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
909 * Zwraca sposób rozwiązywania nazw w sesji.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
910 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
911 * \param gs Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
912 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
913 * \return Sposób rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
914 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
915 gg_resolver_t gg_session_get_resolver(struct gg_session *gs)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
916 {
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
917 GG_SESSION_CHECK(gs, (gg_resolver_t) -1);
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
918
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
919 return gs->resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
920 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
921
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
922 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
923 * Ustawia własny sposób rozwiązywania nazw w sesji.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
924 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
925 * \param gs Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
926 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
927 * \param resolver_cleanup Funkcja zwalniająca zasoby
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
928 *
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
929 * Parametry funkcji rozpoczynającej rozwiązywanie nazwy wyglądają następująco:
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
930 * - \c "int *fd" &mdash; wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor potoku
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
931 * - \c "void **priv_data" &mdash; wskaźnik na zmienną, gdzie można umieścić wskaźnik do prywatnych danych na potrzeby rozwiązywania nazwy
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
932 * - \c "const char *name" &mdash; nazwa serwera do rozwiązania
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
933 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
934 * Parametry funkcji zwalniającej zasoby wyglądają następująco:
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
935 * - \c "void **priv_data" &mdash; wskaźnik na zmienną przechowującą wskaźnik do prywatnych danych, należy go ustawić na \c NULL po zakończeniu
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
936 * - \c "int force" &mdash; flaga mówiąca o tym, że zasoby są zwalniane przed zakończeniem rozwiązywania nazwy, np. z powodu zamknięcia sesji.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
937 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
938 * Własny kod rozwiązywania nazwy powinien stworzyć potok, parę gniazd lub
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
939 * inny deskryptor pozwalający na co najmniej jednostronną komunikację i
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
940 * przekazać go w parametrze \c fd. Po zakończeniu rozwiązywania nazwy,
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
941 * powinien wysłać otrzymany adres IP w postaci sieciowej (big-endian) do
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
942 * deskryptora. Jeśli rozwiązywanie nazwy się nie powiedzie, należy wysłać
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
943 * \c INADDR_NONE. Następnie zostanie wywołana funkcja zwalniająca zasoby
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
944 * z parametrem \c force równym \c 0. Gdyby sesja została zakończona przed
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
945 * rozwiązaniem nazwy, np. za pomocą funkcji \c gg_logoff(), funkcja
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
946 * zwalniająca zasoby zostanie wywołana z parametrem \c force równym \c 1.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
947 *
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
948 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
949 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
950 int gg_session_set_custom_resolver(struct gg_session *gs, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
951 {
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
952 GG_SESSION_CHECK(gs, -1);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
953
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
954 if (resolver_start == NULL || resolver_cleanup == NULL) {
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
955 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
956 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
957 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
958
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
959 gs->resolver_type = GG_RESOLVER_CUSTOM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
960 gs->resolver_start = resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
961 gs->resolver_cleanup = resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
962
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
963 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
964 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
965
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
966 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
967 * Ustawia sposób rozwiązywania nazw połączenia HTTP.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
968 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
969 * \param gh Struktura połączenia
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
970 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
971 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
972 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
973 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
974 int gg_http_set_resolver(struct gg_http *gh, gg_resolver_t type)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
975 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
976 if (gh == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
977 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
978 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
979 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
980
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
981 if (type == GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
982 if (gg_global_resolver_type != GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
983 gh->resolver_type = gg_global_resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
984 gh->resolver_start = gg_global_resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
985 gh->resolver_cleanup = gg_global_resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
986 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
987 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
988
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
989 #ifdef _WIN32
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
990 type = GG_RESOLVER_WIN32;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
991 #else
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
992 type = GG_RESOLVER_FORK;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
993 #endif
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
994
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
995 #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_PTHREAD_DEFAULT)
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
996 type = GG_RESOLVER_PTHREAD;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
997 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
998 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
999
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1000 switch (type) {
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1001 #ifdef _WIN32
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
1002 case GG_RESOLVER_WIN32:
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1003 gh->resolver_type = type;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1004 gh->resolver_start = gg_resolve_win32thread;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1005 gh->resolver_cleanup = gg_resolve_win32thread_cleanup;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1006 return 0;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1007 #else
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
1008 case GG_RESOLVER_FORK:
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1009 gh->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1010 gh->resolver_start = gg_resolver_fork_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1011 gh->resolver_cleanup = gg_resolver_fork_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1012 return 0;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1013 #endif
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1014
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1015 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1016 case GG_RESOLVER_PTHREAD:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1017 gh->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1018 gh->resolver_start = gg_resolver_pthread_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1019 gh->resolver_cleanup = gg_resolver_pthread_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1020 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1021 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1022
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1023 default:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1024 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1025 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1026 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1027 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1028
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1029 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1030 * Zwraca sposób rozwiązywania nazw połączenia HTTP.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1031 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1032 * \param gh Struktura połączenia
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1033 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1034 * \return Sposób rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1035 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1036 gg_resolver_t gg_http_get_resolver(struct gg_http *gh)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1037 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1038 if (gh == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1039 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1040 return GG_RESOLVER_INVALID;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1041 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1042
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1043 return gh->resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1044 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1045
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1046 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1047 * Ustawia własny sposób rozwiązywania nazw połączenia HTTP.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1048 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1049 * \param gh Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1050 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1051 * \param resolver_cleanup Funkcja zwalniająca zasoby
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1052 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1053 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1054 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1055 int gg_http_set_custom_resolver(struct gg_http *gh, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1056 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1057 if (gh == NULL || resolver_start == NULL || resolver_cleanup == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1058 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1059 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1060 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1061
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1062 gh->resolver_type = GG_RESOLVER_CUSTOM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1063 gh->resolver_start = resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1064 gh->resolver_cleanup = resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1065
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1066 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1067 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1068
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1069 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1070 * Ustawia sposób rozwiązywania nazw globalnie dla biblioteki.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1071 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1072 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1073 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1074 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1075 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1076 int gg_global_set_resolver(gg_resolver_t type)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1077 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1078 switch (type) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1079 case GG_RESOLVER_DEFAULT:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1080 gg_global_resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1081 gg_global_resolver_start = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1082 gg_global_resolver_cleanup = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1083 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1084
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1085 #ifndef _WIN32
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1086 case GG_RESOLVER_FORK:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1087 gg_global_resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1088 gg_global_resolver_start = gg_resolver_fork_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1089 gg_global_resolver_cleanup = gg_resolver_fork_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1090 return 0;
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1091 #endif
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
1092
29544
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1093 #ifdef _WIN32
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1094 case GG_RESOLVER_WIN32:
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1095 gg_global_resolver_type = type;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1096 gg_global_resolver_start = gg_resolve_win32thread;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1097 gg_global_resolver_cleanup = gg_resolve_win32thread_cleanup;
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29539
diff changeset
1098 return 0;
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
1099 #endif
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30190
diff changeset
1100
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1101 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1102 case GG_RESOLVER_PTHREAD:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1103 gg_global_resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1104 gg_global_resolver_start = gg_resolver_pthread_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1105 gg_global_resolver_cleanup = gg_resolver_pthread_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1106 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1107 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1108
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1109 default:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1110 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1111 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1112 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1113 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1114
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1115 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1116 * Zwraca sposób rozwiązywania nazw globalnie dla biblioteki.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1117 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1118 * \return Sposób rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1119 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1120 gg_resolver_t gg_global_get_resolver(void)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1121 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1122 return gg_global_resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1123 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1124
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1125 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1126 * Ustawia własny sposób rozwiązywania nazw globalnie dla biblioteki.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1127 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1128 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1129 * \param resolver_cleanup Funkcja zwalniająca zasoby
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1130 *
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31086
diff changeset
1131 * Patrz \ref gg_session_set_custom_resolver.
29538
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1132 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1133 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1134 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1135 int gg_global_set_custom_resolver(int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1136 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1137 if (resolver_start == NULL || resolver_cleanup == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1138 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1139 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1140 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1141
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1142 gg_global_resolver_type = GG_RESOLVER_CUSTOM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1143 gg_global_resolver_start = resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1144 gg_global_resolver_cleanup = resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1145
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1146 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1147 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1148