annotate lib/https.c @ 198:8fea1b1a2ec6

2003-6-22 Brian Masney <masneyb@gftp.org> * lib/config_file.c lib/gftp.h - renamed parse_args to gftp_config_parse_args() and removed the static declaration * lib/protocols.c (gftp_request_destroy) - fixed memory problem with the new local configuration interface * src/gtk/gftp-gtk.c - added gftp_gtk_config_(read|write)_color(). I am overriding the read and write functions for gftp_option_type_color to be these functions. This is so that I can use a GdkColor structure instead of a gftp_color structure * src/gtk/misc-gtk.c - when destroying the dialogs, set the pointers to NULL before we call the callback functions. This is to make sure that they aren't being used in the callbacks * TODO - updated
author masneyb
date Mon, 23 Jun 2003 01:07:05 +0000
parents 13ca1defdc75
children 1ffdbc487a70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1 /*****************************************************************************/
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
2 /* https.c - General purpose routines for the HTTPS protocol */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
3 /* Copyright (C) 1998-2003 Brian Masney <masneyb@gftp.org> */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
4 /* */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
9 /* */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
14 /* */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
18 /*****************************************************************************/
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
19
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
20 #include "gftp.h"
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
21 #include "httpcommon.h"
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
22
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
23 static const char cvsid[] = "$Id$";
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
24
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
25 #ifdef USE_SSL
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
26 static int
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
27 https_get_next_file (gftp_request * request, gftp_file * fle, int fd)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
28 {
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
29 rfc2068_params * params;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
30 int ret, resetptr;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
31
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
32 params = request->protocol_data;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
33 if (request->cached)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
34 {
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
35 params->real_read_function = gftp_fd_read;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
36 request->write_function = gftp_fd_write;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
37 resetptr = 1;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
38 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
39 else
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
40 resetptr = 0;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
41
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
42 ret = rfc2068_get_next_file (request, fle, fd);
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
43
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
44 if (resetptr)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
45 {
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
46 params->real_read_function = gftp_ssl_read;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
47 request->write_function = gftp_ssl_write;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
48 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
49
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
50 return (ret);
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
51 }
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
52 #endif
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
53
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
54 void
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
55 https_register_module (void)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
56 {
174
e643d287fe32 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
57 #ifdef USE_SSL
e643d287fe32 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
58 ssl_register_module ();
e643d287fe32 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 173
diff changeset
59 #endif
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
60 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
61
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
62
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
63 int
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
64 https_init (gftp_request * request)
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
65 {
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
66 #ifdef USE_SSL
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
67 rfc2068_params * params;
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
68 int ret;
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
69
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
70 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
71
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
72 if ((ret = gftp_protocols[GFTP_HTTP_NUM].init (request)) < 0)
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
73 return (ret);
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
74
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
75 params = request->protocol_data;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
76 request->init = https_init;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
77 request->post_connect = gftp_ssl_session_setup;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
78 params->real_read_function = gftp_ssl_read;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
79 request->write_function = gftp_ssl_write;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
80 request->get_next_file = https_get_next_file;
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
81 request->url_prefix = g_strdup ("https");
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
82
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
83 if ((ret = gftp_ssl_startup (NULL)) < 0)
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
84 return (ret);
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
85
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
86 return (0);
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
87 #else
186
13ca1defdc75 2003-6-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 174
diff changeset
88 request->logging_function (gftp_logging_error, request,
173
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
89 _("HTTPS Support unavailable since SSL support was not compiled in. Aborting connection.\n"));
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
90
4c288d05b26a 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 169
diff changeset
91 return (GFTP_EFATAL);
169
d40f9db52cdf 2003-6-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 168
diff changeset
92 #endif
168
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
93 }
c505d9ba9d53 2003-6-6 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
94