Mercurial > gftp.yaz
changeset 173:4c288d05b26a
2003-6-8 Brian Masney <masneyb@gftp.org>
* lib/bookmark.c lib/gftp.h lib/https.c lib/local.c lib/misc.c
lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c
src/text/gftp-text.c src/gtk/gftp-gtk.c - made the init function for
all the protocols return an integer instead of nothing. If there was an
error setting up the protocol, GFTP_EFATAL should be returned and the
connection should be aborted. The HTTPS protocol uses this to return if
SSL support was not compiled in
* lib/protocols.c src/text/gftp-text.c src/gtk/dnd.c
src/gtk/gftp-gtk.c src/gtk/menu-items.c - have gftp_parse_url() log the
error messages to the user. This shouldn't have been done in the
individual ports
* lib/https.c - only initialize the SSL engine the first time a SSL
connection is made.
author | masneyb |
---|---|
date | Mon, 09 Jun 2003 00:53:20 +0000 |
parents | 9273b56e7529 |
children | e643d287fe32 |
files | ChangeLog lib/bookmark.c lib/gftp.h lib/https.c lib/local.c lib/misc.c lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c lib/sslcommon.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/menu-items.c src/text/gftp-text.c |
diffstat | 15 files changed, 119 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jun 08 22:31:07 2003 +0000 +++ b/ChangeLog Mon Jun 09 00:53:20 2003 +0000 @@ -1,3 +1,20 @@ +2003-6-8 Brian Masney <masneyb@gftp.org> + * lib/bookmark.c lib/gftp.h lib/https.c lib/local.c lib/misc.c + lib/protocols.c lib/rfc2068.c lib/rfc959.c lib/sshv2.c + src/text/gftp-text.c src/gtk/gftp-gtk.c - made the init function for + all the protocols return an integer instead of nothing. If there was an + error setting up the protocol, GFTP_EFATAL should be returned and the + connection should be aborted. The HTTPS protocol uses this to return if + SSL support was not compiled in + + * lib/protocols.c src/text/gftp-text.c src/gtk/dnd.c + src/gtk/gftp-gtk.c src/gtk/menu-items.c - have gftp_parse_url() log the + error messages to the user. This shouldn't have been done in the + individual ports + + * lib/https.c - only initialize the SSL engine the first time a SSL + connection is made. + 2003-6-8 Brian Masney <masneyb@gftp.org> * aclocal.m4 - removed, this file is automatically generated @@ -906,7 +923,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.82 2003/06/08 16:01:39 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.83 2003/06/09 00:53:17 masneyb Exp $ tags * debian/* - updated files from Debian maintainer
--- a/lib/bookmark.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/bookmark.c Mon Jun 09 00:53:20 2003 +0000 @@ -52,10 +52,10 @@ } -void +int bookmark_init (gftp_request * request) { - g_return_if_fail (request != NULL); + g_return_val_if_fail (request != NULL, GFTP_EFATAL); request->protonum = GFTP_BOOKMARK_NUM; request->init = bookmark_init; @@ -90,5 +90,7 @@ request->use_cache = 0; request->always_connected = 0; gftp_set_config_options (request); + + return (0); }
--- a/lib/gftp.h Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/gftp.h Mon Jun 09 00:53:20 2003 +0000 @@ -340,7 +340,7 @@ gftp_logging_func logging_function; void *user_data; - void (*init) ( gftp_request * request ); + int (*init) ( gftp_request * request ); ssize_t (*read_function) ( gftp_request * request, void *ptr, size_t size, @@ -474,7 +474,7 @@ typedef struct supported_gftp_protocols_tag { char *name; /* Description of protocol */ - void (*init) (gftp_request * request); /* Init function */ + int (*init) (gftp_request * request); /* Init function */ void (*register_options) (void); /* Protocol options */ char *url_prefix; /* URL Prefix */ int shown; /* Whether this protocol is @@ -669,7 +669,7 @@ (request)->always_connected)) -void rfc959_init ( gftp_request * request ); +int rfc959_init ( gftp_request * request ); void rfc959_register_module ( void ); @@ -677,23 +677,23 @@ gftp_file *fle, int fd ); -void rfc2068_init ( gftp_request * request ); +int rfc2068_init ( gftp_request * request ); void rfc2068_register_module ( void ); -void https_init ( gftp_request * request ); +int https_init ( gftp_request * request ); void https_register_module ( void ); -void local_init ( gftp_request * request ); +int local_init ( gftp_request * request ); void local_register_module ( void ); -void sshv2_init ( gftp_request * request ); +int sshv2_init ( gftp_request * request ); void sshv2_register_module ( void ); -void bookmark_init ( gftp_request * request ); +int bookmark_init ( gftp_request * request ); void bookmark_register_module ( void );
--- a/lib/https.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/https.c Mon Jun 09 00:53:20 2003 +0000 @@ -54,21 +54,21 @@ void https_register_module (void) { -#ifdef USE_SSL - gftp_ssl_startup (NULL); /* FIXME - take out of here */ -#endif } -void +int https_init (gftp_request * request) { #ifdef USE_SSL rfc2068_params * params; + int ret; - g_return_if_fail (request != NULL); + g_return_val_if_fail (request != NULL, GFTP_EFATAL); - gftp_protocols[GFTP_HTTP_NUM].init (request); + if ((ret = gftp_protocols[GFTP_HTTP_NUM].init (request)) < 0) + return (ret); + params = request->protocol_data; request->init = https_init; request->post_connect = gftp_ssl_session_setup; @@ -76,11 +76,16 @@ request->write_function = gftp_ssl_write; request->get_next_file = https_get_next_file; request->url_prefix = g_strdup ("https"); -#else - gftp_protocols[GFTP_HTTP_NUM].init (request); + + if ((ret = gftp_ssl_startup (NULL)) < 0) + return (ret); + return (0); +#else request->logging_function (gftp_logging_error, request->user_data, - _("HTTPS Support unavailable since SSL support was not compiled in. Reverting back to plaintext\n")); + _("HTTPS Support unavailable since SSL support was not compiled in. Aborting connection.\n")); + + return (GFTP_EFATAL); #endif }
--- a/lib/local.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/local.c Mon Jun 09 00:53:20 2003 +0000 @@ -637,12 +637,12 @@ } -void +int local_init (gftp_request * request) { local_protocol_data *lpd; - g_return_if_fail (request != NULL); + g_return_val_if_fail (request != NULL, GFTP_EFATAL); request->protonum = GFTP_LOCAL_NUM; request->init = local_init; @@ -689,5 +689,7 @@ if (request->hostname != NULL) g_free (request->hostname); request->hostname = g_strdup (_("local filesystem")); + + return (0); }
--- a/lib/misc.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/misc.c Mon Jun 09 00:53:20 2003 +0000 @@ -604,7 +604,11 @@ if (copy_local_options) gftp_copy_local_options (newreq, req); - req->init (newreq); + if (req->init (newreq) < 0) + { + gftp_request_destroy (newreq, 1); + return (NULL); + } return (newreq); }
--- a/lib/protocols.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/protocols.c Mon Jun 09 00:53:20 2003 +0000 @@ -392,7 +392,7 @@ gftp_logging_func logging_function; gftp_bookmarks_var * tempentry; char *default_protocol; - int i; + int i, init_ret; g_return_val_if_fail (request != NULL, GFTP_EFATAL); g_return_val_if_fail (bookmark != NULL, GFTP_EFATAL); @@ -433,7 +433,11 @@ { if (strcmp (gftp_protocols[i].name, tempentry->protocol) == 0) { - gftp_protocols[i].init (request); + if ((init_ret = gftp_protocols[i].init (request)) < 0) + { + gftp_request_destroy (request, 0); + return (init_ret); + } break; } } @@ -456,7 +460,12 @@ i = GFTP_FTP_NUM; } - gftp_protocols[i].init (request); + if ((init_ret = gftp_protocols[i].init (request)) < 0) + { + gftp_request_destroy (request, 0); + return (init_ret); + } + return (0); } @@ -466,8 +475,8 @@ { char *pos, *endpos, *endhostpos, tempchar, *default_protocol, *stpos; gftp_logging_func logging_function; + int len, i, init_ret; const char *cpos; - int len, i; g_return_val_if_fail (request != NULL, GFTP_EFATAL); g_return_val_if_fail (url != NULL, GFTP_EFATAL); @@ -493,13 +502,16 @@ break; } - *pos = ':'; - if (gftp_protocols[i].url_prefix == NULL) { + request->logging_function (gftp_logging_misc, NULL, + _("The protocol '%s' is currently not supported.\n"), + stpos); g_free (stpos); return (GFTP_EFATAL); } + + *pos = ':'; } else { @@ -519,7 +531,11 @@ if (gftp_protocols[i].url_prefix == NULL) i = GFTP_FTP_NUM; - gftp_protocols[i].init (request); + if ((init_ret = gftp_protocols[i].init (request)) < 0) + { + gftp_request_destroy (request, 0); + return (init_ret); + } if (request->parse_url != NULL) {
--- a/lib/rfc2068.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/rfc2068.c Mon Jun 09 00:53:20 2003 +0000 @@ -766,12 +766,12 @@ } -void +int rfc2068_init (gftp_request * request) { rfc2068_params * params; - g_return_if_fail (request != NULL); + g_return_val_if_fail (request != NULL, GFTP_EFATAL); request->protonum = GFTP_HTTP_NUM; request->init = rfc2068_init; @@ -813,5 +813,7 @@ params->real_read_function = gftp_fd_read; gftp_set_config_options (request); + + return (0); }
--- a/lib/rfc959.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/rfc959.c Mon Jun 09 00:53:20 2003 +0000 @@ -1598,7 +1598,8 @@ gftp_lookup_request_option (request, "proxy_config", &proxy_config); if (strcmp (proxy_config, "http") == 0) { - gftp_protocols[GFTP_HTTP_NUM].init (request); + gftp_protocols[GFTP_HTTP_NUM].init (request); /* FIXME - check return value */ + gftp_set_request_option (request, "proxy_config", "ftp"); } } @@ -1631,12 +1632,12 @@ } -void +int rfc959_init (gftp_request * request) { rfc959_parms * parms; - g_return_if_fail (request != NULL); + g_return_val_if_fail (request != NULL, GFTP_EFATAL); request->protonum = GFTP_FTP_NUM; request->init = rfc959_init; @@ -1679,5 +1680,7 @@ parms->data_connection = -1; gftp_set_config_options (request); + + return (0); }
--- a/lib/sshv2.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/sshv2.c Mon Jun 09 00:53:20 2003 +0000 @@ -2245,12 +2245,12 @@ } -void +int sshv2_init (gftp_request * request) { sshv2_params * params; - g_return_if_fail (request != NULL); + g_return_val_if_fail (request != NULL, GFTP_EFATAL); request->protonum = GFTP_SSHV2_NUM; request->init = sshv2_init; @@ -2293,5 +2293,7 @@ params = request->protocol_data; params->id = 1; + + return (0); }
--- a/lib/sslcommon.c Sun Jun 08 22:31:07 2003 +0000 +++ b/lib/sslcommon.c Mon Jun 09 00:53:20 2003 +0000 @@ -138,15 +138,17 @@ int gftp_ssl_startup (gftp_request * request) { + if (gftp_ssl_initialized) + return (0); + gftp_ssl_initialized = 1; /* FIXME _ thread setup */ /* FIXME - only call this from one place */ if (!SSL_library_init ()) { - if (request != NULL) - request->logging_function (gftp_logging_error, request->user_data, - _("Cannot initialized the OpenSSL library\n")); + request->logging_function (gftp_logging_error, request->user_data, + _("Cannot initialized the OpenSSL library\n")); return (GFTP_EFATAL); } @@ -159,7 +161,7 @@ { request->logging_function (gftp_logging_error, request->user_data, _("Error loading default SSL certificates\n")); - return (GFTP_EFATAL); + return (GFTP_EFATAL); } SSL_CTX_set_verify (ctx, SSL_VERIFY_PEER, gftp_ssl_verify_callback); @@ -173,7 +175,6 @@ return (GFTP_EFATAL); } - return (0); }
--- a/src/gtk/dnd.c Sun Jun 08 22:31:07 2003 +0000 +++ b/src/gtk/dnd.c Mon Jun 09 00:53:20 2003 +0000 @@ -52,8 +52,6 @@ current_ftpdata->directory == NULL || (pos = strrchr (current_ftpdata->directory, '/')) == NULL) { - ftp_log (gftp_logging_misc, NULL, - _("Drag-N-Drop: Ignoring url %s: Not a valid url\n"), url); gftp_request_destroy (current_ftpdata, 1); free_fdata (newfle); return (0); @@ -110,11 +108,6 @@ ftp_connect (current_wdata, current_wdata->request, 1); } - else - { - ftp_log (gftp_logging_misc, NULL, _("Could not parse URL %s\n"), - selection_data->data); - } } }
--- a/src/gtk/gftp-gtk.c Sun Jun 08 22:31:07 2003 +0000 +++ b/src/gtk/gftp-gtk.c Mon Jun 09 00:53:20 2003 +0000 @@ -891,7 +891,7 @@ void toolbar_hostedit (GtkWidget * widget, gpointer data) { - void (*init) (gftp_request * request); + int (*init) (gftp_request * request); gftp_config_list_vars * tmplistvar; GtkWidget *tempwid; const char *txt; @@ -911,7 +911,8 @@ tempwid = gtk_menu_get_active (GTK_MENU (protocol_menu)); num = (int) gtk_object_get_user_data (GTK_OBJECT (tempwid)); init = gftp_protocols[num].init; - init (current_wdata->request); + if (init (current_wdata->request) < 0) + return; gftp_set_hostname (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry))); alltrim (current_wdata->request->hostname); @@ -1114,15 +1115,16 @@ _("gFTP comes with ABSOLUTELY NO WARRANTY; for details, see the COPYING file. This is free software, and you are welcome to redistribute it under certain conditions; for details, see the COPYING file\n")); gtk_timeout_add (1000, update_downloads, NULL); - gftp_protocols[GFTP_LOCAL_NUM].init (window1.request); + if (gftp_protocols[GFTP_LOCAL_NUM].init (window1.request) == 0) + { + gftp_lookup_request_option (window1.request, "startup_directory", + &startup_directory); + if (*startup_directory != '\0') + gftp_set_directory (window1.request, startup_directory); - gftp_lookup_request_option (window1.request, "startup_directory", - &startup_directory); - if (*startup_directory != '\0') - gftp_set_directory (window1.request, startup_directory); - - gftp_connect (window1.request); - ftp_list_files (&window1, 0); + gftp_connect (window1.request); + ftp_list_files (&window1, 0); + } /* On the remote window, even though we aren't connected, draw the sort icon on that side */
--- a/src/gtk/menu-items.c Sun Jun 08 22:31:07 2003 +0000 +++ b/src/gtk/menu-items.c Mon Jun 09 00:53:20 2003 +0000 @@ -115,10 +115,8 @@ ftp_connect (wdata, wdata->request, 1); } else - { - gtk_widget_destroy (ddata->dialog); - ftp_log (gftp_logging_misc, NULL, _("Could not parse URL %s\n"), tempstr); - } + gtk_widget_destroy (ddata->dialog); + ddata->dialog = NULL; }
--- a/src/text/gftp-text.c Sun Jun 08 22:31:07 2003 +0000 +++ b/src/text/gftp-text.c Mon Jun 09 00:53:20 2003 +0000 @@ -135,14 +135,15 @@ GINT_TO_POINTER(0)); gftp_text_locreq->logging_function = gftp_text_log; - gftp_protocols[GFTP_LOCAL_NUM].init (gftp_text_locreq); + if (gftp_protocols[GFTP_LOCAL_NUM].init (gftp_text_locreq) == 0) + { + gftp_lookup_request_option (gftp_text_locreq, "startup_directory", + &startup_directory); + if (*startup_directory != '\0') + gftp_set_directory (gftp_text_locreq, startup_directory); - gftp_lookup_request_option (gftp_text_locreq, "startup_directory", - &startup_directory); - if (*startup_directory != '\0') - gftp_set_directory (gftp_text_locreq, startup_directory); - - gftp_connect (gftp_text_locreq); + gftp_connect (gftp_text_locreq); + } gftp_text_log (gftp_logging_misc, NULL, "%s, Copyright (C) 1998-2003 Brian Masney <", gftp_version); gftp_text_log (gftp_logging_recv, NULL, "masneyb@gftp.org"); @@ -329,11 +330,7 @@ } if (gftp_parse_url (request, command) < 0) - { - gftp_text_log (gftp_logging_error, NULL, - _("Could not parse URL %s\n"), command); - return (1); - } + return (1); if (request->need_userpass) {