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;
|
516
|
30 int resetptr;
|
|
31 size_t ret;
|
168
|
32
|
|
33 params = request->protocol_data;
|
|
34 if (request->cached)
|
|
35 {
|
|
36 params->real_read_function = gftp_fd_read;
|
|
37 request->write_function = gftp_fd_write;
|
|
38 resetptr = 1;
|
|
39 }
|
|
40 else
|
|
41 resetptr = 0;
|
|
42
|
|
43 ret = rfc2068_get_next_file (request, fle, fd);
|
|
44
|
|
45 if (resetptr)
|
|
46 {
|
|
47 params->real_read_function = gftp_ssl_read;
|
|
48 request->write_function = gftp_ssl_write;
|
|
49 }
|
|
50
|
|
51 return (ret);
|
|
52 }
|
169
|
53 #endif
|
168
|
54
|
|
55 void
|
|
56 https_register_module (void)
|
|
57 {
|
174
|
58 #ifdef USE_SSL
|
|
59 ssl_register_module ();
|
|
60 #endif
|
168
|
61 }
|
|
62
|
|
63
|
173
|
64 int
|
168
|
65 https_init (gftp_request * request)
|
|
66 {
|
169
|
67 #ifdef USE_SSL
|
168
|
68 rfc2068_params * params;
|
173
|
69 int ret;
|
168
|
70
|
173
|
71 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
|
168
|
72
|
173
|
73 if ((ret = gftp_protocols[GFTP_HTTP_NUM].init (request)) < 0)
|
|
74 return (ret);
|
|
75
|
168
|
76 params = request->protocol_data;
|
415
|
77 request->protonum = GFTP_HTTPS_NUM;
|
168
|
78 request->init = https_init;
|
|
79 request->post_connect = gftp_ssl_session_setup;
|
|
80 params->real_read_function = gftp_ssl_read;
|
|
81 request->write_function = gftp_ssl_write;
|
|
82 request->get_next_file = https_get_next_file;
|
|
83 request->url_prefix = g_strdup ("https");
|
173
|
84
|
|
85 if ((ret = gftp_ssl_startup (NULL)) < 0)
|
|
86 return (ret);
|
169
|
87
|
173
|
88 return (0);
|
|
89 #else
|
186
|
90 request->logging_function (gftp_logging_error, request,
|
173
|
91 _("HTTPS Support unavailable since SSL support was not compiled in. Aborting connection.\n"));
|
|
92
|
|
93 return (GFTP_EFATAL);
|
169
|
94 #endif
|
168
|
95 }
|
|
96
|