comparison src/protocols/qq/udp_proxy_s5.c @ 14021:ef8490f9e823

[gaim-migrate @ 16618] Replaced all C++-style comments with C-style ones. Cleaned up some comments and implemented a more consistent formatting scheme. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Wed, 02 Aug 2006 15:35:36 +0000
parents 983fd420e86b
children 3cefea0bf4a2
comparison
equal deleted inserted replaced
14020:13e7ba964993 14021:ef8490f9e823
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24 // START OF FILE 24 #include "debug.h"
25 /*****************************************************************************/
26 #include "debug.h" // gaim_debug
27 25
28 #include "udp_proxy_s5.h" 26 #include "udp_proxy_s5.h"
29 27
30 extern gint // defined in qq_proxy.c 28 extern gint /* defined in qq_proxy.c */
31 _qq_fill_host(struct sockaddr_in *addr, const gchar * host, guint16 port); 29 _qq_fill_host(struct sockaddr_in *addr, const gchar * host, guint16 port);
32 30
33 /*****************************************************************************/
34 static void _qq_s5_canread_again(gpointer data, gint source, GaimInputCondition cond) 31 static void _qq_s5_canread_again(gpointer data, gint source, GaimInputCondition cond)
35 { 32 {
36 unsigned char buf[512]; 33 unsigned char buf[512];
37 struct PHB *phb = data; 34 struct PHB *phb = data;
38 struct sockaddr_in sin; 35 struct sockaddr_in sin;
101 98
102 g_free(phb->host); 99 g_free(phb->host);
103 g_free(phb); 100 g_free(phb);
104 } 101 }
105 102
106 /*****************************************************************************/
107 static void _qq_s5_sendconnect(gpointer data, gint source) 103 static void _qq_s5_sendconnect(gpointer data, gint source)
108 { 104 {
109 unsigned char buf[512]; 105 unsigned char buf[512];
110 struct PHB *phb = data; 106 struct PHB *phb = data;
111 struct sockaddr_in sin, ctlsin; 107 struct sockaddr_in sin, ctlsin;
171 } 167 }
172 168
173 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, _qq_s5_canread_again, phb); 169 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, _qq_s5_canread_again, phb);
174 } 170 }
175 171
176 /*****************************************************************************/
177 static void _qq_s5_readauth(gpointer data, gint source, GaimInputCondition cond) 172 static void _qq_s5_readauth(gpointer data, gint source, GaimInputCondition cond)
178 { 173 {
179 unsigned char buf[512]; 174 unsigned char buf[512];
180 struct PHB *phb = data; 175 struct PHB *phb = data;
181 176
209 } 204 }
210 205
211 _qq_s5_sendconnect(phb, source); 206 _qq_s5_sendconnect(phb, source);
212 } 207 }
213 208
214 /*****************************************************************************/
215 static void _qq_s5_canread(gpointer data, gint source, GaimInputCondition cond) 209 static void _qq_s5_canread(gpointer data, gint source, GaimInputCondition cond)
216 { 210 {
217 unsigned char buf[512]; 211 unsigned char buf[512];
218 struct PHB *phb = data; 212 struct PHB *phb = data;
219 213
279 gaim_debug(GAIM_DEBUG_INFO, "s5_canread", "calling s5_sendconnect\n"); 273 gaim_debug(GAIM_DEBUG_INFO, "s5_canread", "calling s5_sendconnect\n");
280 _qq_s5_sendconnect(phb, source); 274 _qq_s5_sendconnect(phb, source);
281 } 275 }
282 } 276 }
283 277
284 /*****************************************************************************/
285 void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond) 278 void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond)
286 { 279 {
287 unsigned char buf[512]; 280 unsigned char buf[512];
288 int i; 281 int i;
289 struct PHB *phb = data; 282 struct PHB *phb = data;
340 } 333 }
341 334
342 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, _qq_s5_canread, phb); 335 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, _qq_s5_canread, phb);
343 } 336 }
344 337
345 /*****************************************************************************/ 338 gint qq_proxy_socks5(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen)
346 gint qq_proxy_socks5(struct PHB * phb, struct sockaddr * addr, socklen_t addrlen) 339 {
347 {
348
349 gint fd; 340 gint fd;
350 gaim_debug(GAIM_DEBUG_INFO, "QQ", 341 gaim_debug(GAIM_DEBUG_INFO, "QQ",
351 "Connecting to %s:%d via %s:%d using SOCKS5\n", 342 "Connecting to %s:%d via %s:%d using SOCKS5\n",
352 phb->host, phb->port, gaim_proxy_info_get_host(phb->gpi), gaim_proxy_info_get_port(phb->gpi)); 343 phb->host, phb->port, gaim_proxy_info_get_host(phb->gpi), gaim_proxy_info_get_port(phb->gpi));
353 344
362 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Connect in asynchronous mode.\n"); 353 gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Connect in asynchronous mode.\n");
363 phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, _qq_s5_canwrite, phb); 354 phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, _qq_s5_canwrite, phb);
364 } else { 355 } else {
365 close(fd); 356 close(fd);
366 return -1; 357 return -1;
367 } // if error 358 }
368 } else { 359 } else {
369 gaim_debug(GAIM_DEBUG_MISC, "QQ", "Connect in blocking mode.\n"); 360 gaim_debug(GAIM_DEBUG_MISC, "QQ", "Connect in blocking mode.\n");
370 fcntl(fd, F_SETFL, 0); 361 fcntl(fd, F_SETFL, 0);
371 _qq_s5_canwrite(phb, fd, GAIM_INPUT_WRITE); 362 _qq_s5_canwrite(phb, fd, GAIM_INPUT_WRITE);
372 } // if connect 363 }
373 364
374 return fd; 365 return fd;
375 } // qq_proxy_connect 366 }