Sat, 22 Mar 2014 00:42:07 +0100
Update libgadu to the current version from repo
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
1 | /* $Id$ */ |
| 11360 | 2 | |
| 3 | /* | |
| 4 | * (C) Copyright 2001-2002 Wojtek Kaniewski <wojtekka@irc.pl> | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
5 | * Robert J. Woźny <speedy@ziew.org> |
| 11360 | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU Lesser General Public License Version | |
| 9 | * 2.1 as published by the Free Software Foundation. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU Lesser General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU Lesser General Public | |
| 17 | * License along with this program; if not, write to the Free Software | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, |
| 11360 | 19 | * USA. |
| 20 | */ | |
| 21 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
22 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
23 | * \file common.c |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
24 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
25 | * \brief Funkcje wykorzystywane przez różne moduły biblioteki |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
26 | */ |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
27 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
28 | #include "network.h" |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
29 | #include "strman.h" |
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
30 | #include "fileio.h" |
| 11360 | 31 | |
| 32 | #include <errno.h> | |
| 33 | #include <stdarg.h> | |
| 34 | #include <stdlib.h> | |
| 35 | #include <string.h> | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
36 | #include <ctype.h> |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
37 | #include <time.h> |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
38 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
39 | #include "config.h" |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
40 | #include "libgadu.h" |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
41 | #include "internal.h" |
| 11360 | 42 | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
43 | #ifndef GG_CONFIG_HAVE_VA_COPY |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
44 | # ifdef GG_CONFIG_HAVE___VA_COPY |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
45 | # define va_copy(dest, src) __va_copy((dest), (src)) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
46 | # else |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
47 | /* Taka wersja va_copy() działa poprawnie tylko na platformach, które |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
48 | * va_copy() de facto wcale nie potrzebują, np. MSVC. Definicja tylko dla |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
49 | * przejrzystości kodu. */ |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
50 | # define va_copy(dest, src) (dest) = (src) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
51 | # endif |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
52 | #endif |
| 11360 | 53 | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
54 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
55 | * \internal Odpowiednik funkcji \c vsprintf alokujący miejsce na wynik. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
56 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
57 | * Funkcja korzysta z funkcji \c vsnprintf, sprawdzając czy dostępna funkcja |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
58 | * systemowa jest zgodna ze standardem C99 czy wcześniejszymi. |
| 11360 | 59 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
60 | * \param format Format wiadomości (zgodny z \c printf) |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
61 | * \param ap Lista argumentów (zgodna z \c printf) |
| 11360 | 62 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
63 | * \return Zaalokowany bufor lub NULL, jeśli zabrakło pamięci. |
| 11360 | 64 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
65 | * \ingroup helper |
| 11360 | 66 | */ |
| 67 | char *gg_vsaprintf(const char *format, va_list ap) | |
| 68 | { | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
69 | int size; |
| 11360 | 70 | char *buf = NULL; |
| 71 | va_list aq; | |
| 72 | ||
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
73 | #if !defined(GG_CONFIG_HAVE_C99_VSNPRINTF) && !defined(HAVE__VSCPRINTF) |
| 11360 | 74 | { |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
75 | int res = 0; |
| 11360 | 76 | char *tmp; |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
77 | |
| 11360 | 78 | size = 128; |
| 79 | do { | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
80 | if (res > size) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
81 | /* Jednak zachowanie zgodne z C99. */ |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
82 | size = res + 1; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
83 | } else { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
84 | size *= 2; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
85 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
86 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
87 | if (!(tmp = realloc(buf, size))) { |
| 11360 | 88 | free(buf); |
| 89 | return NULL; | |
| 90 | } | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
91 | |
| 11360 | 92 | buf = tmp; |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
93 | va_copy(aq, ap); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
94 | res = vsnprintf(buf, size, format, aq); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
95 | va_end(aq); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
96 | } while (res >= size || res < 0); |
| 11360 | 97 | } |
| 98 | #else | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
99 | va_copy(aq, ap); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
100 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
101 | # ifdef HAVE__VSCPRINTF |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
102 | size = _vscprintf(format, aq) + 1; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
103 | # else |
| 11360 | 104 | { |
| 105 | char tmp[2]; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
106 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
107 | /* libce Solarisa przy buforze NULL zawsze zwracają -1, więc |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
108 | * musimy podać coś istniejącego jako cel printf()owania. */ |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
109 | size = vsnprintf(tmp, sizeof(tmp), format, aq) + 1; |
| 11360 | 110 | } |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
111 | # endif |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
112 | va_end(aq); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
113 | if (!(buf = malloc(size))) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
114 | return NULL; |
| 11360 | 115 | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
116 | vsnprintf(buf, size, format, ap); |
| 11360 | 117 | #endif |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
118 | |
| 11360 | 119 | return buf; |
| 120 | } | |
| 121 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
122 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
123 | * \internal Odpowiednik funkcji \c sprintf alokujący miejsce na wynik. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
124 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
125 | * Funkcja korzysta z funkcji \c vsnprintf, sprawdzając czy dostępna funkcja |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
126 | * systemowa jest zgodna ze standardem C99 czy wcześniejszymi. |
| 11360 | 127 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
128 | * \param format Format wiadomości (zgodny z \c printf) |
| 11360 | 129 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
130 | * \return Zaalokowany bufor lub NULL, jeśli zabrakło pamięci. |
| 11360 | 131 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
132 | * \ingroup helper |
| 11360 | 133 | */ |
| 134 | char *gg_saprintf(const char *format, ...) | |
| 135 | { | |
| 136 | va_list ap; | |
| 137 | char *res; | |
| 138 | ||
| 139 | va_start(ap, format); | |
| 140 | res = gg_vsaprintf(format, ap); | |
| 141 | va_end(ap); | |
| 142 | ||
| 143 | return res; | |
| 144 | } | |
| 145 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
146 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
147 | * \internal Pobiera linię tekstu z bufora. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
148 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
149 | * Funkcja niszczy bufor źródłowy bezpowrotnie, dzieląc go na kolejne ciągi |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
150 | * znaków i obcina znaki końca linii. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
151 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
152 | * \param ptr Wskaźnik do zmiennej, która przechowuje aktualne położenie |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
153 | * w analizowanym buforze |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
154 | * |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
155 | * \note Funkcja nie jest już używana. Pozostała dla zachowania ABI. |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
156 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
157 | * \return Wskaźnik do kolejnej linii tekstu lub NULL, jeśli to już koniec |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
158 | * bufora. |
| 11360 | 159 | */ |
| 160 | char *gg_get_line(char **ptr) | |
| 161 | { | |
| 162 | char *foo, *res; | |
| 163 | ||
| 164 | if (!ptr || !*ptr || !strcmp(*ptr, "")) | |
| 165 | return NULL; | |
| 166 | ||
| 167 | res = *ptr; | |
| 168 | ||
| 169 | if (!(foo = strchr(*ptr, '\n'))) | |
| 170 | *ptr += strlen(*ptr); | |
| 171 | else { | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
172 | size_t len; |
| 11360 | 173 | *ptr = foo + 1; |
| 174 | *foo = 0; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
175 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
176 | len = strlen(res); |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
177 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
178 | if (len > 1 && res[len - 1] == '\r') |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
179 | res[len - 1] = 0; |
| 11360 | 180 | } |
| 181 | ||
| 182 | return res; | |
| 183 | } | |
| 184 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
185 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
186 | * \internal Czyta linię tekstu z gniazda. |
| 11360 | 187 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
188 | * Funkcja czyta tekst znak po znaku, więc nie jest efektywna, ale dzięki |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
189 | * brakowi buforowania, nie koliduje z innymi funkcjami odczytu. |
| 11360 | 190 | * |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
191 | * \note W przypadku zakończenia połączenia przez drugą stronę, ostatnia |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
192 | * linia nie jest zwracana. |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
193 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
194 | * \param sock Deskryptor gniazda |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
195 | * \param buf Wskaźnik do bufora |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
196 | * \param length Długość bufora |
| 11360 | 197 | * |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
198 | * \return Zwraca wskaźnik na koniec odebranej linii jeśli się powiodło, |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
199 | * lub \c NULL w przypadku błędu. |
| 11360 | 200 | */ |
| 201 | char *gg_read_line(int sock, char *buf, int length) | |
| 202 | { | |
| 203 | int ret; | |
| 204 | ||
| 205 | if (!buf || length < 0) | |
| 206 | return NULL; | |
| 207 | ||
| 208 | for (; length > 1; buf++, length--) { | |
| 209 | do { | |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
210 | if ((ret = recv(sock, buf, 1, 0)) == -1 && |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
211 | errno != EINTR && errno != EAGAIN) |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
212 | { |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
213 | gg_debug(GG_DEBUG_MISC, "// gg_read_line() " |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
214 | "error on read (errno=%d, %s)\n", |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
215 | errno, strerror(errno)); |
| 11360 | 216 | *buf = 0; |
| 217 | return NULL; | |
| 218 | } else if (ret == 0) { | |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
219 | gg_debug(GG_DEBUG_MISC, "// gg_read_line() " |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
220 | "eof reached\n"); |
| 11360 | 221 | *buf = 0; |
| 222 | return NULL; | |
| 223 | } | |
|
31609
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
224 | } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); |
| 11360 | 225 | |
| 226 | if (*buf == '\n') { | |
| 227 | buf++; | |
| 228 | break; | |
| 229 | } | |
| 230 | } | |
| 231 | ||
| 232 | *buf = 0; | |
| 233 | return buf; | |
| 234 | } | |
| 235 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
236 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
237 | * \internal Nawiązuje połączenie TCP. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
238 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
239 | * \param addr Wskaźnik na strukturę \c in_addr z adresem serwera |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
240 | * \param port Port serwera |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
241 | * \param async Flaga asynchronicznego połączenia |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
242 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
243 | * \return Deskryptor gniazda lub -1 w przypadku błędu |
| 11360 | 244 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
245 | * \ingroup helper |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
246 | */ |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
247 | int gg_connect(void *addr, int port, int async) |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
248 | { |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
249 | int sock, errno2; |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
250 | struct sockaddr_in sin; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
251 | struct in_addr *a = addr; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
252 | struct sockaddr_in myaddr; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
253 | |
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
254 | gg_debug(GG_DEBUG_FUNCTION, "** gg_connect(%s, %d, %d);\n", |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
255 | inet_ntoa(*a), port, async); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
256 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
257 | if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { |
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
258 | gg_debug(GG_DEBUG_MISC, "// gg_connect() socket() failed " |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
259 | "(errno=%d, %s)\n", errno, strerror(errno)); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
260 | return -1; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
261 | } |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
262 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
263 | memset(&myaddr, 0, sizeof(myaddr)); |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
264 | myaddr.sin_family = AF_INET; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
265 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
266 | myaddr.sin_addr.s_addr = gg_local_ip; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
267 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
268 | if (bind(sock, (struct sockaddr *) &myaddr, sizeof(myaddr)) == -1) { |
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
269 | gg_debug(GG_DEBUG_MISC, "// gg_connect() bind() failed " |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
270 | "(errno=%d, %s)\n", errno, strerror(errno)); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
271 | errno2 = errno; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
272 | close(sock); |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
273 | errno = errno2; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
274 | return -1; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
275 | } |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
276 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
277 | if (async) { |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
278 | if (!gg_fd_set_nonblocking(sock)) { |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
279 | gg_debug(GG_DEBUG_MISC, "// gg_connect() can't set " |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
280 | "nonblocking (errno=%d, %s)\n", |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
281 | errno, strerror(errno)); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
282 | errno2 = errno; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
283 | close(sock); |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
284 | errno = errno2; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
285 | return -1; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
286 | } |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
287 | } |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
288 | |
|
33709
84fb3f1d401b
Gadu-Gadu: fix some harmless Coverity issues
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
31826
diff
changeset
|
289 | memset(&sin, 0, sizeof(sin)); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
290 | sin.sin_port = htons(port); |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
291 | sin.sin_family = AF_INET; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
292 | sin.sin_addr.s_addr = a->s_addr; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
293 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
294 | if (connect(sock, (struct sockaddr*) &sin, sizeof(sin)) == -1) { |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
295 | if (errno && (!async || errno != EINPROGRESS)) { |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
296 | gg_debug(GG_DEBUG_MISC, "// gg_connect() connect() " |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
297 | "failed (errno=%d, %s)\n", |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
298 | errno, strerror(errno)); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
299 | errno2 = errno; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
300 | close(sock); |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
301 | errno = errno2; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
302 | return -1; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
303 | } |
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
304 | gg_debug(GG_DEBUG_MISC, |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
305 | "// gg_connect() connect() in progress\n"); |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
306 | } |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
307 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
308 | return sock; |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
309 | } |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
310 | |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
311 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
312 | * \internal Usuwa znaki końca linii. |
| 11360 | 313 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
314 | * Funkcja działa bezpośrednio na buforze. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
315 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
316 | * \param line Bufor z tekstem |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
317 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
318 | * \ingroup helper |
| 11360 | 319 | */ |
| 320 | void gg_chomp(char *line) | |
| 321 | { | |
| 322 | int len; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
323 | |
| 11360 | 324 | if (!line) |
| 325 | return; | |
| 326 | ||
| 327 | len = strlen(line); | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
328 | |
| 11360 | 329 | if (len > 0 && line[len - 1] == '\n') |
| 330 | line[--len] = 0; | |
| 331 | if (len > 0 && line[len - 1] == '\r') | |
| 332 | line[--len] = 0; | |
| 333 | } | |
| 334 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
335 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
336 | * \internal Koduje ciąg znaków do postacji adresu HTTP. |
| 11360 | 337 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
338 | * Zamienia znaki niedrukowalne, spoza ASCII i mające specjalne znaczenie |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
339 | * dla protokołu HTTP na encje postaci \c %XX, gdzie \c XX jest szesnastkową |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
340 | * wartością znaku. |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
341 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
342 | * \param str Ciąg znaków do zakodowania |
| 11360 | 343 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
344 | * \return Zaalokowany bufor lub \c NULL w przypadku błędu. |
| 11360 | 345 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
346 | * \ingroup helper |
| 11360 | 347 | */ |
| 348 | char *gg_urlencode(const char *str) | |
| 349 | { | |
|
31609
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
350 | char *q, *buf; |
|
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
351 | const char hex[] = "0123456789abcdef"; |
| 11360 | 352 | const char *p; |
| 353 | unsigned int size = 0; | |
| 354 | ||
| 355 | if (!str) | |
| 356 | str = ""; | |
| 357 | ||
| 358 | for (p = str; *p; p++, size++) { | |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
359 | if (!((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
360 | (*p >= '0' && *p <= '9') || *p == ' ') || (*p == '@') || |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
361 | (*p == '.') || (*p == '-')) |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
362 | { |
| 11360 | 363 | size += 2; |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
364 | } |
| 11360 | 365 | } |
| 366 | ||
| 367 | if (!(buf = malloc(size + 1))) | |
| 368 | return NULL; | |
| 369 | ||
| 370 | for (p = str, q = buf; *p; p++, q++) { | |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
371 | if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
372 | (*p >= '0' && *p <= '9') || (*p == '@') || |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
373 | (*p == '.') || (*p == '-')) |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
374 | { |
| 11360 | 375 | *q = *p; |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
376 | } else { |
| 11360 | 377 | if (*p == ' ') |
| 378 | *q = '+'; | |
| 379 | else { | |
| 380 | *q++ = '%'; | |
| 381 | *q++ = hex[*p >> 4 & 15]; | |
| 382 | *q = hex[*p & 15]; | |
| 383 | } | |
| 384 | } | |
| 385 | } | |
| 386 | ||
| 387 | *q = 0; | |
| 388 | ||
| 389 | return buf; | |
| 390 | } | |
| 391 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
392 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
393 | * \internal Wyznacza skrót dla usług HTTP. |
| 11360 | 394 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
395 | * Funkcja jest wykorzystywana do wyznaczania skrótu adresu e-mail, hasła |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
396 | * i innych wartości przekazywanych jako parametry usług HTTP. |
| 11360 | 397 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
398 | * W parametrze \c format należy umieścić znaki określające postać kolejnych |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
399 | * parametrów: \c 's' jeśli parametr jest ciągiem znaków, \c 'u' jeśli jest |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
400 | * liczbą. |
| 11360 | 401 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
402 | * \param format Format kolejnych parametrów (niezgodny z \c printf) |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
403 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
404 | * \return Wartość skrótu |
| 11360 | 405 | */ |
| 406 | int gg_http_hash(const char *format, ...) | |
| 407 | { | |
| 408 | unsigned int a, c, i, j; | |
| 409 | va_list ap; | |
| 410 | int b = -1; | |
| 411 | ||
| 412 | va_start(ap, format); | |
| 413 | ||
| 414 | for (j = 0; j < strlen(format); j++) { | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
415 | const char *arg; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
416 | char buf[16]; |
| 11360 | 417 | |
| 418 | if (format[j] == 'u') { | |
| 419 | snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t)); | |
| 420 | arg = buf; | |
| 421 | } else { | |
| 422 | if (!(arg = va_arg(ap, char*))) | |
| 423 | arg = ""; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
424 | } |
| 11360 | 425 | |
| 426 | i = 0; | |
| 427 | while ((c = (unsigned char) arg[i++]) != 0) { | |
| 428 | a = (c ^ b) + (c << 8); | |
| 429 | b = (a >> 24) | (a << 8); | |
| 430 | } | |
| 431 | } | |
| 432 | ||
| 433 | va_end(ap); | |
| 434 | ||
| 435 | return (b < 0 ? -b : b); | |
| 436 | } | |
| 437 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
438 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
439 | * \internal Zestaw znaków kodowania base64. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
440 | */ |
| 11360 | 441 | static char gg_base64_charset[] = |
| 442 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
| 443 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
444 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
445 | * \internal Koduje ciąg znaków do base64. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
446 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
447 | * Wynik funkcji należy zwolnić za pomocą \c free. |
| 11360 | 448 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
449 | * \param buf Bufor z danami do zakodowania |
| 11360 | 450 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
451 | * \return Zaalokowany bufor z zakodowanymi danymi |
| 11360 | 452 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
453 | * \ingroup helper |
| 11360 | 454 | */ |
| 455 | char *gg_base64_encode(const char *buf) | |
| 456 | { | |
| 457 | char *out, *res; | |
| 458 | unsigned int i = 0, j = 0, k = 0, len = strlen(buf); | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
459 | |
| 11360 | 460 | res = out = malloc((len / 3 + 1) * 4 + 2); |
| 461 | ||
| 462 | if (!res) | |
| 463 | return NULL; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
464 | |
| 11360 | 465 | while (j <= len) { |
| 466 | switch (i % 4) { | |
| 467 | case 0: | |
| 468 | k = (buf[j] & 252) >> 2; | |
| 469 | break; | |
| 470 | case 1: | |
| 471 | if (j < len) | |
| 472 | k = ((buf[j] & 3) << 4) | ((buf[j + 1] & 240) >> 4); | |
| 473 | else | |
| 474 | k = (buf[j] & 3) << 4; | |
| 475 | ||
| 476 | j++; | |
| 477 | break; | |
| 478 | case 2: | |
| 479 | if (j < len) | |
| 480 | k = ((buf[j] & 15) << 2) | ((buf[j + 1] & 192) >> 6); | |
| 481 | else | |
| 482 | k = (buf[j] & 15) << 2; | |
| 483 | ||
| 484 | j++; | |
| 485 | break; | |
| 486 | case 3: | |
| 487 | k = buf[j++] & 63; | |
| 488 | break; | |
| 489 | } | |
| 490 | *out++ = gg_base64_charset[k]; | |
| 491 | i++; | |
| 492 | } | |
| 493 | ||
| 494 | if (i % 4) | |
| 495 | for (j = 0; j < 4 - (i % 4); j++, out++) | |
| 496 | *out = '='; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
497 | |
| 11360 | 498 | *out = 0; |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
499 | |
| 11360 | 500 | return res; |
| 501 | } | |
| 502 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
503 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
504 | * \internal Dekoduje ciąg znaków zapisany w base64. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
505 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
506 | * Wynik funkcji należy zwolnić za pomocą \c free. |
| 11360 | 507 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
508 | * \param buf Bufor źródłowy z danymi do zdekodowania |
| 11360 | 509 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
510 | * \return Zaalokowany bufor ze zdekodowanymi danymi |
| 11360 | 511 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
512 | * \ingroup helper |
| 11360 | 513 | */ |
| 514 | char *gg_base64_decode(const char *buf) | |
| 515 | { | |
| 516 | char *res, *save, *foo, val; | |
| 517 | const char *end; | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
518 | unsigned int idx = 0; |
| 11360 | 519 | |
| 520 | if (!buf) | |
| 521 | return NULL; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
522 | |
| 11360 | 523 | save = res = calloc(1, (strlen(buf) / 4 + 1) * 3 + 2); |
| 524 | ||
| 525 | if (!save) | |
| 526 | return NULL; | |
| 527 | ||
| 528 | end = buf + strlen(buf); | |
| 529 | ||
| 530 | while (*buf && buf < end) { | |
| 531 | if (*buf == '\r' || *buf == '\n') { | |
| 532 | buf++; | |
| 533 | continue; | |
| 534 | } | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
535 | if (!(foo = memchr(gg_base64_charset, *buf, sizeof(gg_base64_charset)))) |
| 11360 | 536 | foo = gg_base64_charset; |
| 537 | val = (int)(foo - gg_base64_charset); | |
| 538 | buf++; | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
539 | switch (idx) { |
| 11360 | 540 | case 0: |
| 541 | *res |= val << 2; | |
| 542 | break; | |
| 543 | case 1: | |
| 544 | *res++ |= val >> 4; | |
| 545 | *res |= val << 4; | |
| 546 | break; | |
| 547 | case 2: | |
| 548 | *res++ |= val >> 2; | |
| 549 | *res |= val << 6; | |
| 550 | break; | |
| 551 | case 3: | |
| 552 | *res++ |= val; | |
| 553 | break; | |
| 554 | } | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
555 | idx++; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
556 | idx %= 4; |
| 11360 | 557 | } |
| 558 | *res = 0; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
559 | |
| 11360 | 560 | return save; |
| 561 | } | |
| 562 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
563 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
564 | * \internal Tworzy nagłówek autoryzacji serwera pośredniczącego. |
| 11360 | 565 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
566 | * Dane pobiera ze zmiennych globalnych \c gg_proxy_username i |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
567 | * \c gg_proxy_password. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
568 | * |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
569 | * \return Zaalokowany bufor z tekstem lub NULL, jeśli serwer pośredniczący |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
570 | * nie jest używany lub nie wymaga autoryzacji. |
| 11360 | 571 | */ |
|
31609
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
572 | char *gg_proxy_auth(void) |
| 11360 | 573 | { |
| 574 | char *tmp, *enc, *out; | |
| 575 | unsigned int tmp_size; | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
576 | |
| 11360 | 577 | if (!gg_proxy_enabled || !gg_proxy_username || !gg_proxy_password) |
| 578 | return NULL; | |
| 579 | ||
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
580 | tmp_size = strlen(gg_proxy_username) + strlen(gg_proxy_password) + 2; |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
581 | tmp = malloc(tmp_size); |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
582 | if (!tmp) |
| 11360 | 583 | return NULL; |
| 584 | ||
| 585 | snprintf(tmp, tmp_size, "%s:%s", gg_proxy_username, gg_proxy_password); | |
| 586 | ||
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
587 | enc = gg_base64_encode(tmp); |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
588 | if (!enc) { |
| 11360 | 589 | free(tmp); |
| 590 | return NULL; | |
| 591 | } | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
592 | |
| 11360 | 593 | free(tmp); |
| 594 | ||
|
35645
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
595 | out = malloc(strlen(enc) + 40); |
|
0143226782bb
Update libgadu to the current version from repo
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35627
diff
changeset
|
596 | if (!out) { |
| 11360 | 597 | free(enc); |
| 598 | return NULL; | |
| 599 | } | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
600 | |
| 11360 | 601 | snprintf(out, strlen(enc) + 40, "Proxy-Authorization: Basic %s\r\n", enc); |
| 602 | ||
| 603 | free(enc); | |
| 604 | ||
| 605 | return out; | |
| 606 | } | |
| 607 | ||
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
608 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
609 | * \internal Tablica pomocnicza do wyznaczania sumy kontrolnej. |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
610 | */ |
|
31609
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
611 | static const uint32_t gg_crc32_table[256] = |
| 11360 | 612 | { |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
613 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
614 | 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
615 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
616 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
617 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
618 | 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
619 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
620 | 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
621 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
622 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
623 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
624 | 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
625 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
626 | 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
627 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
628 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
629 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
630 | 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
631 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
632 | 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
633 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
634 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
635 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
636 | 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
637 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
638 | 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
639 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
640 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
641 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
642 | 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
643 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
644 | 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
645 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
646 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
647 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
648 | 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
649 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
650 | 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
651 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
652 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
653 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
654 | 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
655 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
656 | 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
657 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
658 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
659 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
660 | 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
661 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
662 | 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
663 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
664 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
665 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
666 | 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
667 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
668 | 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
669 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
670 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
671 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
672 | 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
673 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
674 | 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, |
|
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
675 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, |
|
31609
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
676 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d |
|
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
677 | }; |
| 11360 | 678 | |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
679 | /** |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
680 | * Wyznacza sumę kontrolną CRC32. |
| 11360 | 681 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
682 | * \param crc Suma kontrola poprzedniego bloku danych lub 0 jeśli liczona |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
683 | * jest suma kontrolna pierwszego bloku |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
684 | * \param buf Bufor danych |
|
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
685 | * \param len Długość bufora danych |
| 11360 | 686 | * |
|
29751
438f88ecc11e
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29106
diff
changeset
|
687 | * \return Suma kontrolna. |
| 11360 | 688 | */ |
| 689 | uint32_t gg_crc32(uint32_t crc, const unsigned char *buf, int len) | |
| 690 | { | |
|
31609
d67fbc90b28a
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31294
diff
changeset
|
691 | if (buf == NULL || len < 0) |
| 11360 | 692 | return crc; |
| 693 | ||
| 694 | crc ^= 0xffffffffL; | |
| 695 | ||
| 696 | while (len--) | |
| 697 | crc = (crc >> 8) ^ gg_crc32_table[(crc ^ *buf++) & 0xff]; | |
| 698 | ||
| 699 | return crc ^ 0xffffffffL; | |
| 700 | } | |
| 701 | ||
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
702 | /** |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
703 | * \internal Parsuje identyfikator użytkownika. |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
704 | * |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
705 | * \param str Ciąg tekstowy, zawierający identyfikator |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
706 | * \param len Długość identyfikatora |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
707 | * |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
708 | * \return Identyfikator, lub 0, jeżeli nie udało się odczytać |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
709 | */ |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
710 | uin_t gg_str_to_uin(const char *str, int len) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
711 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
712 | char buff[11]; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
713 | char *endptr; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
714 | uin_t uin; |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
715 | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
716 | if (len < 0) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
717 | len = strlen(str); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
718 | if (len > 10) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
719 | return 0; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
720 | memcpy(buff, str, len); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
721 | buff[len] = '\0'; |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
722 | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
723 | errno = 0; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
724 | uin = strtoul(buff, &endptr, 10); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
725 | if (errno == ERANGE || endptr[0] != '\0') |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
726 | return 0; |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
727 | |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
728 | return uin; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
729 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
730 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
731 | /** |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
732 | * Szuka informacji o konferencji o podanym identyfikatorze. |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
733 | * |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
734 | * \param sess Struktura sesji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
735 | * \param id Identyfikator konferencji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
736 | * |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
737 | * \return Struktura z informacjami o konferencji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
738 | */ |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
739 | gg_chat_list_t *gg_chat_find(struct gg_session *sess, uint64_t id) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
740 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
741 | gg_chat_list_t *chat_list = sess->private_data->chat_list; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
742 | |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
743 | while (chat_list != NULL) { |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
744 | if (chat_list->id == id) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
745 | return chat_list; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
746 | chat_list = chat_list->next; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
747 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
748 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
749 | return NULL; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
750 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
751 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
752 | /** |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
753 | * \internal Aktualizuje informacje o konferencji. |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
754 | * |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
755 | * \param sess Struktura sesji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
756 | * \param id Identyfikator konferencji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
757 | * \param version Wersja informacji o konferencji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
758 | * \param participants Lista uczestników konferencji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
759 | * \param participants_count Ilość uczestników konferencji |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
760 | * |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
761 | * \return Wartość równa 0, jeżeli zakończono powodzeniem |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
762 | */ |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
763 | int gg_chat_update(struct gg_session *sess, uint64_t id, uint32_t version, |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
764 | const uin_t *participants, unsigned int participants_count) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
765 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
766 | gg_chat_list_t *chat; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
767 | uin_t *participants_new; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
768 | |
|
35627
fd11790cc4d6
Update internal libgadu to the current version from git
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35617
diff
changeset
|
769 | if (participants_count >= ~(unsigned int)0 / sizeof(uin_t)) |
|
35617
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
770 | return -1; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
771 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
772 | chat = gg_chat_find(sess, id); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
773 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
774 | if (!chat) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
775 | chat = malloc(sizeof(gg_chat_list_t)); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
776 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
777 | if (!chat) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
778 | return -1; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
779 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
780 | memset(chat, 0, sizeof(gg_chat_list_t)); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
781 | chat->id = id; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
782 | chat->next = sess->private_data->chat_list; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
783 | sess->private_data->chat_list = chat; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
784 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
785 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
786 | participants_new = realloc(chat->participants, |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
787 | sizeof(uin_t) * participants_count); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
788 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
789 | if (participants_new == NULL) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
790 | return -1; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
791 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
792 | chat->version = version; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
793 | chat->participants = participants_new; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
794 | chat->participants_count = participants_count; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
795 | memcpy(chat->participants, participants, |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
796 | sizeof(uin_t) * participants_count); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
797 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
798 | return 0; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
799 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
800 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
801 | void gg_connection_failure(struct gg_session *gs, struct gg_event *ge, |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
802 | enum gg_failure_t failure) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
803 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
804 | gg_close(gs); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
805 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
806 | if (ge != NULL) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
807 | ge->type = GG_EVENT_CONN_FAILED; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
808 | ge->event.failure = failure; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
809 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
810 | gs->state = GG_STATE_IDLE; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
811 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
812 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
813 | time_t gg_server_time(struct gg_session *gs) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
814 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
815 | time_t now = time(NULL); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
816 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
817 | if (gs == NULL || gs->private_data == NULL) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
818 | gg_debug_session(gs, GG_DEBUG_ERROR, "time diff data is not " |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
819 | "accessible\n"); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
820 | return now; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
821 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
822 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
823 | return now + gs->private_data->time_diff; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
824 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
825 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
826 | void gg_strarr_free(char **strarr) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
827 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
828 | char **it; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
829 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
830 | if (strarr == NULL) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
831 | return; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
832 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
833 | for (it = strarr; *it != NULL; it++) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
834 | free(*it); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
835 | free(strarr); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
836 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
837 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
838 | char ** gg_strarr_dup(char **strarr) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
839 | { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
840 | size_t i, len, size; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
841 | char **it, **out; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
842 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
843 | if (strarr == NULL) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
844 | return NULL; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
845 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
846 | len = 0; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
847 | for (it = strarr; *it != NULL; it++) |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
848 | len++; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
849 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
850 | size = (len + 1) * sizeof(char*); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
851 | out = malloc(size); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
852 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
853 | if (out == NULL) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
854 | gg_debug(GG_DEBUG_MISC | GG_DEBUG_ERROR, "// gg_strarr_dup() " |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
855 | "not enough memory for the array\n"); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
856 | return NULL; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
857 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
858 | memset(out, 0, size); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
859 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
860 | for (i = 0; i < len; i++) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
861 | out[i] = strdup(strarr[i]); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
862 | if (out[i] == NULL) { |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
863 | gg_debug(GG_DEBUG_MISC | GG_DEBUG_ERROR, |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
864 | "// gg_strarr_dup() " |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
865 | "not enough memory for the array element\n"); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
866 | gg_strarr_free(out); |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
867 | return NULL; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
868 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
869 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
870 | |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
871 | return out; |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
872 | } |
|
c9069e0e3c36
Update internal libgadu to 1.12.0-rc2
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33709
diff
changeset
|
873 | |
| 11360 | 874 | /* |
| 875 | * Local variables: | |
| 876 | * c-indentation-style: k&r | |
| 877 | * c-basic-offset: 8 | |
| 878 | * indent-tabs-mode: notnil | |
| 879 | * End: | |
| 880 | * | |
| 881 | * vim: shiftwidth=8: | |
| 882 | */ |