Changeset ba9edaa for protocols/proxy.c
- Timestamp:
- 2006-05-10T17:34:46Z (18 years ago)
- Branches:
- master
- Children:
- 13cc96c
- Parents:
- 67b6766
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/proxy.c
r67b6766 rba9edaa 49 49 50 50 struct PHB { 51 GaimInputFunctionfunc, proxy_func;51 b_event_handler func, proxy_func; 52 52 gpointer data, proxy_data; 53 53 char *host; … … 78 78 } 79 79 80 static void gaim_io_connected(gpointer data, gint source, GaimInputCondition cond)80 static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond) 81 81 { 82 82 struct PHB *phb = data; … … 88 88 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 89 89 closesocket(source); 90 gaim_input_remove(phb->inpa);90 b_event_remove(phb->inpa); 91 91 if( phb->proxy_func ) 92 92 phb->proxy_func(phb->proxy_data, -1, GAIM_INPUT_READ); … … 95 95 g_free(phb); 96 96 } 97 return ;97 return FALSE; 98 98 } 99 99 #endif 100 100 sock_make_blocking(source); 101 gaim_input_remove(phb->inpa);101 b_event_remove(phb->inpa); 102 102 if( phb->proxy_func ) 103 103 phb->proxy_func(phb->proxy_data, source, GAIM_INPUT_READ); … … 106 106 g_free(phb); 107 107 } 108 109 return FALSE; 108 110 } 109 111 … … 127 129 if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { 128 130 if (sockerr_again()) { 129 phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);131 phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb); 130 132 phb->fd = fd; 131 133 } else { … … 145 147 #define HTTP_GOODSTRING2 "HTTP/1.1 200 Connection established" 146 148 147 static void http_canread(gpointer data, gint source, GaimInputCondition cond)149 static gboolean http_canread(gpointer data, gint source, b_input_condition cond) 148 150 { 149 151 int nlc = 0; … … 152 154 char inputline[8192]; 153 155 154 gaim_input_remove(phb->inpa);156 b_event_remove(phb->inpa); 155 157 156 158 while ((pos < sizeof(inputline)-1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) { … … 167 169 g_free(phb->host); 168 170 g_free(phb); 169 return ;171 return FALSE; 170 172 } 171 173 … … 174 176 g_free(phb->host); 175 177 g_free(phb); 176 return; 177 } 178 179 static void http_canwrite(gpointer data, gint source, GaimInputCondition cond) 178 179 return FALSE; 180 } 181 182 static gboolean http_canwrite(gpointer data, gint source, b_input_condition cond) 180 183 { 181 184 char cmd[384]; … … 184 187 int error = ETIMEDOUT; 185 188 if (phb->inpa > 0) 186 gaim_input_remove(phb->inpa);189 b_event_remove(phb->inpa); 187 190 len = sizeof(error); 188 191 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { … … 191 194 g_free(phb->host); 192 195 g_free(phb); 193 return ;196 return FALSE; 194 197 } 195 198 sock_make_blocking(source); … … 202 205 g_free(phb->host); 203 206 g_free(phb); 204 return ;207 return FALSE; 205 208 } 206 209 … … 217 220 g_free(phb->host); 218 221 g_free(phb); 219 return ;222 return FALSE; 220 223 } 221 224 } … … 227 230 g_free(phb->host); 228 231 g_free(phb); 229 return; 230 } 231 232 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_canread, phb); 232 return FALSE; 233 } 234 235 phb->inpa = b_input_add(source, GAIM_INPUT_READ, http_canread, phb); 236 237 return FALSE; 233 238 } 234 239 … … 246 251 /* Connecting to SOCKS4 proxies */ 247 252 248 static void s4_canread(gpointer data, gint source, GaimInputCondition cond)253 static gboolean s4_canread(gpointer data, gint source, b_input_condition cond) 249 254 { 250 255 unsigned char packet[12]; 251 256 struct PHB *phb = data; 252 257 253 gaim_input_remove(phb->inpa);258 b_event_remove(phb->inpa); 254 259 255 260 memset(packet, 0, sizeof(packet)); … … 258 263 g_free(phb->host); 259 264 g_free(phb); 260 return ;265 return FALSE; 261 266 } 262 267 … … 265 270 g_free(phb->host); 266 271 g_free(phb); 267 } 268 269 static void s4_canwrite(gpointer data, gint source, GaimInputCondition cond) 272 273 return FALSE; 274 } 275 276 static gboolean s4_canwrite(gpointer data, gint source, b_input_condition cond) 270 277 { 271 278 unsigned char packet[12]; … … 275 282 int error = ETIMEDOUT; 276 283 if (phb->inpa > 0) 277 gaim_input_remove(phb->inpa);284 b_event_remove(phb->inpa); 278 285 len = sizeof(error); 279 286 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { … … 282 289 g_free(phb->host); 283 290 g_free(phb); 284 return ;291 return FALSE; 285 292 } 286 293 sock_make_blocking(source); … … 292 299 g_free(phb->host); 293 300 g_free(phb); 294 return ;301 return FALSE; 295 302 } 296 303 … … 309 316 g_free(phb->host); 310 317 g_free(phb); 311 return; 312 } 313 314 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s4_canread, phb); 318 return FALSE; 319 } 320 321 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s4_canread, phb); 322 323 return FALSE; 315 324 } 316 325 … … 328 337 /* Connecting to SOCKS5 proxies */ 329 338 330 static void s5_canread_again(gpointer data, gint source, GaimInputCondition cond)339 static gboolean s5_canread_again(gpointer data, gint source, b_input_condition cond) 331 340 { 332 341 unsigned char buf[512]; 333 342 struct PHB *phb = data; 334 343 335 gaim_input_remove(phb->inpa);344 b_event_remove(phb->inpa); 336 345 337 346 if (read(source, buf, 10) < 10) { … … 340 349 g_free(phb->host); 341 350 g_free(phb); 342 return ;351 return FALSE; 343 352 } 344 353 if ((buf[0] != 0x05) || (buf[1] != 0x00)) { … … 347 356 g_free(phb->host); 348 357 g_free(phb); 349 return ;358 return FALSE; 350 359 } 351 360 … … 353 362 g_free(phb->host); 354 363 g_free(phb); 355 return; 364 365 return FALSE; 356 366 } 357 367 … … 361 371 struct PHB *phb = data; 362 372 int hlen = strlen(phb->host); 363 373 364 374 buf[0] = 0x05; 365 375 buf[1] = 0x01; /* CONNECT */ … … 379 389 } 380 390 381 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb);382 } 383 384 static void s5_readauth(gpointer data, gint source, GaimInputCondition cond)391 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb); 392 } 393 394 static gboolean s5_readauth(gpointer data, gint source, b_input_condition cond) 385 395 { 386 396 unsigned char buf[512]; 387 397 struct PHB *phb = data; 388 398 389 gaim_input_remove(phb->inpa);399 b_event_remove(phb->inpa); 390 400 391 401 if (read(source, buf, 2) < 2) { … … 394 404 g_free(phb->host); 395 405 g_free(phb); 396 return ;406 return FALSE; 397 407 } 398 408 … … 402 412 g_free(phb->host); 403 413 g_free(phb); 404 return ;414 return FALSE; 405 415 } 406 416 407 417 s5_sendconnect(phb, source); 408 } 409 410 static void s5_canread(gpointer data, gint source, GaimInputCondition cond) 418 419 return FALSE; 420 } 421 422 static gboolean s5_canread(gpointer data, gint source, b_input_condition cond) 411 423 { 412 424 unsigned char buf[512]; 413 425 struct PHB *phb = data; 414 426 415 gaim_input_remove(phb->inpa);427 b_event_remove(phb->inpa); 416 428 417 429 if (read(source, buf, 2) < 2) { … … 420 432 g_free(phb->host); 421 433 g_free(phb); 422 return ;434 return FALSE; 423 435 } 424 436 … … 428 440 g_free(phb->host); 429 441 g_free(phb); 430 return ;442 return FALSE; 431 443 } 432 444 … … 443 455 g_free(phb->host); 444 456 g_free(phb); 445 return ;457 return FALSE; 446 458 } 447 459 448 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);460 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_readauth, phb); 449 461 } else { 450 462 s5_sendconnect(phb, source); 451 463 } 452 } 453 454 static void s5_canwrite(gpointer data, gint source, GaimInputCondition cond) 464 465 return FALSE; 466 } 467 468 static gboolean s5_canwrite(gpointer data, gint source, b_input_condition cond) 455 469 { 456 470 unsigned char buf[512]; … … 460 474 int error = ETIMEDOUT; 461 475 if (phb->inpa > 0) 462 gaim_input_remove(phb->inpa);476 b_event_remove(phb->inpa); 463 477 len = sizeof(error); 464 478 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { … … 467 481 g_free(phb->host); 468 482 g_free(phb); 469 return ;483 return FALSE; 470 484 } 471 485 sock_make_blocking(source); … … 489 503 g_free(phb->host); 490 504 g_free(phb); 491 return; 492 } 493 494 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread, phb); 505 return FALSE; 506 } 507 508 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread, phb); 509 510 return FALSE; 495 511 } 496 512 … … 508 524 /* Export functions */ 509 525 510 int proxy_connect(const char *host, int port, GaimInputFunctionfunc, gpointer data)526 int proxy_connect(const char *host, int port, b_event_handler func, gpointer data) 511 527 { 512 528 struct PHB *phb;
Note: See TracChangeset
for help on using the changeset viewer.