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