1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
4 * $Id: proxy.c 2096 2001-07-31 01:00:39Z warmenhoven $
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
7 * Bill Soudan <soudan@kde.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
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
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 void icq_HandleProxyResponse(icq_Link
*icqlink
)
38 s
= recv(icqlink
->icq_ProxySok
, buf
, sizeof(buf
), 0);
40 s
= read(icqlink
->icq_ProxySok
, &buf
, sizeof(buf
));
44 icq_FmtLog(icqlink
, ICQ_LOG_FATAL
, "[SOCKS] Connection terminated\n");
45 icq_Disconnect(icqlink
);
46 invoke_callback(icqlink
, icq_Disconnected
)(icqlink
);
53 void icq_SetProxy(icq_Link
*icqlink
, const char *phost
, unsigned short pport
,
54 int pauth
, const char *pname
, const char *ppass
)
56 if(icqlink
->icq_ProxyHost
)
57 free(icqlink
->icq_ProxyHost
);
58 if(icqlink
->icq_ProxyName
)
59 free(icqlink
->icq_ProxyName
);
60 if(icqlink
->icq_ProxyPass
)
61 free(icqlink
->icq_ProxyPass
);
65 icq_FmtLog(icqlink
, ICQ_LOG_ERROR
, "[SOCKS] Proxy host is empty\n");
66 icqlink
->icq_UseProxy
= 0;
71 icq_FmtLog(icqlink
, ICQ_LOG_ERROR
, "[SOCKS] User name is empty\n");
72 icqlink
->icq_UseProxy
= 0;
77 icq_FmtLog(icqlink
, ICQ_LOG_ERROR
, "[SOCKS] User password is empty\n");
78 icqlink
->icq_UseProxy
= 0;
84 icq_FmtLog(icqlink
, ICQ_LOG_ERROR
, "[SOCKS] User name greater than 255 chars\n");
85 icqlink
->icq_UseProxy
= 0;
90 icq_FmtLog(icqlink
, ICQ_LOG_ERROR
, "[SOCKS] User password greater than 255 chars\n");
91 icqlink
->icq_UseProxy
= 0;
95 icqlink
->icq_UseProxy
= 1;
96 icqlink
->icq_ProxyHost
= strdup(phost
);
97 icqlink
->icq_ProxyPort
= pport
;
98 icqlink
->icq_ProxyAuth
= pauth
;
99 icqlink
->icq_ProxyName
= strdup(pname
);
100 icqlink
->icq_ProxyPass
= strdup(ppass
);
103 void icq_UnsetProxy(icq_Link
*icqlink
)
105 icqlink
->icq_UseProxy
= 0;
108 int icq_GetProxySok(icq_Link
*icqlink
)
110 return icqlink
->icq_ProxySok
;