Mercurial > pidgin.yaz
annotate libpurple/protocols/gg/lib/resolver.c @ 32744:b8646c6ae19a
Gadu-Gadu: more debug messages for win32thread resolver.
author | tomkiewicz@cpw.pidgin.im |
---|---|
date | Fri, 14 Oct 2011 19:24:43 +0000 |
parents | 84f72590a319 |
children | 326591e64aaa |
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 |
32127
84f72590a319
Fixed some warnings when compiling Gadu-Gadu prpl under Windows.
tomkiewicz@cpw.pidgin.im
parents:
32072
diff
changeset
|
252 #if defined(GG_CONFIG_HAVE_PTHREAD) || !defined(_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
|
253 /** |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
254 * \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
|
255 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
256 * \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
|
257 * \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
|
258 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
259 * \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
|
260 */ |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
261 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
|
262 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
263 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
|
264 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
|
265 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
|
266 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
267 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
|
268 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
269 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
|
270 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
|
271 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
|
272 /* 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
|
273 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
274 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
275 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
|
276 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
|
277 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
|
278 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
279 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
280 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
|
281 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
282 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
|
283 res = -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
284 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
285 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
|
286 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
|
287 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
288 return res; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
289 } |
32127
84f72590a319
Fixed some warnings when compiling Gadu-Gadu prpl under Windows.
tomkiewicz@cpw.pidgin.im
parents:
32072
diff
changeset
|
290 #endif |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
291 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
292 /** |
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
|
293 * \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
|
294 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
295 * 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
|
296 * 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
|
297 * 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
|
298 * 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
|
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 * \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
|
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 * \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
|
303 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
304 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
|
305 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
306 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
|
307 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
|
308 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
309 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
|
310 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
|
311 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
312 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
|
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 |
6359fde67f4c
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 * \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
|
317 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
318 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
|
319 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
|
320 }; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
321 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
322 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
323 /** |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
324 * 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
|
325 * 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
|
326 * |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
327 * -This is thanks to Tor Lillqvist. |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
328 * 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
|
329 */ |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
330 static int |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
331 socket_pipe (int *fds) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
332 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
333 SOCKET temp, socket1 = -1, socket2 = -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
334 struct sockaddr_in saddr; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
335 int len; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
336 u_long arg; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
337 fd_set read_set, write_set; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
338 struct timeval tv; |
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 temp = socket(AF_INET, SOCK_STREAM, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
341 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
342 if (temp == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
343 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
344 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
345 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
346 arg = 1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
347 if (ioctlsocket(temp, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
348 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
349 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
350 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
351 memset(&saddr, 0, sizeof(saddr)); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
352 saddr.sin_family = AF_INET; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
353 saddr.sin_port = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
354 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
|
355 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
356 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
|
357 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
358 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
359 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
360 if (listen(temp, 1) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
361 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
362 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
363 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
364 len = sizeof(saddr); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
365 if (getsockname(temp, (struct sockaddr *)&saddr, &len)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
366 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
367 } |
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 socket1 = socket(AF_INET, SOCK_STREAM, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
370 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
371 if (socket1 == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
372 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
373 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
374 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
375 arg = 1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
376 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
377 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
378 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
379 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
380 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
|
381 WSAGetLastError() != WSAEWOULDBLOCK) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
382 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
383 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
384 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
385 FD_ZERO(&read_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
386 FD_SET(temp, &read_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
387 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
388 tv.tv_sec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
389 tv.tv_usec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
390 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
391 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
|
392 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
393 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
394 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
395 if (!FD_ISSET(temp, &read_set)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
396 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
397 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
398 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
399 socket2 = accept(temp, (struct sockaddr *) &saddr, &len); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
400 if (socket2 == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
401 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
402 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
403 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
404 FD_ZERO(&write_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
405 FD_SET(socket1, &write_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
406 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
407 tv.tv_sec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
408 tv.tv_usec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
409 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
410 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
|
411 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
412 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
413 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
414 if (!FD_ISSET(socket1, &write_set)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
415 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
416 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
417 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
418 arg = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
419 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
420 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
421 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
422 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
423 arg = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
424 if (ioctlsocket(socket2, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
425 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
426 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
427 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
428 fds[0] = socket1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
429 fds[1] = socket2; |
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 closesocket (temp); |
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 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
434 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
435 out2: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
436 closesocket (socket2); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
437 out1: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
438 closesocket (socket1); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
439 out0: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
440 closesocket (temp); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
441 errno = EIO; /* XXX */ |
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 return -1; |
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 #endif |
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 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
448 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
449 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
450 struct gg_resolve_win32thread_data { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
451 char *hostname; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
452 int fd; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
453 }; |
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 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
|
456 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
457 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
|
458 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
|
459 int addr_count; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
460 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
461 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
|
462 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
463 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
|
464 /* 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
|
465 * 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
|
466 * 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
|
467 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
|
468 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
469 addr_list = addr_ip; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
470 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
471 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
472 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
|
473 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
|
474 addr_count = 1; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
475 } |
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 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
|
478 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
479 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
|
480 close(d->fd); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
481 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
482 free(d->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
483 d->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
484 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
485 free(d); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
486 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
487 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
|
488 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
|
489 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
490 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
|
491 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
492 return 0; |
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 |
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 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
|
497 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
498 struct gg_resolve_win32thread_data *d = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
499 HANDLE h; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
500 DWORD dwTId; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
501 int pipes[2], new_errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
502 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
503 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
|
504 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
505 if (!resolver || !fd || !hostname) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
506 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
|
507 errno = EFAULT; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
508 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
509 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
510 |
32744
b8646c6ae19a
Gadu-Gadu: more debug messages for win32thread resolver.
tomkiewicz@cpw.pidgin.im
parents:
32127
diff
changeset
|
511 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() creating pipes...\n"); |
b8646c6ae19a
Gadu-Gadu: more debug messages for win32thread resolver.
tomkiewicz@cpw.pidgin.im
parents:
32127
diff
changeset
|
512 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
513 if (socket_pipe(pipes) == -1) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
514 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
|
515 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
516 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
517 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
518 if (!(d = malloc(sizeof(*d)))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
519 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
|
520 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
521 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
522 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
523 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
524 d->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
525 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
526 if (!(d->hostname = strdup(hostname))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
527 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
|
528 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
529 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
530 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
531 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
532 d->fd = pipes[1]; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
533 |
32744
b8646c6ae19a
Gadu-Gadu: more debug messages for win32thread resolver.
tomkiewicz@cpw.pidgin.im
parents:
32127
diff
changeset
|
534 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() creating thread...\n"); |
b8646c6ae19a
Gadu-Gadu: more debug messages for win32thread resolver.
tomkiewicz@cpw.pidgin.im
parents:
32127
diff
changeset
|
535 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
536 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
|
537 d, 0, &dwTId); |
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 if (h == NULL) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
540 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
|
541 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
542 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
543 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
544 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
545 *resolver = h; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
546 *fd = pipes[0]; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
547 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
548 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() done\n"); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
549 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
550 return 0; |
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 cleanup: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
553 if (d) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
554 free(d->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
555 free(d); |
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 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
558 close(pipes[0]); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
559 close(pipes[1]); |
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 errno = new_errno; |
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 return -1; |
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 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
566 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
567 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
|
568 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
569 struct gg_resolve_win32thread_data *data; |
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 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
|
572 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
573 if (priv_data == NULL || *priv_data == NULL) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
574 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
|
575 return; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
576 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
577 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
|
578 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
|
579 *priv_data = NULL; |
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 if (force) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
582 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
|
583 //pthread_cancel(data->thread); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
584 //pthread_join(data->thread, NULL); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
585 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
586 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
587 free(data->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
588 data->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
589 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
590 if (data->fd != -1) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
591 close(data->fd); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
592 data->fd = -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
593 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
594 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
|
595 free(data); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
596 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
597 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
598 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
599 #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
|
600 /** |
6359fde67f4c
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 * \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
|
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 * 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
|
604 * 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
|
605 * 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
|
606 * 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
|
607 * \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
|
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 * \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
|
610 * 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
|
611 * \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
|
612 * 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
|
613 * \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
|
614 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
615 * \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
|
616 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
617 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
|
618 { |
6359fde67f4c
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 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
|
620 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
|
621 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 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
|
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 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
|
625 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
|
626 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
|
627 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 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
|
631 |
6359fde67f4c
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 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
|
633 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
|
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 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
|
638 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
|
639 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
|
640 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
|
641 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
643 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
|
644 |
6359fde67f4c
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 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
|
646 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
|
647 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
|
648 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
649 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
650 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
|
651 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
|
652 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
653 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
|
654 _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
|
655 else |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
656 _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
|
657 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
658 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
659 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
|
660 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
661 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
|
662 |
6359fde67f4c
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 *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
|
664 *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
|
665 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
666 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
|
667 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 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
|
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 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
|
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 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
|
676 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
677 |
6359fde67f4c
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 /** |
6359fde67f4c
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 * \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
|
680 * |
6359fde67f4c
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 * 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
|
682 * 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
|
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 * \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
|
685 * 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
|
686 * \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
|
687 */ |
30101
eb8b1cfd3349
Silence some gadu-gadu warnings
Paul Aurich <paul@darkrain42.org>
parents:
29944
diff
changeset
|
688 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
|
689 { |
6359fde67f4c
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 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
|
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 (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
|
693 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
|
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 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
|
696 *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
|
697 |
6359fde67f4c
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 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
|
699 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
|
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 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
|
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 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
|
704 } |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
705 #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
|
706 |
6359fde67f4c
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 #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
|
708 |
6359fde67f4c
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 /** |
6359fde67f4c
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 * \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
|
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 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 }; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
718 |
6359fde67f4c
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 /** |
6359fde67f4c
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 * \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
|
721 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
722 * 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
|
723 * 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
|
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 * \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
|
726 * 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
|
727 * \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
|
728 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
729 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
|
730 { |
6359fde67f4c
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 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
|
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 (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
|
734 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
|
735 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
736 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
|
737 *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
|
738 |
6359fde67f4c
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 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
|
740 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
|
741 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
|
742 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
743 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
744 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
|
745 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
|
746 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
747 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
|
748 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
|
749 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
|
750 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
751 |
6359fde67f4c
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 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
|
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 |
6359fde67f4c
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 * \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
|
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 * \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
|
759 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
760 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
|
761 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
762 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
|
763 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
764 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
|
765 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
766 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
|
767 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
|
768 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
|
769 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
|
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 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
|
772 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
773 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
774 /** |
6359fde67f4c
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 * \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
|
776 * |
6359fde67f4c
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 * 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
|
778 * ż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
|
779 * 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
|
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 * \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
|
782 * 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
|
783 * \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
|
784 * 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
|
785 * \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
|
786 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
787 * \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
|
788 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
789 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
|
790 { |
6359fde67f4c
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 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
|
792 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
|
793 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
794 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
|
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 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
|
797 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
|
798 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
|
799 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
800 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
801 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
802 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
|
803 |
6359fde67f4c
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 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
|
805 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
|
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 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
|
810 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
|
811 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
|
812 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
|
813 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
814 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
815 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
|
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 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
|
818 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
|
819 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
|
820 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
|
821 } |
6359fde67f4c
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 |
6359fde67f4c
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 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
|
824 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
|
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 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
|
827 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
|
828 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
|
829 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
|
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 |
6359fde67f4c
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 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
|
833 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
834 *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
|
835 *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
|
836 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
837 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
|
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 cleanup: |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
840 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
|
841 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
|
842 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
843 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
|
844 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
845 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
|
846 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
|
847 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
848 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
|
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 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
|
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 |
6359fde67f4c
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 #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
|
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 /** |
6359fde67f4c
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 * 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
|
857 * |
6359fde67f4c
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 * \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
|
859 * \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
|
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 * \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
|
862 */ |
6359fde67f4c
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 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
|
864 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
865 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
|
866 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
867 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
|
868 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
|
869 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
|
870 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
|
871 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
|
872 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
|
873 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
874 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
875 #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
|
876 # ifdef _WIN32 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
877 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
|
878 # 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
|
879 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
|
880 # endif |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
881 #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
|
882 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
|
883 #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
|
884 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
885 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
886 switch (type) { |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
887 #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
|
888 case GG_RESOLVER_WIN32: |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
889 gs->resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
890 gs->resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
891 gs->resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
892 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
893 #else |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
894 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
|
895 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
|
896 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
|
897 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
|
898 return 0; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
899 #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
|
900 |
6359fde67f4c
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 #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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 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
|
907 #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
|
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 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
|
910 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
|
911 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
|
912 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
913 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
914 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
915 /** |
6359fde67f4c
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 * 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
|
917 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
918 * \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
|
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 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
|
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 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
|
923 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
924 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
|
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 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
|
927 } |
6359fde67f4c
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 |
6359fde67f4c
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 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
930 * 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
|
931 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
932 * \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
|
933 * \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
|
934 * \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
|
935 * |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
936 * 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
|
937 * - \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
|
938 * - \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
|
939 * - \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
|
940 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
941 * 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
|
942 * - \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
|
943 * - \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
|
944 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
945 * 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
|
946 * 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
|
947 * 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
|
948 * 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
|
949 * 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
|
950 * \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
|
951 * 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
|
952 * 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
|
953 * 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
|
954 * |
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
|
955 * \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
|
956 */ |
6359fde67f4c
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 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
|
958 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
959 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
|
960 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
961 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
|
962 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
|
963 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
|
964 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
965 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
966 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
|
967 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
|
968 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
|
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 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
|
971 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
972 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
973 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
974 * 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
|
975 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
976 * \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
|
977 * \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
|
978 * |
6359fde67f4c
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 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
|
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 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
|
982 { |
6359fde67f4c
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 (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
|
984 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
|
985 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
|
986 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
987 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
988 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
|
989 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
|
990 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
|
991 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
|
992 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
|
993 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
|
994 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
995 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
996 #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
|
997 # ifdef _WIN32 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
998 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
|
999 # 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
|
1000 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
|
1001 # endif |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1002 #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
|
1003 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
|
1004 #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
|
1005 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1006 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1007 switch (type) { |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1008 #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
|
1009 case GG_RESOLVER_WIN32: |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1010 gh->resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1011 gh->resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1012 gh->resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1013 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1014 #else |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1015 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
|
1016 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
|
1017 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
|
1018 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
|
1019 return 0; |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1020 #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
|
1021 |
6359fde67f4c
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 #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
|
1023 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 #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
|
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 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
|
1031 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
|
1032 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
|
1033 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1034 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1035 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1036 /** |
6359fde67f4c
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 * 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
|
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 * \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
|
1040 * |
6359fde67f4c
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 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
|
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 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
|
1044 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1045 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
|
1046 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
|
1047 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
|
1048 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1049 |
6359fde67f4c
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 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
|
1051 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1052 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1053 /** |
6359fde67f4c
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 * 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
|
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 * \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
|
1057 * \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
|
1058 * \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
|
1059 * |
6359fde67f4c
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 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
|
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 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
|
1063 { |
6359fde67f4c
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 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
|
1065 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
|
1066 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
|
1067 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1068 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1069 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
|
1070 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
|
1071 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
|
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 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
|
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 |
6359fde67f4c
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 * 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
|
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 * \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
|
1080 * |
6359fde67f4c
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 * \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
|
1082 */ |
6359fde67f4c
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 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
|
1084 { |
6359fde67f4c
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 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
|
1086 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
|
1087 gg_global_resolver_type = type; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1088 gg_global_resolver_start = 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
|
1089 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
|
1090 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
|
1091 |
29944
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1092 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1093 case GG_RESOLVER_WIN32: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1094 gg_global_resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1095 gg_global_resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29939
diff
changeset
|
1096 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
|
1097 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
|
1098 #else |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 return 0; |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
1104 #endif |
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30616
diff
changeset
|
1105 |
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
|
1106 #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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 #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
|
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 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
|
1115 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
|
1116 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
|
1117 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1118 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1119 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1120 /** |
6359fde67f4c
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 * 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
|
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 * \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
|
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 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
|
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 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
|
1128 } |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1130 /** |
6359fde67f4c
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 * 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
|
1132 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1133 * \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
|
1134 * \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
|
1135 * |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1136 * 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
|
1137 * |
6359fde67f4c
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 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
|
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 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
|
1141 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1142 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
|
1143 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
|
1144 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
|
1145 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1146 |
6359fde67f4c
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 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
|
1148 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
|
1149 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
|
1150 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1151 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
|
1152 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1153 |