comparison src/html.c @ 3717:988485669631

[gaim-migrate @ 3850] Warning fixes and WIN32 ifdef removals committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Wed, 16 Oct 2002 19:57:03 +0000
parents 9682c0e022c6
children a789969fc198
comparison
equal deleted inserted replaced
3716:d7e83b4db191 3717:988485669631
30 #include <sys/time.h> 30 #include <sys/time.h>
31 #include <unistd.h> 31 #include <unistd.h>
32 #include <sys/socket.h> 32 #include <sys/socket.h>
33 #include <netdb.h> 33 #include <netdb.h>
34 #include <netinet/in.h> 34 #include <netinet/in.h>
35 #else
36 #include <winsock.h>
37 #include <io.h>
38 #endif 35 #endif
39 36
40 #include <sys/types.h> 37 #include <sys/types.h>
41 #include <fcntl.h> 38 #include <fcntl.h>
42 #include <errno.h> 39 #include <errno.h>
43 #include "gaim.h" 40 #include "gaim.h"
44 #include "proxy.h" 41 #include "proxy.h"
42
43 #ifdef _WIN32
44 #include "win32dep.h"
45 #endif
45 46
46 gchar *strip_html(gchar *text) 47 gchar *strip_html(gchar *text)
47 { 48 {
48 int i, j, k; 49 int i, j, k;
49 int visible = 1; 50 int visible = 1;
142 return; 143 return;
143 } 144 }
144 145
145 if (!gunk->sentreq) { 146 if (!gunk->sentreq) {
146 char buf[256]; 147 char buf[256];
147 #ifdef _WIN32 148
148 int imode=1;
149 #endif
150 g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/", 149 g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/",
151 gunk->full ? gunk->url : gunk->website->page); 150 gunk->full ? gunk->url : gunk->website->page);
152 debug_printf("Request: %s\n", buf); 151 debug_printf("Request: %s\n", buf);
153 #ifdef _WIN32 152
154 send(sock, buf, strlen(buf), 0);
155 ioctlsocket(sock, FIONBIO, (unsigned long *)&imode);
156 #else
157 write(sock, buf, strlen(buf)); 153 write(sock, buf, strlen(buf));
158 fcntl(sock, F_SETFL, O_NONBLOCK); 154 fcntl(sock, F_SETFL, O_NONBLOCK);
159 #endif
160 gunk->sentreq = TRUE; 155 gunk->sentreq = TRUE;
161 gunk->inpa = gaim_input_add(sock, GAIM_INPUT_READ, grab_url_callback, dat); 156 gunk->inpa = gaim_input_add(sock, GAIM_INPUT_READ, grab_url_callback, dat);
162 return; 157 return;
163 } 158 }
164 159
165 #ifdef _WIN32
166 if (recv(sock, &data, 1, 0) > 0 || WSAEWOULDBLOCK == WSAGetLastError()) {
167 if (WSAEWOULDBLOCK == WSAGetLastError()) {
168 WSASetLastError(0);
169 return;
170 }
171 #else
172 if (read(sock, &data, 1) > 0 || errno == EWOULDBLOCK) { 160 if (read(sock, &data, 1) > 0 || errno == EWOULDBLOCK) {
173 if (errno == EWOULDBLOCK) { 161 if (errno == EWOULDBLOCK) {
174 errno = 0; 162 errno = 0;
175 return; 163 return;
176 } 164 }
177 #endif
178 if (!gunk->startsaving) { 165 if (!gunk->startsaving) {
179 if (data == '\r') 166 if (data == '\r')
180 return; 167 return;
181 if (data == '\n') { 168 if (data == '\n') {
182 if (gunk->newline) 169 if (gunk->newline)
189 } else { 176 } else {
190 gunk->len++; 177 gunk->len++;
191 gunk->webdata = g_realloc(gunk->webdata, gunk->len); 178 gunk->webdata = g_realloc(gunk->webdata, gunk->len);
192 gunk->webdata[gunk->len - 1] = data; 179 gunk->webdata[gunk->len - 1] = data;
193 } 180 }
194 #ifdef _WIN32
195 } else if (WSAETIMEDOUT == WSAGetLastError()) {
196 #else
197 } else if (errno != ETIMEDOUT) { 181 } else if (errno != ETIMEDOUT) {
198 #endif
199 gunk->webdata = g_realloc(gunk->webdata, gunk->len + 1); 182 gunk->webdata = g_realloc(gunk->webdata, gunk->len + 1);
200 gunk->webdata[gunk->len] = 0; 183 gunk->webdata[gunk->len] = 0;
201 184
202 debug_printf(_("Received: '%s'\n"), gunk->webdata); 185 debug_printf(_("Received: '%s'\n"), gunk->webdata);
203 186
204 gaim_input_remove(gunk->inpa); 187 gaim_input_remove(gunk->inpa);
205 #ifdef _WIN32
206 closesocket(sock);
207 #else
208 close(sock); 188 close(sock);
209 #endif
210 gunk->callback(gunk->data, gunk->webdata); 189 gunk->callback(gunk->data, gunk->webdata);
211 if (gunk->webdata) 190 if (gunk->webdata)
212 g_free(gunk->webdata); 191 g_free(gunk->webdata);
213 g_free(gunk->website); 192 g_free(gunk->website);
214 g_free(gunk->url); 193 g_free(gunk->url);
215 g_free(gunk); 194 g_free(gunk);
216 } else { 195 } else {
217 gaim_input_remove(gunk->inpa); 196 gaim_input_remove(gunk->inpa);
218 #ifdef _WIN32
219 closesocket(sock);
220 #else
221 close(sock); 197 close(sock);
222 #endif
223 gunk->callback(gunk->data, NULL); 198 gunk->callback(gunk->data, NULL);
224 if (gunk->webdata) 199 if (gunk->webdata)
225 g_free(gunk->webdata); 200 g_free(gunk->webdata);
226 g_free(gunk->website); 201 g_free(gunk->website);
227 g_free(gunk->url); 202 g_free(gunk->url);