Mercurial > pidgin.yaz
annotate plugins/icq/proxy.c @ 1309:0a766047b4fd
[gaim-migrate @ 1319]
Yay, new icqlib
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 19 Dec 2000 10:08:29 +0000 |
parents | 201ec77f3a60 |
children | 4c510ca3563f |
rev | line source |
---|---|
1152 | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
3 $Id: proxy.c 1319 2000-12-19 10:08:29Z warmenhoven $ |
1152 | 4 $Log$ |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
5 Revision 1.2 2000/12/19 10:08:29 warmenhoven |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
6 Yay, new icqlib |
1152 | 7 |
8 Revision 1.8 2000/05/10 18:51:23 denis | |
9 icq_Disconnect() now called before icq_Disconnected callback to | |
10 prevent high CPU usage in kicq's "reconnect on disconnect" code. | |
11 | |
12 Revision 1.7 2000/05/03 18:29:15 denis | |
13 Callbacks have been moved to the ICQLINK structure. | |
14 | |
15 Revision 1.6 2000/04/05 14:37:02 denis | |
16 Applied patch from "Guillaume R." <grs@mail.com> for basic Win32 | |
17 compatibility. | |
18 | |
19 Revision 1.5 1999/10/07 18:00:59 denis | |
20 proxy.h file removed. | |
21 | |
22 Revision 1.4 1999/07/16 12:01:06 denis | |
23 ICQLINK support added. | |
24 | |
25 Revision 1.3 1999/07/12 15:13:33 cproch | |
26 - added definition of ICQLINK to hold session-specific global variabled | |
27 applications which have more than one connection are now possible | |
28 - changed nearly every function defintion to support ICQLINK parameter | |
29 | |
30 Revision 1.2 1999/04/14 14:51:42 denis | |
31 Switched from icq_Log callback to icq_Fmt function. | |
32 Cleanups for "strict" compiling (-ansi -pedantic) | |
33 | |
34 Revision 1.1 1999/03/24 11:37:38 denis | |
35 Underscored files with TCP stuff renamed. | |
36 TCP stuff cleaned up | |
37 Function names changed to corresponding names. | |
38 icqlib.c splitted to many small files by subject. | |
39 C++ comments changed to ANSI C comments. | |
40 | |
41 */ | |
42 | |
43 #ifndef _WIN32 | |
44 #include <unistd.h> | |
45 #endif | |
46 | |
47 #ifdef _WIN32 | |
48 #include <winsock.h> | |
49 #endif | |
50 | |
51 #include <stdlib.h> | |
52 | |
53 #include "util.h" | |
54 #include "icqtypes.h" | |
55 #include "icq.h" | |
56 #include "icqlib.h" | |
57 | |
58 void icq_HandleProxyResponse(ICQLINK *link) | |
59 { | |
60 int s; | |
61 char buf[256]; | |
62 #ifdef _WIN32 | |
63 s = recv(link->icq_ProxySok, buf, sizeof(buf), 0); | |
64 #else | |
65 s = read(link->icq_ProxySok, &buf, sizeof(buf)); | |
66 #endif | |
67 if(s<=0) | |
68 { | |
69 icq_FmtLog(link, ICQ_LOG_FATAL, "[SOCKS] Connection terminated\n"); | |
70 icq_Disconnect(link); | |
71 if(link->icq_Disconnected) | |
72 (*link->icq_Disconnected)(link); | |
73 } | |
74 } | |
75 | |
76 /******************* | |
77 SOCKS5 Proxy support | |
78 ********************/ | |
79 void icq_SetProxy(ICQLINK *link, const char *phost, unsigned short pport, int pauth, const char *pname, const char *ppass) | |
80 { | |
81 if(link->icq_ProxyHost) | |
82 free(link->icq_ProxyHost); | |
83 if(link->icq_ProxyName) | |
84 free(link->icq_ProxyName); | |
85 if(link->icq_ProxyPass) | |
86 free(link->icq_ProxyPass); | |
87 if(strlen(pname)>255) | |
88 { | |
89 icq_FmtLog(link, ICQ_LOG_ERROR, "[SOCKS] User name greater than 255 chars\n"); | |
90 link->icq_UseProxy = 0; | |
91 return; | |
92 } | |
93 if(strlen(ppass)>255) | |
94 { | |
95 icq_FmtLog(link, ICQ_LOG_ERROR, "[SOCKS] User password greater than 255 chars\n"); | |
96 link->icq_UseProxy = 0; | |
97 return; | |
98 } | |
99 link->icq_UseProxy = 1; | |
100 link->icq_ProxyHost = strdup(phost); | |
101 link->icq_ProxyPort = pport; | |
102 link->icq_ProxyAuth = pauth; | |
103 link->icq_ProxyName = strdup(pname); | |
104 link->icq_ProxyPass = strdup(ppass); | |
105 } | |
106 | |
107 void icq_UnsetProxy(ICQLINK *link) | |
108 { | |
109 link->icq_UseProxy = 0; | |
110 } | |
111 | |
112 int icq_GetProxySok(ICQLINK *link) | |
113 { | |
114 return link->icq_ProxySok; | |
115 } |