Mercurial > gftp.yaz
changeset 422:38bfc112ab46
2004-3-14 Brian Masney <masneyb@gftp.org>
* lib/misc.c (expand_path) - skip over paths that are empty
* lib/misc.c (gftp_sort_filelist) - fixed NULL pointer dereference
that would occur when attempting to sort an empty filelist
(from Hans-J?rgen Sch?ler <hjschaeler@t-online.de>)
* src/uicommon/gftpui.c (_gftpui_common_thread_callback) - fix so that
retries would occur properly after a timeout
(from Nam SungHyun <namsh@kldp.org>)
* src/gtk/Makefile.am - removed unneeded localedir defination
(from Nam SungHyun <namsh@kldp.org>)
* lib/gftp.h lib/protocols.c src/gtk/gftp-gtk.c src/text/gftp-text.c -
added gftp_setup_startup_directory(). This function will expand the
startup directory so that ~ directories will work properly
* lib/rfc959.c - removed invalid response error message if the user
enters an invalid password
* src/gtk/bookmarks.c - only allow one bookmark entry to be edited at a
time. This is a design flaw in my code and I'll remove this restriction
until I have time to recode this. Also, fixed segfault that would occur
when renaming a bookmark
* src/gtk/view_dialog.c - when editing a file, make sure the file has
the right suffix so that syntax highlighting works
author | masneyb |
---|---|
date | Mon, 15 Mar 2004 18:07:15 +0000 |
parents | cf22a94fb55a |
children | 4cee2498761d |
files | ChangeLog lib/gftp.h lib/misc.c lib/protocols.c lib/rfc959.c src/gtk/Makefile.am src/gtk/bookmarks.c src/gtk/gftp-gtk.c src/gtk/view_dialog.c src/text/gftp-text.c src/uicommon/gftpui.c |
diffstat | 11 files changed, 133 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Mar 10 17:54:33 2004 +0000 +++ b/ChangeLog Mon Mar 15 18:07:15 2004 +0000 @@ -1,3 +1,32 @@ +2004-3-14 Brian Masney <masneyb@gftp.org> + * lib/misc.c (expand_path) - skip over paths that are empty + + * lib/misc.c (gftp_sort_filelist) - fixed NULL pointer dereference + that would occur when attempting to sort an empty filelist + (from Hans-J?rgen Sch?ler <hjschaeler@t-online.de>) + + * src/uicommon/gftpui.c (_gftpui_common_thread_callback) - fix so that + retries would occur properly after a timeout + (from Nam SungHyun <namsh@kldp.org>) + + * src/gtk/Makefile.am - removed unneeded localedir defination + (from Nam SungHyun <namsh@kldp.org>) + + * lib/gftp.h lib/protocols.c src/gtk/gftp-gtk.c src/text/gftp-text.c - + added gftp_setup_startup_directory(). This function will expand the + startup directory so that ~ directories will work properly + + * lib/rfc959.c - removed invalid response error message if the user + enters an invalid password + + * src/gtk/bookmarks.c - only allow one bookmark entry to be edited at a + time. This is a design flaw in my code and I'll remove this restriction + until I have time to recode this. Also, fixed segfault that would occur + when renaming a bookmark + + * src/gtk/view_dialog.c - when editing a file, make sure the file has + the right suffix so that syntax highlighting works + 2004-3-1 Brian Masney <masneyb@gftp.org> * lib/sslcommon.c - added verify_ssl_peer option @@ -2236,7 +2265,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.229 2004/03/02 02:37:16 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.230 2004/03/15 18:06:51 masneyb Exp $ tags * debian/* - updated files from Debian maintainer
--- a/lib/gftp.h Wed Mar 10 17:54:33 2004 +0000 +++ b/lib/gftp.h Mon Mar 15 18:07:15 2004 +0000 @@ -986,6 +986,8 @@ int flags, mode_t perms ); +void gftp_setup_startup_directory ( gftp_request * request ); + /* pty.c */ char * gftp_get_pty_impl ( void );
--- a/lib/misc.c Wed Mar 10 17:54:33 2004 +0000 +++ b/lib/misc.c Mon Mar 15 18:07:15 2004 +0000 @@ -794,6 +794,9 @@ gftp_file * tempfle; intptr_t sort_dirs_first; + if (filelist == NULL) /* nothing to sort */ + return (filelist); + files = dirs = dotdot = NULL; if (column == GFTP_SORT_COL_FILE) @@ -1195,6 +1198,9 @@ { len = strlen (element); + if (len == 0) + continue; + if (retlen > 0 && (ret[retlen - 1] == '/' || element[0] == '/')) add_separator = 0; else
--- a/lib/protocols.c Wed Mar 10 17:54:33 2004 +0000 +++ b/lib/protocols.c Mon Mar 15 18:07:15 2004 +0000 @@ -2764,3 +2764,20 @@ return (fd); } + + +void +gftp_setup_startup_directory (gftp_request * request) +{ + char *startup_directory, *tempstr; + + gftp_lookup_request_option (request, "startup_directory", &startup_directory); + + if (*startup_directory != '\0' && + (tempstr = expand_path (startup_directory)) != NULL) + { + gftp_set_directory (request, tempstr); + g_free (tempstr); + } +} +
--- a/lib/rfc959.c Wed Mar 10 17:54:33 2004 +0000 +++ b/lib/rfc959.c Mon Mar 15 18:07:15 2004 +0000 @@ -530,9 +530,6 @@ if (resp != '2') { - request->logging_function (gftp_logging_error, request, - _("Invalid response '%c' received from server.\n"), - resp); gftp_disconnect (request); if (resp == '5')
--- a/src/gtk/Makefile.am Wed Mar 10 17:54:33 2004 +0000 +++ b/src/gtk/Makefile.am Mon Mar 15 18:07:15 2004 +0000 @@ -8,4 +8,3 @@ INCLUDES = @GTK_CFLAGS@ @PTHREAD_CFLAGS@ -DSHARE_DIR=\"$(datadir)/gftp\" -I../../intl LDADD = ../../lib/libgftp.a ../uicommon/libgftpui.a @GTK_LIBS@ @PTHREAD_LIBS@ @EXTRA_LIBS@ @GTHREAD_LIBS@ @SSL_LIBS@ @LIBINTL@ noinst_HEADERS = gftp-gtk.h -localedir = $(datadir)/locale
--- a/src/gtk/bookmarks.c Wed Mar 10 17:54:33 2004 +0000 +++ b/src/gtk/bookmarks.c Mon Mar 15 18:07:15 2004 +0000 @@ -20,9 +20,10 @@ #include "gftp-gtk.h" static const char cvsid[] = "$Id$"; -static GtkWidget * bm_hostedit, * bm_portedit, * bm_localdiredit, - * bm_remotediredit, * bm_useredit, * bm_passedit, * bm_acctedit, * anon_chk, - * bm_pathedit, * bm_protocol, * tree; +static GtkWidget * bm_dialog = NULL, * bm_hostedit, * bm_portedit, + * bm_localdiredit, * bm_remotediredit, * bm_useredit, + * bm_passedit, * bm_acctedit, * anon_chk, * bm_pathedit, + * bm_protocol, * tree; static GHashTable * new_bookmarks_htable = NULL; static gftp_bookmarks_var * new_bookmarks = NULL; static GtkItemFactory * edit_factory; @@ -694,8 +695,6 @@ } origpath = newpath = gftp_build_path (entry->path, gtk_entry_get_text (GTK_ENTRY (bm_pathedit)), NULL); - - for (; *newpath == '/'; newpath++); *pos = tempchar; str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit)); @@ -757,7 +756,12 @@ while (tempentry != NULL) { g_hash_table_remove (new_bookmarks_htable, tempentry->path); - tempstr = gftp_build_path (newpath, tempentry->path + oldpathlen, NULL); + + if (tempentry->path + oldpathlen == '\0') + tempstr = g_strdup (newpath); + else + tempstr = gftp_build_path (newpath, tempentry->path + oldpathlen, NULL); + g_free (tempentry->path); tempentry->path = tempstr; g_hash_table_insert (new_bookmarks_htable, tempentry->path, @@ -782,7 +786,18 @@ } -#if GTK_MAJOR_VERSION > 1 +#if GTK_MAJOR_VERSION == 1 + +static void +entry_close_dialog (void * data) +{ + gtk_widget_destroy (bm_dialog); + bm_dialog = NULL; +} + + +#else + static void bmedit_action (GtkWidget * widget, gint response, gpointer user_data) { @@ -796,6 +811,7 @@ /* no break */ default: gtk_widget_destroy (widget); + bm_dialog = NULL; } } #endif @@ -804,11 +820,17 @@ static void edit_entry (gpointer data) { - GtkWidget * table, * tempwid, * dialog, * menu, * notebook; + GtkWidget * table, * tempwid, * menu, * notebook; gftp_bookmarks_var * entry; int i, num; char *pos; + if (bm_dialog != NULL) + { + gtk_widget_grab_focus (bm_dialog); + return; + } + if (GTK_CLIST (tree)->selection == NULL) return; @@ -819,33 +841,34 @@ return; #if GTK_MAJOR_VERSION == 1 - dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Entry")); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15); + bm_dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (bm_dialog), _("Edit Entry")); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), 15); #else - dialog = gtk_dialog_new_with_buttons (_("Edit Entry"), NULL, 0, - GTK_STOCK_SAVE, - GTK_RESPONSE_OK, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_APPLY, - GTK_RESPONSE_APPLY, - NULL); + bm_dialog = gtk_dialog_new_with_buttons (_("Edit Entry"), NULL, 0, + GTK_STOCK_SAVE, + GTK_RESPONSE_OK, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_APPLY, + GTK_RESPONSE_APPLY, + NULL); #endif - gtk_window_set_wmclass (GTK_WINDOW (dialog), "Edit Bookmark Entry", "gFTP"); - gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); - gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 10); - gtk_widget_realize (dialog); + gtk_window_set_wmclass (GTK_WINDOW (bm_dialog), "Edit Bookmark Entry", + "gFTP"); + gtk_window_set_position (GTK_WINDOW (bm_dialog), GTK_WIN_POS_MOUSE); + gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (bm_dialog)->vbox), 10); + gtk_widget_realize (bm_dialog); if (gftp_icon != NULL) { - gdk_window_set_icon (dialog->window, NULL, gftp_icon->pixmap, + gdk_window_set_icon (bm_dialog->window, NULL, gftp_icon->pixmap, gftp_icon->bitmap); - gdk_window_set_icon_name (dialog->window, gftp_version); + gdk_window_set_icon_name (bm_dialog->window, gftp_version); } notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, TRUE, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->vbox), notebook, TRUE, TRUE, 0); gtk_widget_show (notebook); @@ -1015,29 +1038,28 @@ #if GTK_MAJOR_VERSION == 1 tempwid = gtk_button_new_with_label (_("OK")); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), tempwid, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (entry_apply_changes), (gpointer) entry); gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (dialog)); + GTK_SIGNAL_FUNC (entry_close_dialog), NULL); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_widget_show (tempwid); tempwid = gtk_button_new_with_label (_(" Cancel ")); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), tempwid, TRUE, TRUE, 0); gtk_signal_connect_object (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (dialog)); + GTK_OBJECT (bm_dialog)); GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_widget_grab_focus (tempwid); gtk_widget_show (tempwid); tempwid = gtk_button_new_with_label (_("Apply")); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid, + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), tempwid, TRUE, TRUE, 0); gtk_signal_connect (GTK_OBJECT (tempwid), "clicked", GTK_SIGNAL_FUNC (entry_apply_changes), @@ -1045,13 +1067,13 @@ GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT); gtk_widget_show (tempwid); #else - g_signal_connect (GTK_OBJECT (dialog), "response", + g_signal_connect (GTK_OBJECT (bm_dialog), "response", G_CALLBACK (bmedit_action), (gpointer) entry); #endif gftp_gtk_setup_bookmark_options (notebook, entry); - gtk_widget_show (dialog); + gtk_widget_show (bm_dialog); }
--- a/src/gtk/gftp-gtk.c Wed Mar 10 17:54:33 2004 +0000 +++ b/src/gtk/gftp-gtk.c Mon Mar 15 18:07:15 2004 +0000 @@ -1211,7 +1211,6 @@ int main (int argc, char **argv) { - char *startup_directory; GtkWidget *window, *ui; gftpui_common_init (&argc, &argv, ftp_log); @@ -1260,11 +1259,7 @@ gtk_timeout_add (1000, update_downloads, NULL); 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_setup_startup_directory (window1.request); gftp_connect (window1.request); ftp_list_files (&window1, 0); }
--- a/src/gtk/view_dialog.c Wed Mar 10 17:54:33 2004 +0000 +++ b/src/gtk/view_dialog.c Mon Mar 15 18:07:15 2004 +0000 @@ -97,7 +97,7 @@ gftp_window_data * fromwdata, * towdata; GList * templist, * filelist, * newfile; gftp_file * new_fle; - char *edit_program; + char *edit_program, *suffix; int num; fromwdata = data; @@ -135,9 +135,21 @@ new_fle = copy_fdata (curfle); if (new_fle->destfile) g_free (new_fle->destfile); - new_fle->destfile = g_strconcat (g_get_tmp_dir (), "/gftp-view.XXXXXX", - NULL); - if ((new_fle->fd = mkstemp (new_fle->destfile)) < 0) + + if ((suffix = strrchr (curfle->file, '.')) != NULL) + { + new_fle->destfile = g_strconcat (g_get_tmp_dir (), + "/gftp-view.XXXXXX", suffix, NULL); + new_fle->fd = mkstemps (new_fle->destfile, strlen (suffix)); + } + else + { + new_fle->destfile = g_strconcat (g_get_tmp_dir (), + "/gftp-view.XXXXXX", NULL); + new_fle->fd = mkstemps (new_fle->destfile, 0); + } + + if (new_fle->fd < 0) { ftp_log (gftp_logging_misc, NULL, _("Error: Cannot open %s for writing: %s\n"),
--- a/src/text/gftp-text.c Wed Mar 10 17:54:33 2004 +0000 +++ b/src/text/gftp-text.c Mon Mar 15 18:07:15 2004 +0000 @@ -223,8 +223,8 @@ int main (int argc, char **argv) { - char *startup_directory, *pos; void *locuidata, *remuidata; + char *pos; #if HAVE_LIBREADLINE char *tempstr, prompt[20]; #else @@ -254,11 +254,7 @@ gftp_text_locreq->logging_function = gftp_text_log; 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_setup_startup_directory (gftp_text_locreq); gftp_connect (gftp_text_locreq); }
--- a/src/uicommon/gftpui.c Wed Mar 10 17:54:33 2004 +0000 +++ b/src/uicommon/gftpui.c Mon Mar 15 18:07:15 2004 +0000 @@ -45,7 +45,7 @@ gftpui_common_use_jmp_environment = 1; success = GFTP_ERETRYABLE; - if (sj == 0) + if (sj != 1) { while (1) { @@ -57,12 +57,12 @@ if (success == GFTP_EFATAL || success == 0 || cdata->retries == 0) break; + cdata->retries--; cdata->request->logging_function (gftp_logging_misc, cdata->request, _("Waiting %d seconds until trying to connect again\n"), sleep_time); alarm (sleep_time); pause (); - cdata->retries--; } } else @@ -579,7 +579,7 @@ gftpui_lookup_file_colors (fle, &startcolor, &endcolor); tempstr = gftp_gen_ls_string (fle, startcolor, endcolor); - request->logging_function (gftp_logging_misc_nolog, request, "%s\n", + request->logging_function (gftp_logging_misc_nolog, request, "%s", tempstr); g_free (tempstr);