libpurple/protocols/gg/lib/resolver.c

Tue, 18 Oct 2011 00:55:59 +0000

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Tue, 18 Oct 2011 00:55:59 +0000
changeset 32675
a8ba546a18bc
parent 32674
2de7f0cebb8b
child 32688
9e137d441acd
permissions
-rw-r--r--

Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343

29751
438f88ecc11e 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 /*
438f88ecc11e 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>
438f88ecc11e 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>
438f88ecc11e 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>
438f88ecc11e 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>
438f88ecc11e 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>
438f88ecc11e 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 *
438f88ecc11e 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
438f88ecc11e 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
438f88ecc11e 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.
438f88ecc11e 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 *
438f88ecc11e 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,
438f88ecc11e 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
438f88ecc11e 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
438f88ecc11e 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.
438f88ecc11e 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 *
438f88ecc11e 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
438f88ecc11e 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
438f88ecc11e 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,
438f88ecc11e 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.
438f88ecc11e 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 */
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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
438f88ecc11e 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 *
438f88ecc11e 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
438f88ecc11e 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 */
438f88ecc11e 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
29752
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
29 #ifndef _WIN32
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
30 # include <sys/wait.h>
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
31 # include <netdb.h>
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
32 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
33 #include <errno.h>
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
34 #include <stdlib.h>
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
35 #include <string.h>
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
36 #include <unistd.h>
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
37 #ifndef _WIN32
29752
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
38 # include <signal.h>
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
39 # include <netinet/in.h>
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
40 # include <arpa/inet.h>
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
41 #endif
5cb6314b2477 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29751
diff changeset
42
29751
438f88ecc11e 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"
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 #include "resolver.h"
438f88ecc11e 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 "compat.h"
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
46 #include "session.h"
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
47
438f88ecc11e 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 /** Sposób rozwiązywania nazw serwerów */
438f88ecc11e 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 static gg_resolver_t gg_global_resolver_type = GG_RESOLVER_DEFAULT;
438f88ecc11e 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
438f88ecc11e 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 /** Funkcja rozpoczynająca rozwiązywanie nazwy */
438f88ecc11e 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 static int (*gg_global_resolver_start)(int *fd, void **private_data, const char *hostname);
438f88ecc11e 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
438f88ecc11e 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 /** Funkcja zwalniająca zasoby po rozwiązaniu nazwy */
438f88ecc11e 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 static void (*gg_global_resolver_cleanup)(void **private_data, int force);
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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
438f88ecc11e 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 #include <pthread.h>
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * \internal Funkcja pomocnicza zwalniająca zasoby po rozwiązywaniu nazwy
438f88ecc11e 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 * w wątku.
438f88ecc11e 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 *
438f88ecc11e 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 * \param data Wskaźnik na wskaźnik bufora zaalokowanego w wątku
438f88ecc11e 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 */
438f88ecc11e 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 static void gg_gethostbyname_cleaner(void *data)
438f88ecc11e 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 {
438f88ecc11e 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 char **buf_ptr = (char**) data;
438f88ecc11e 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
438f88ecc11e 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 if (buf_ptr != NULL) {
438f88ecc11e 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 free(*buf_ptr);
438f88ecc11e 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 *buf_ptr = NULL;
438f88ecc11e 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 }
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 #endif /* GG_CONFIG_HAVE_PTHREAD */
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność.
438f88ecc11e 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 *
438f88ecc11e 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 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
83 * nie, to zwykłej \c gethostbyname. Wynikiem jest tablica adresów zakończona
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
84 * wartością INADDR_NONE, którą należy zwolnić po użyciu.
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
85 *
438f88ecc11e 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 * \param hostname Nazwa serwera
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
87 * \param result Wskaźnik na wskaźnik z tablicą adresów zakończoną INADDR_NONE
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
88 * \param count Wskaźnik na zmienną, do ktorej zapisze się liczbę wyników
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
89 * \param pthread Flaga blokowania unicestwiania wątku podczas alokacji pamięci
438f88ecc11e 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 *
438f88ecc11e 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e 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 */
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
93 int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *count, int pthread)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 {
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_GETHOSTBYNAME_R
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96 char *buf = NULL;
438f88ecc11e 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 *new_buf = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 struct hostent he;
438f88ecc11e 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_ptr = NULL;
438f88ecc11e 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 size_t buf_len = 1024;
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
101 int res = -1;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 int h_errnop;
438f88ecc11e 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 ret = 0;
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 int old_state;
438f88ecc11e 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 #endif
438f88ecc11e 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
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
108 if (result == NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
109 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
110 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
111 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
112
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 pthread_cleanup_push(gg_gethostbyname_cleaner, &buf);
438f88ecc11e 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
438f88ecc11e 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 if (pthread)
438f88ecc11e 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 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 buf = malloc(buf_len);
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 if (pthread)
438f88ecc11e 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 pthread_setcancelstate(old_state, NULL);
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 if (buf != NULL) {
438f88ecc11e 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 #ifndef sun
438f88ecc11e 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 while ((ret = gethostbyname_r(hostname, &he, buf, buf_len, &he_ptr, &h_errnop)) == ERANGE) {
438f88ecc11e 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 #else
438f88ecc11e 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 while (((he_ptr = gethostbyname_r(hostname, &he, buf, buf_len, &h_errnop)) == NULL) && (errno == ERANGE)) {
438f88ecc11e 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 #endif
438f88ecc11e 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 buf_len *= 2;
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 if (pthread)
438f88ecc11e 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 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 new_buf = realloc(buf, buf_len);
438f88ecc11e 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
438f88ecc11e 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 if (new_buf != NULL)
438f88ecc11e 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 buf = new_buf;
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 if (pthread)
438f88ecc11e 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 pthread_setcancelstate(old_state, NULL);
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 if (new_buf == NULL) {
438f88ecc11e 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 ret = ENOMEM;
438f88ecc11e 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 break;
438f88ecc11e 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 }
438f88ecc11e 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 }
438f88ecc11e 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
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
156 if (ret == 0 && he_ptr != NULL && he_ptr->h_addr_list[0] != NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
157 int i;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
158
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
159 /* Policz liczbę adresów */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
160
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
161 for (i = 0; he_ptr->h_addr_list[i] != NULL; i++)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
162 ;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
163
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
164 /* Zaalokuj */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
165
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
166 #ifdef GG_CONFIG_HAVE_PTHREAD
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
167 if (pthread)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
168 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
169 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
170
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
171 *result = malloc((i + 1) * sizeof(struct in_addr));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
172
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
173 #ifdef GG_CONFIG_HAVE_PTHREAD
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
174 if (pthread)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
175 pthread_setcancelstate(old_state, NULL);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
176 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
177
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
178 if (*result == NULL)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
179 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
180
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
181 /* Kopiuj */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
182
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
183 for (i = 0; he_ptr->h_addr_list[i] != NULL; i++)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
184 memcpy(&((*result)[i]), he_ptr->h_addr_list[i], sizeof(struct in_addr));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
185
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
186 (*result)[i].s_addr = INADDR_NONE;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
187
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
188 *count = i;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
189
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
190 res = 0;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
191 }
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 if (pthread)
438f88ecc11e 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 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 free(buf);
438f88ecc11e 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 buf = NULL;
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 if (pthread)
438f88ecc11e 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 pthread_setcancelstate(old_state, NULL);
438f88ecc11e 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 #endif
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 pthread_cleanup_pop(1);
438f88ecc11e 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 #endif
438f88ecc11e 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
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
211 return res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
212 #else /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
213 struct hostent *he;
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
214 int i;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
215
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
216 if (result == NULL || count == NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
217 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
218 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
219 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221 he = gethostbyname(hostname);
438f88ecc11e 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
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
223 if (he == NULL || he->h_addr_list[0] == NULL)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
224 return -1;
438f88ecc11e 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
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
226 /* Policz liczbę adresów */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
227
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
228 for (i = 0; he->h_addr_list[i] != NULL; i++)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
229 ;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
230
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
231 /* Zaalokuj */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
232
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
233 *result = malloc((i + 1) * sizeof(struct in_addr));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
234
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
235 if (*result == NULL)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
236 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
237
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
238 /* Kopiuj */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
239
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
240 for (i = 0; he->h_addr_list[i] != NULL; i++)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
241 memcpy(&((*result)[i]), he->h_addr_list[0], sizeof(struct in_addr));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
242
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
243 (*result)[i].s_addr = INADDR_NONE;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
244
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
245 *count = i;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
246
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
247 return 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
248 #endif /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */
438f88ecc11e 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 }
438f88ecc11e 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
32675
a8ba546a18bc Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32674
diff changeset
251 #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_HAVE_FORK)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
252 /**
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
253 * \internal Rozwiązuje nazwę i zapisuje wynik do podanego desktyptora.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
254 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
255 * \param fd Deskryptor
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
256 * \param hostname Nazwa serwera
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
257 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
258 * \return 0 jeśli się powiodło, -1 w przypadku błędu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
259 */
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
260 static int gg_resolver_run(int fd, const char *hostname)
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
261 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
262 struct in_addr addr_ip[2], *addr_list;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
263 int addr_count;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
264 int res = 0;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
265
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
266 gg_debug(GG_DEBUG_MISC, "// gg_resolver_run(%d, %s)\n", fd, hostname);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
267
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
268 if ((addr_ip[0].s_addr = inet_addr(hostname)) == INADDR_NONE) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
269 if (gg_gethostbyname_real(hostname, &addr_list, &addr_count, 1) == -1) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
270 addr_list = addr_ip;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
271 /* addr_ip[0] już zawiera INADDR_NONE */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
272 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
273 } else {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
274 addr_list = addr_ip;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
275 addr_ip[1].s_addr = INADDR_NONE;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
276 addr_count = 1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
277 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
278
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
279 gg_debug(GG_DEBUG_MISC, "// gg_resolver_run() count = %d\n", addr_count);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
280
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
281 if (write(fd, addr_list, (addr_count + 1) * sizeof(struct in_addr)) != (addr_count + 1) * sizeof(struct in_addr))
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
282 res = -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
283
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
284 if (addr_list != addr_ip)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
285 free(addr_list);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
286
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
287 return res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
288 }
31880
b3fee5c4d236 Fixed some warnings when compiling Gadu-Gadu prpl under Windows.
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 31826
diff changeset
289 #endif
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
290
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
291 /**
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność.
438f88ecc11e 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 *
438f88ecc11e 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 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
295 * nie, to zwykłej \c gethostbyname. Funkcja służy do zachowania zgodności
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
296 * ABI i służy do pobierania tylko pierwszego adresu -- pozostałe mogą
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
297 * zostać zignorowane przez aplikację.
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 *
438f88ecc11e 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 * \param hostname Nazwa serwera
438f88ecc11e 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 *
438f88ecc11e 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 * \return Zaalokowana struktura \c in_addr lub NULL w przypadku błędu.
438f88ecc11e 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 */
438f88ecc11e 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 struct in_addr *gg_gethostbyname(const char *hostname)
438f88ecc11e 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 {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
305 struct in_addr *result;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
306 int count;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
308 if (gg_gethostbyname_real(hostname, &result, &count, 0) == -1)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
309 return NULL;
438f88ecc11e 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
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
311 return result;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
312 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * \internal Struktura przekazywana do wątku rozwiązującego nazwę.
438f88ecc11e 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 */
438f88ecc11e 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 struct gg_resolver_fork_data {
438f88ecc11e 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 int pid; /*< Identyfikator procesu */
438f88ecc11e 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 };
438f88ecc11e 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
32675
a8ba546a18bc Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32674
diff changeset
321 #ifdef GG_CONFIG_HAVE_FORK
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
322 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
323 * \internal Rozwiązuje nazwę serwera w osobnym procesie.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
324 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
325 * Połączenia asynchroniczne nie mogą blokować procesu w trakcie rozwiązywania
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
326 * nazwy serwera. W tym celu tworzony jest potok, nowy proces i dopiero w nim
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
327 * przeprowadzane jest rozwiązywanie nazwy. Deskryptor strony do odczytu
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
328 * zapisuje się w strukturze sieci i czeka na dane w postaci struktury
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
329 * \c in_addr. Jeśli nie znaleziono nazwy, zwracana jest \c INADDR_NONE.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
330 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
332 * potoku
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
333 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
334 * do numeru procesu potomnego rozwiązującego nazwę
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
335 * \param hostname Nazwa serwera do rozwiązania
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
336 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
337 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
338 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
339 static int gg_resolver_fork_start(int *fd, void **priv_data, const char *hostname)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
340 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
341 struct gg_resolver_fork_data *data = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
342 int pipes[2], new_errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
343
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
344 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_fork_start(%p, %p, \"%s\");\n", fd, priv_data, hostname);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
345
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
346 if (fd == NULL || priv_data == NULL || hostname == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
347 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() invalid arguments\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
348 errno = EFAULT;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
349 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
350 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
351
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
352 data = malloc(sizeof(struct gg_resolver_fork_data));
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
353
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
354 if (data == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
355 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() out of memory for resolver data\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
356 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
357 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
358
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
359 if (pipe(pipes) == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
360 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
361 free(data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
362 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
363 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
364
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
365 data->pid = fork();
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
366
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
367 if (data->pid == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
368 new_errno = errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
369 goto cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
370 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
371
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
372 if (data->pid == 0) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
373 close(pipes[0]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
374
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
375 if (gg_resolver_run(pipes[1], hostname) == -1)
30443
58456ab971cf gg: s/exit/_exit/ in the resolver fork() code
Paul Aurich <darkrain42@pidgin.im>
parents: 29974
diff changeset
376 _exit(1);
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
377 else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
378 _exit(0);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
379 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
380
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
381 close(pipes[1]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
382
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
383 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() %p\n", data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
384
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
385 *fd = pipes[0];
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
386 *priv_data = data;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
387
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
388 return 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
389
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
390 cleanup:
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
391 free(data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
392 close(pipes[0]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
393 close(pipes[1]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
394
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
395 errno = new_errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
396
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
397 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
398 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
399
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
400 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
401 * \internal Usuwanie zasobów po procesie rozwiązywaniu nazwy.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
402 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
403 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
404 * zasobów sesji podczas rozwiązywania nazwy.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
405 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
406 * \param priv_data Wskaźnik na zmienną przechowującą wskaźnik do prywatnych
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
407 * danych
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
408 * \param force Flaga usuwania zasobów przed zakończeniem działania
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
409 */
29974
d4d47163ff18 Silence some gadu-gadu warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 29824
diff changeset
410 static void gg_resolver_fork_cleanup(void **priv_data, int force)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
411 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
412 struct gg_resolver_fork_data *data;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
413
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
414 if (priv_data == NULL || *priv_data == NULL)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
415 return;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
416
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
417 data = (struct gg_resolver_fork_data*) *priv_data;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
418 *priv_data = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
419
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
420 if (force)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
421 kill(data->pid, SIGKILL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
422
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
423 waitpid(data->pid, NULL, WNOHANG);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
424
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
425 free(data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
426 }
29824
9878119b5d78 Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29752
diff changeset
427 #endif
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
428
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
429 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
430
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
431 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
432 * \internal Struktura przekazywana do wątku rozwiązującego nazwę.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
433 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
434 struct gg_resolver_pthread_data {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
435 pthread_t thread; /*< Identyfikator wątku */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
436 char *hostname; /*< Nazwa serwera */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
437 int rfd; /*< Deskryptor do odczytu */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
438 int wfd; /*< Deskryptor do zapisu */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
439 };
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
440
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
441 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
442 * \internal Usuwanie zasobów po wątku rozwiązywaniu nazwy.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
443 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
444 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
445 * zasobów sesji podczas rozwiązywania nazwy.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
446 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
447 * \param priv_data Wskaźnik na zmienną przechowującą wskaźnik do prywatnych
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
448 * danych
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
449 * \param force Flaga usuwania zasobów przed zakończeniem działania
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
450 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
451 static void gg_resolver_pthread_cleanup(void **priv_data, int force)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
452 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
453 struct gg_resolver_pthread_data *data;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
454
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
455 if (priv_data == NULL || *priv_data == NULL)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
456 return;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
457
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
458 data = (struct gg_resolver_pthread_data *) *priv_data;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
459 *priv_data = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
460
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
461 if (force) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
462 pthread_cancel(data->thread);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
463 pthread_join(data->thread, NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
464 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
465
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
466 free(data->hostname);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
467 data->hostname = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
468
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
469 if (data->wfd != -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
470 close(data->wfd);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
471 data->wfd = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
472 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
473
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
474 free(data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
475 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
476
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
477 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
478 * \internal Wątek rozwiązujący nazwę.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
479 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
480 * \param arg Wskaźnik na strukturę \c gg_resolver_pthread_data
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
481 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
482 static void *gg_resolver_pthread_thread(void *arg)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
483 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
484 struct gg_resolver_pthread_data *data = arg;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
485
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
486 pthread_detach(pthread_self());
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
487
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
488 if (gg_resolver_run(data->wfd, data->hostname) == -1)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
489 pthread_exit((void*) -1);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
490 else
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
491 pthread_exit(NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
492
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
493 return NULL; /* żeby kompilator nie marudził */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
494 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
495
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
496 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
497 * \internal Rozwiązuje nazwę serwera w osobnym wątku.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
498 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
499 * Funkcja działa analogicznie do \c gg_resolver_fork_start(), z tą różnicą,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
500 * że działa na wątkach, nie procesach. Jest dostępna wyłącznie gdy podczas
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
501 * kompilacji włączono odpowiednią opcję.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
502 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
503 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
504 * potoku
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
505 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
506 * do prywatnych danych wątku rozwiązującego nazwę
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
507 * \param hostname Nazwa serwera do rozwiązania
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
508 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
509 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
510 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
511 static int gg_resolver_pthread_start(int *fd, void **priv_data, const char *hostname)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
512 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
513 struct gg_resolver_pthread_data *data = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
514 int pipes[2], new_errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
515
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
516 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_pthread_start(%p, %p, \"%s\");\n", fd, priv_data, hostname);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
517
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
518 if (fd == NULL || priv_data == NULL || hostname == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
519 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() invalid arguments\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
520 errno = EFAULT;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
521 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
522 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
523
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
524 data = malloc(sizeof(struct gg_resolver_pthread_data));
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
525
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
526 if (data == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
527 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory for resolver data\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
528 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
529 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
530
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
531 if (pipe(pipes) == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
532 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
533 free(data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
535 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
536
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
537 data->hostname = strdup(hostname);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
538
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
539 if (data->hostname == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
540 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
541 new_errno = errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
542 goto cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
543 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
544
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
545 data->rfd = pipes[0];
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
546 data->wfd = pipes[1];
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
547
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
548 if (pthread_create(&data->thread, NULL, gg_resolver_pthread_thread, data)) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
549 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() unable to create thread\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
550 new_errno = errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
551 goto cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
552 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
553
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
554 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() %p\n", data);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 *fd = pipes[0];
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 *priv_data = data;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
558
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
559 return 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
560
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
561 cleanup:
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
562 if (data != NULL)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563 free(data->hostname);
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
564
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
565 free(data);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
566
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
567 close(pipes[0]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
568 close(pipes[1]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
569
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
570 errno = new_errno;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
571
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
572 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
573 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
574
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
575 #endif /* GG_CONFIG_HAVE_PTHREAD */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
577 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
578 * Ustawia sposób rozwiązywania nazw w sesji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
579 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
580 * \param gs Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
581 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
582 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
583 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
585 int gg_session_set_resolver(struct gg_session *gs, gg_resolver_t type)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
587 GG_SESSION_CHECK(gs, -1);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
588
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
589 if (type == GG_RESOLVER_DEFAULT) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
590 if (gg_global_resolver_type != GG_RESOLVER_DEFAULT) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
591 gs->resolver_type = gg_global_resolver_type;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
592 gs->resolver_start = gg_global_resolver_start;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
593 gs->resolver_cleanup = gg_global_resolver_cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
594 return 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
595 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
596
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
597 #if !defined(GG_CONFIG_HAVE_PTHREAD) || !defined(GG_CONFIG_PTHREAD_DEFAULT)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
598 type = GG_RESOLVER_FORK;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
599 #else
29751
438f88ecc11e 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 type = GG_RESOLVER_PTHREAD;
438f88ecc11e 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 #endif
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 switch (type) {
32674
2de7f0cebb8b Gadu-Gadu: move our win32 resolver out of libgadu sources. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32655
diff changeset
605 #ifdef GG_CONFIG_HAVE_FORK
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
606 case GG_RESOLVER_FORK:
29751
438f88ecc11e 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 gs->resolver_type = type;
438f88ecc11e 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 gs->resolver_start = gg_resolver_fork_start;
438f88ecc11e 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 gs->resolver_cleanup = gg_resolver_fork_cleanup;
438f88ecc11e 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 return 0;
29824
9878119b5d78 Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29752
diff changeset
611 #endif
29751
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 case GG_RESOLVER_PTHREAD:
438f88ecc11e 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 gs->resolver_type = type;
438f88ecc11e 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 gs->resolver_start = gg_resolver_pthread_start;
438f88ecc11e 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 gs->resolver_cleanup = gg_resolver_pthread_cleanup;
438f88ecc11e 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 return 0;
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 default:
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e 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 return -1;
438f88ecc11e 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 }
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Zwraca sposób rozwiązywania nazw w sesji.
438f88ecc11e 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 *
438f88ecc11e 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 * \param gs Struktura sesji
438f88ecc11e 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 *
438f88ecc11e 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 * \return Sposób rozwiązywania nazw
438f88ecc11e 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 */
438f88ecc11e 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 gg_resolver_t gg_session_get_resolver(struct gg_session *gs)
438f88ecc11e 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 {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
636 GG_SESSION_CHECK(gs, (gg_resolver_t) -1);
29751
438f88ecc11e 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
438f88ecc11e 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 return gs->resolver_type;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Ustawia własny sposób rozwiązywania nazw w sesji.
438f88ecc11e 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 *
438f88ecc11e 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 * \param gs Struktura sesji
438f88ecc11e 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 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
438f88ecc11e 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 * \param resolver_cleanup Funkcja zwalniająca zasoby
438f88ecc11e 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 *
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
648 * Parametry funkcji rozpoczynającej rozwiązywanie nazwy wyglądają następująco:
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
649 * - \c "int *fd" &mdash; wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor potoku
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
650 * - \c "void **priv_data" &mdash; wskaźnik na zmienną, gdzie można umieścić wskaźnik do prywatnych danych na potrzeby rozwiązywania nazwy
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
651 * - \c "const char *name" &mdash; nazwa serwera do rozwiązania
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
652 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
653 * Parametry funkcji zwalniającej zasoby wyglądają następująco:
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
654 * - \c "void **priv_data" &mdash; wskaźnik na zmienną przechowującą wskaźnik do prywatnych danych, należy go ustawić na \c NULL po zakończeniu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
655 * - \c "int force" &mdash; flaga mówiąca o tym, że zasoby są zwalniane przed zakończeniem rozwiązywania nazwy, np. z powodu zamknięcia sesji.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
656 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
657 * Własny kod rozwiązywania nazwy powinien stworzyć potok, parę gniazd lub
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
658 * inny deskryptor pozwalający na co najmniej jednostronną komunikację i
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
659 * przekazać go w parametrze \c fd. Po zakończeniu rozwiązywania nazwy,
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
660 * powinien wysłać otrzymany adres IP w postaci sieciowej (big-endian) do
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
661 * deskryptora. Jeśli rozwiązywanie nazwy się nie powiedzie, należy wysłać
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
662 * \c INADDR_NONE. Następnie zostanie wywołana funkcja zwalniająca zasoby
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
663 * z parametrem \c force równym \c 0. Gdyby sesja została zakończona przed
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
664 * rozwiązaniem nazwy, np. za pomocą funkcji \c gg_logoff(), funkcja
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
665 * zwalniająca zasoby zostanie wywołana z parametrem \c force równym \c 1.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
666 *
29751
438f88ecc11e 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e 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 */
438f88ecc11e 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 int gg_session_set_custom_resolver(struct gg_session *gs, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
438f88ecc11e 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 {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
671 GG_SESSION_CHECK(gs, -1);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
672
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
673 if (resolver_start == NULL || resolver_cleanup == NULL) {
29751
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e 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;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 gs->resolver_type = GG_RESOLVER_CUSTOM;
438f88ecc11e 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 gs->resolver_start = resolver_start;
438f88ecc11e 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 gs->resolver_cleanup = resolver_cleanup;
438f88ecc11e 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
438f88ecc11e 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 return 0;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Ustawia sposób rozwiązywania nazw połączenia HTTP.
438f88ecc11e 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 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
688 * \param gh Struktura połączenia
438f88ecc11e 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 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
438f88ecc11e 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 *
438f88ecc11e 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e 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 */
438f88ecc11e 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 int gg_http_set_resolver(struct gg_http *gh, gg_resolver_t type)
438f88ecc11e 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 {
438f88ecc11e 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 if (gh == NULL) {
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e 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 return -1;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 if (type == GG_RESOLVER_DEFAULT) {
438f88ecc11e 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 if (gg_global_resolver_type != GG_RESOLVER_DEFAULT) {
438f88ecc11e 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 gh->resolver_type = gg_global_resolver_type;
438f88ecc11e 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 gh->resolver_start = gg_global_resolver_start;
438f88ecc11e 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 gh->resolver_cleanup = gg_global_resolver_cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
705 return 0;
438f88ecc11e 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 }
438f88ecc11e 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
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
708 #if !defined(GG_CONFIG_HAVE_PTHREAD) || !defined(GG_CONFIG_PTHREAD_DEFAULT)
29751
438f88ecc11e 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 type = GG_RESOLVER_FORK;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
710 #else
29751
438f88ecc11e 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 type = GG_RESOLVER_PTHREAD;
438f88ecc11e 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 #endif
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 switch (type) {
32674
2de7f0cebb8b Gadu-Gadu: move our win32 resolver out of libgadu sources. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32655
diff changeset
716 #ifdef GG_CONFIG_HAVE_FORK
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
717 case GG_RESOLVER_FORK:
29751
438f88ecc11e 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 gh->resolver_type = type;
438f88ecc11e 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 gh->resolver_start = gg_resolver_fork_start;
438f88ecc11e 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 gh->resolver_cleanup = gg_resolver_fork_cleanup;
438f88ecc11e 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 return 0;
29824
9878119b5d78 Finish making libgadu compile on Windows. Fixes #10542 finally!
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29752
diff changeset
722 #endif
29751
438f88ecc11e 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
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 case GG_RESOLVER_PTHREAD:
438f88ecc11e 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 gh->resolver_type = type;
438f88ecc11e 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 gh->resolver_start = gg_resolver_pthread_start;
438f88ecc11e 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 gh->resolver_cleanup = gg_resolver_pthread_cleanup;
438f88ecc11e 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 return 0;
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 default:
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e 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 -1;
438f88ecc11e 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 }
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Zwraca sposób rozwiązywania nazw połączenia HTTP.
438f88ecc11e 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 *
438f88ecc11e 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 * \param gh Struktura połączenia
438f88ecc11e 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 *
438f88ecc11e 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 * \return Sposób rozwiązywania nazw
438f88ecc11e 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 */
438f88ecc11e 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 gg_resolver_t gg_http_get_resolver(struct gg_http *gh)
438f88ecc11e 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 {
438f88ecc11e 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 (gh == NULL) {
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e 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 return GG_RESOLVER_INVALID;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 return gh->resolver_type;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Ustawia własny sposób rozwiązywania nazw połączenia HTTP.
438f88ecc11e 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 *
438f88ecc11e 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 gh Struktura sesji
438f88ecc11e 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 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
438f88ecc11e 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 * \param resolver_cleanup Funkcja zwalniająca zasoby
438f88ecc11e 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 *
438f88ecc11e 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e 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 */
438f88ecc11e 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 int gg_http_set_custom_resolver(struct gg_http *gh, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
438f88ecc11e 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 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
766 if (gh == NULL || resolver_start == NULL || resolver_cleanup == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
767 errno = EINVAL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
768 return -1;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 gh->resolver_type = GG_RESOLVER_CUSTOM;
438f88ecc11e 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 gh->resolver_start = resolver_start;
438f88ecc11e 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 gh->resolver_cleanup = resolver_cleanup;
438f88ecc11e 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
438f88ecc11e 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 return 0;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Ustawia sposób rozwiązywania nazw globalnie dla biblioteki.
438f88ecc11e 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 *
438f88ecc11e 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 type Sposób rozwiązywania nazw (patrz \ref build-resolver)
438f88ecc11e 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 *
438f88ecc11e 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e 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 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
785 int gg_global_set_resolver(gg_resolver_t type)
438f88ecc11e 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 {
438f88ecc11e 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 switch (type) {
438f88ecc11e 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 case GG_RESOLVER_DEFAULT:
438f88ecc11e 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 gg_global_resolver_type = type;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
790 gg_global_resolver_start = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
791 gg_global_resolver_cleanup = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
792 return 0;
438f88ecc11e 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
32674
2de7f0cebb8b Gadu-Gadu: move our win32 resolver out of libgadu sources. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32655
diff changeset
794 #ifdef GG_CONFIG_HAVE_FORK
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
795 case GG_RESOLVER_FORK:
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
796 gg_global_resolver_type = type;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
797 gg_global_resolver_start = gg_resolver_fork_start;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
798 gg_global_resolver_cleanup = gg_resolver_fork_cleanup;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
799 return 0;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30443
diff changeset
800 #endif
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30443
diff changeset
801
29751
438f88ecc11e 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 #ifdef GG_CONFIG_HAVE_PTHREAD
438f88ecc11e 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 case GG_RESOLVER_PTHREAD:
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
804 gg_global_resolver_type = type;
438f88ecc11e 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_global_resolver_start = gg_resolver_pthread_start;
438f88ecc11e 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 gg_global_resolver_cleanup = gg_resolver_pthread_cleanup;
438f88ecc11e 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 return 0;
438f88ecc11e 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 #endif
438f88ecc11e 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
438f88ecc11e 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 default:
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e 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;
438f88ecc11e 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 }
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Zwraca sposób rozwiązywania nazw globalnie dla biblioteki.
438f88ecc11e 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 *
438f88ecc11e 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 * \return Sposób rozwiązywania nazw
438f88ecc11e 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 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
821 gg_resolver_t gg_global_get_resolver(void)
438f88ecc11e 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 {
438f88ecc11e 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 return gg_global_resolver_type;
438f88ecc11e 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 }
438f88ecc11e 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
438f88ecc11e 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 /**
438f88ecc11e 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 * Ustawia własny sposób rozwiązywania nazw globalnie dla biblioteki.
438f88ecc11e 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 *
438f88ecc11e 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 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
438f88ecc11e 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 * \param resolver_cleanup Funkcja zwalniająca zasoby
438f88ecc11e 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 *
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
832 * Patrz \ref gg_session_set_custom_resolver.
29751
438f88ecc11e 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 *
438f88ecc11e 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e 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 */
438f88ecc11e 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 int gg_global_set_custom_resolver(int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
438f88ecc11e 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 {
438f88ecc11e 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 if (resolver_start == NULL || resolver_cleanup == NULL) {
438f88ecc11e 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 errno = EINVAL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
840 return -1;
438f88ecc11e 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 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
842
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
843 gg_global_resolver_type = GG_RESOLVER_CUSTOM;
438f88ecc11e 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 gg_global_resolver_start = resolver_start;
438f88ecc11e 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 gg_global_resolver_cleanup = resolver_cleanup;
438f88ecc11e 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
438f88ecc11e 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 return 0;
438f88ecc11e 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 }
438f88ecc11e 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

mercurial