Mercurial > pidgin
annotate libpurple/protocols/gg/lib/resolver.c @ 31086:a8cc50c2279f
Remove trailing whitespace
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 04 Jan 2011 06:55:30 +0000 |
parents | e4c57ecc54ee |
children | 93b08d43f684 |
rev | line source |
---|---|
29538
6359fde67f4c
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$ */ |
6359fde67f4c
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 |
6359fde67f4c
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 /* |
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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, |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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, |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
26 * \file resolver.c |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
27 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
28 * \brief Funkcje rozwiązywania nazw |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 */ |
6359fde67f4c
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 |
29539
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
31 #ifndef _WIN32 |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
32 # include <sys/wait.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
33 # include <netdb.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
34 # include <signal.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
35 # include <netinet/in.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
36 # include <arpa/inet.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
37 #endif |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29538
diff
changeset
|
38 |
29538
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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> |
6359fde67f4c
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 |
6359fde67f4c
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" |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 #include "resolver.h" |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 #include "compat.h" |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
56 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
57 #ifdef GG_CONFIG_HAVE_PTHREAD |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
58 |
6359fde67f4c
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> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
60 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
61 /** |
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
64 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
65 * \param data Wskaźnik na wskaźnik bufora zaalokowanego w wątku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 static void gg_gethostbyname_cleaner(void *data) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 { |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 if (buf_ptr != NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 free(*buf_ptr); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 *buf_ptr = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 |
6359fde67f4c
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 */ |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
80 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 * Jeśli dany system dostarcza \c gethostbyname_r, używa się tej wersji, jeśli |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 int gg_gethostbyname_real(const char *hostname, struct in_addr *addr, int pthread) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 { |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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) { |
6359fde67f4c
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 |
6359fde67f4c
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) { |
6359fde67f4c
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 |
6359fde67f4c
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)) { |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 #ifdef GG_CONFIG_HAVE_PTHREAD |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 if (pthread) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_state); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 #endif |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 #ifdef GG_CONFIG_HAVE_PTHREAD |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 if (pthread) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 pthread_setcancelstate(old_state, NULL); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 #endif |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 if (new_buf == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
144 ret = ENOMEM; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
145 break; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
146 } |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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) { |
6359fde67f4c
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)); |
6359fde67f4c
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; |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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)); |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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 */ |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
187 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
188 * \internal Odpowiednik \c gethostbyname zapewniający współbieżność. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 * |
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
192 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
193 * \param hostname Nazwa serwera |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 * |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 struct in_addr *gg_gethostbyname(const char *hostname) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
198 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 struct in_addr *addr; |
6359fde67f4c
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 |
6359fde67f4c
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)))) |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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)) { |
6359fde67f4c
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); |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 return addr; |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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 /** |
6359fde67f4c
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ę. |
6359fde67f4c
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 */ |
6359fde67f4c
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 { |
6359fde67f4c
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 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 }; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
218 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
219 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
220 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
221 /** |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
222 * Deal with the fact that you can't select() on a win32 file fd. |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
223 * This makes it practically impossible to tie into purple's event loop. |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
224 * |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
225 * -This is thanks to Tor Lillqvist. |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
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. |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
227 */ |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
228 static int |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
229 socket_pipe (int *fds) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
230 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
231 SOCKET temp, socket1 = -1, socket2 = -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
232 struct sockaddr_in saddr; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
233 int len; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
234 u_long arg; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
235 fd_set read_set, write_set; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
236 struct timeval tv; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
237 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
238 temp = socket(AF_INET, SOCK_STREAM, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
239 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
240 if (temp == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
241 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
242 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
243 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
244 arg = 1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
245 if (ioctlsocket(temp, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
246 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
247 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
248 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
249 memset(&saddr, 0, sizeof(saddr)); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
250 saddr.sin_family = AF_INET; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
251 saddr.sin_port = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
252 saddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
253 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
254 if (bind(temp, (struct sockaddr *)&saddr, sizeof (saddr))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
255 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
256 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
257 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
258 if (listen(temp, 1) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
259 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
260 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
261 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
262 len = sizeof(saddr); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
263 if (getsockname(temp, (struct sockaddr *)&saddr, &len)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
264 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
265 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
266 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
267 socket1 = socket(AF_INET, SOCK_STREAM, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
268 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
269 if (socket1 == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
270 goto out0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
271 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
272 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
273 arg = 1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
274 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
275 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
276 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
277 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
278 if (connect(socket1, (struct sockaddr *)&saddr, len) != SOCKET_ERROR || |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
279 WSAGetLastError() != WSAEWOULDBLOCK) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
280 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
281 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
282 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
283 FD_ZERO(&read_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
284 FD_SET(temp, &read_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
285 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
286 tv.tv_sec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
287 tv.tv_usec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
288 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
289 if (select(0, &read_set, NULL, NULL, NULL) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
290 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
291 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
292 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
293 if (!FD_ISSET(temp, &read_set)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
294 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
295 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
296 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
297 socket2 = accept(temp, (struct sockaddr *) &saddr, &len); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
298 if (socket2 == INVALID_SOCKET) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
299 goto out1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
300 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
301 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
302 FD_ZERO(&write_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
303 FD_SET(socket1, &write_set); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
304 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
305 tv.tv_sec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
306 tv.tv_usec = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
307 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
308 if (select(0, NULL, &write_set, NULL, NULL) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
309 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
310 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
311 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
312 if (!FD_ISSET(socket1, &write_set)) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
313 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
314 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
315 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
316 arg = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
317 if (ioctlsocket(socket1, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
318 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
319 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
320 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
321 arg = 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
322 if (ioctlsocket(socket2, FIONBIO, &arg) == SOCKET_ERROR) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
323 goto out2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
324 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
325 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
326 fds[0] = socket1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
327 fds[1] = socket2; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
328 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
329 closesocket (temp); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
330 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
331 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
332 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
333 out2: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
334 closesocket (socket2); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
335 out1: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
336 closesocket (socket1); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
337 out0: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
338 closesocket (temp); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
339 errno = EIO; /* XXX */ |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
340 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
341 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
342 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
343 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
344 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
345 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
346 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
347 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
348 struct gg_resolve_win32thread_data { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
349 char *hostname; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
350 int fd; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
351 }; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
352 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
353 static DWORD WINAPI gg_resolve_win32thread_thread(LPVOID arg) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
354 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
355 struct gg_resolve_win32thread_data *d = arg; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
356 struct in_addr a; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
357 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
358 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() host: %s, fd: %i called\n", d->hostname, d->fd); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
359 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
360 if ((a.s_addr = inet_addr(d->hostname)) == INADDR_NONE) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
361 /* W przypadku błędu gg_gethostbyname_real() zwróci -1 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
362 * i nie zmieni &addr. Tam jest już INADDR_NONE, |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
363 * więc nie musimy robić nic więcej. */ |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
364 gg_gethostbyname_real(d->hostname, &a, 0); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
365 } |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
366 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
367 // if ((a.s_addr = inet_addr(d->hostname)) == INADDR_NONE) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
368 // struct in_addr *hn; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
369 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
370 // if (!(hn = gg_gethostbyname(d->hostname))) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
371 // a.s_addr = INADDR_NONE; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
372 // else { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
373 // a.s_addr = hn->s_addr; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
374 // free(hn); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
375 // } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
376 // } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
377 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
378 write(d->fd, &a, sizeof(a)); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
379 close(d->fd); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
380 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
381 free(d->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
382 d->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
383 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
384 free(d); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
385 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
386 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_thread() done\n"); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
387 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
388 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
389 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
390 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
391 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
392 static int gg_resolve_win32thread(int *fd, void **resolver, const char *hostname) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
393 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
394 struct gg_resolve_win32thread_data *d = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
395 HANDLE h; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
396 DWORD dwTId; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
397 int pipes[2], new_errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
398 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
399 gg_debug(GG_DEBUG_FUNCTION, "** gg_resolve_win32thread(%p, %p, \"%s\");\n", fd, resolver, hostname); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
400 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
401 if (!resolver || !fd || !hostname) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
402 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() invalid arguments\n"); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
403 errno = EFAULT; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
404 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
405 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
406 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
407 if (socket_pipe(pipes) == -1) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
408 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() unable to create pipes (errno=%d, %s)\n", errno, strerror(errno)); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
409 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
410 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
411 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
412 if (!(d = malloc(sizeof(*d)))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
413 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() out of memory\n"); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
414 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
415 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
416 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
417 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
418 d->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
419 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
420 if (!(d->hostname = strdup(hostname))) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
421 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() out of memory\n"); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
422 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
423 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
424 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
425 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
426 d->fd = pipes[1]; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
427 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
428 h = CreateThread(NULL, 0, gg_resolve_win32thread_thread, |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
429 d, 0, &dwTId); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
430 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
431 if (h == NULL) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
432 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() unable to create thread\n"); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
433 new_errno = errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
434 goto cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
435 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
436 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
437 *resolver = h; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
438 *fd = pipes[0]; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
439 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
440 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread() done\n"); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
441 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
442 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
443 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
444 cleanup: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
445 if (d) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
446 free(d->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
447 free(d); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
448 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
449 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
450 close(pipes[0]); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
451 close(pipes[1]); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
452 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
453 errno = new_errno; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
454 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
455 return -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
456 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
457 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
458 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
459 static void gg_resolve_win32thread_cleanup(void **priv_data, int force) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
460 { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
461 struct gg_resolve_win32thread_data *data; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
462 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
463 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() force: %i called\n", force); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
464 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
465 if (priv_data == NULL || *priv_data == NULL) |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
466 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() priv_data: NULL\n"); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
467 return; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
468 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
469 data = (struct gg_resolve_win32thread_data*) *priv_data; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
470 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() data: %s called\n", data->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
471 *priv_data = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
472 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
473 if (force) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
474 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() force called\n", force); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
475 //pthread_cancel(data->thread); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
476 //pthread_join(data->thread, NULL); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
477 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
478 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
479 free(data->hostname); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
480 data->hostname = NULL; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
481 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
482 if (data->fd != -1) { |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
483 close(data->fd); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
484 data->fd = -1; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
485 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
486 gg_debug(GG_DEBUG_MISC, "// gg_resolve_win32thread_cleanup() done\n"); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
487 free(data); |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
488 } |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
489 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
490 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
491 #ifndef _WIN32 |
29538
6359fde67f4c
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 /** |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
497 * przeprowadzane jest rozwiązywanie nazwy. Deskryptor strony do odczytu |
29538
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
500 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
501 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 * potoku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
503 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 * do numeru procesu potomnego rozwiązującego nazwę |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
505 * \param hostname Nazwa serwera do rozwiązania |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
506 * |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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) |
6359fde67f4c
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 { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
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 |
6359fde67f4c
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) { |
6359fde67f4c
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"); |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
522 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
523 data = malloc(sizeof(struct gg_resolver_fork_data)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
524 |
6359fde67f4c
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) { |
6359fde67f4c
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"); |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
528 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
529 |
6359fde67f4c
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) { |
6359fde67f4c
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)); |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
533 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
534 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
535 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
536 data->pid = fork(); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
537 |
6359fde67f4c
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) { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
541 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
542 |
6359fde67f4c
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) { |
6359fde67f4c
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]); |
6359fde67f4c
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 |
6359fde67f4c
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) { |
6359fde67f4c
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 |
6359fde67f4c
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, |
6359fde67f4c
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. */ |
6359fde67f4c
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); |
6359fde67f4c
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 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
552 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
553 if (write(pipes[1], &addr, sizeof(addr)) != sizeof(addr)) |
30190
e4c57ecc54ee
gg: s/exit/_exit/ in the resolver fork() code
Paul Aurich <paul@darkrain42.org>
parents:
29691
diff
changeset
|
554 _exit(1); |
29538
6359fde67f4c
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 |
30190
e4c57ecc54ee
gg: s/exit/_exit/ in the resolver fork() code
Paul Aurich <paul@darkrain42.org>
parents:
29691
diff
changeset
|
556 _exit(0); |
29538
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
557 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
558 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
559 close(pipes[1]); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
560 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
561 gg_debug(GG_DEBUG_MISC, "// gg_resolver_fork_start() %p\n", data); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
562 |
6359fde67f4c
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]; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
565 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
566 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
567 |
6359fde67f4c
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: |
6359fde67f4c
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); |
6359fde67f4c
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]); |
6359fde67f4c
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]); |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
574 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
575 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
576 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
577 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
578 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 * \internal Usuwanie zasobów po procesie rozwiązywaniu nazwy. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 * |
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
29691
eb8b1cfd3349
Silence some gadu-gadu warnings
Paul Aurich <paul@darkrain42.org>
parents:
29544
diff
changeset
|
588 static void gg_resolver_fork_cleanup(void **priv_data, int force) |
29538
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
589 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
590 struct gg_resolver_fork_data *data; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
591 |
6359fde67f4c
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) |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
595 data = (struct gg_resolver_fork_data*) *priv_data; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 *priv_data = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
597 |
6359fde67f4c
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) |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
600 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
601 waitpid(data->pid, NULL, WNOHANG); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 free(data); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
604 } |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
605 #endif |
29538
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
609 /** |
6359fde67f4c
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ę. |
6359fde67f4c
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 */ |
6359fde67f4c
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 { |
6359fde67f4c
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 */ |
6359fde67f4c
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 */ |
6359fde67f4c
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 */ |
6359fde67f4c
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 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
617 }; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
618 |
6359fde67f4c
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 /** |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
621 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 * Funkcja wywoływana po zakończeniu rozwiązanywania nazwy lub przy zwalnianiu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 * zasobów sesji podczas rozwiązywania nazwy. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 static void gg_resolver_pthread_cleanup(void **priv_data, int force) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
631 struct gg_resolver_pthread_data *data; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
632 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
633 if (priv_data == NULL || *priv_data == NULL) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 return; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 data = (struct gg_resolver_pthread_data *) *priv_data; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
637 *priv_data = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
638 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
639 if (force) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
640 pthread_cancel(data->thread); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
641 pthread_join(data->thread, NULL); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
643 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
644 free(data->hostname); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
645 data->hostname = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
646 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
647 if (data->wfd != -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
648 close(data->wfd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
649 data->wfd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
650 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
651 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
652 free(data); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
653 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
654 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
655 /** |
6359fde67f4c
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ę. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
657 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
658 * \param arg Wskaźnik na strukturę \c gg_resolver_pthread_data |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
659 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
660 static void *gg_resolver_pthread_thread(void *arg) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
661 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
662 struct gg_resolver_pthread_data *data = arg; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
663 struct in_addr addr; |
6359fde67f4c
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 |
6359fde67f4c
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()); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
666 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
667 if ((addr.s_addr = inet_addr(data->hostname)) == INADDR_NONE) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
668 /* W przypadku błędu gg_gethostbyname_real() zwróci -1 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
669 * i nie zmieni &addr. Tam jest już INADDR_NONE, |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
670 * więc nie musimy robić nic więcej. */ |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
672 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
673 |
6359fde67f4c
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)) |
6359fde67f4c
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); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
676 else |
29538
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
678 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
679 return NULL; /* żeby kompilator nie marudził */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
680 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
681 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
682 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
683 * \internal Rozwiązuje nazwę serwera w osobnym wątku. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
684 * |
6359fde67f4c
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ą, |
6359fde67f4c
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 |
6359fde67f4c
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ę. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
688 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
689 * \param fd Wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
690 * potoku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
691 * \param priv_data Wskaźnik na zmienną, gdzie zostanie umieszczony wskaźnik |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
692 * do prywatnych danych wątku rozwiązującego nazwę |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
693 * \param hostname Nazwa serwera do rozwiązania |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
694 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
695 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
696 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
697 static int gg_resolver_pthread_start(int *fd, void **priv_data, const char *hostname) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
698 { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
703 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
704 if (fd == NULL || priv_data == NULL || hostname == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
705 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() invalid arguments\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
706 errno = EFAULT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
707 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
708 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
709 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
710 data = malloc(sizeof(struct gg_resolver_pthread_data)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
711 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
712 if (data == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
713 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory for resolver data\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
714 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
715 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
716 |
6359fde67f4c
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) { |
6359fde67f4c
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)); |
6359fde67f4c
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); |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
721 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
722 |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
724 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
725 if (data->hostname == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
726 gg_debug(GG_DEBUG_MISC, "// gg_resolver_pthread_start() out of memory\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
727 new_errno = errno; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
728 goto cleanup; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
729 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
730 |
6359fde67f4c
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]; |
6359fde67f4c
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]; |
6359fde67f4c
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 |
6359fde67f4c
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)) { |
6359fde67f4c
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"); |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
738 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
739 |
6359fde67f4c
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); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
741 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
742 *fd = pipes[0]; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
743 *priv_data = data; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
744 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
745 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
746 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
747 cleanup: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
748 if (data) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
749 free(data->hostname); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
750 free(data); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
751 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
752 |
6359fde67f4c
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]); |
6359fde67f4c
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]); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
755 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
756 errno = new_errno; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
757 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
758 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
759 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
760 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
761 #endif /* GG_CONFIG_HAVE_PTHREAD */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
762 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
763 /** |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
768 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
769 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
770 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
771 int gg_session_set_resolver(struct gg_session *gs, gg_resolver_t type) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
772 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
773 if (gs == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
774 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
775 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
776 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
777 |
6359fde67f4c
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) { |
6359fde67f4c
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) { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
784 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
785 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
786 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
787 type = GG_RESOLVER_WIN32; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
788 #else |
29538
6359fde67f4c
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; |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
790 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
791 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
792 #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_PTHREAD_DEFAULT) |
29538
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
795 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
796 |
6359fde67f4c
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) { |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
798 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
799 case GG_RESOLVER_WIN32: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
800 gs->resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
801 gs->resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
802 gs->resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
803 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
804 #else |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
805 case GG_RESOLVER_FORK: |
29538
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
810 #endif |
29538
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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: |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
819 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
820 default: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
821 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
822 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
823 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
824 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
825 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
826 /** |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
830 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
831 * \return Sposób rozwiązywania nazw |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
832 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
833 gg_resolver_t gg_session_get_resolver(struct gg_session *gs) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
834 { |
6359fde67f4c
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) { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
838 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
839 |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
841 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
842 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
843 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
844 * Ustawia własny sposób rozwiązywania nazw w sesji. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
845 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
846 * \param gs Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
847 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
848 * \param resolver_cleanup Funkcja zwalniająca zasoby |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
849 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
850 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
851 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
852 int gg_session_set_custom_resolver(struct gg_session *gs, int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int)) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
853 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
854 if (gs == NULL || resolver_start == NULL || resolver_cleanup == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
855 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
856 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
857 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
858 |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
862 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
863 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
864 } |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
866 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
867 * Ustawia sposób rozwiązywania nazw połączenia HTTP. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
868 * |
6359fde67f4c
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 |
6359fde67f4c
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) |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
873 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
874 int gg_http_set_resolver(struct gg_http *gh, gg_resolver_t type) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
875 { |
6359fde67f4c
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) { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
879 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
880 |
6359fde67f4c
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) { |
6359fde67f4c
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) { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 } |
6359fde67f4c
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 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
889 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
890 type = GG_RESOLVER_WIN32; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
891 #else |
29538
6359fde67f4c
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; |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
893 #endif |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
894 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
895 #if defined(GG_CONFIG_HAVE_PTHREAD) || defined(GG_CONFIG_PTHREAD_DEFAULT) |
29538
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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) { |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
901 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
902 case GG_RESOLVER_WIN32: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
903 gh->resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
904 gh->resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
905 gh->resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
906 return 0; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
907 #else |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
908 case GG_RESOLVER_FORK: |
29538
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
913 #endif |
29538
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
914 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
915 #ifdef GG_CONFIG_HAVE_PTHREAD |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
916 case GG_RESOLVER_PTHREAD: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
917 gh->resolver_type = type; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
918 gh->resolver_start = gg_resolver_pthread_start; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
919 gh->resolver_cleanup = gg_resolver_pthread_cleanup; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
920 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
921 #endif |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
922 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
923 default: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
924 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
925 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
926 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
927 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
928 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
929 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
930 * Zwraca sposób rozwiązywania nazw połączenia HTTP. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
931 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
932 * \param gh Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
933 * |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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) |
6359fde67f4c
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 { |
6359fde67f4c
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) { |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
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 /** |
6359fde67f4c
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. |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 * |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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)) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
956 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
957 if (gh == NULL || resolver_start == NULL || resolver_cleanup == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
958 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
959 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
960 } |
6359fde67f4c
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 |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
965 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
966 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
967 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
968 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
969 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
970 * Ustawia sposób rozwiązywania nazw globalnie dla biblioteki. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
971 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
972 * \param type Sposób rozwiązywania nazw (patrz \ref build-resolver) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
973 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
974 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
975 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
976 int gg_global_set_resolver(gg_resolver_t type) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
977 { |
6359fde67f4c
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) { |
6359fde67f4c
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: |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
985 #ifndef _WIN32 |
29538
6359fde67f4c
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: |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
991 #endif |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
992 |
29544
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
993 #ifdef _WIN32 |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
994 case GG_RESOLVER_WIN32: |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
995 gg_global_resolver_type = type; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
996 gg_global_resolver_start = gg_resolve_win32thread; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
997 gg_global_resolver_cleanup = gg_resolve_win32thread_cleanup; |
818f2845ab47
Finish making libgadu compile on Windows. Fixes #10542 finally!
kkszysiu@gmail.com
parents:
29539
diff
changeset
|
998 return 0; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
999 #endif |
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
1000 |
29538
6359fde67f4c
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 |
6359fde67f4c
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: |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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: |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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 } |
6359fde67f4c
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 } |
6359fde67f4c
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 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1015 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1016 * Zwraca sposób rozwiązywania nazw globalnie dla biblioteki. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1017 * |
6359fde67f4c
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 |
6359fde67f4c
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 */ |
6359fde67f4c
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) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1021 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1022 return gg_global_resolver_type; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1023 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1024 |
6359fde67f4c
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 /** |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1027 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1028 * \param resolver_start Funkcja rozpoczynająca rozwiązywanie nazwy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1029 * \param resolver_cleanup Funkcja zwalniająca zasoby |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1030 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1031 * Parametry funkcji rozpoczynającej rozwiązywanie nazwy wyglądają następująco: |
6359fde67f4c
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" — wskaźnik na zmienną, gdzie zostanie umieszczony deskryptor potoku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1033 * - \c "void **priv_data" — wskaźnik na zmienną, gdzie można umieścić wskaźnik do prywatnych danych na potrzeby rozwiązywania nazwy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1034 * - \c "const char *name" — nazwa serwera do rozwiązania |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1035 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1036 * Parametry funkcji zwalniającej zasoby wyglądają następująco: |
6359fde67f4c
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" — wskaźnik na zmienną przechowującą wskaźnik do prywatnych danych, należy go ustawić na \c NULL po zakończeniu |
6359fde67f4c
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" — flaga mówiąca o tym, że zasoby są zwalniane przed zakończeniem rozwiązywania nazwy, np. z powodu zamknięcia sesji. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1039 * |
6359fde67f4c
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 |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30190
diff
changeset
|
1041 * inny deskryptor pozwalający na co najmniej jednostronną komunikację i |
29538
6359fde67f4c
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, |
6359fde67f4c
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 |
6359fde67f4c
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ć |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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 |
6359fde67f4c
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. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1049 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1050 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1051 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1052 int gg_global_set_custom_resolver(int (*resolver_start)(int*, void**, const char*), void (*resolver_cleanup)(void**, int)) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1053 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1054 if (resolver_start == NULL || resolver_cleanup == NULL) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1055 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1056 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1057 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1058 |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
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; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1062 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1063 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1064 } |
6359fde67f4c
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 |