Mercurial > pidgin
annotate src/sslconn.c @ 19789:7e36832172a9
[gaim-migrate @ 16601]
change Windows Live ID authentication code style
to simplify the code.
add some comments
committed by Ma Yuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Sun, 30 Jul 2006 15:55:30 +0000 |
parents | b76c6de0c3b5 |
children | 8a8b4f7f7d99 |
rev | line source |
---|---|
6703 | 1 /** |
2 * @file sslconn.c SSL API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6703 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include "internal.h" | |
26 | |
27 #include "debug.h" | |
28 #include "sslconn.h" | |
29 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
30 static gboolean _ssl_initialized = FALSE; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
31 static GaimSslOps *_ssl_ops = NULL; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
32 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
33 static gboolean |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
34 ssl_init(void) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
35 { |
7018
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
36 GaimPlugin *plugin; |
7863 | 37 GaimSslOps *ops; |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
38 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
39 if (_ssl_initialized) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
40 return FALSE; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
41 |
7024
001d11a7e345
[gaim-migrate @ 7587]
Christian Hammond <chipx86@chipx86.com>
parents:
7018
diff
changeset
|
42 plugin = gaim_plugins_find_with_id("core-ssl"); |
7018
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
43 |
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
44 if (plugin != NULL && !gaim_plugin_is_loaded(plugin)) |
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
45 gaim_plugin_load(plugin); |
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
46 |
7863 | 47 ops = gaim_ssl_get_ops(); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
48 if (ops != NULL && ops->init != NULL) |
7863 | 49 return ops->init(); |
50 else | |
51 return FALSE; | |
6703 | 52 } |
53 | |
54 gboolean | |
55 gaim_ssl_is_supported(void) | |
56 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
57 #ifdef HAVE_SSL |
7355 | 58 ssl_init(); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
59 return (gaim_ssl_get_ops() != NULL); |
6703 | 60 #else |
61 return FALSE; | |
62 #endif | |
63 } | |
64 | |
65 GaimSslConnection * | |
66 gaim_ssl_connect(GaimAccount *account, const char *host, int port, | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
67 GaimSslInputFunction func, GaimSslErrorFunction error_func, |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
68 void *data) |
6703 | 69 { |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
70 GaimSslConnection *gsc; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
71 GaimSslOps *ops; |
6703 | 72 int i; |
73 | |
74 g_return_val_if_fail(host != NULL, NULL); | |
75 g_return_val_if_fail(port != 0 && port != -1, NULL); | |
76 g_return_val_if_fail(func != NULL, NULL); | |
77 g_return_val_if_fail(gaim_ssl_is_supported(), NULL); | |
78 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
79 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
80 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
81 g_return_val_if_fail(ops != NULL, NULL); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
82 g_return_val_if_fail(ops->connect_cb != NULL, NULL); |
6703 | 83 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
84 if (!_ssl_initialized) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
85 { |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
86 if (!ssl_init()) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
87 return NULL; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
88 } |
6703 | 89 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
90 gsc = g_new0(GaimSslConnection, 1); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
91 |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
92 gsc->host = g_strdup(host); |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
93 gsc->port = port; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
94 gsc->connect_cb_data = data; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
95 gsc->connect_cb = func; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
96 gsc->error_cb = error_func; |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
97 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
98 i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); |
6703 | 99 |
100 if (i < 0) | |
101 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
102 g_free(gsc->host); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
103 g_free(gsc); |
6703 | 104 |
105 return NULL; | |
106 } | |
107 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
108 return (GaimSslConnection *)gsc; |
6703 | 109 } |
110 | |
6764 | 111 static void |
112 recv_cb(gpointer data, gint source, GaimInputCondition cond) | |
113 { | |
114 GaimSslConnection *gsc = data; | |
115 | |
116 gsc->recv_cb(gsc->recv_cb_data, gsc, cond); | |
117 } | |
118 | |
119 void | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
120 gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
121 void *data) |
6764 | 122 { |
123 g_return_if_fail(func != NULL); | |
124 g_return_if_fail(gaim_ssl_is_supported()); | |
125 | |
126 gsc->recv_cb_data = data; | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
127 gsc->recv_cb = func; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
128 |
6764 | 129 gsc->inpa = gaim_input_add(gsc->fd, GAIM_INPUT_READ, recv_cb, gsc); |
130 } | |
131 | |
6762
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
132 GaimSslConnection * |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
133 gaim_ssl_connect_fd(GaimAccount *account, int fd, |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
134 GaimSslInputFunction func, |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
135 GaimSslErrorFunction error_func, void *data) |
6762
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
136 { |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
137 GaimSslConnection *gsc; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
138 GaimSslOps *ops; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
139 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
140 g_return_val_if_fail(fd > 0, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
141 g_return_val_if_fail(func != NULL, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
142 g_return_val_if_fail(gaim_ssl_is_supported(), NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
143 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
144 ops = gaim_ssl_get_ops(); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
145 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
146 g_return_val_if_fail(ops != NULL, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
147 g_return_val_if_fail(ops->connect_cb != NULL, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
148 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
149 if (!_ssl_initialized) |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
150 { |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
151 if (!ssl_init()) |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
152 return NULL; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
153 } |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
154 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
155 gsc = g_new0(GaimSslConnection, 1); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
156 |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
157 gsc->connect_cb_data = data; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
158 gsc->connect_cb = func; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
159 gsc->error_cb = error_func; |
6762
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
160 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
161 ops->connect_cb(gsc, fd, GAIM_INPUT_READ); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
162 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
163 return (GaimSslConnection *)gsc; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
164 } |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
165 |
6703 | 166 void |
167 gaim_ssl_close(GaimSslConnection *gsc) | |
168 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
169 GaimSslOps *ops; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
170 |
6703 | 171 g_return_if_fail(gsc != NULL); |
172 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
173 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
174 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
175 if (gsc->inpa) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
176 gaim_input_remove(gsc->inpa); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
177 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
178 if (ops != NULL && ops->close != NULL) |
6745
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
179 (ops->close)(gsc); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
180 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
181 if (gsc->fd) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
182 close(gsc->fd); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
183 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
184 if (gsc->host != NULL) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
185 g_free(gsc->host); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
186 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
187 g_free(gsc); |
6703 | 188 } |
189 | |
190 size_t | |
191 gaim_ssl_read(GaimSslConnection *gsc, void *data, size_t len) | |
192 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
193 GaimSslOps *ops; |
6703 | 194 |
195 g_return_val_if_fail(gsc != NULL, 0); | |
196 g_return_val_if_fail(data != NULL, 0); | |
197 g_return_val_if_fail(len > 0, 0); | |
198 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
199 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
200 |
6745
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
201 if (ops != NULL && (ops->read) != NULL) |
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
202 return (ops->read)(gsc, data, len); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
203 |
6703 | 204 return 0; |
205 } | |
206 | |
207 size_t | |
208 gaim_ssl_write(GaimSslConnection *gsc, const void *data, size_t len) | |
209 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
210 GaimSslOps *ops; |
6703 | 211 |
212 g_return_val_if_fail(gsc != NULL, 0); | |
213 g_return_val_if_fail(data != NULL, 0); | |
214 g_return_val_if_fail(len > 0, 0); | |
215 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
216 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
217 |
6745
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
218 if (ops != NULL && (ops->write) != NULL) |
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
219 return (ops->write)(gsc, data, len); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
220 |
6703 | 221 return 0; |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
222 } |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
223 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
224 void |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
225 gaim_ssl_set_ops(GaimSslOps *ops) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
226 { |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
227 _ssl_ops = ops; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
228 } |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
229 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
230 GaimSslOps * |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
231 gaim_ssl_get_ops(void) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
232 { |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
233 return _ssl_ops; |
6703 | 234 } |
235 | |
236 void | |
237 gaim_ssl_init(void) | |
238 { | |
239 } | |
240 | |
241 void | |
242 gaim_ssl_uninit(void) | |
243 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
244 GaimSslOps *ops; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
245 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
246 if (!_ssl_initialized) |
6703 | 247 return; |
248 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
249 ops = gaim_ssl_get_ops(); |
6703 | 250 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
251 if (ops != NULL && ops->uninit != NULL) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
252 ops->uninit(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
253 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
254 _ssl_initialized = FALSE; |
6703 | 255 } |