Mercurial > pidgin.yaz
annotate libpurple/protocols/gg/lib/resolver.c @ 32072:3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Fixes 14248
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Sun, 05 Jun 2011 01:28:53 +0000 |
parents | 93b08d43f684 |
children | 84f72590a319 |
rev | line source |
---|---|
29938
6359fde67f4c
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 |
29939
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
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:
29938
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:
29938
diff
changeset
|
31 # include <netdb.h> |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
32 #endif |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
33 #include <errno.h> |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
34 #include <stdlib.h> |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
35 #include <string.h> |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
36 #include <unistd.h> |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
37 #ifndef _WIN32 |
29939
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
38 # 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:
29938
diff
changeset
|
39 # 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:
29938
diff
changeset
|
40 # 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:
29938
diff
changeset
|
41 #endif |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
42 |
29938
6359fde67f4c
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 "libgadu.h" |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
44 #include "libgadu-config.h" |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 #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
|
46 #include "compat.h" |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
47 #include "session.h" |
29938
6359fde67f4c
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 |
6359fde67f4c
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 /** 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
|
50 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
|
51 |
6359fde67f4c
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 /** 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
|
53 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
|
54 |
6359fde67f4c
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 /** 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
|
56 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
|
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 #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
|
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 #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
|
61 |
6359fde67f4c
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 /** |
6359fde67f4c
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 * \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
|
64 * 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 * \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
|
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 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
|
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 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
|
71 |
6359fde67f4c
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 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
|
73 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
|
74 *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
|
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 } |
6359fde67f4c
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 #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
|
79 |
6359fde67f4c
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 * \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
|
82 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
84 * 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:
31534
diff
changeset
|
85 * wartością INADDR_NONE, którą należy zwolnić po użyciu. |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 * \param hostname Nazwa serwera |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
88 * \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:
31534
diff
changeset
|
89 * \param count Wskaźnik na zmienną, do ktorej zapisze się liczbę wyników |
29938
6359fde67f4c
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 * \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
|
91 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 * \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
|
93 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
94 int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *count, int pthread) |
29938
6359fde67f4c
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 { |
6359fde67f4c
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 #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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 size_t buf_len = 1024; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
102 int res = -1; |
29938
6359fde67f4c
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 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
|
104 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
|
105 #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
|
106 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
|
107 #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
|
108 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
109 if (result == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
110 errno = EINVAL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
111 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
112 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
113 |
29938
6359fde67f4c
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 #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
|
115 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
|
116 |
6359fde67f4c
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 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
|
118 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
|
119 #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
|
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 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
|
122 |
6359fde67f4c
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 #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
|
124 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
|
125 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
|
126 #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
|
127 |
6359fde67f4c
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 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
|
129 #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
|
130 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
|
131 #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
|
132 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
|
133 #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
|
134 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
|
135 |
6359fde67f4c
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 #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
|
137 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
|
138 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
|
139 #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
|
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 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
|
142 |
6359fde67f4c
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 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
|
144 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
|
145 |
6359fde67f4c
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 #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
|
147 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
|
148 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
|
149 #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
|
150 |
6359fde67f4c
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 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
|
152 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
|
153 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
|
154 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
155 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
156 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
157 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:
31534
diff
changeset
|
158 int i; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
159 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
160 /* Policz liczbę adresów */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
161 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
162 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:
31534
diff
changeset
|
163 ; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
164 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
165 /* Zaalokuj */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
166 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
167 #ifdef GG_CONFIG_HAVE_PTHREAD |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
168 if (pthread) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
169 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:
31534
diff
changeset
|
170 #endif |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
171 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
172 *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:
31534
diff
changeset
|
173 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
174 #ifdef GG_CONFIG_HAVE_PTHREAD |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
175 if (pthread) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
176 pthread_setcancelstate(old_state, NULL); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
177 #endif |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
178 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
179 if (*result == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
180 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
181 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
182 /* Kopiuj */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
183 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
184 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:
31534
diff
changeset
|
185 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:
31534
diff
changeset
|
186 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
187 (*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:
31534
diff
changeset
|
188 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
189 *count = i; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
190 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
191 res = 0; |
29938
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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 #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
|
195 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
|
196 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
|
197 #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
|
198 |
6359fde67f4c
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 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
|
200 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
|
201 |
6359fde67f4c
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 #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
|
203 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
|
204 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
|
205 #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
|
206 } |
6359fde67f4c
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 |
6359fde67f4c
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 #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
|
209 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
|
210 #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
|
211 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
212 return res; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
213 #else /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */ |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 struct hostent *he; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
215 int i; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
216 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
217 if (result == NULL || count == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
218 errno = EINVAL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
219 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
220 } |
29938
6359fde67f4c
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 |
6359fde67f4c
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 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
|
223 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
224 if (he == NULL || he->h_addr_list[0] == NULL) |
29938
6359fde67f4c
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 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
|
226 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
227 /* Policz liczbę adresów */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
228 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
229 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:
31534
diff
changeset
|
230 ; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
231 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
232 /* Zaalokuj */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
233 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
234 *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:
31534
diff
changeset
|
235 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
236 if (*result == NULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
237 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
238 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
239 /* Kopiuj */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
240 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
241 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:
31534
diff
changeset
|
242 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:
31534
diff
changeset
|
243 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
244 (*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:
31534
diff
changeset
|
245 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
246 *count = i; |
29938
6359fde67f4c
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 |
6359fde67f4c
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 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
|
249 #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
|
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
252 /** |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
253 * \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:
31534
diff
changeset
|
254 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
255 * \param fd Deskryptor |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
256 * \param hostname Nazwa serwera |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
257 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
258 * \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:
31534
diff
changeset
|
259 */ |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
260 static int gg_resolver_run(int fd, const char *hostname) |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
261 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
262 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:
31534
diff
changeset
|
263 int addr_count; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
264 int res = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
265 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
266 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:
31534
diff
changeset
|
267 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
268 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:
31534
diff
changeset
|
269 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:
31534
diff
changeset
|
270 addr_list = addr_ip; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
271 /* 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:
31534
diff
changeset
|
272 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
273 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
274 addr_list = addr_ip; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
275 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:
31534
diff
changeset
|
276 addr_count = 1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
277 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
278 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
279 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:
31534
diff
changeset
|
280 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
281 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:
31534
diff
changeset
|
282 res = -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
283 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
284 if (addr_list != addr_ip) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
285 free(addr_list); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
286 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
287 return res; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
288 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
289 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
290 /** |
29938
6359fde67f4c
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 * \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
|
292 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
293 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
294 * 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:
31534
diff
changeset
|
295 * 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:
31534
diff
changeset
|
296 * zostać zignorowane przez aplikację. |
29938
6359fde67f4c
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 * |
6359fde67f4c
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 * \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
|
299 * |
6359fde67f4c
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 * \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
|
301 */ |
6359fde67f4c
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 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
|
303 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
304 struct in_addr *result; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
305 int count; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
306 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
307 if (gg_gethostbyname_real(hostname, &result, &count, 0) == -1) |
29938
6359fde67f4c
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 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
|
309 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
310 return result; |
29938
6359fde67f4c
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 /** |
6359fde67f4c
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 * \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
|
315 */ |
6359fde67f4c
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 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
|
317 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
|
318 }; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
319 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
320 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
321 /** |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
322 * 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:
29939
diff
changeset
|
323 * 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:
29939
diff
changeset
|
324 * |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
325 * -This is thanks to Tor Lillqvist. |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
326 * 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:
29939
diff
changeset
|
327 */ |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
328 static int |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
329 socket_pipe (int *fds) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
330 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
331 SOCKET temp, socket1 = -1, socket2 = -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
332 struct sockaddr_in saddr; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
333 int len; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
334 u_long arg; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
335 fd_set read_set, write_set; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
336 struct timeval tv; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
337 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
338 temp = socket(AF_INET, SOCK_STREAM, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
339 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
340 if (temp == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
341 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
342 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
343 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
344 arg = 1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
345 if (ioctlsocket(temp, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
346 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
347 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
348 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
349 memset(&saddr, 0, sizeof(saddr)); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
350 saddr.sin_family = AF_INET; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
351 saddr.sin_port = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
352 saddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
353 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
354 if (bind(temp, (struct sockaddr *)&saddr, sizeof (saddr))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
355 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
356 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
357 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
358 if (listen(temp, 1) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
359 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
360 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
361 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
362 len = sizeof(saddr); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
363 if (getsockname(temp, (struct sockaddr *)&saddr, &len)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
364 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
365 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
366 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
367 socket1 = socket(AF_INET, SOCK_STREAM, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
368 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
369 if (socket1 == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
370 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
371 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
372 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
373 arg = 1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
374 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
375 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
376 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
377 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
378 if (connect(socket1, (struct sockaddr *)&saddr, len) != SOCKET_ERROR || |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
379 WSAGetLastError() != WSAEWOULDBLOCK) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
380 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
381 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
382 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
383 FD_ZERO(&read_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
384 FD_SET(temp, &read_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
385 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
386 tv.tv_sec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
387 tv.tv_usec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
388 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
389 if (select(0, &read_set, NULL, NULL, NULL) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
390 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
391 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
392 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
393 if (!FD_ISSET(temp, &read_set)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
394 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
395 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
396 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
397 socket2 = accept(temp, (struct sockaddr *) &saddr, &len); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
398 if (socket2 == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
399 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
400 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
401 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
402 FD_ZERO(&write_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
403 FD_SET(socket1, &write_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
404 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
405 tv.tv_sec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
406 tv.tv_usec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
407 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
408 if (select(0, NULL, &write_set, NULL, NULL) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
409 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
410 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
411 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
412 if (!FD_ISSET(socket1, &write_set)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
413 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
414 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
415 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
416 arg = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
417 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
418 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
419 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
420 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
421 arg = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
422 if (ioctlsocket(socket2, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
423 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
424 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
425 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
426 fds[0] = socket1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
427 fds[1] = socket2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
428 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
429 closesocket (temp); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
430 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
431 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
432 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
433 out2: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
434 closesocket (socket2); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
435 out1: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
436 closesocket (socket1); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
437 out0: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
438 closesocket (temp); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
439 errno = EIO; /* XXX */ |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
440 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
441 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
442 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
443 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
444 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
445 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
446 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
447 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
448 struct gg_resolve_win32thread_data { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
449 char *hostname; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
450 int fd; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
451 }; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
452 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
453 static DWORD WINAPI gg_resolve_win32thread_thread(LPVOID arg) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
454 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
455 struct gg_resolve_win32thread_data *d = arg; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
456 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:
31534
diff
changeset
|
457 int addr_count; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
458 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
459 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() host: %s, fd: %i called\n", d->hostname, d->fd); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
460 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
461 if ((addr_ip[0].s_addr = inet_addr(d->hostname)) == INADDR_NONE) { |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
462 /* W przypadku błędu gg_gethostbyname_real() zwróci -1 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
463 * i nie zmieni &addr. Tam jest już INADDR_NONE, |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
464 * więc nie musimy robić nic więcej. */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
465 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:
31534
diff
changeset
|
466 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
467 addr_list = addr_ip; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
468 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
469 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
470 addr_list = addr_ip; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
471 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:
31534
diff
changeset
|
472 addr_count = 1; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
473 } |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
474 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
475 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() count = %d\n", addr_count); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
476 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
477 write(d->fd, addr_list, (addr_count+1) * sizeof(struct in_addr)); |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
478 close(d->fd); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
479 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
480 free(d->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
481 d->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
482 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
483 free(d); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
484 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
485 if (addr_list != addr_ip) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
486 free(addr_list); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
487 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
488 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() done\n"); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
489 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
490 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
491 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
492 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
493 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
494 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:
29939
diff
changeset
|
495 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
496 struct gg_resolve_win32thread_data *d = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
497 HANDLE h; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
498 DWORD dwTId; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
499 int pipes[2], new_errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
500 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
501 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolve_win32thread(%p, %p, \"%s\");\n", fd, resolver, hostname); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
502 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
503 if (!resolver || !fd || !hostname) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
504 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:
29939
diff
changeset
|
505 errno = EFAULT; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
506 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
507 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
508 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
509 if (socket_pipe(pipes) == -1) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
510 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:
29939
diff
changeset
|
511 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
512 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
513 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
514 if (!(d = malloc(sizeof(*d)))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
515 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:
29939
diff
changeset
|
516 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
517 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
518 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
519 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
520 d->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
521 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
522 if (!(d->hostname = strdup(hostname))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
523 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:
29939
diff
changeset
|
524 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
525 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
526 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
527 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
528 d->fd = pipes[1]; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
529 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
530 h = CreateThread(NULL, 0, gg_resolve_win32thread_thread, |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
531 d, 0, &dwTId); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
532 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
533 if (h == NULL) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
534 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:
29939
diff
changeset
|
535 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
536 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
537 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
538 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
539 *resolver = h; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
540 *fd = pipes[0]; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
541 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
542 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() done\n"); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
543 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
544 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
545 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
546 cleanup: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
547 if (d) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
548 free(d->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
549 free(d); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
550 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
551 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
552 close(pipes[0]); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
553 close(pipes[1]); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
554 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
555 errno = new_errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
556 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
557 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
558 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
559 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
560 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
561 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:
29939
diff
changeset
|
562 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
563 struct gg_resolve_win32thread_data *data; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
564 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
565 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() force: %i called\n", force); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
566 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
567 if (priv_data == NULL || *priv_data == NULL) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
568 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:
29939
diff
changeset
|
569 return; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
570 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
571 data = (struct gg_resolve_win32thread_data*) *priv_data; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
572 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:
29939
diff
changeset
|
573 *priv_data = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
574 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
575 if (force) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
576 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:
29939
diff
changeset
|
577 //pthread_cancel(data->thread); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
578 //pthread_join(data->thread, NULL); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
579 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
580 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
581 free(data->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
582 data->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
583 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
584 if (data->fd != -1) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
585 close(data->fd); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
586 data->fd = -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
587 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
588 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:
29939
diff
changeset
|
589 free(data); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
590 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
591 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
592 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
593 #ifndef _WIN32 |
29938
6359fde67f4c
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 /** |
6359fde67f4c
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 * \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
|
596 * |
6359fde67f4c
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 * 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
|
598 * nazwy serwera. W tym celu tworzony jest potok, nowy proces i dopiero w nim |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
599 * przeprowadzane jest rozwiązywanie nazwy. Deskryptor strony do odczytu |
29938
6359fde67f4c
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 * 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
|
601 * \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
|
602 * |
6359fde67f4c
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 * \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
|
604 * 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
|
605 * \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
|
606 * 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
|
607 * \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
|
608 * |
6359fde67f4c
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 * \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
|
610 */ |
6359fde67f4c
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 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
|
612 { |
6359fde67f4c
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 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
|
614 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
|
615 |
6359fde67f4c
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 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
|
617 |
6359fde67f4c
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 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
|
619 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
|
620 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
|
621 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
|
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 |
6359fde67f4c
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 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
|
625 |
6359fde67f4c
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 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
|
627 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
|
628 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
|
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 |
6359fde67f4c
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 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
|
632 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
|
633 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
|
634 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
|
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 |
6359fde67f4c
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 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
|
638 |
6359fde67f4c
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 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
|
640 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
|
641 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
|
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 |
6359fde67f4c
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 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
|
645 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
|
646 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
647 if (gg_resolver_run(pipes[1], hostname) == -1) |
30616
e4c57ecc54ee
gg: s/exit/_exit/ in the resolver fork() code
Paul Aurich <paul@darkrain42.org>
parents:
30101
diff
changeset
|
648 _exit(1); |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
649 else |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
650 _exit(0); |
29938
6359fde67f4c
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 |
6359fde67f4c
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 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
|
654 |
6359fde67f4c
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 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
|
656 |
6359fde67f4c
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 *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
|
658 *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
|
659 |
6359fde67f4c
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 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
|
661 |
6359fde67f4c
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 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
|
663 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
|
664 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
|
665 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
|
666 |
6359fde67f4c
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 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
|
668 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * \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
|
674 * |
6359fde67f4c
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 * 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
|
676 * 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
|
677 * |
6359fde67f4c
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 * \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
|
679 * 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
|
680 * \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
|
681 */ |
30101
eb8b1cfd3349
Silence some gadu-gadu warnings
Paul Aurich <paul@darkrain42.org>
parents:
29944
diff
changeset
|
682 static void gg_resolver_fork_cleanup(void **priv_data, int force) |
29938
6359fde67f4c
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 { |
6359fde67f4c
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 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
|
685 |
6359fde67f4c
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 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
|
687 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
|
688 |
6359fde67f4c
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 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
|
690 *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
|
691 |
6359fde67f4c
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 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
|
693 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
|
694 |
6359fde67f4c
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 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
|
696 |
6359fde67f4c
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 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
|
698 } |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
699 #endif |
29938
6359fde67f4c
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 |
6359fde67f4c
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 #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
|
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 /** |
6359fde67f4c
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 * \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
|
705 */ |
6359fde67f4c
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 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
|
707 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
|
708 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
|
709 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
|
710 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
|
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 /** |
6359fde67f4c
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 * \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
|
715 * |
6359fde67f4c
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 * 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
|
717 * 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
|
718 * |
6359fde67f4c
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 * \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
|
720 * 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
|
721 * \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
|
722 */ |
6359fde67f4c
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 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
|
724 { |
6359fde67f4c
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 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
|
726 |
6359fde67f4c
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 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
|
728 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
|
729 |
6359fde67f4c
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 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
|
731 *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
|
732 |
6359fde67f4c
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 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
|
734 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
|
735 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
|
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 |
6359fde67f4c
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 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
|
739 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
|
740 |
6359fde67f4c
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 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
|
742 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
|
743 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
|
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 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * \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
|
751 * |
6359fde67f4c
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 * \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
|
753 */ |
6359fde67f4c
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 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
|
755 { |
6359fde67f4c
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 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
|
757 |
6359fde67f4c
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 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
|
759 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
760 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:
31534
diff
changeset
|
761 pthread_exit((void*) -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
762 else |
29938
6359fde67f4c
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 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
|
764 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * \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
|
770 * |
6359fde67f4c
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 * 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
|
772 * ż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
|
773 * 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
|
774 * |
6359fde67f4c
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 * \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
|
776 * 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
|
777 * \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
|
778 * 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
|
779 * \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
|
780 * |
6359fde67f4c
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 * \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
|
782 */ |
6359fde67f4c
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 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
|
784 { |
6359fde67f4c
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 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
|
786 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
|
787 |
6359fde67f4c
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 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
|
789 |
6359fde67f4c
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 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
|
791 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
|
792 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
|
793 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
|
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 |
6359fde67f4c
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 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
|
797 |
6359fde67f4c
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 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
|
799 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
|
800 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
|
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 |
6359fde67f4c
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 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
|
804 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
|
805 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
|
806 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
|
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 |
6359fde67f4c
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 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
|
810 |
6359fde67f4c
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 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
|
812 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
|
813 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
|
814 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
|
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 |
6359fde67f4c
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->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
|
818 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
|
819 |
6359fde67f4c
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 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
|
821 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
|
822 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
|
823 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
|
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 |
6359fde67f4c
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 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
|
827 |
6359fde67f4c
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 *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
|
829 *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
|
830 |
6359fde67f4c
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 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
|
832 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
833 cleanup: |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
834 if (data != NULL) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
835 free(data->hostname); |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
836 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
837 free(data); |
29938
6359fde67f4c
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 |
6359fde67f4c
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[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
|
840 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
|
841 |
6359fde67f4c
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 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
|
843 |
6359fde67f4c
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 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
|
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 |
6359fde67f4c
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 #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
|
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 /** |
6359fde67f4c
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 * 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
|
851 * |
6359fde67f4c
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 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
|
853 * \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
|
854 * |
6359fde67f4c
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 * \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
|
856 */ |
6359fde67f4c
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 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
|
858 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
859 GG_SESSION_CHECK(gs, -1); |
29938
6359fde67f4c
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 |
6359fde67f4c
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 (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 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
868 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
869 #if !defined(GG_CONFIG_HAVE_PTHREAD) || !defined(GG_CONFIG_PTHREAD_DEFAULT) |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
870 # ifdef _WIN32 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
871 type = GG_RESOLVER_WIN32; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
872 # else |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
873 type = GG_RESOLVER_FORK; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
874 # endif |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
875 #else |
29938
6359fde67f4c
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 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
|
877 #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
|
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
880 switch (type) { |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
881 #ifdef _WIN32 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
882 case GG_RESOLVER_WIN32: |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
883 gs->resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
884 gs->resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
885 gs->resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
886 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
887 #else |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
888 case GG_RESOLVER_FORK: |
29938
6359fde67f4c
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_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
|
890 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
|
891 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
|
892 return 0; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
893 #endif |
29938
6359fde67f4c
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 |
6359fde67f4c
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 #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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 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
|
901 #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
|
902 |
6359fde67f4c
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 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
|
904 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
|
905 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
|
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 /** |
6359fde67f4c
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 * 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
|
911 * |
6359fde67f4c
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 * \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
|
913 * |
6359fde67f4c
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 * \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
|
915 */ |
6359fde67f4c
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 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
|
917 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
918 GG_SESSION_CHECK(gs, (gg_resolver_t) -1); |
29938
6359fde67f4c
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 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * 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
|
925 * |
6359fde67f4c
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 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
|
927 * \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
|
928 * \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
|
929 * |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
930 * 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:
31534
diff
changeset
|
931 * - \c "int *fd" — 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:
31534
diff
changeset
|
932 * - \c "void **priv_data" — 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:
31534
diff
changeset
|
933 * - \c "const char *name" — nazwa serwera do rozwiązania |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
934 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
935 * 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:
31534
diff
changeset
|
936 * - \c "void **priv_data" — 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:
31534
diff
changeset
|
937 * - \c "int force" — 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:
31534
diff
changeset
|
938 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
939 * Własny kod rozwiązywania nazwy powinien stworzyć potok, parę gniazd lub |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
940 * inny deskryptor pozwalający na co najmniej jednostronną komunikację i |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
941 * 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:
31534
diff
changeset
|
942 * 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:
31534
diff
changeset
|
943 * 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:
31534
diff
changeset
|
944 * \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:
31534
diff
changeset
|
945 * 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:
31534
diff
changeset
|
946 * 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:
31534
diff
changeset
|
947 * 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:
31534
diff
changeset
|
948 * |
29938
6359fde67f4c
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 * \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
|
950 */ |
6359fde67f4c
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 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
|
952 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
953 GG_SESSION_CHECK(gs, -1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
954 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
955 if (resolver_start == NULL || resolver_cleanup == NULL) { |
29938
6359fde67f4c
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 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
|
957 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
|
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 |
6359fde67f4c
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_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
|
961 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
|
962 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
|
963 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * 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
|
969 * |
6359fde67f4c
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 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
|
971 * \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
|
972 * |
6359fde67f4c
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 * \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
|
974 */ |
6359fde67f4c
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 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
|
976 { |
6359fde67f4c
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 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
|
978 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
|
979 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
|
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 |
6359fde67f4c
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 (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 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
|
984 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
|
985 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
|
986 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
|
987 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
|
988 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
989 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
990 #if !defined(GG_CONFIG_HAVE_PTHREAD) || !defined(GG_CONFIG_PTHREAD_DEFAULT) |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
991 # ifdef _WIN32 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
992 type = GG_RESOLVER_WIN32; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
993 # else |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
994 type = GG_RESOLVER_FORK; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
995 # endif |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
996 #else |
29938
6359fde67f4c
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 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
|
998 #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
|
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1001 switch (type) { |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1002 #ifdef _WIN32 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1003 case GG_RESOLVER_WIN32: |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1004 gh->resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1005 gh->resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1006 gh->resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1007 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1008 #else |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1009 case GG_RESOLVER_FORK: |
29938
6359fde67f4c
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_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
|
1011 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
|
1012 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
|
1013 return 0; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1014 #endif |
29938
6359fde67f4c
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 |
6359fde67f4c
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 #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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 #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
|
1023 |
6359fde67f4c
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 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
|
1025 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
|
1026 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
|
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 /** |
6359fde67f4c
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 * 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
|
1032 * |
6359fde67f4c
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 * \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
|
1034 * |
6359fde67f4c
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 * \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
|
1036 */ |
6359fde67f4c
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 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
|
1038 { |
6359fde67f4c
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 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
|
1040 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
|
1041 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
|
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 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * 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
|
1049 * |
6359fde67f4c
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 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
|
1051 * \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
|
1052 * \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
|
1053 * |
6359fde67f4c
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 * \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
|
1055 */ |
6359fde67f4c
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 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
|
1057 { |
6359fde67f4c
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 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
|
1059 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
|
1060 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
|
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 |
6359fde67f4c
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_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
|
1064 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
|
1065 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
|
1066 |
6359fde67f4c
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 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
|
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 /** |
6359fde67f4c
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 * 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
|
1072 * |
6359fde67f4c
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 * \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
|
1074 * |
6359fde67f4c
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 * \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
|
1076 */ |
6359fde67f4c
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 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
|
1078 { |
6359fde67f4c
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 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
|
1080 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
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1086 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1087 case GG_RESOLVER_WIN32: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1088 gg_global_resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1089 gg_global_resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1090 gg_global_resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1091 return 0; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1092 #else |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1093 case GG_RESOLVER_FORK: |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1094 gg_global_resolver_type = type; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1095 gg_global_resolver_start = gg_resolver_fork_start; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1096 gg_global_resolver_cleanup = gg_resolver_fork_cleanup; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1097 return 0; |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
1098 #endif |
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
1099 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1100 #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
|
1101 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
|
1102 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
|
1103 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
|
1104 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
|
1105 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
|
1106 #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
|
1107 |
6359fde67f4c
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 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
|
1109 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
|
1110 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
|
1111 } |
6359fde67f4c
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 * 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
|
1116 * |
6359fde67f4c
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 * \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
|
1118 */ |
6359fde67f4c
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 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
|
1120 { |
6359fde67f4c
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 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
|
1122 } |
6359fde67f4c
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 * 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
|
1126 * |
6359fde67f4c
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 * \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
|
1128 * \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
|
1129 * |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1130 * Patrz \ref gg_session_set_custom_resolver. |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1131 * |
6359fde67f4c
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 * \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
|
1133 */ |
6359fde67f4c
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 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
|
1135 { |
6359fde67f4c
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 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
|
1137 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
|
1138 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
|
1139 } |
6359fde67f4c
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 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
|
1142 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
|
1143 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
|
1144 |
6359fde67f4c
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 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
|
1146 } |
6359fde67f4c
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 |