libpurple/protocols/gg/lib/resolver.c

Fri, 09 Apr 2010 02:16:10 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Fri, 09 Apr 2010 02:16:10 +0000
changeset 29974
d4d47163ff18
parent 29824
9878119b5d78
child 30443
58456ab971cf
permissions
-rw-r--r--

Silence some gadu-gadu warnings

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

mercurial