annotate libpurple/protocols/gg/lib/resolver.c @ 32777:e2ff2ac0e022

Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
author tomkiewicz@cpw.pidgin.im
date Fri, 21 Oct 2011 12:48:30 +0000
parents ef01f180114b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * (C) Copyright 2001-2009 Wojtek Kaniewski <wojtekka@irc.pl>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 * Robert J. Woźny <speedy@ziew.org>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4 * Arkadiusz Miśkiewicz <arekm@pld-linux.org>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 * Tomasz Chiliński <chilek@chilan.com>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * Adam Wysocki <gophi@ekg.chmurka.net>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * it under the terms of the GNU Lesser General Public License Version
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 * 2.1 as published by the Free Software Foundation.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 * GNU Lesser General Public License for more details.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * License along with this program; if not, write to the Free Software
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 * USA.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 * \file resolver.c
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
26 * \brief Funkcje rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
27 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28
32072
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
29 #include <errno.h>
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
30 #include <stdlib.h>
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
31 #include <string.h>
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
32 #include <unistd.h>
29939
db6735e579f8 Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29938
diff changeset
33
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 #include "libgadu.h"
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 #include "resolver.h"
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36 #include "compat.h"
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
37 #include "session.h"
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
39 #ifdef GG_CONFIG_HAVE_FORK
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
40 #include <sys/wait.h>
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
41 #include <signal.h>
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
42 #endif
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
43
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 /** Sposób rozwiązywania nazw serwerów */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
45 static gg_resolver_t gg_global_resolver_type = GG_RESOLVER_DEFAULT;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
47 /** Funkcja rozpoczynająca rozwiązywanie nazwy */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 static int (*gg_global_resolver_start)(int *fd, void **private_data, const char *hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50 /** Funkcja zwalniająca zasoby po rozwiązaniu nazwy */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 static void (*gg_global_resolver_cleanup)(void **private_data, int force);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
52
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
53 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
54
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55 #include <pthread.h>
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
56
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
57 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 * \internal Funkcja pomocnicza zwalniająca zasoby po rozwiązywaniu nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59 * w wątku.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
60 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61 * \param data Wskaźnik na wskaźnik bufora zaalokowanego w wątku
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
62 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63 static void gg_gethostbyname_cleaner(void *data)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
64 {
6359fde67f4c 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 char **buf_ptr = (char**) data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66
6359fde67f4c 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 if (buf_ptr != NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 free(*buf_ptr);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69 *buf_ptr = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72
6359fde67f4c 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 #endif /* GG_CONFIG_HAVE_PTHREAD */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
74
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
76 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
77 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
78 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
79 * nie, to zwykłej \c gethostbyname. Wynikiem jest tablica adresów zakończona
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
80 * wartością INADDR_NONE, którą należy zwolnić po użyciu.
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
81 *
6359fde67f4c 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 * \param hostname Nazwa serwera
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
83 * \param result Wskaźnik na wskaźnik z tablicą adresów zakończoną INADDR_NONE
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
84 * \param count Wskaźnik na zmienną, do ktorej zapisze się liczbę wyników
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
85 * \param pthread Flaga blokowania unicestwiania wątku podczas alokacji pamięci
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
86 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
87 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
88 */
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
89 int gg_gethostbyname_real(const char *hostname, struct in_addr **result, int *count, int pthread)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
90 {
6359fde67f4c 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 #ifdef GG_CONFIG_HAVE_GETHOSTBYNAME_R
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
92 char *buf = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93 char *new_buf = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 struct hostent he;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
95 struct hostent *he_ptr = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96 size_t buf_len = 1024;
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
97 int res = -1;
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 int h_errnop;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 int ret = 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
100 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 int old_state;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
104 if (result == NULL) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
105 errno = EINVAL;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
106 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
107 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
108
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
110 pthread_cleanup_push(gg_gethostbyname_cleaner, &buf);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
111
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
114 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115
6359fde67f4c 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 buf = malloc(buf_len);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
117
6359fde67f4c 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 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
119 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
120 pthread_setcancelstate(old_state, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123 if (buf != NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
124 #ifndef sun
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
125 while ((ret = gethostbyname_r(hostname, &he, buf, buf_len, &he_ptr, &h_errnop)) == ERANGE) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
126 #else
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
127 while (((he_ptr = gethostbyname_r(hostname, &he, buf, buf_len, &h_errnop)) == NULL) && (errno == ERANGE)) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 buf_len *= 2;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
130
6359fde67f4c 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 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
136 new_buf = realloc(buf, buf_len);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
137
6359fde67f4c 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 if (new_buf != NULL)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
139 buf = new_buf;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
140
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
141 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
142 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
143 pthread_setcancelstate(old_state, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
144 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
145
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
146 if (new_buf == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
147 ret = ENOMEM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
148 break;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
149 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
150 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
151
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
152 if (ret == 0 && he_ptr != NULL && he_ptr->h_addr_list[0] != NULL) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
153 int i;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
154
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
155 /* Policz liczbę adresów */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
156
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
157 for (i = 0; he_ptr->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
158 ;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
159
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
160 /* Zaalokuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
161
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
162 #ifdef GG_CONFIG_HAVE_PTHREAD
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
163 if (pthread)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
164 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
165 #endif
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
166
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
167 *result = malloc((i + 1) * sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
168
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
169 #ifdef GG_CONFIG_HAVE_PTHREAD
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
170 if (pthread)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
171 pthread_setcancelstate(old_state, NULL);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
172 #endif
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
173
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
174 if (*result == NULL)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
175 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
176
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
177 /* Kopiuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
178
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
179 for (i = 0; he_ptr->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
180 memcpy(&((*result)[i]), he_ptr->h_addr_list[i], sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
181
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
182 (*result)[i].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
183
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
184 *count = i;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
185
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
186 res = 0;
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
187 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
188
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
189 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
190 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
191 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
192 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
193
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 free(buf);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
195 buf = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
197 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
198 if (pthread)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199 pthread_setcancelstate(old_state, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
200 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202
6359fde67f4c 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 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204 pthread_cleanup_pop(1);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
207 return res;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
208 #else /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209 struct hostent *he;
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
210 int i;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
211
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
212 if (result == NULL || count == NULL) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
213 errno = EINVAL;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
214 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
215 }
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
216
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
217 he = gethostbyname(hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
218
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
219 if (he == NULL || he->h_addr_list[0] == NULL)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
222 /* Policz liczbę adresów */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
223
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
224 for (i = 0; he->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
225 ;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
226
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
227 /* Zaalokuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
228
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
229 *result = malloc((i + 1) * sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
230
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
231 if (*result == NULL)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
232 return -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
233
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
234 /* Kopiuj */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
235
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
236 for (i = 0; he->h_addr_list[i] != NULL; i++)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
237 memcpy(&((*result)[i]), he->h_addr_list[0], sizeof(struct in_addr));
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
238
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
239 (*result)[i].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
240
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
241 *count = i;
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
242
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
243 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
244 #endif /* GG_CONFIG_HAVE_GETHOSTBYNAME_R */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
245 }
6359fde67f4c 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
32764
ef01f180114b Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32763
diff changeset
247 #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_HAVE_FORK)
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
248
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
249 /**
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
250 * \internal Rozwiązuje nazwę i zapisuje wynik do podanego desktyptora.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
251 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
252 * \param fd Deskryptor
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
253 * \param hostname Nazwa serwera
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
254 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
255 * \return 0 jeśli się powiodło, -1 w przypadku błędu
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
256 */
32072
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
257 static int gg_resolver_run(int fd, const char *hostname)
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
258 {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
259 struct in_addr addr_ip[2], *addr_list;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
260 int addr_count;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
261 int res = 0;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
262
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
263 gg_debug(GG_DEBUG_MISC, "// gg_resolver_run(%d, %s)\n", fd, hostname);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
264
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
265 if ((addr_ip[0].s_addr = inet_addr(hostname)) == INADDR_NONE) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
266 if (gg_gethostbyname_real(hostname, &addr_list, &addr_count, 1) == -1) {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
267 addr_list = addr_ip;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
268 /* addr_ip[0] już zawiera INADDR_NONE */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
269 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
270 } else {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
271 addr_list = addr_ip;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
272 addr_ip[1].s_addr = INADDR_NONE;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
273 addr_count = 1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
274 }
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
275
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
276 gg_debug(GG_DEBUG_MISC, "// gg_resolver_run() count = %d\n", addr_count);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
277
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
278 if (write(fd, addr_list, (addr_count + 1) * sizeof(struct in_addr)) != (addr_count + 1) * sizeof(struct in_addr))
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
279 res = -1;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
280
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
281 if (addr_list != addr_ip)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
282 free(addr_list);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
283
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
284 return res;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
285 }
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
286
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
287 #endif /* GG_CONFIG_HAVE_PTHREAD || GG_CONFIG_HAVE_FORK */
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
288
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
289 /**
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
290 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
291 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
293 * nie, to zwykłej \c gethostbyname. Funkcja służy do zachowania zgodności
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
294 * ABI i służy do pobierania tylko pierwszego adresu -- pozostałe mogą
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
295 * zostać zignorowane przez aplikację.
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
297 * \param hostname Nazwa serwera
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299 * \return Zaalokowana struktura \c in_addr lub NULL w przypadku błędu.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
301 struct in_addr *gg_gethostbyname(const char *hostname)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
302 {
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
303 struct in_addr *result;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
304 int count;
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
305
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
306 if (gg_gethostbyname_real(hostname, &result, &count, 0) == -1)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307 return NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
308
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
309 return result;
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
310 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
311
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
312 #ifdef GG_CONFIG_HAVE_FORK
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
313
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
314 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315 * \internal Struktura przekazywana do wątku rozwiązującego nazwę.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
316 */
6359fde67f4c 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 {
6359fde67f4c 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 */
6359fde67f4c 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 };
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
320
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
321 /**
6359fde67f4c 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 * \internal Rozwiązuje nazwę serwera w osobnym procesie.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
323 *
6359fde67f4c 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 * Połączenia asynchroniczne nie mogą blokować procesu w trakcie rozwiązywania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
325 * nazwy serwera. W tym celu tworzony jest potok, nowy proces i dopiero w nim
32072
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
326 * przeprowadzane jest rozwiązywanie nazwy. Deskryptor strony do odczytu
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
327 * zapisuje się w strukturze sieci i czeka na dane w postaci struktury
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
328 * \c in_addr. Jeśli nie znaleziono nazwy, zwracana jest \c INADDR_NONE.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
329 *
6359fde67f4c 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 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 * potoku
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
332 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
333 * do numeru procesu potomnego rozwiązującego nazwę
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
334 * \param hostname Nazwa serwera do rozwiązania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
335 *
6359fde67f4c 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
337 */
6359fde67f4c 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 static int gg_resolver_fork_start(int *fd, void **priv_data, const char *hostname)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
339 {
6359fde67f4c 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 struct gg_resolver_fork_data *data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
341 int pipes[2], new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
342
6359fde67f4c 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 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_fork_start(%p, %p, \"%s\");\n", fd, priv_data, hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
344
6359fde67f4c 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 if (fd == NULL || priv_data == NULL || hostname == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
346 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() invalid arguments\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
347 errno = EFAULT;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
348 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
349 }
6359fde67f4c 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
6359fde67f4c 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 data = malloc(sizeof(struct gg_resolver_fork_data));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
352
6359fde67f4c 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 if (data == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
354 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() out of memory for resolver data\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
355 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
356 }
6359fde67f4c 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
6359fde67f4c 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 if (pipe(pipes) == -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
359 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
360 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
361 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
362 }
6359fde67f4c 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
6359fde67f4c 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 data->pid = fork();
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
365
6359fde67f4c 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 if (data->pid == -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
367 new_errno = errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
368 goto cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
369 }
6359fde67f4c 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
6359fde67f4c 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 if (data->pid == 0) {
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
372 int status;
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
373
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
374 close(pipes[0]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
375
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
376 status = (gg_resolver_run(pipes[1], hostname) == -1) ? 1 : 0;
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
377
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
378 #ifdef GG_CONFIG_HAVE__EXIT
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
379 _exit(status);
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
380 #else
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
381 exit(status);
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
382 #endif
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
383 }
6359fde67f4c 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
6359fde67f4c 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 close(pipes[1]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
386
6359fde67f4c 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 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() %p\n", data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
388
6359fde67f4c 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 *fd = pipes[0];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
390 *priv_data = data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
391
6359fde67f4c 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 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
393
6359fde67f4c 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 cleanup:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
395 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
396 close(pipes[0]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
397 close(pipes[1]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
398
6359fde67f4c 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 errno = new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
400
6359fde67f4c 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 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
402 }
6359fde67f4c 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
6359fde67f4c 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 /**
6359fde67f4c 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 * \internal Usuwanie zasobów po procesie rozwiązywaniu nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
406 *
6359fde67f4c 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 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
408 * zasobów sesji podczas rozwiązywania nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
409 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
410 * \param priv_data Wskaźnik na zmienną przechowującą wskaźnik do prywatnych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
411 * danych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
412 * \param force Flaga usuwania zasobów przed zakończeniem działania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
413 */
30101
eb8b1cfd3349 Silence some gadu-gadu warnings
Paul Aurich <paul@darkrain42.org>
parents: 29944
diff changeset
414 static void gg_resolver_fork_cleanup(void **priv_data, int force)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
415 {
6359fde67f4c 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 struct gg_resolver_fork_data *data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
417
6359fde67f4c 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 if (priv_data == NULL || *priv_data == NULL)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
419 return;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
420
6359fde67f4c 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 data = (struct gg_resolver_fork_data*) *priv_data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
422 *priv_data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
423
6359fde67f4c 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 if (force)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
425 kill(data->pid, SIGKILL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
426
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
427 waitpid(data->pid, NULL, WNOHANG);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
428
6359fde67f4c 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 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
430 }
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
431
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
432 #endif /* GG_CONFIG_HAVE_FORK */
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
433
6359fde67f4c 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 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
435
6359fde67f4c 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 /**
6359fde67f4c 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 * \internal Struktura przekazywana do wątku rozwiązującego nazwę.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
438 */
6359fde67f4c 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 struct gg_resolver_pthread_data {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
440 pthread_t thread; /*< Identyfikator wątku */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
441 char *hostname; /*< Nazwa serwera */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
442 int rfd; /*< Deskryptor do odczytu */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
443 int wfd; /*< Deskryptor do zapisu */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
444 };
6359fde67f4c 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
6359fde67f4c 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 /**
6359fde67f4c 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 * \internal Usuwanie zasobów po wątku rozwiązywaniu nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
448 *
6359fde67f4c 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 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
450 * zasobów sesji podczas rozwiązywania nazwy.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
451 *
6359fde67f4c 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 * \param priv_data Wskaźnik na zmienną przechowującą wskaźnik do prywatnych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
453 * danych
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
454 * \param force Flaga usuwania zasobów przed zakończeniem działania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
455 */
6359fde67f4c 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 static void gg_resolver_pthread_cleanup(void **priv_data, int force)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
457 {
6359fde67f4c 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 struct gg_resolver_pthread_data *data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
459
6359fde67f4c 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 if (priv_data == NULL || *priv_data == NULL)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
461 return;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
462
6359fde67f4c 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 data = (struct gg_resolver_pthread_data *) *priv_data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
464 *priv_data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
465
6359fde67f4c 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 if (force) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
467 pthread_cancel(data->thread);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
468 pthread_join(data->thread, NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
469 }
6359fde67f4c 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
6359fde67f4c 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 free(data->hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
472 data->hostname = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
473
6359fde67f4c 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 if (data->wfd != -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
475 close(data->wfd);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
476 data->wfd = -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
477 }
6359fde67f4c 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
6359fde67f4c 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 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
480 }
6359fde67f4c 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
6359fde67f4c 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 /**
6359fde67f4c 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 * \internal Wątek rozwiązujący nazwę.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
484 *
6359fde67f4c 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 * \param arg Wskaźnik na strukturę \c gg_resolver_pthread_data
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
486 */
6359fde67f4c 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 static void *gg_resolver_pthread_thread(void *arg)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
488 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
489 struct gg_resolver_pthread_data *data = arg;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
490
6359fde67f4c 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_detach(pthread_self());
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
492
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
493 if (gg_resolver_run(data->wfd, data->hostname) == -1)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
494 pthread_exit((void*) -1);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
495 else
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
496 pthread_exit(NULL);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
497
6359fde67f4c 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 return NULL; /* żeby kompilator nie marudził */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
499 }
6359fde67f4c 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
6359fde67f4c 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 /**
6359fde67f4c 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 * \internal Rozwiązuje nazwę serwera w osobnym wątku.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
503 *
6359fde67f4c 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 * Funkcja działa analogicznie do \c gg_resolver_fork_start(), z tą różnicą,
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
505 * że działa na wątkach, nie procesach. Jest dostępna wyłącznie gdy podczas
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
506 * kompilacji włączono odpowiednią opcję.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
507 *
6359fde67f4c 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 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
509 * potoku
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
510 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
511 * do prywatnych danych wątku rozwiązującego nazwę
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
512 * \param hostname Nazwa serwera do rozwiązania
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
513 *
6359fde67f4c 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
515 */
6359fde67f4c 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 static int gg_resolver_pthread_start(int *fd, void **priv_data, const char *hostname)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
517 {
6359fde67f4c 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 struct gg_resolver_pthread_data *data = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
519 int pipes[2], new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
520
6359fde67f4c 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 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_pthread_start(%p, %p, \"%s\");\n", fd, priv_data, hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
522
6359fde67f4c 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 if (fd == NULL || priv_data == NULL || hostname == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
524 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() invalid arguments\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
525 errno = EFAULT;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
526 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
527 }
6359fde67f4c 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
6359fde67f4c 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 data = malloc(sizeof(struct gg_resolver_pthread_data));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
530
6359fde67f4c 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 (data == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
532 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory for resolver data\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
533 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 }
6359fde67f4c 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
6359fde67f4c 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 if (pipe(pipes) == -1) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
537 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno));
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
538 free(data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
539 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
540 }
6359fde67f4c 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
6359fde67f4c 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 data->hostname = strdup(hostname);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
543
6359fde67f4c 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 if (data->hostname == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
545 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
546 new_errno = errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
547 goto cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
548 }
6359fde67f4c 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
6359fde67f4c 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 data->rfd = pipes[0];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
551 data->wfd = pipes[1];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
552
6359fde67f4c 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 if (pthread_create(&data->thread, NULL, gg_resolver_pthread_thread, data)) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
554 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() unable to create thread\n");
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555 new_errno = errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 goto cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 }
6359fde67f4c 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
6359fde67f4c 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 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() %p\n", data);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
560
6359fde67f4c 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 *fd = pipes[0];
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
562 *priv_data = data;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
564 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
565
6359fde67f4c 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 cleanup:
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
567 if (data != NULL)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
568 free(data->hostname);
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
569
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
570 free(data);
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
571
6359fde67f4c 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 close(pipes[0]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
573 close(pipes[1]);
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
574
6359fde67f4c 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 errno = new_errno;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576
6359fde67f4c 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 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
578 }
6359fde67f4c 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
6359fde67f4c 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 #endif /* GG_CONFIG_HAVE_PTHREAD */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
581
6359fde67f4c 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 /**
6359fde67f4c 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 * Ustawia sposób rozwiązywania nazw w sesji.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584 *
6359fde67f4c 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 * \param gs Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
587 *
6359fde67f4c 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 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
589 */
6359fde67f4c 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 int gg_session_set_resolver(struct gg_session *gs, gg_resolver_t type)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
591 {
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
592 GG_SESSION_CHECK(gs, -1);
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
593
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
594 if (type == GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
595 if (gg_global_resolver_type != GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
596 gs->resolver_type = gg_global_resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
597 gs->resolver_start = gg_global_resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
598 gs->resolver_cleanup = gg_global_resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
599 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
600 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
601
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
602 #if defined(GG_CONFIG_HAVE_PTHREAD) && defined(GG_CONFIG_PTHREAD_DEFAULT)
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
603 type = GG_RESOLVER_PTHREAD;
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
604 #elif defined(GG_CONFIG_HAVE_FORK)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 type = GG_RESOLVER_FORK;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
606 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
607 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
608
6359fde67f4c 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 switch (type) {
32763
326591e64aaa Gadu-Gadu: move our win32 resolver out of libgadu sources. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32744
diff changeset
610 #ifdef GG_CONFIG_HAVE_FORK
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
611 case GG_RESOLVER_FORK:
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
612 gs->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613 gs->resolver_start = gg_resolver_fork_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
614 gs->resolver_cleanup = gg_resolver_fork_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
615 return 0;
29944
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29939
diff changeset
616 #endif
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
617
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
618 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
619 case GG_RESOLVER_PTHREAD:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
620 gs->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
621 gs->resolver_start = gg_resolver_pthread_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
622 gs->resolver_cleanup = gg_resolver_pthread_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
623 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
624 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
625
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
626 default:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
627 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
628 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
629 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
630 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
631
6359fde67f4c 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 /**
6359fde67f4c 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 * Zwraca sposób rozwiązywania nazw w sesji.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
634 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
635 * \param gs Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
636 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
637 * \return Sposób rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
638 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
639 gg_resolver_t gg_session_get_resolver(struct gg_session *gs)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
640 {
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
641 GG_SESSION_CHECK(gs, (gg_resolver_t) -1);
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
642
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
643 return gs->resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
644 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
645
6359fde67f4c 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 /**
6359fde67f4c 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 * Ustawia własny sposób rozwiązywania nazw w sesji.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
648 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
649 * \param gs Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
650 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
651 * \param resolver_cleanup Funkcja zwalniająca zasoby
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
652 *
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
653 * Parametry funkcji rozpoczynającej rozwiązywanie nazwy wyglądają następująco:
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
654 * - \c "int *fd" &mdash; wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor potoku
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
655 * - \c "void **priv_data" &mdash; wskaźnik na zmienną, gdzie można umieścić wskaźnik do prywatnych danych na potrzeby rozwiązywania nazwy
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
656 * - \c "const char *name" &mdash; nazwa serwera do rozwiązania
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
657 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
658 * Parametry funkcji zwalniającej zasoby wyglądają następująco:
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
659 * - \c "void **priv_data" &mdash; wskaźnik na zmienną przechowującą wskaźnik do prywatnych danych, należy go ustawić na \c NULL po zakończeniu
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
660 * - \c "int force" &mdash; flaga mówiąca o tym, że zasoby są zwalniane przed zakończeniem rozwiązywania nazwy, np. z powodu zamknięcia sesji.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
661 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
662 * Własny kod rozwiązywania nazwy powinien stworzyć potok, parę gniazd lub
32072
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
663 * inny deskryptor pozwalający na co najmniej jednostronną komunikację i
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
664 * przekazać go w parametrze \c fd. Po zakończeniu rozwiązywania nazwy,
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
665 * powinien wysłać otrzymany adres IP w postaci sieciowej (big-endian) do
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
666 * deskryptora. Jeśli rozwiązywanie nazwy się nie powiedzie, należy wysłać
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
667 * \c INADDR_NONE. Następnie zostanie wywołana funkcja zwalniająca zasoby
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
668 * z parametrem \c force równym \c 0. Gdyby sesja została zakończona przed
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
669 * rozwiązaniem nazwy, np. za pomocą funkcji \c gg_logoff(), funkcja
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
670 * zwalniająca zasoby zostanie wywołana z parametrem \c force równym \c 1.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
671 *
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
672 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
673 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
674 int gg_session_set_custom_resolver(struct gg_session *gs, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
675 {
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
676 GG_SESSION_CHECK(gs, -1);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
677
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
678 if (resolver_start == NULL || resolver_cleanup == NULL) {
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
679 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
680 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
681 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
682
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
683 gs->resolver_type = GG_RESOLVER_CUSTOM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
684 gs->resolver_start = resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
685 gs->resolver_cleanup = resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
686
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
687 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
688 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
689
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
690 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
691 * Ustawia sposób rozwiązywania nazw połączenia HTTP.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
692 *
6359fde67f4c 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 * \param gh Struktura połączenia
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
694 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
695 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
696 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
697 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
698 int gg_http_set_resolver(struct gg_http *gh, gg_resolver_t type)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
699 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
700 if (gh == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
701 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
702 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
703 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
704
6359fde67f4c 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 if (type == GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
706 if (gg_global_resolver_type != GG_RESOLVER_DEFAULT) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
707 gh->resolver_type = gg_global_resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
708 gh->resolver_start = gg_global_resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
709 gh->resolver_cleanup = gg_global_resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
710 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
711 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
712
32777
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
713 #if defined(GG_CONFIG_HAVE_PTHREAD) && defined(GG_CONFIG_PTHREAD_DEFAULT)
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
714 type = GG_RESOLVER_PTHREAD;
e2ff2ac0e022 Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32764
diff changeset
715 #elif defined(GG_CONFIG_HAVE_FORK)
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
716 type = GG_RESOLVER_FORK;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
717 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
718 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
719
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
720 switch (type) {
32763
326591e64aaa Gadu-Gadu: move our win32 resolver out of libgadu sources. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32744
diff changeset
721 #ifdef GG_CONFIG_HAVE_FORK
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
722 case GG_RESOLVER_FORK:
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
723 gh->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
724 gh->resolver_start = gg_resolver_fork_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
725 gh->resolver_cleanup = gg_resolver_fork_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
726 return 0;
29944
818f2845ab47 Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents: 29939
diff changeset
727 #endif
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
728
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
729 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
730 case GG_RESOLVER_PTHREAD:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
731 gh->resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
732 gh->resolver_start = gg_resolver_pthread_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
733 gh->resolver_cleanup = gg_resolver_pthread_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
734 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
735 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
736
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
737 default:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
738 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
739 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
740 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
741 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
742
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
743 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
744 * Zwraca sposób rozwiązywania nazw połączenia HTTP.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
745 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
746 * \param gh Struktura połączenia
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
747 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
748 * \return Sposób rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
749 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
750 gg_resolver_t gg_http_get_resolver(struct gg_http *gh)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
751 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
752 if (gh == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
753 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
754 return GG_RESOLVER_INVALID;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
755 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
756
6359fde67f4c 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 return gh->resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
758 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
759
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
760 /**
6359fde67f4c 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 * Ustawia własny sposób rozwiązywania nazw połączenia HTTP.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
762 *
6359fde67f4c 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 * \param gh Struktura sesji
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
764 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
765 * \param resolver_cleanup Funkcja zwalniająca zasoby
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
766 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
767 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
768 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
769 int gg_http_set_custom_resolver(struct gg_http *gh, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
770 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
771 if (gh == NULL || resolver_start == NULL || resolver_cleanup == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
772 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
773 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
774 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
775
6359fde67f4c 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 gh->resolver_type = GG_RESOLVER_CUSTOM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
777 gh->resolver_start = resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
778 gh->resolver_cleanup = resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
779
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
780 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
781 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
782
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
783 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
784 * Ustawia sposób rozwiązywania nazw globalnie dla biblioteki.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
785 *
6359fde67f4c 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 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
787 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
788 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
789 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
790 int gg_global_set_resolver(gg_resolver_t type)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
791 {
6359fde67f4c 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 switch (type) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
793 case GG_RESOLVER_DEFAULT:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
794 gg_global_resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
795 gg_global_resolver_start = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
796 gg_global_resolver_cleanup = NULL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
797 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
798
32763
326591e64aaa Gadu-Gadu: move our win32 resolver out of libgadu sources. Refs #343
tomkiewicz@cpw.pidgin.im
parents: 32744
diff changeset
799 #ifdef GG_CONFIG_HAVE_FORK
32072
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
800 case GG_RESOLVER_FORK:
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
801 gg_global_resolver_type = type;
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
802 gg_global_resolver_start = gg_resolver_fork_start;
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
803 gg_global_resolver_cleanup = gg_resolver_fork_cleanup;
3a90a59ddea2 Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31860
diff changeset
804 return 0;
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30616
diff changeset
805 #endif
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 30616
diff changeset
806
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
807 #ifdef GG_CONFIG_HAVE_PTHREAD
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
808 case GG_RESOLVER_PTHREAD:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
809 gg_global_resolver_type = type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
810 gg_global_resolver_start = gg_resolver_pthread_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
811 gg_global_resolver_cleanup = gg_resolver_pthread_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
812 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
813 #endif
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
814
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
815 default:
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
816 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
817 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
818 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
819 }
6359fde67f4c 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
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
821 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
822 * Zwraca sposób rozwiązywania nazw globalnie dla biblioteki.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
823 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
824 * \return Sposób rozwiązywania nazw
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
825 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
826 gg_resolver_t gg_global_get_resolver(void)
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
827 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
828 return gg_global_resolver_type;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
829 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
830
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
831 /**
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
832 * Ustawia własny sposób rozwiązywania nazw globalnie dla biblioteki.
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
833 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
834 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
835 * \param resolver_cleanup Funkcja zwalniająca zasoby
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
836 *
31860
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31534
diff changeset
837 * Patrz \ref gg_session_set_custom_resolver.
29938
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
838 *
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
839 * \return 0 jeśli się powiodło, -1 w przypadku błędu
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
840 */
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
841 int gg_global_set_custom_resolver(int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int))
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
842 {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
843 if (resolver_start == NULL || resolver_cleanup == NULL) {
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
844 errno = EINVAL;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
845 return -1;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
846 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
847
6359fde67f4c 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 gg_global_resolver_type = GG_RESOLVER_CUSTOM;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
849 gg_global_resolver_start = resolver_start;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
850 gg_global_resolver_cleanup = resolver_cleanup;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
851
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
852 return 0;
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
853 }
6359fde67f4c Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
854