168
|
1 /*****************************************************************************/
|
|
2 /* https.c - General purpose routines for the HTTPS protocol */
|
|
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
|
|
4 /* */
|
|
5 /* This program is free software; you can redistribute it and/or modify */
|
|
6 /* it under the terms of the GNU General Public License as published by */
|
|
7 /* the Free Software Foundation; either version 2 of the License, or */
|
|
8 /* (at your option) any later version. */
|
|
9 /* */
|
|
10 /* This program is distributed in the hope that it will be useful, */
|
|
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
13 /* GNU General Public License for more details. */
|
|
14 /* */
|
|
15 /* You should have received a copy of the GNU General Public License */
|
|
16 /* along with this program; if not, write to the Free Software */
|
|
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
|
|
18 /*****************************************************************************/
|
|
19
|
|
20 #include "gftp.h"
|
|
21 #include "httpcommon.h"
|
|
22
|
|
23 static const char cvsid[] = "$Id$";
|
|
24
|
169
|
25 #ifdef USE_SSL
|
168
|
26 static int
|
|
27 https_get_next_file (gftp_request * request, gftp_file * fle, int fd)
|
|
28 {
|
|
29 rfc2068_params * params;
|
|
30 int ret, resetptr;
|
|
31
|
|
32 params = request->protocol_data;
|
|
33 if (request->cached)
|
|
34 {
|
|
35 params->real_read_function = gftp_fd_read;
|
|
36 request->write_function = gftp_fd_write;
|
|
37 resetptr = 1;
|
|
38 }
|
|
39 else
|
|
40 resetptr = 0;
|
|
41
|
|
42 ret = rfc2068_get_next_file (request, fle, fd);
|
|
43
|
|
44 if (resetptr)
|
|
45 {
|
|
46 params->real_read_function = gftp_ssl_read;
|
|
47 request->write_function = gftp_ssl_write;
|
|
48 }
|
|
49
|
|
50 return (ret);
|
|
51 }
|
169
|
52 #endif
|
168
|
53
|
|
54 void
|
|
55 https_register_module (void)
|
|
56 {
|
174
|
57 #ifdef USE_SSL
|
|
58 ssl_register_module ();
|
|
59 #endif
|
168
|
60 }
|
|
61
|
|
62
|
173
|
63 int
|
168
|
64 https_init (gftp_request * request)
|
|
65 {
|
169
|
66 #ifdef USE_SSL
|
168
|
67 rfc2068_params * params;
|
173
|
68 int ret;
|
168
|
69
|
173
|
70 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
|
168
|
71
|
173
|
72 if ((ret = gftp_protocols[GFTP_HTTP_NUM].init (request)) < 0)
|
|
73 return (ret);
|
|
74
|
168
|
75 params = request->protocol_data;
|
|
76 request->init = https_init;
|
|
77 request->post_connect = gftp_ssl_session_setup;
|
|
78 params->real_read_function = gftp_ssl_read;
|
|
79 request->write_function = gftp_ssl_write;
|
|
80 request->get_next_file = https_get_next_file;
|
|
81 request->url_prefix = g_strdup ("https");
|
173
|
82
|
|
83 if ((ret = gftp_ssl_startup (NULL)) < 0)
|
|
84 return (ret);
|
169
|
85
|
173
|
86 return (0);
|
|
87 #else
|
186
|
88 request->logging_function (gftp_logging_error, request,
|
173
|
89 _("HTTPS Support unavailable since SSL support was not compiled in. Aborting connection.\n"));
|
|
90
|
|
91 return (GFTP_EFATAL);
|
169
|
92 #endif
|
168
|
93 }
|
|
94
|