Mercurial > pidgin.yaz
annotate src/sslconn.c @ 7279:0d24c94e4fbc
[gaim-migrate @ 7858]
compiling is super-cool
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 16 Oct 2003 03:58:50 +0000 |
parents | 448e39ace278 |
children | ef0684dfdf74 |
rev | line source |
---|---|
6703 | 1 /** |
2 * @file sslconn.c SSL API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
8 * | |
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. | |
13 * | |
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. | |
18 * | |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #include "internal.h" | |
24 | |
25 #include "debug.h" | |
26 #include "sslconn.h" | |
27 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
28 static gboolean _ssl_initialized = FALSE; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
29 static GaimSslOps *_ssl_ops = NULL; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
30 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
31 static gboolean |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
32 ssl_init(void) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
33 { |
7018
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
34 GaimPlugin *plugin; |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
35 GaimSslOps *ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
36 gboolean success = FALSE; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
37 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
38 if (_ssl_initialized) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
39 return FALSE; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
40 |
7024
001d11a7e345
[gaim-migrate @ 7587]
Christian Hammond <chipx86@chipx86.com>
parents:
7018
diff
changeset
|
41 plugin = gaim_plugins_find_with_id("core-ssl"); |
7018
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
42 |
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
43 if (plugin != NULL && !gaim_plugin_is_loaded(plugin)) |
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
44 gaim_plugin_load(plugin); |
cd8a9907c779
[gaim-migrate @ 7581]
Christian Hammond <chipx86@chipx86.com>
parents:
7016
diff
changeset
|
45 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
46 if (ops != NULL && ops->init != NULL) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
47 success = ops->init(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
48 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
49 _ssl_initialized = success; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
50 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
51 return success; |
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 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
58 return (gaim_ssl_get_ops() != NULL); |
6703 | 59 #else |
60 return FALSE; | |
61 #endif | |
62 } | |
63 | |
64 GaimSslConnection * | |
65 gaim_ssl_connect(GaimAccount *account, const char *host, int port, | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
66 GaimSslInputFunction func, GaimSslErrorFunction error_func, |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
67 void *data) |
6703 | 68 { |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
69 GaimSslConnection *gsc; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
70 GaimSslOps *ops; |
6703 | 71 int i; |
72 | |
73 g_return_val_if_fail(host != NULL, NULL); | |
74 g_return_val_if_fail(port != 0 && port != -1, NULL); | |
75 g_return_val_if_fail(func != NULL, NULL); | |
76 g_return_val_if_fail(gaim_ssl_is_supported(), NULL); | |
77 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
78 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
79 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
80 g_return_val_if_fail(ops != NULL, NULL); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
81 g_return_val_if_fail(ops->connect_cb != NULL, NULL); |
6703 | 82 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
83 if (!_ssl_initialized) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
84 { |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
85 if (!ssl_init()) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
86 return NULL; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
87 } |
6703 | 88 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
89 gsc = g_new0(GaimSslConnection, 1); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
90 |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
91 gsc->host = g_strdup(host); |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
92 gsc->port = port; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
93 gsc->connect_cb_data = data; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
94 gsc->connect_cb = func; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
95 gsc->error_cb = error_func; |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
96 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
97 i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); |
6703 | 98 |
99 if (i < 0) | |
100 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
101 g_free(gsc->host); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
102 g_free(gsc); |
6703 | 103 |
104 return NULL; | |
105 } | |
106 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
107 return (GaimSslConnection *)gsc; |
6703 | 108 } |
109 | |
6764 | 110 static void |
111 recv_cb(gpointer data, gint source, GaimInputCondition cond) | |
112 { | |
113 GaimSslConnection *gsc = data; | |
114 | |
115 gsc->recv_cb(gsc->recv_cb_data, gsc, cond); | |
116 } | |
117 | |
118 void | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
119 gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
120 void *data) |
6764 | 121 { |
122 GaimSslOps *ops; | |
123 | |
124 g_return_if_fail(func != NULL); | |
125 g_return_if_fail(gaim_ssl_is_supported()); | |
126 | |
127 ops = gaim_ssl_get_ops(); | |
128 | |
129 gsc->recv_cb_data = data; | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
130 gsc->recv_cb = func; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
131 |
6764 | 132 gsc->inpa = gaim_input_add(gsc->fd, GAIM_INPUT_READ, recv_cb, gsc); |
133 } | |
134 | |
6762
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
135 GaimSslConnection * |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
136 gaim_ssl_connect_fd(GaimAccount *account, int fd, |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
137 GaimSslInputFunction func, |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
138 GaimSslErrorFunction error_func, void *data) |
6762
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 GaimSslConnection *gsc; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
141 GaimSslOps *ops; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
142 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
143 g_return_val_if_fail(fd > 0, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
144 g_return_val_if_fail(func != NULL, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
145 g_return_val_if_fail(gaim_ssl_is_supported(), NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
146 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
147 ops = gaim_ssl_get_ops(); |
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 g_return_val_if_fail(ops != NULL, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
150 g_return_val_if_fail(ops->connect_cb != NULL, NULL); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
151 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
152 if (!_ssl_initialized) |
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 if (!ssl_init()) |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
155 return NULL; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
156 } |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
157 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
158 gsc = g_new0(GaimSslConnection, 1); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
159 |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
160 gsc->connect_cb_data = data; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
161 gsc->connect_cb = func; |
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7024
diff
changeset
|
162 gsc->error_cb = error_func; |
6762
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
163 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
164 ops->connect_cb(gsc, fd, GAIM_INPUT_READ); |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
165 |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
166 return (GaimSslConnection *)gsc; |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
167 } |
818ce550d2ce
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6745
diff
changeset
|
168 |
6703 | 169 void |
170 gaim_ssl_close(GaimSslConnection *gsc) | |
171 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
172 GaimSslOps *ops; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
173 |
6703 | 174 g_return_if_fail(gsc != NULL); |
175 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
176 ops = gaim_ssl_get_ops(); |
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 (gsc->inpa) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
179 gaim_input_remove(gsc->inpa); |
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 (ops != NULL && ops->close != NULL) |
6745
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
182 (ops->close)(gsc); |
6738
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->fd) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
185 close(gsc->fd); |
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 if (gsc->host != NULL) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
188 g_free(gsc->host); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
189 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
190 g_free(gsc); |
6703 | 191 } |
192 | |
193 size_t | |
194 gaim_ssl_read(GaimSslConnection *gsc, void *data, size_t len) | |
195 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
196 GaimSslOps *ops; |
6703 | 197 |
198 g_return_val_if_fail(gsc != NULL, 0); | |
199 g_return_val_if_fail(data != NULL, 0); | |
200 g_return_val_if_fail(len > 0, 0); | |
201 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
202 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
203 |
6745
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
204 if (ops != NULL && (ops->read) != NULL) |
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
205 return (ops->read)(gsc, data, len); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
206 |
6703 | 207 return 0; |
208 } | |
209 | |
210 size_t | |
211 gaim_ssl_write(GaimSslConnection *gsc, const void *data, size_t len) | |
212 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
213 GaimSslOps *ops; |
6703 | 214 |
215 g_return_val_if_fail(gsc != NULL, 0); | |
216 g_return_val_if_fail(data != NULL, 0); | |
217 g_return_val_if_fail(len > 0, 0); | |
218 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
219 ops = gaim_ssl_get_ops(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
220 |
6745
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
221 if (ops != NULL && (ops->write) != NULL) |
57a24492434b
[gaim-migrate @ 7277]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6738
diff
changeset
|
222 return (ops->write)(gsc, data, len); |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
223 |
6703 | 224 return 0; |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
225 } |
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 void |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
228 gaim_ssl_set_ops(GaimSslOps *ops) |
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 _ssl_ops = ops; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
231 } |
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 GaimSslOps * |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
234 gaim_ssl_get_ops(void) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
235 { |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
236 return _ssl_ops; |
6703 | 237 } |
238 | |
239 void | |
240 gaim_ssl_init(void) | |
241 { | |
242 } | |
243 | |
244 void | |
245 gaim_ssl_uninit(void) | |
246 { | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
247 GaimSslOps *ops; |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
248 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
249 if (!_ssl_initialized) |
6703 | 250 return; |
251 | |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
252 ops = gaim_ssl_get_ops(); |
6703 | 253 |
6738
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
254 if (ops != NULL && ops->uninit != NULL) |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
255 ops->uninit(); |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
256 |
6c95f01aaf49
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6735
diff
changeset
|
257 _ssl_initialized = FALSE; |
6703 | 258 } |