changeset 129:fe0b21c006f6

2003-4-13 Brian Masney <masneyb@gftp.org> * lib/config_file.c - implemented gftp_set_global_option() * lib/gftp.h lib/misc.c - added gftp_tdata_new() * src/text/gftp-text.c src/gtk/transfer.c - use gftp_tdata_new() * src/gtk/bookmarks.c - In run_bookmark(), use gftp_parse_bookmark() function. Renamed all instances of gftp_bookmarks to gftp_bookmarks_var * src/gtk/gftp-gtk.[ch] - added global variables viewedit_processes and viewedit_processes_done. These used to be declared in lib/options.h * src/gtk/gftp-gtk.h (struct gftp_window_data) - removed sortcol and sortasds variables. Added prefix_col_str variable. This will either be local or remote * src/gtk/misc-gtk.c - removed r_gethostbyname() and r_getservbyname() * src/gtk/transfer.c - removed gftp_gtk_calc_kbs(), get_status() and parse_attribs(). These are in the lib/ directory now. Also, use g_static_mutex_*() functions from glib instead of pthread_mutex_*() * src/gtk/bookmark.c src/gtk/dnd.c src/gtk/menu-items.c src/gtk/transfer.c - use g_strdup() instead of g_malloc()/strcpy() * src/gtk/options_dialog.c - commented out large parts of this file. This file is busted at the moment * src/gtk/*.[ch] - Use new configuration interface in all source files. Updated copyright dates on all source files
author masneyb
date Sun, 13 Apr 2003 15:21:13 +0000
parents 7616ab674d4e
children e2712348440d
files ChangeLog lib/config_file.c lib/gftp.h lib/misc.c src/gtk/bookmarks.c src/gtk/chmod_dialog.c src/gtk/dnd.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/mkdir_dialog.c src/gtk/options_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c src/gtk/view_dialog.c src/text/gftp-text.c
diffstat 17 files changed, 555 insertions(+), 748 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 11 06:35:43 2003 +0000
+++ b/ChangeLog	Sun Apr 13 15:21:13 2003 +0000
@@ -1,3 +1,37 @@
+2003-4-13 Brian Masney <masneyb@gftp.org>
+	* lib/config_file.c - implemented gftp_set_global_option()
+
+	* lib/gftp.h lib/misc.c - added gftp_tdata_new()
+
+	* src/text/gftp-text.c src/gtk/transfer.c - use gftp_tdata_new()
+
+	* src/gtk/bookmarks.c - In run_bookmark(), use gftp_parse_bookmark()
+	function. Renamed all instances of gftp_bookmarks to
+	gftp_bookmarks_var
+
+	* src/gtk/gftp-gtk.[ch] - added global variables viewedit_processes
+	and viewedit_processes_done. These used to be declared in
+	lib/options.h
+
+	* src/gtk/gftp-gtk.h (struct gftp_window_data) - removed sortcol and
+	sortasds variables. Added prefix_col_str variable. This will either be
+	local or remote
+
+	* src/gtk/misc-gtk.c - removed r_gethostbyname() and r_getservbyname()
+
+	* src/gtk/transfer.c - removed gftp_gtk_calc_kbs(), get_status() and
+	parse_attribs(). These are in the lib/ directory now. Also, use
+	g_static_mutex_*() functions from glib instead of pthread_mutex_*()
+
+	* src/gtk/bookmark.c src/gtk/dnd.c src/gtk/menu-items.c
+	src/gtk/transfer.c - use g_strdup() instead of g_malloc()/strcpy()
+
+	* src/gtk/options_dialog.c - commented out large parts of this file.
+	This file is busted at the moment
+
+	* src/gtk/*.[ch] - Use new configuration interface in all source 
+	files. Updated copyright dates on all source files
+
 2003-4-9 Brian Masney <masneyb@gftp.org>
 	* lib/gftp.h lib/config_file.c - reordered config option types. Added
 	gftp_option_type_textcomboedt type
@@ -650,7 +684,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.68 2003/04/10 02:29:42 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.69 2003/04/13 15:21:10 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/config_file.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/lib/config_file.c	Sun Apr 13 15:21:13 2003 +0000
@@ -1057,6 +1057,17 @@
 void
 gftp_set_global_option (char * key, void *value)
 {
+  gftp_config_vars * tmpconfigvar;
+
+  if (gftp_global_options_htable != NULL &&
+      (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
+                                           key)) != NULL)
+    memcpy (&tmpconfigvar->value, value, sizeof (tmpconfigvar->value));
+  else
+    {
+      fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
+      exit (1);
+    }
 }
 
 
--- a/lib/gftp.h	Fri Apr 11 06:35:43 2003 +0000
+++ b/lib/gftp.h	Sun Apr 13 15:21:13 2003 +0000
@@ -599,6 +599,8 @@
 					  gftp_request * request2, 
 					  int compare_dirs );
 
+gftp_transfer * gftp_tdata_new 		( void );
+
 void free_tdata 			( gftp_transfer * tdata );
 
 gftp_request * copy_request 		( gftp_request * req );
--- a/lib/misc.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/lib/misc.c	Sun Apr 13 15:21:13 2003 +0000
@@ -523,6 +523,20 @@
 }
 
 
+gftp_transfer *
+gftp_tdata_new (void)
+{
+  gftp_transfer * tdata;
+
+  tdata = g_malloc0 (sizeof (*tdata));
+/* FIXME
+  tdata->statmutex = G_STATIC_MUTEX_INIT;
+  tdata->structmutex = G_STATIC_MUTEX_INIT;
+*/
+  return (tdata);
+}
+
+
 void
 free_tdata (gftp_transfer * tdata)
 {
--- a/src/gtk/bookmarks.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/bookmarks.c	Sun Apr 13 15:21:13 2003 +0000
@@ -24,16 +24,13 @@
   * bm_remotediredit, * bm_useredit, * bm_passedit, * bm_acctedit, * anon_chk,
   * bm_pathedit, * bm_protocol, * tree, *bm_sftppath;
 static GHashTable * new_bookmarks_htable;
-static gftp_bookmarks * new_bookmarks;
+static gftp_bookmarks_var * new_bookmarks;
 static GtkItemFactory * edit_factory;
 
 
 void
 run_bookmark (gpointer data)
 {
-  gftp_bookmarks * tempentry;
-  int i;
-
   if (window1.request->stopable || window2.request->stopable)
     {
       ftp_log (gftp_logging_misc, NULL,
@@ -42,55 +39,12 @@
       return;
     }
 
-  if ((tempentry = g_hash_table_lookup (bookmarks_htable, (char *) data)) == NULL)
-    {
-      ftp_log (gftp_logging_misc, NULL,
-	       _("Internal gFTP Error: Could not look up bookmark entry. This is definately a bug. Please email masneyb@gftp.org about it. Please be sure to include the version number and how you can reproduce it\n"));
-      return;
-    }
-  else if (tempentry->hostname == NULL || *tempentry->hostname == '\0' ||
-	   tempentry->user == NULL || *tempentry->user == '\0')
-    {
-      ftp_log (gftp_logging_misc, NULL, _("Bookmarks Error: There are some missing entries in this bookmark. Make sure you have a hostname and username\n"));
-      return;
-    }
+  if (gftp_parse_bookmark (current_wdata->request, (char *) data) < 0)
+    return;
 
   if (GFTP_IS_CONNECTED (current_wdata->request))
     disconnect (current_wdata);
 
-  if (tempentry->local_dir && *tempentry->local_dir != '\0')
-    {
-      gftp_set_directory (other_wdata->request, tempentry->local_dir);
-      gtk_clist_freeze (GTK_CLIST (other_wdata->listbox));
-      remove_files_window (other_wdata);
-      ftp_list_files (other_wdata, 1);
-      gtk_clist_thaw (GTK_CLIST (other_wdata->listbox));
-    }
-
-  gftp_set_username (current_wdata->request, tempentry->user);
-  if (strncmp (tempentry->pass, "@EMAIL@", 7) == 0)
-    gftp_set_password (current_wdata->request, emailaddr);
-  else
-    gftp_set_password (current_wdata->request, tempentry->pass);
-  if (tempentry->acct != NULL)
-    gftp_set_account (current_wdata->request, tempentry->acct);
-  gftp_set_hostname (current_wdata->request, tempentry->hostname);
-  gftp_set_directory (current_wdata->request, tempentry->remote_dir);
-  gftp_set_port (current_wdata->request, tempentry->port);
-  gftp_set_sftpserv_path (current_wdata->request, tempentry->sftpserv_path);
-
-  for (i = 0; gftp_protocols[i].name; i++)
-    {
-      if (strcmp (gftp_protocols[i].name, tempentry->protocol) == 0)
-	{
-	  gftp_protocols[i].init (current_wdata->request);
-	  break;
-	}
-    }
-
-  if (!gftp_protocols[i].name)
-    gftp_protocols[0].init (current_wdata->request);
-
   ftp_connect (current_wdata, current_wdata->request, 1);
 }
 
@@ -100,8 +54,8 @@
 {
   GtkItemFactoryEntry test = { NULL, NULL, run_bookmark, 0 };
   const char *edttxt, *spos;
-  gftp_bookmarks * tempentry;
-  char *dpos;
+  gftp_bookmarks_var * tempentry;
+  char *dpos, *proto;
 
   edttxt = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
   if (*edttxt == '\0')
@@ -111,7 +65,7 @@
       return;
     }
 
-  if (g_hash_table_lookup (bookmarks_htable, edttxt) != NULL)
+  if (g_hash_table_lookup (gftp_bookmarks_htable, edttxt) != NULL)
     {
       ftp_log (gftp_logging_error, NULL,
 	       _("Add Bookmark: Cannot add bookmark %s because that name already exists\n"), edttxt);
@@ -133,36 +87,30 @@
   *dpos = '\0';
 
   edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry));
-  tempentry->hostname = g_malloc (strlen (edttxt) + 1);
-  strcpy (tempentry->hostname, edttxt);
+  tempentry->hostname = g_strdup (edttxt);
 
   edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry));
   tempentry->port = strtol (edttxt, NULL, 10);
 
-  tempentry->protocol =
-    g_malloc (strlen (GFTP_GET_PROTOCOL_NAME (current_wdata->request)) + 1);
-  strcpy (tempentry->protocol, GFTP_GET_PROTOCOL_NAME (current_wdata->request));
+  proto = gftp_protocols[current_wdata->request->protonum].name;
+  tempentry->protocol = g_strdup (proto);
 
   edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (other_wdata->combo)->entry));
-  tempentry->local_dir = g_malloc (strlen (edttxt) + 1);
-  strcpy (tempentry->local_dir, edttxt);
+  tempentry->local_dir = g_strdup (edttxt);
 
   edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (current_wdata->combo)->entry));
-  tempentry->remote_dir = g_malloc (strlen (edttxt) + 1);
-  strcpy (tempentry->remote_dir, edttxt);
+  tempentry->remote_dir = g_strdup (edttxt);
 
   if ((edttxt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry))) != NULL)
     {
-      tempentry->user = g_malloc (strlen (edttxt) + 1);
-      strcpy (tempentry->user, edttxt);
+      tempentry->user = g_strdup (edttxt);
 
       edttxt = gtk_entry_get_text (GTK_ENTRY (passedit));
-      tempentry->pass = g_malloc (strlen (edttxt) + 1);
-      strcpy (tempentry->pass, edttxt);
+      tempentry->pass = g_strdup (edttxt);
       tempentry->save_password = GTK_TOGGLE_BUTTON (ddata->checkbox)->active;
     }
 
-  add_to_bookmark (tempentry);
+  gftp_add_bookmark (tempentry);
 
   test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL);
   gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path,
@@ -196,9 +144,9 @@
 build_bookmarks_menu (void)
 {
   GtkItemFactoryEntry test = { NULL, NULL, NULL, 0 };
-  gftp_bookmarks * tempentry;
+  gftp_bookmarks_var * tempentry;
 
-  tempentry = bookmarks->children;
+  tempentry = gftp_bookmarks->children;
   while (tempentry != NULL)
     {
       test.path = g_strconcat ("/Bookmarks/", tempentry->path, NULL);
@@ -229,7 +177,7 @@
 
 
 static void
-free_bookmark_entry_items (gftp_bookmarks * entry)
+free_bookmark_entry_items (gftp_bookmarks_var * entry)
 {
   if (entry->hostname)
     g_free (entry->hostname);
@@ -248,10 +196,10 @@
 }
 
 
-static gftp_bookmarks *
-copy_bookmarks (gftp_bookmarks * bookmarks)
+static gftp_bookmarks_var *
+copy_bookmarks (gftp_bookmarks_var * bookmarks)
 {
-  gftp_bookmarks * new_bm, * preventry, * tempentry, * sibling, * newentry,
+  gftp_bookmarks_var * new_bm, * preventry, * tempentry, * sibling, * newentry,
                  * tentry;
 
   new_bm = g_malloc0 (sizeof (*new_bm));
@@ -268,51 +216,29 @@
       newentry->save_password = tempentry->save_password;
       newentry->cnode = tempentry->cnode;
       if (tempentry->path)
-	{
-	  newentry->path = g_malloc (strlen (tempentry->path) + 1);
-	  strcpy (newentry->path, tempentry->path);
-	}
+	newentry->path = g_strdup (tempentry->path);
+
       if (tempentry->hostname)
-	{
-	  newentry->hostname = g_malloc (strlen (tempentry->hostname) + 1);
-	  strcpy (newentry->hostname, tempentry->hostname);
-	}
+	newentry->hostname = g_strdup (tempentry->hostname);
+
       if (tempentry->protocol)
-	{
-	  newentry->protocol = g_malloc (strlen (tempentry->protocol) + 1);
-	  strcpy (newentry->protocol, tempentry->protocol);
-	}
+	newentry->protocol = g_strdup (tempentry->protocol);
+
       if (tempentry->local_dir)
-	{
-	  newentry->local_dir = g_malloc (strlen (tempentry->local_dir) + 1);
-	  strcpy (newentry->local_dir, tempentry->local_dir);
-	}
+	newentry->local_dir = g_strdup (tempentry->local_dir);
+
       if (tempentry->remote_dir)
-	{
-	  newentry->remote_dir =
-	    g_malloc (strlen (tempentry->remote_dir) + 1);
-	  strcpy (newentry->remote_dir, tempentry->remote_dir);
-	}
+	newentry->remote_dir = g_strdup (tempentry->remote_dir);
+
       if (tempentry->user)
-	{
-	  newentry->user = g_malloc (strlen (tempentry->user) + 1);
-	  strcpy (newentry->user, tempentry->user);
-	}
+	newentry->user = g_strdup (tempentry->user);
+
       if (tempentry->pass)
-	{
-	  newentry->pass = g_malloc (strlen (tempentry->pass) + 1);
-	  strcpy (newentry->pass, tempentry->pass);
-	}
+	newentry->pass = g_strdup (tempentry->pass);
+
       if (tempentry->acct)
-	{
-	  newentry->acct = g_malloc (strlen (tempentry->acct) + 1);
-	  strcpy (newentry->acct, tempentry->acct);
-	}
-      if (tempentry->sftpserv_path)
-        {
-          newentry->sftpserv_path = g_malloc (strlen (tempentry->sftpserv_path) + 1);
-          strcpy (newentry->sftpserv_path, tempentry->sftpserv_path);
-        }
+	newentry->acct = g_strdup (tempentry->acct);
+
       newentry->port = tempentry->port;
 
       if (sibling == NULL)
@@ -363,10 +289,10 @@
 static void
 bm_apply_changes (GtkWidget * widget, gpointer backup_data)
 {
-  gftp_bookmarks * tempentry, * delentry;
+  gftp_bookmarks_var * tempentry, * delentry;
   char *tempstr;
 
-  tempentry = bookmarks->children;
+  tempentry = gftp_bookmarks->children;
   while (tempentry != NULL)
     {
       if (tempentry->path && !tempentry->isfolder)
@@ -421,14 +347,14 @@
 	    }
 	}
     }
-  g_free (bookmarks);
-  g_hash_table_destroy (bookmarks_htable);
+  g_free (gftp_bookmarks);
+  g_hash_table_destroy (gftp_bookmarks_htable);
 
-  bookmarks = new_bookmarks;
-  bookmarks_htable = new_bookmarks_htable;
+  gftp_bookmarks = new_bookmarks;
+  gftp_bookmarks_htable = new_bookmarks_htable;
   if (backup_data)
     {
-      new_bookmarks = copy_bookmarks (bookmarks);
+      new_bookmarks = copy_bookmarks (gftp_bookmarks);
       new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks);
     }
   else
@@ -444,7 +370,7 @@
 static void
 bm_close_dialog (GtkWidget * widget, GtkWidget * dialog)
 {
-  gftp_bookmarks * tempentry, * delentry;
+  gftp_bookmarks_var * tempentry, * delentry;
 
   if (new_bookmarks_htable)
     g_hash_table_destroy (new_bookmarks_htable);
@@ -500,7 +426,7 @@
 {
   GdkPixmap * closedir_pixmap, * opendir_pixmap;
   GdkBitmap * closedir_bitmap, * opendir_bitmap;  
-  gftp_bookmarks * tempentry, * newentry;
+  gftp_bookmarks_var * tempentry, * newentry;
   GtkCTreeNode * sibling;
   char *pos, *text[2];
   const char *str;
@@ -587,9 +513,9 @@
 
 
 static void
-do_delete_entry (gftp_bookmarks * entry, gftp_dialog_data * ddata)
+do_delete_entry (gftp_bookmarks_var * entry, gftp_dialog_data * ddata)
 {
-  gftp_bookmarks * tempentry, * delentry;
+  gftp_bookmarks_var * tempentry, * delentry;
 
   g_hash_table_remove (new_bookmarks_htable, entry->path);
   gtk_ctree_remove_node (GTK_CTREE (tree), entry->cnode);
@@ -644,7 +570,7 @@
 static void
 delete_entry (gpointer data)
 {
-  gftp_bookmarks * entry;
+  gftp_bookmarks_var * entry;
   char *tempstr, *pos;
 
   if (GTK_CLIST (tree)->selection == NULL)
@@ -686,7 +612,7 @@
 {
   GdkPixmap * closedir_pixmap, * opendir_pixmap;
   GdkBitmap * closedir_bitmap, * opendir_bitmap;  
-  gftp_bookmarks * tempentry, * preventry;
+  gftp_bookmarks_var * tempentry, * preventry;
   char *pos, *prevpos, *text[2], *str;
   GtkCTreeNode * parent;
 
@@ -714,8 +640,7 @@
 	  while ((pos = strchr (pos, '/')) != NULL)
 	    {
 	      *pos = '\0';
-	      str = g_malloc (strlen (tempentry->path) + 1);
-	      strcpy (str, tempentry->path);
+              str = g_strdup (tempentry->path);
 	      *pos = '/';
 	      preventry = g_hash_table_lookup (new_bookmarks_htable, str);
 	      if (preventry->cnode == NULL)
@@ -761,7 +686,7 @@
 static void
 clear_bookmarks_tree (void)
 {
-  gftp_bookmarks * tempentry;
+  gftp_bookmarks_var * tempentry;
 
   tempentry = new_bookmarks->children;
   while (tempentry != NULL)
@@ -785,10 +710,10 @@
 
 
 static void
-entry_apply_changes (GtkWidget * widget, gftp_bookmarks * entry)
+entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry)
 {
   char *pos, *newpath, tempchar, *tempstr, *origpath;
-  gftp_bookmarks * tempentry, * nextentry;
+  gftp_bookmarks_var * tempentry, * nextentry;
   GtkWidget * tempwid;
   const char *str;
   int oldpathlen;
@@ -814,8 +739,7 @@
   str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit));
   if (entry->hostname)
     g_free (entry->hostname);
-  entry->hostname = g_malloc (strlen (str) + 1);
-  strcpy (entry->hostname, str);
+  entry->hostname = g_strdup (str);
 
   str = gtk_entry_get_text (GTK_ENTRY (bm_portedit));
   entry->port = strtol (str, NULL, 10);
@@ -824,31 +748,17 @@
   str = gtk_object_get_user_data (GTK_OBJECT (tempwid));
   if (entry->protocol)
     g_free (entry->protocol);
-  entry->protocol = g_malloc (strlen (str) + 1);
-  strcpy (entry->protocol, str);
+  entry->protocol = g_strdup (str);
 
   str = gtk_entry_get_text (GTK_ENTRY (bm_remotediredit));
   if (entry->remote_dir)
     g_free (entry->remote_dir);
-  entry->remote_dir = g_malloc (strlen (str) + 1);
-  strcpy (entry->remote_dir, str);
+  entry->remote_dir = g_strdup (str);
 
   str = gtk_entry_get_text (GTK_ENTRY (bm_localdiredit));
   if (entry->local_dir)
     g_free (entry->local_dir);
-  entry->local_dir = g_malloc (strlen (str) + 1);
-  strcpy (entry->local_dir, str);
-
-  str = gtk_entry_get_text (GTK_ENTRY (bm_sftppath));
-  if (entry->sftpserv_path)
-    g_free (entry->sftpserv_path);
-  if (strlen (str) > 0)
-    {
-      entry->sftpserv_path = g_malloc (strlen (str) + 1);
-      strcpy (entry->sftpserv_path, str);
-    }
-  else
-    entry->sftpserv_path = NULL;
+  entry->local_dir = g_strdup (str);
 
   if (GTK_TOGGLE_BUTTON (anon_chk)->active)
     str = "anonymous";
@@ -856,8 +766,7 @@
     str = gtk_entry_get_text (GTK_ENTRY (bm_useredit));
   if (entry->user)
     g_free (entry->user);
-  entry->user = g_malloc (strlen (str) + 1);
-  strcpy (entry->user, str);
+  entry->user = g_strdup (str);
 
   if (GTK_TOGGLE_BUTTON (anon_chk)->active)
     str = "@EMAIL@";
@@ -865,8 +774,7 @@
     str = gtk_entry_get_text (GTK_ENTRY (bm_passedit));
   if (entry->pass)
     g_free (entry->pass);
-  entry->pass = g_malloc (strlen (str) + 1);
-  strcpy (entry->pass, str);
+  entry->pass = g_strdup (str);
   entry->save_password = *entry->pass != '\0';
 
   if (GTK_TOGGLE_BUTTON (anon_chk)->active)
@@ -875,8 +783,7 @@
     str = gtk_entry_get_text (GTK_ENTRY (bm_acctedit));
   if (entry->acct)
     g_free (entry->acct);
-  entry->acct = g_malloc (strlen (str) + 1);
-  strcpy (entry->acct, str);
+  entry->acct = g_strdup (str);
 
   if (strcmp (entry->path, newpath) != 0)
     {
@@ -936,7 +843,7 @@
 edit_entry (gpointer data)
 {
   GtkWidget * table, * tempwid, * dialog, * menu;
-  gftp_bookmarks * entry;
+  gftp_bookmarks_var * entry;
   int i, num;
   char *pos;
 
@@ -1218,7 +1125,7 @@
 	    GtkCTreeNode * sibling, gpointer data)
 {
 
-  gftp_bookmarks * childentry, * siblingentry, * parententry, * tempentry;
+  gftp_bookmarks_var * childentry, * siblingentry, * parententry, * tempentry;
   char *tempstr, *pos, *stpos;
 
   childentry = gtk_ctree_node_get_row_data (ctree, child);
@@ -1269,8 +1176,7 @@
 	  tempstr = g_strdup_printf ("%s/%s", tempentry->prev->path, pos);
 	  for (stpos = tempstr; *stpos == '/'; stpos++);
 	  g_free (tempentry->path);
-	  tempentry->path = g_malloc (strlen (stpos) + 1);
-	  strcpy (tempentry->path, stpos);
+	  tempentry->path = g_strdup (stpos);
 	  g_free (tempstr);
 	  g_hash_table_insert (new_bookmarks_htable, tempentry->path,
 			       tempentry);
@@ -1330,7 +1236,7 @@
   GtkWidget * tempwid;
 #endif
 
-  new_bookmarks = copy_bookmarks (bookmarks);
+  new_bookmarks = copy_bookmarks (gftp_bookmarks);
   new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks);
 
 #if GTK_MAJOR_VERSION == 1
--- a/src/gtk/chmod_dialog.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/chmod_dialog.c	Sun Apr 13 15:21:13 2003 +0000
@@ -28,13 +28,16 @@
 static void *
 do_chmod_thread (void * data)
 {
+  int success, num, sj, network_timeout;
   GList * filelist, * templist;
   gftp_window_data * wdata;
-  int success, num, sj;
   gftp_file * tempfle;
 
   wdata = data;
 
+  gftp_lookup_request_option (wdata->request, "network_timeout", 
+                              &network_timeout);
+
   if (wdata->request->use_threads)
     {
       sj = sigsetjmp (jmp_environment, 1);
@@ -53,8 +56,8 @@
         {
           templist = get_next_selection (templist, &filelist, &num);
           tempfle = filelist->data;
-          if (wdata->request->network_timeout > 0)
-            alarm (wdata->request->network_timeout);
+          if (network_timeout > 0)
+            alarm (network_timeout);
           if (gftp_chmod (wdata->request, tempfle->file, mode) == 0)
             success = 1;
           if (!GFTP_IS_CONNECTED (wdata->request))
--- a/src/gtk/dnd.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/dnd.c	Sun Apr 13 15:21:13 2003 +0000
@@ -78,12 +78,10 @@
     fromwdata = NULL;
 
   *(pos - 1) = '/';
-  newfle->file = g_malloc (strlen (current_ftpdata->directory) + 1);
-  strcpy (newfle->file, current_ftpdata->directory);
+  newfle->file = g_strdup (current_ftpdata->directory);
   *(pos - 1) = '\0';
   
-  newfle->destfile = g_strconcat (GFTP_GET_DIRECTORY (wdata->request),
-                                     "/", pos, NULL);
+  newfle->destfile = g_strconcat (wdata->request->directory, "/", pos, NULL);
   templist = g_malloc0 (sizeof (*templist));
   templist->data = newfle;
   templist->next = NULL;
@@ -151,32 +149,32 @@
         continue;
 
       oldlen = totlen;
-      if (GFTP_GET_HOSTNAME (wdata->request) == NULL || 
+      if (wdata->request->hostname == NULL || 
           wdata->request->protonum == GFTP_LOCAL_NUM)
         {
           tempstr = g_strdup_printf ("%s://%s/%s ", 
-                                 GFTP_GET_URL_PREFIX (wdata->request),
-                                 GFTP_GET_DIRECTORY (wdata->request), 
+                                 wdata->request->url_prefix,
+                                 wdata->request->directory, 
                                  tempfle->file);
         }
-      else if (GFTP_GET_USERNAME (wdata->request) == NULL 
-               || *GFTP_GET_USERNAME (wdata->request) == '\0')
+      else if (wdata->request->username == NULL 
+               || *wdata->request->username == '\0')
         {
           tempstr = g_strdup_printf ("%s://%s:%d%s/%s ", 
-                                 GFTP_GET_URL_PREFIX (wdata->request),
-                                 GFTP_GET_HOSTNAME (wdata->request),
-                                 GFTP_GET_PORT (wdata->request),
-                                 GFTP_GET_DIRECTORY (wdata->request), 
+                                 wdata->request->url_prefix,
+                                 wdata->request->hostname,
+                                 wdata->request->port,
+                                 wdata->request->directory, 
                                  tempfle->file);
         }
       else
         {
           tempstr = g_strdup_printf ("%s://%s@%s:%d%s/%s ", 
-                                 GFTP_GET_URL_PREFIX (wdata->request),
-                                 GFTP_GET_USERNAME (wdata->request), 
-                                 GFTP_GET_HOSTNAME (wdata->request),
-                                 GFTP_GET_PORT (wdata->request),
-                                 GFTP_GET_DIRECTORY (wdata->request), 
+                                 wdata->request->url_prefix,
+                                 wdata->request->username, 
+                                 wdata->request->hostname,
+                                 wdata->request->port,
+                                 wdata->request->directory, 
                                  tempfle->file);
         }
 
--- a/src/gtk/gftp-gtk.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/gftp-gtk.c	Sun Apr 13 15:21:13 2003 +0000
@@ -41,6 +41,8 @@
 sigjmp_buf jmp_environment;
 volatile int use_jmp_environment = 0;
 pthread_t main_thread_id;
+GList * viewedit_processes = NULL;
+volatile sig_atomic_t viewedit_process_done;
 
 static int
 get_column (GtkCListColumn * col)
@@ -57,27 +59,47 @@
 static void
 doexit (GtkWidget * widget, gpointer data)
 {
-  listbox_local_width = GTK_WIDGET (local_frame)->allocation.width;
-  listbox_remote_width = GTK_WIDGET (remote_frame)->allocation.width;
-  listbox_file_height = GTK_WIDGET (remote_frame)->allocation.height;
-  log_height = GTK_WIDGET (log_table)->allocation.height;
-  transfer_height = GTK_WIDGET (transfer_scroll)->allocation.height;
+  int ret;
+
+  ret = GTK_WIDGET (local_frame)->allocation.width;
+  gftp_set_global_option ("listbox_local_width", &ret);
+  ret = GTK_WIDGET (remote_frame)->allocation.width;
+  gftp_set_global_option ("listbox_remote_width", &ret);
+  ret = GTK_WIDGET (remote_frame)->allocation.height;
+  gftp_set_global_option ("listbox_file_height", &ret);
+  ret = GTK_WIDGET (log_table)->allocation.height;
+  gftp_set_global_option ("log_height", &ret);
+  ret = GTK_WIDGET (transfer_scroll)->allocation.height;
+  gftp_set_global_option ("transfer_height", &ret);
+
+  ret = get_column (&GTK_CLIST (dlwdw)->column[0]);
+  gftp_set_global_option ("file_trans_column", &ret);
 
-  local_columns[0] = get_column (&GTK_CLIST (window1.listbox)->column[1]);
-  local_columns[1] = get_column (&GTK_CLIST (window1.listbox)->column[2]);
-  local_columns[2] = get_column (&GTK_CLIST (window1.listbox)->column[3]);
-  local_columns[3] = get_column (&GTK_CLIST (window1.listbox)->column[4]);
-  local_columns[4] = get_column (&GTK_CLIST (window1.listbox)->column[5]);
-  local_columns[5] = get_column (&GTK_CLIST (window1.listbox)->column[6]);
+  ret = get_column (&GTK_CLIST (window1.listbox)->column[1]);
+  gftp_set_global_option ("local_file_width", &ret);
+  ret = get_column (&GTK_CLIST (window1.listbox)->column[2]);
+  gftp_set_global_option ("local_size_width", &ret);
+  ret = get_column (&GTK_CLIST (window1.listbox)->column[3]);
+  gftp_set_global_option ("local_user_width", &ret);
+  ret = get_column (&GTK_CLIST (window1.listbox)->column[4]);
+  gftp_set_global_option ("local_group_width", &ret);
+  ret = get_column (&GTK_CLIST (window1.listbox)->column[5]);
+  gftp_set_global_option ("local_date_width", &ret);
+  ret = get_column (&GTK_CLIST (window1.listbox)->column[6]);
+  gftp_set_global_option ("local_attribs_width", &ret);
 
-  remote_columns[0] = get_column (&GTK_CLIST (window2.listbox)->column[1]);
-  remote_columns[1] = get_column (&GTK_CLIST (window2.listbox)->column[2]);
-  remote_columns[2] = get_column (&GTK_CLIST (window2.listbox)->column[3]);
-  remote_columns[3] = get_column (&GTK_CLIST (window2.listbox)->column[4]);
-  remote_columns[4] = get_column (&GTK_CLIST (window2.listbox)->column[5]);
-  remote_columns[5] = get_column (&GTK_CLIST (window2.listbox)->column[6]);
-
-  file_trans_column = get_column (&GTK_CLIST (dlwdw)->column[0]);
+  ret = get_column (&GTK_CLIST (window2.listbox)->column[1]);
+  gftp_set_global_option ("remote_file_width", &ret);
+  ret = get_column (&GTK_CLIST (window2.listbox)->column[2]);
+  gftp_set_global_option ("remote_size_width", &ret);
+  ret = get_column (&GTK_CLIST (window2.listbox)->column[3]);
+  gftp_set_global_option ("remote_user_width", &ret);
+  ret = get_column (&GTK_CLIST (window2.listbox)->column[4]);
+  gftp_set_global_option ("remote_group_width", &ret);
+  ret = get_column (&GTK_CLIST (window2.listbox)->column[5]);
+  gftp_set_global_option ("remote_date_width", &ret);
+  ret = get_column (&GTK_CLIST (window2.listbox)->column[6]);
+  gftp_set_global_option ("remote_attribs_width", &ret);
 
   gftp_write_config_file ();
   gftp_clear_cache_files ();
@@ -88,7 +110,7 @@
 static gint
 delete_event (GtkWidget * widget, GdkEvent * event, gpointer data)
 {
-  if (file_transfers == NULL)
+  if (gftp_file_transfers == NULL)
     doexit (NULL, NULL);
   else
     {
@@ -311,6 +333,8 @@
     {"application/x-rootwin-drop", 0, 1}
   };
   GtkWidget *toolbar, *box, *tempwid;
+  gftp_config_list_vars * tmplistvar;
+  char *default_protocol;
   int i, num;
 
   toolbar = gtk_handle_box_new ();
@@ -340,8 +364,11 @@
 
   gtk_signal_connect (GTK_OBJECT (GTK_COMBO (hostedit)->entry), "activate",
 		      GTK_SIGNAL_FUNC (toolbar_hostedit), NULL);
-  if (host_history)
-    gtk_combo_set_popdown_strings (GTK_COMBO (hostedit), host_history);
+
+  gftp_lookup_global_option ("hosthistory", &tmplistvar);
+  if (tmplistvar->list)
+    gtk_combo_set_popdown_strings (GTK_COMBO (hostedit), tmplistvar->list);
+
   gtk_combo_disable_activate (GTK_COMBO (hostedit));
   gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry), "");
   gtk_box_pack_start (GTK_BOX (box), hostedit, TRUE, TRUE, 0);
@@ -355,8 +382,11 @@
 
   gtk_signal_connect (GTK_OBJECT (GTK_COMBO (portedit)->entry), "activate",
 		      GTK_SIGNAL_FUNC (toolbar_hostedit), NULL);
-  if (port_history)
-    gtk_combo_set_popdown_strings (GTK_COMBO (portedit), port_history);
+
+  gftp_lookup_global_option ("porthistory", &tmplistvar);
+  if (tmplistvar->list)
+    gtk_combo_set_popdown_strings (GTK_COMBO (portedit), tmplistvar->list);
+
   gtk_combo_disable_activate (GTK_COMBO (portedit));
   gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (portedit)->entry), "");
   gtk_box_pack_start (GTK_BOX (box), portedit, FALSE, FALSE, 0);
@@ -370,8 +400,11 @@
 
   gtk_signal_connect (GTK_OBJECT (GTK_COMBO (useredit)->entry), "activate",
 		      GTK_SIGNAL_FUNC (toolbar_hostedit), NULL);
-  if (user_history)
-    gtk_combo_set_popdown_strings (GTK_COMBO (useredit), user_history);
+
+  gftp_lookup_global_option ("userhistory", &tmplistvar);
+  if (tmplistvar->list)
+    gtk_combo_set_popdown_strings (GTK_COMBO (useredit), tmplistvar->list);
+
   gtk_combo_disable_activate (GTK_COMBO (useredit));
   gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (useredit)->entry), "");
   gtk_box_pack_start (GTK_BOX (box), useredit, TRUE, TRUE, 0);
@@ -394,17 +427,19 @@
   gtk_box_pack_start (GTK_BOX (tempwid), optionmenu, TRUE, FALSE, 0);
 
   num = 0;
+  gftp_lookup_global_option ("default_protocol", &default_protocol);
   protocol_menu = gtk_menu_new ();
   for (i = 0; gftp_protocols[i].name; i++)
     {
       if (!gftp_protocols[i].shown)
         continue;
 
-      if (strcmp (gftp_protocols[i].name, default_protocol) == 0)
+      if (default_protocol != NULL &&
+          strcmp (gftp_protocols[i].name, default_protocol) == 0)
         num = i;
 
       tempwid = gtk_menu_item_new_with_label (gftp_protocols[i].name);
-      gtk_object_set_user_data (GTK_OBJECT (tempwid), (gpointer) i);
+      gtk_object_set_user_data (GTK_OBJECT (tempwid), GINT_TO_POINTER(i));
       gtk_menu_append (GTK_MENU (protocol_menu), tempwid);
       gtk_widget_show (tempwid);
     }
@@ -445,10 +480,13 @@
 static void
 list_doaction (gftp_window_data * wdata)
 {
+  int num, dir, success, list_dblclk_action;
   GList *templist, *filelist;
-  int num, dir, success;
   gftp_file *tempfle;
 
+  gftp_lookup_request_option (wdata->request, "list_dblclk_action", 
+                              &list_dblclk_action);
+
   filelist = wdata->files;
   templist = GTK_CLIST (wdata->listbox)->selection;
   num = 0;
@@ -463,7 +501,7 @@
 
   if (!dir && !success)
     {
-      switch (listbox_dblclick_action)
+      switch (list_dblclk_action)
         {
           case 0:
             view_dialog (wdata);
@@ -536,7 +574,7 @@
 
 
 static GtkWidget *
-CreateFTPWindow (gftp_window_data * wdata, int width, int columns[6])
+CreateFTPWindow (gftp_window_data * wdata)
 {
   const GtkTargetEntry possible_types[] = {
     {"STRING", 0, 0},
@@ -544,7 +582,8 @@
     {"application/x-rootwin-drop", 0, 1}
   };
   GtkWidget *box, *scroll_list, *parent;
-  char *titles[7];
+  int listbox_file_height, colwidth;
+  char *titles[7], tempstr[50];
 
   titles[0] = "";
   titles[1] = _("Filename");
@@ -560,7 +599,11 @@
   *wdata->filespec = '*';
 
   parent = gtk_frame_new (NULL);
-  gtk_widget_set_size_request (parent, width, listbox_file_height);
+  
+  gftp_lookup_global_option ("listbox_file_height", &listbox_file_height);
+  g_snprintf (tempstr, sizeof (tempstr), "listbox_%s_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  gtk_widget_set_size_request (parent, colwidth, listbox_file_height);
 
   gtk_container_border_width (GTK_CONTAINER (parent), 5);
 
@@ -599,14 +642,34 @@
   gtk_clist_set_column_width (GTK_CLIST (wdata->listbox), 0, 16);
   gtk_clist_set_column_justification (GTK_CLIST (wdata->listbox), 0,
 				      GTK_JUSTIFY_CENTER);
-  setup_column (wdata->listbox, 1, columns[0]);
+
+  g_snprintf (tempstr, sizeof (tempstr), "%s_file_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  setup_column (wdata->listbox, 1, colwidth);
+
   gtk_clist_set_column_justification (GTK_CLIST (wdata->listbox), 2,
 				      GTK_JUSTIFY_RIGHT);
-  setup_column (wdata->listbox, 2, columns[1]);
-  setup_column (wdata->listbox, 3, columns[2]);
-  setup_column (wdata->listbox, 4, columns[3]);
-  setup_column (wdata->listbox, 5, columns[4]);
-  setup_column (wdata->listbox, 6, columns[5]);
+
+  g_snprintf (tempstr, sizeof (tempstr), "%s_size_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  setup_column (wdata->listbox, 2, colwidth);
+
+  g_snprintf (tempstr, sizeof (tempstr), "%s_user_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  setup_column (wdata->listbox, 3, colwidth);
+
+  g_snprintf (tempstr, sizeof (tempstr), "%s_group_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  setup_column (wdata->listbox, 4, colwidth);
+
+  g_snprintf (tempstr, sizeof (tempstr), "%s_date_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  setup_column (wdata->listbox, 5, colwidth);
+
+  g_snprintf (tempstr, sizeof (tempstr), "%s_attribs_width", wdata->prefix_col_str);
+  gftp_lookup_global_option (tempstr, &colwidth);
+  setup_column (wdata->listbox, 6, colwidth);
+
   gtk_box_pack_start (GTK_BOX (box), scroll_list, TRUE, TRUE, 0);
   gtk_signal_connect (GTK_OBJECT (wdata->listbox), "click_column",
 	 	      GTK_SIGNAL_FUNC (sortrows), (gpointer) wdata);
@@ -644,20 +707,26 @@
 {
   GtkWidget *box, *dlbox, *winpane, *dlpane, *logpane, *mainvbox, *tempwid,
             *button;
+  gftp_config_list_vars * tmplistvar;
   char *dltitles[2];
+  int tmplookup;
 #if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
   GtkTextIter iter;
   GtkTextTag *tag;
-  GdkColor fore;
+  GdkColor * fore;
 #endif
 
   memset (&window1, 0, sizeof (window1));
   memset (&window2, 0, sizeof (window2));
-  window1.history = &localhistory;
-  window1.histlen = &localhistlen;
-  window2.history = &remotehistory;
-  window2.histlen = &remotehistlen;
+
+  gftp_lookup_global_option ("localhistory", &tmplistvar);
+  window1.history = &tmplistvar->list;
+  window1.histlen = &tmplistvar->num_items;
+
+  gftp_lookup_global_option ("remotehistory", &tmplistvar);
+  window2.history = &tmplistvar->list;
+  window2.histlen = &tmplistvar->num_items;
  
   mainvbox = gtk_vbox_new (FALSE, 0);
 
@@ -671,9 +740,8 @@
 
   box = gtk_hbox_new (FALSE, 0);
 
-  local_frame = CreateFTPWindow (&window1, listbox_local_width, local_columns);
-  window1.sortcol = &local_sortcol;
-  window1.sortasds = &local_sortasds;
+  window1.prefix_col_str = "local";
+  local_frame = CreateFTPWindow (&window1);
   gtk_box_pack_start (GTK_BOX (box), local_frame, TRUE, TRUE, 0);
 
   dlbox = gtk_vbox_new (FALSE, 0);
@@ -708,17 +776,17 @@
 
   gtk_paned_pack1 (GTK_PANED (winpane), box, 1, 1);
 
-  remote_frame = CreateFTPWindow (&window2, listbox_remote_width, 
-                                  remote_columns);
-  window2.sortcol = &remote_sortcol;
-  window2.sortasds = &remote_sortasds;
+  window2.prefix_col_str = "remote";
+  remote_frame = CreateFTPWindow (&window2);
+
   gtk_paned_pack2 (GTK_PANED (winpane), remote_frame, 1, 1);
 
   dlpane = gtk_vpaned_new ();
   gtk_paned_pack1 (GTK_PANED (dlpane), winpane, 1, 1);
 
   transfer_scroll = gtk_scrolled_window_new (NULL, NULL);
-  gtk_widget_set_size_request (transfer_scroll, -1, transfer_height);
+  gftp_lookup_global_option ("transfer_height", &tmplookup);
+  gtk_widget_set_size_request (transfer_scroll, -1, tmplookup);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (transfer_scroll),
 				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
@@ -728,10 +796,11 @@
   gtk_clist_set_selection_mode (GTK_CLIST (dlwdw), GTK_SELECTION_SINGLE);
   gtk_clist_set_reorderable (GTK_CLIST (dlwdw), 0);
 
-  if (file_trans_column == 0)
+  gftp_lookup_global_option ("file_trans_column", &tmplookup);
+  if (tmplookup == 0)
     gtk_clist_set_column_auto_resize (GTK_CLIST (dlwdw), 0, TRUE);
   else
-    gtk_clist_set_column_width (GTK_CLIST (dlwdw), 0, file_trans_column);
+    gtk_clist_set_column_width (GTK_CLIST (dlwdw), 0, tmplookup);
 
   gtk_container_add (GTK_CONTAINER (transfer_scroll), dlwdw);
   gtk_signal_connect (GTK_OBJECT (dlwdw), "button_press_event",
@@ -742,7 +811,8 @@
   gtk_paned_pack1 (GTK_PANED (logpane), dlpane, 1, 1);
 
   log_table = gtk_table_new (1, 2, FALSE);
-  gtk_widget_set_size_request (log_table, -1, log_height);
+  gftp_lookup_global_option ("log_height", &tmplookup);
+  gtk_widget_set_size_request (log_table, -1, tmplookup);
 
 #if GTK_MAJOR_VERSION == 1
   logwdw = gtk_text_new (NULL, NULL);
@@ -770,27 +840,19 @@
   textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw));
 
   tag = gtk_text_buffer_create_tag (textbuf, "send", NULL);
-  fore.red = send_color.red;
-  fore.green = send_color.green;
-  fore.blue = send_color.blue;
-  g_object_set (G_OBJECT (tag), "foreground_gdk", &fore, NULL);
+  gftp_lookup_global_option ("send_color", &fore);
+  g_object_set (G_OBJECT (tag), "foreground_gdk", fore, NULL);
 
   tag = gtk_text_buffer_create_tag (textbuf, "recv", NULL);
-  fore.red = recv_color.red;
-  fore.green = recv_color.green;
-  fore.blue = recv_color.blue;
-  g_object_set (G_OBJECT (tag), "foreground_gdk", &fore, NULL);
+  gftp_lookup_global_option ("recv_color", &fore);
+  g_object_set (G_OBJECT (tag), "foreground_gdk", fore, NULL);
 
   tag = gtk_text_buffer_create_tag (textbuf, "error", NULL);
-  fore.red = error_color.red;
-  fore.green = error_color.green;
-  fore.blue = error_color.blue;
-  g_object_set (G_OBJECT (tag), "foreground_gdk", &fore, NULL);
+  gftp_lookup_global_option ("error_color", &fore);
+  g_object_set (G_OBJECT (tag), "foreground_gdk", fore, NULL);
 
   tag = gtk_text_buffer_create_tag (textbuf, "misc", NULL);
-  fore.red = misc_color.red;
-  fore.green = misc_color.green;
-  fore.blue = misc_color.blue;
+  gftp_lookup_global_option ("misc_color", &fore);
   g_object_set (G_OBJECT (tag), "foreground_gdk", &fore, NULL);
 
   tempwid = gtk_scrolled_window_new (NULL, NULL);
@@ -830,6 +892,7 @@
 toolbar_hostedit (GtkWidget * widget, gpointer data)
 {
   void (*init) (gftp_request * request);
+  gftp_config_list_vars * tmplistvar;
   GtkWidget *tempwid;
   const char *txt;
   int num;
@@ -861,7 +924,8 @@
       return;
     }
 
-  add_history (hostedit, &host_history, &host_len, 
+  gftp_lookup_global_option ("hosthistory", &tmplistvar);
+  add_history (hostedit, &tmplistvar->list, &tmplistvar->num_items, 
                current_wdata->request->hostname);
 
   if (strchr (current_wdata->request->hostname, '/') != NULL &&
@@ -874,12 +938,15 @@
  
   txt = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (portedit)->entry));
   gftp_set_port (current_wdata->request, strtol (txt, NULL, 10));
-  add_history (portedit, &port_history, &port_len, txt);
+
+  gftp_lookup_global_option ("porthistory", &tmplistvar);
+  add_history (portedit, &tmplistvar->list, &tmplistvar->num_items, txt);
 
   gftp_set_username (current_wdata->request, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (useredit)->entry)));
   alltrim (current_wdata->request->username);
 
-  add_history (useredit, &user_history, &user_len, 
+  gftp_lookup_global_option ("userhistory", &tmplistvar);
+  add_history (useredit, &tmplistvar->list, &tmplistvar->num_items, 
                current_wdata->request->username);
 
   gftp_set_password (current_wdata->request,
@@ -898,15 +965,25 @@
 void
 sortrows (GtkCList * clist, gint column, gpointer data)
 {
+  char sortcol_name[25], sortasds_name[25];
+  int swap_col, sortcol, sortasds;
   gftp_window_data * wdata;
   GtkWidget * sort_wid;
   GList * templist;
-  int swap_col;
 
   wdata = data;
-  if (column == 0 || (column == *wdata->sortcol && wdata->sorted))
+  g_snprintf (sortcol_name, sizeof (sortcol_name), "%s_sortcol", wdata->prefix_col_str);
+  gftp_lookup_global_option (sortcol_name, &sortcol);
+  g_snprintf (sortasds_name, sizeof (sortasds_name), "%s_sortasds", wdata->prefix_col_str);
+  gftp_lookup_global_option (sortasds_name, &sortasds);
+
+  if (column == -1)
+    column = sortcol;
+
+  if (column == 0 || (column == sortcol && wdata->sorted))
     {
-      *wdata->sortasds = !(*wdata->sortasds);
+      sortasds = !sortasds;
+      gftp_set_global_option (sortasds_name, &sortasds);
       swap_col = 1;
     }
   else
@@ -917,12 +994,12 @@
       sort_wid = gtk_clist_get_column_widget (clist, 0);
       gtk_widget_destroy (sort_wid);
 #if GTK_MAJOR_VERSION == 1
-      if (*wdata->sortasds)
+      if (sortasds)
 	sort_wid = toolbar_pixmap (wdata->listbox, "down.xpm");
       else
 	sort_wid = toolbar_pixmap (wdata->listbox, "up.xpm");
 #else
-      if (*wdata->sortasds)
+      if (sortasds)
         sort_wid = gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, 
                                              GTK_ICON_SIZE_SMALL_TOOLBAR);
       else
@@ -933,7 +1010,10 @@
       gtk_clist_set_column_widget (clist, 0, sort_wid);
     }
   else
-    *wdata->sortcol = column;
+    {
+      sortcol = column;
+      gftp_set_global_option (sortcol_name, &sortcol);
+    }
 
   if (!GFTP_IS_CONNECTED (wdata->request))
     return;
@@ -941,8 +1021,7 @@
   gtk_clist_freeze (clist);
   gtk_clist_clear (clist);
 
-  wdata->files = gftp_sort_filelist (wdata->files, *wdata->sortcol, 
-                                     *wdata->sortasds);
+  wdata->files = gftp_sort_filelist (wdata->files, sortcol, sortasds);
 
   templist = wdata->files; 
   while (templist != NULL)
@@ -973,8 +1052,8 @@
 int
 main (int argc, char **argv)
 {
+  char *startup_directory;
   GtkWidget *window, *ui;
-  int i;
 
 #ifdef HAVE_GETTEXT
   setlocale (LC_ALL, "");
@@ -997,12 +1076,7 @@
 
   graphic_hash_table = g_hash_table_new (string_hash_function, string_hash_compare);
  
-  for (i=0; gftp_protocols[i].register_options != NULL; i++)
-    {
-      gftp_protocols[i].register_options ();
-    }
-
-  gftp_read_config_file (argv, 1);
+  gftp_read_config_file (SHARE_DIR);
   if (gftp_parse_command_line (&argc, &argv) != 0)
     exit (0);
 
@@ -1011,9 +1085,9 @@
 		      GTK_SIGNAL_FUNC (delete_event), NULL);
   gtk_signal_connect (GTK_OBJECT (window), "destroy",
 		      GTK_SIGNAL_FUNC (destroy), NULL);
-  gtk_window_set_title (GTK_WINDOW (window), version);
+  gtk_window_set_title (GTK_WINDOW (window), gftp_version);
   gtk_window_set_wmclass (GTK_WINDOW(window), "main", "gFTP");
-  gtk_widget_set_name (window, version);
+  gtk_widget_set_name (window, gftp_version);
   gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE);
   gtk_widget_realize (window);
 
@@ -1032,7 +1106,7 @@
   gtk_widget_show (window);
 
   ftp_log (gftp_logging_misc, NULL,
-	   "%s, Copyright (C) 1998-2002 Brian Masney <", version);
+	   "%s, Copyright (C) 1998-2002 Brian Masney <", gftp_version);
   ftp_log (gftp_logging_recv, NULL, "masneyb@gftp.org");
   ftp_log (gftp_logging_misc, NULL,
 	   _(">. If you have any questions, comments, or suggestions about this program, please feel free to email them to me. You can always find out the latest news about gFTP from my website at http://www.gftp.org/\n"));
@@ -1041,14 +1115,18 @@
 
   gtk_timeout_add (1000, update_downloads, NULL);
   gftp_protocols[GFTP_LOCAL_NUM].init (window1.request);
-  if (startup_directory != NULL && *startup_directory != '\0')
+
+  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);
 
   /* On the remote window, even though we aren't connected, draw the sort
      icon on that side */
-  sortrows (GTK_CLIST (window2.listbox), *window2.sortcol, &window2);
+  sortrows (GTK_CLIST (window2.listbox), -1, &window2);
 
   init_gftp (argc, argv, window);
 
--- a/src/gtk/gftp-gtk.h	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/gftp-gtk.h	Sun Apr 13 15:21:13 2003 +0000
@@ -65,8 +65,6 @@
    				   a directory */
             *hoststxt, 		/* Show which directory we're in */
             *listbox; 		/* Our listbox showing the files */
-  unsigned int *sortcol, 	/* Which column we are sorting by */
-               *sortasds; 	/* Sorted ascending or descending */
   unsigned int sorted : 1,	/* Is the output sorted? */
                show_selected : 1, /* Show only selected files */
                *histlen;	/* Pointer to length of history */
@@ -78,6 +76,7 @@
                                    come up when you right click */
   pthread_t tid;		/* Thread for the stop button */
   unsigned long gotbytes;
+  char *prefix_col_str;
 } gftp_window_data;
 
 
@@ -151,6 +150,9 @@
 extern sigjmp_buf jmp_environment;
 extern volatile int use_jmp_environment;
 extern pthread_t main_thread_id;
+extern GList * viewedit_processes;
+extern volatile sig_atomic_t viewedit_process_done;
+
 
 /* bookmarks.c */
 void run_bookmark 				( gpointer data );
--- a/src/gtk/menu-items.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/menu-items.c	Sun Apr 13 15:21:13 2003 +0000
@@ -26,12 +26,18 @@
   switch (menuitem)
     {
     case 1:
-      if (wdata->request != NULL)
-        gftp_set_data_type (wdata->request, GFTP_TYPE_ASCII);
+      if (window1.request != NULL)
+        gftp_set_request_option (window1.request, "ascii_transfers", GINT_TO_POINTER(1));
+
+      if (window2.request != NULL)
+        gftp_set_request_option (window2.request, "ascii_transfers", GINT_TO_POINTER(1));
       break;
     case 2:
-      if (wdata->request != NULL)
-        gftp_set_data_type (wdata->request, GFTP_TYPE_BINARY);
+      if (window1.request != NULL)
+        gftp_set_request_option (window1.request, "ascii_transfers", GINT_TO_POINTER(0));
+
+      if (window2.request != NULL)
+        gftp_set_request_option (window2.request, "ascii_transfers", GINT_TO_POINTER(0));
       break;
     case 3:
       current_wdata = &window1;
@@ -158,8 +164,7 @@
     }
   if (wdata->filespec)
     g_free (wdata->filespec);
-  wdata->filespec = g_malloc (strlen (edttext) + 1);
-  strcpy (wdata->filespec, edttext);
+  wdata->filespec = g_strdup (edttext);
 
   filelist = wdata->files;
   templist = GTK_CLIST (wdata->listbox)->selection;
@@ -421,8 +426,8 @@
 static void *
 do_change_dir_thread (void * data)
 {
+  int success, sj, network_timeout;
   gftp_window_data * wdata;
-  int success, sj;
 
   wdata = data;
 
@@ -434,11 +439,14 @@
   else
     sj = 0;
 
+  gftp_lookup_request_option (wdata->request, "network_timeout", 
+                              &network_timeout);
+
   success = 0;
   if (sj == 0) 
     {
-      if (wdata->request->network_timeout > 0)
-        alarm (wdata->request->network_timeout);
+      if (network_timeout > 0)
+        alarm (network_timeout);
       success = gftp_set_directory (wdata->request, wdata->request->directory);
       alarm (0);
     }
@@ -467,8 +475,7 @@
   if (directory != wdata->request->directory)
     {
       olddir = wdata->request->directory;
-      wdata->request->directory = g_malloc (strlen (directory) + 1);
-      strcpy (wdata->request->directory, directory);
+      wdata->request->directory = g_strdup (directory);
     }
   else
     olddir = NULL;
@@ -554,8 +561,7 @@
   templist = get_next_selection (templist, &filelist, &num);
   tempfle = filelist->data;
 
-  newdir = g_strconcat (GFTP_GET_DIRECTORY (wdata->request), "/",
-		        tempfle->file, NULL);
+  newdir = g_strconcat (wdata->request->directory, "/", tempfle->file, NULL);
   remove_double_slashes (newdir);
   if ((tempstr = expand_path (newdir)) == NULL)
     return (0);
@@ -792,8 +798,7 @@
   gtk_box_pack_start (GTK_BOX (box), tempwid, FALSE, FALSE, 0);
   gtk_widget_show (tempwid);
 
-  tempstr = g_strdup_printf (_("%s\nCopyright (C) 1998-2002 Brian Masney <masneyb@gftp.org>\nOfficial Homepage: http://www.gftp.org/\nLogo by: Aaron Worley <planet_hoth@yahoo.com>\n"),
-version);
+  tempstr = g_strdup_printf (_("%s\nCopyright (C) 1998-2002 Brian Masney <masneyb@gftp.org>\nOfficial Homepage: http://www.gftp.org/\nLogo by: Aaron Worley <planet_hoth@yahoo.com>\n"), gftp_version);
   str = _("Translated by");
   if (strcmp (str, "Translated by") != 0)
     {
--- a/src/gtk/misc-gtk.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/misc-gtk.c	Sun Apr 13 15:21:13 2003 +0000
@@ -20,7 +20,6 @@
 #include <gftp-gtk.h>
 static const char cvsid[] = "$Id$";
 
-static pthread_mutex_t netfunclock = PTHREAD_MUTEX_INITIALIZER;
 static GtkWidget * statuswid;
 
 
@@ -39,6 +38,7 @@
 void
 ftp_log (gftp_logging_level level, void *ptr, const char *string, ...)
 {
+  guint max_log_window_size;
   int upd, free_logstr;
   gftp_log * newlog;
   char *logstr;
@@ -65,7 +65,7 @@
       va_end (argp);
 
       pthread_mutex_lock (&log_mutex);
-      file_transfer_logs = g_list_append (file_transfer_logs, newlog);
+      gftp_file_transfer_logs = g_list_append (gftp_file_transfer_logs, newlog);
       pthread_mutex_unlock (&log_mutex);
       return;
     }
@@ -83,26 +83,28 @@
     }
   va_end (argp);
 
-  if (logfd != NULL)
+  if (gftp_logfd != NULL)
     {
-      if (fwrite (logstr, strlen (logstr), 1, logfd) != 1)
+      if (fwrite (logstr, strlen (logstr), 1, gftp_logfd) != 1)
         {
-          fclose (logfd);
-          logfd = NULL;
+          fclose (gftp_logfd);
+          gftp_logfd = NULL;
         }
       else
         {
-          fflush (logfd);
-          if (ferror (logfd))
+          fflush (gftp_logfd);
+          if (ferror (gftp_logfd))
             {
-              fclose (logfd);
-              logfd = NULL;
+              fclose (gftp_logfd);
+              gftp_logfd = NULL;
             }
         }
     }
 
   upd = logwdw_vadj->upper - logwdw_vadj->page_size == logwdw_vadj->value;
 
+  gftp_lookup_global_option ("max_log_window_size", &max_log_window_size);
+
 #if GTK_MAJOR_VERSION == 1
   switch (level)
     {
@@ -226,21 +228,21 @@
 
   if (current_wdata->request != NULL)
     {
-      if ((tempstr = GFTP_GET_HOSTNAME (current_wdata->request)) == NULL)
+      if ((tempstr = current_wdata->request->hostname) == NULL)
         tempstr = empty;
       gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (hostedit)->entry), tempstr);
 
-      if ((tempstr = GFTP_GET_USERNAME (current_wdata->request)) == NULL)
+      if ((tempstr = current_wdata->request->username) == NULL)
         tempstr = empty;
       gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (useredit)->entry), tempstr);
 
-      if ((tempstr = GFTP_GET_PASSWORD (current_wdata->request)) == NULL)
+      if ((tempstr = current_wdata->request->password) == NULL)
         tempstr = empty;
       gtk_entry_set_text (GTK_ENTRY (passedit), tempstr);
 
-      if (GFTP_GET_PORT (current_wdata->request) != 0)
+      if (current_wdata->request->port != 0)
         {
-          tempstr = g_strdup_printf ("%d", GFTP_GET_PORT (current_wdata->request));
+          tempstr = g_strdup_printf ("%d", current_wdata->request->port);
           gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (portedit)->entry), tempstr);
           g_free (tempstr);
         }
@@ -298,17 +300,17 @@
     {
       fspec = wdata->show_selected ? "Selected" : strcmp (wdata->filespec, "*") == 0 ?  _("All Files") : wdata->filespec;
 
-      if ((temp1str = GFTP_GET_HOSTNAME (wdata->request)) == NULL ||
+      if ((temp1str = wdata->request->hostname) == NULL ||
           wdata->request->protonum == GFTP_LOCAL_NUM)
 	temp1str = "";
       tempstr = g_strconcat (temp1str, *temp1str == '\0' ? "[" : " [",
-		     GFTP_GET_PROTOCOL_NAME (wdata->request),
+		     gftp_protocols[wdata->request->protonum].name,
 		     wdata->request->cached ? _("] (Cached) [") : "] [",
                      fspec, "]", current_wdata == wdata ? "*" : "", NULL);
       gtk_label_set (GTK_LABEL (wdata->hoststxt), tempstr);
       g_free (tempstr);
 
-      if ((dir = GFTP_GET_DIRECTORY (wdata->request)) == NULL)
+      if ((dir = wdata->request->directory) == NULL)
         temp1str = "";
       else
         temp1str = dir;
@@ -408,8 +410,7 @@
       return (NULL);
     }
 
-  graphic->filename = g_malloc (strlen (filename) + 1);
-  strcpy (graphic->filename, filename);
+  graphic->filename = g_strdup (filename);
   g_hash_table_insert (graphic_hash_table, graphic->filename, graphic);
 
   return (graphic);
@@ -664,8 +665,7 @@
 	    }
 	  g_list_free (node);
 	}
-      tempstr = g_malloc (strlen (str) + 1);
-      strcpy (tempstr, str);
+      tempstr = g_strdup (str);
       *history = g_list_prepend (*history, tempstr);
       ++*histlen;
     }
@@ -697,14 +697,18 @@
 add_file_listbox (gftp_window_data * wdata, gftp_file * fle)
 {
   char *add_data[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, *pos;
+  gftp_config_list_vars * tmplistvar;
+  int clist_num, show_hidden_files;
   gftp_file_extensions * tempext;
   char *tempstr, *str;
   GdkBitmap * bitmap;
   GList * templist;
   GdkPixmap * pix;
-  int clist_num;
   size_t stlen;
 
+  gftp_lookup_request_option (wdata->request, "show_hidden_files", 
+                              &show_hidden_files);
+
   if (wdata->show_selected)
     {
       fle->shown = fle->was_sel;
@@ -745,16 +749,14 @@
   else
     {
       stlen = strlen (fle->file);
-      templist = registered_exts;
+      gftp_lookup_global_option ("ext", &tmplistvar);
+      templist = tmplistvar->list;
       while (templist != NULL)
         {
           tempext = templist->data;
           if (stlen >= tempext->stlen &&
               strcmp (&fle->file[stlen - tempext->stlen], tempext->ext) == 0)
             {
-              if (toupper (*tempext->ascii_binary) == 'A')
-                fle->ascii = 1;
-
               gftp_get_pixmap (wdata->listbox, tempext->filename, &pix, 
                                &bitmap);
               break;
@@ -1242,7 +1244,7 @@
   GList * templist; 
 
   pthread_mutex_lock (&log_mutex);
-  templist = file_transfer_logs;
+  templist = gftp_file_transfer_logs;
   while (templist != NULL)
     { 
       templog = (gftp_log *) templist->data;
@@ -1252,8 +1254,8 @@
       templist->data = NULL;
       templist = templist->next;
     }
-  g_list_free (file_transfer_logs);
-  file_transfer_logs = NULL;
+  g_list_free (gftp_file_transfer_logs);
+  gftp_file_transfer_logs = NULL;
   pthread_mutex_unlock (&log_mutex);
 }
 
@@ -1269,49 +1271,3 @@
     exit (1);
 }
 
-
-#if !defined (HAVE_GETADDRINFO) || !defined (HAVE_GAI_STRERROR)
-
-struct hostent *
-r_gethostbyname (const char *name, struct hostent *result_buf, int *h_errnop)
-{
-  struct hostent *hent;
-
-  pthread_mutex_lock (&netfunclock);
-  if ((hent = gethostbyname (name)) == NULL)
-    {
-      if (h_errnop)
-        *h_errnop = h_errno;
-    }
-  else
-    {
-      *result_buf = *hent;
-      hent = result_buf;
-    }
-  pthread_mutex_unlock (&netfunclock);
-  return (hent);
-}
-
-#endif /* !HAVE_GETADDRINFO */
-
-struct servent *
-r_getservbyname (const char *name, const char *proto,
-                 struct servent *result_buf, int *h_errnop)
-{
-  struct servent *sent;
-
-  pthread_mutex_lock (&netfunclock);
-  if ((sent = getservbyname (name, proto)) == NULL)
-    {
-      if (h_errnop)
-        *h_errnop = h_errno;
-    }
-  else
-    {
-      *result_buf = *sent;
-      sent = result_buf;
-    }
-  pthread_mutex_unlock (&netfunclock);
-  return (sent);
-}
-
--- a/src/gtk/mkdir_dialog.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/mkdir_dialog.c	Sun Apr 13 15:21:13 2003 +0000
@@ -26,11 +26,14 @@
 static void *
 do_make_dir_thread (void * data)
 {
+  int success, sj, network_timeout;
   gftp_window_data * wdata;
-  int success, sj;
 
   wdata = data;
 
+  gftp_lookup_request_option (wdata->request, "network_timeout", 
+                              &network_timeout);
+
   if (wdata->request->use_threads)
     {
       sj = sigsetjmp (jmp_environment, 1);
@@ -42,8 +45,8 @@
   success = 0;
   if (sj == 0)
     {
-      if (wdata->request->network_timeout > 0)
-        alarm (wdata->request->network_timeout);
+      if (network_timeout > 0)
+        alarm (network_timeout);
       success = gftp_make_directory (wdata->request, edttext) == 0;
       alarm (0);
     }
--- a/src/gtk/options_dialog.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/options_dialog.c	Sun Apr 13 15:21:13 2003 +0000
@@ -131,6 +131,8 @@
 static void
 apply_changes (GtkWidget * widget, gpointer data)
 {
+#if 0
+FIXME
   const char *tempstr;
   int num, found, i;
   GList *templist;
@@ -196,6 +198,7 @@
   proxy_config = get_proxy_config ();
 
   gftp_write_config_file ();
+#endif
 }
 
 
@@ -221,6 +224,8 @@
 static void
 proxy_toggle (GtkList * list, GtkWidget * child, gpointer data)
 {
+#if 0
+FIXME
   int proxy_num;
   char *str;
 
@@ -253,6 +258,7 @@
   gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len - 1);
   gtk_text_buffer_insert (textbuf, &iter, str, -1);
 #endif
+#endif
 }
 
 
@@ -696,6 +702,8 @@
 		      GTK_SIGNAL_FUNC (delete_proxy_host), NULL);
   gtk_widget_show (tempwid);
 
+#if 0
+FIXME
   new_proxy_hosts = NULL;
   for (templist = proxy_hosts; templist != NULL;
        templist = templist->next)
@@ -711,6 +719,7 @@
       new_proxy_hosts = g_list_prepend (new_proxy_hosts, newhosts);
       add_host_to_listbox (new_proxy_hosts);
     }
+#endif
 }
 
 
@@ -759,6 +768,9 @@
 
   tbl_num = tbl_col = 0;
   table = box = NULL;
+
+#if 0
+FIXME
   for (i=0; config_file_vars[i].key != NULL; i++)
     {
       if (!(config_file_vars[i].ports_shown & GFTP_PORT_GTK))
@@ -957,6 +969,7 @@
   gtk_list_select_item (GTK_LIST (GTK_COMBO (proxy_combo)->list), combo_num);
 
   make_proxy_hosts_tab (notebook);
+#endif
 
 #if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
--- a/src/gtk/rename_dialog.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/rename_dialog.c	Sun Apr 13 15:21:13 2003 +0000
@@ -27,11 +27,14 @@
 static void *
 do_rename_thread (void * data)
 {
+  int success, sj, network_timeout;
   gftp_window_data * wdata;
-  int success, sj;
 
   wdata = data;
 
+  gftp_lookup_request_option (wdata->request, "network_timeout", 
+                              &network_timeout);
+
   if (wdata->request->use_threads)
     { 
       sj = sigsetjmp (jmp_environment, 1);
@@ -43,8 +46,8 @@
   success = 0;
   if (sj == 0)
     {
-      if (wdata->request->network_timeout > 0)
-        alarm (wdata->request->network_timeout);
+      if (network_timeout > 0)
+        alarm (network_timeout);
       success = gftp_rename_file (wdata->request, curfle->file, edttext) == 0;
       alarm (0);
     }
--- a/src/gtk/transfer.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/transfer.c	Sun Apr 13 15:21:13 2003 +0000
@@ -21,6 +21,7 @@
 static const char cvsid[] = "$Id$";
 
 static GtkWidget * dialog;
+static int num_transfers_in_progress = 0;
 
 static void 
 wakeup_main_thread (gpointer data, gint source, GdkInputCondition condition)
@@ -136,8 +137,7 @@
       if (!havedotdot)
         {
           fle = g_malloc0 (sizeof (*fle));
-          fle->file = g_malloc (3);
-          strcpy (fle->file, "..");
+          fle->file = g_strdup ("..");
           fle->user = g_malloc0 (1);
           fle->group = g_malloc0 (1);
           fle->attribs = g_malloc0 (1);
@@ -207,7 +207,7 @@
     }
 
   wdata->sorted = 0;
-  sortrows (GTK_CLIST (wdata->listbox), *wdata->sortcol, (gpointer) wdata);
+  sortrows (GTK_CLIST (wdata->listbox), -1, (gpointer) wdata);
   if (IS_NONE_SELECTED (wdata))
     gtk_clist_select_row (GTK_CLIST (wdata->listbox), 0, 0);
   return (1);
@@ -232,12 +232,16 @@
 static void *
 connect_thread (void *data)
 {
+  int ret, sj, retries, sleep_time, network_timeout;
   static int conn_num;
   gftp_request * request;
-  int ret, sj;
 
   request = data;
 
+  gftp_lookup_request_option (request, "retries", &retries);
+  gftp_lookup_request_option (request, "sleep_time", &sleep_time);
+  gftp_lookup_request_option (request, "network_timeout", &network_timeout);
+
   conn_num = 0;
   if (request->use_threads)
     {
@@ -254,11 +258,11 @@
       gftp_disconnect (request);
     }
 
-  while (sj != 1 && (request->retries == 0 || conn_num < request->retries))
+  while (sj != 1 && (retries == 0 || conn_num < retries))
     {
       conn_num++;
-      if (request->network_timeout > 0)
-        alarm (request->network_timeout);
+      if (network_timeout > 0)
+        alarm (network_timeout);
       ret = gftp_connect (request);
       alarm (0);
 
@@ -272,12 +276,12 @@
           ret = 1;
           break;
         }
-      else if (request->retries == 0 || conn_num < request->retries)
+      else if (retries == 0 || conn_num < retries)
         {
           request->logging_function (gftp_logging_misc, request->user_data,
                      _("Waiting %d seconds until trying to connect again\n"),
-		     request->sleep_time);
-          alarm (request->sleep_time);
+		     sleep_time);
+          alarm (sleep_time);
           pause ();
         }  
     }
@@ -328,8 +332,7 @@
 #endif
             }
 
-          if (GFTP_GET_PASSWORD (request) == NULL || 
-              *GFTP_GET_PASSWORD (request) == '\0')
+          if (request->password == NULL || *request->password == '\0')
             return (0);
         }
       else
@@ -496,13 +499,7 @@
       g_free (transfer);
     }
   else
-    {
-      if (transfer->statmutex)
-        pthread_mutex_destroy (transfer->statmutex);
-      if (transfer->structmutex)
-        pthread_mutex_destroy (transfer->structmutex);
-      free_tdata (transfer);
-    }
+    free_tdata (transfer);
 }
 
 void *
@@ -544,211 +541,12 @@
 }
 
 
-static void
-gftp_gtk_calc_kbs (gftp_transfer * tdata, ssize_t num_read)
-{
-  unsigned long waitusecs;
-  double difftime, curkbs;
-  gftp_file * tempfle;
-  struct timeval tv;
-  unsigned long toadd;
-
-  gettimeofday (&tv, NULL);
-  pthread_mutex_lock (tdata->statmutex);
-
-  tempfle = tdata->curfle->data;
-  tdata->trans_bytes += num_read;
-  tdata->curtrans += num_read;
-  tdata->stalled = 0;
-
-  difftime = (tv.tv_sec - tdata->starttime.tv_sec) + ((double) (tv.tv_usec - tdata->starttime.tv_usec) / 1000000.0);
-  if (difftime <= 0)
-    tdata->kbs = (double) tdata->trans_bytes / 1024.0;
-  else
-    tdata->kbs = (double) tdata->trans_bytes / 1024.0 / difftime;
-
-  difftime = (tv.tv_sec - tdata->lasttime.tv_sec) + ((double) (tv.tv_usec - tdata->lasttime.tv_usec) / 1000000.0);
-
-  if (difftime <= 0)
-    curkbs = (double) (num_read / 1024.0);
-  else
-    curkbs = (double) (num_read / 1024.0 / difftime);
-
-  if (tdata->fromreq->maxkbs > 0 &&
-      curkbs > tdata->fromreq->maxkbs)
-    {
-      waitusecs = (double) num_read / 1024.0 / tdata->fromreq->maxkbs * 1000000.0 - difftime;
-
-      if (waitusecs > 0)
-        {
-          pthread_mutex_unlock (tdata->statmutex);
-          difftime += ((double) waitusecs / 1000000.0);
-          usleep (waitusecs);
-          pthread_mutex_lock (tdata->statmutex);
-        }
-    }
-
-  /* I don't call gettimeofday (&tdata->lasttime) here because this will use
-     less system resources. This will be close enough for what we need */
-  difftime += tdata->lasttime.tv_usec / 1000000.0;
-  toadd = (long) difftime;
-  difftime -= toadd;
-  tdata->lasttime.tv_sec += toadd;
-  tdata->lasttime.tv_usec = difftime * 1000000.0;
-
-  pthread_mutex_unlock (tdata->statmutex);
-}
-
-
-static int
-get_status (gftp_transfer * tdata, ssize_t num_read)
-{
-  gftp_file * tempfle;
-  struct timeval tv;
-  int ret1 = 0, 
-      ret2 = 0;
-
-  pthread_mutex_lock (tdata->structmutex);
-  if (tdata->curfle == NULL)
-    {
-      pthread_mutex_unlock (tdata->structmutex);
-      return (-1);
-    }
-  tempfle = tdata->curfle->data;
-  pthread_mutex_unlock (tdata->structmutex);
-
-  gftp_disconnect (tdata->fromreq);
-  gftp_disconnect (tdata->toreq);
-  if (num_read < 0 || tdata->skip_file)
-    {
-      if (num_read == GFTP_EFATAL)
-        return (-1);
-      else if (tdata->fromreq->retries != 0 && 
-               tdata->current_file_retries >= tdata->fromreq->retries)
-        {
-          tdata->fromreq->logging_function (gftp_logging_error, 
-                   tdata->fromreq->user_data,
-                   _("Error: Remote site %s disconnected. Max retries reached...giving up\n"),
-                   tdata->fromreq->hostname != NULL ? 
-                         tdata->fromreq->hostname : tdata->toreq->hostname);
-          return (-1);
-        }
-      else
-        {
-          tdata->fromreq->logging_function (gftp_logging_error, 
-                     tdata->fromreq->user_data,
-                     _("Error: Remote site %s disconnected. Will reconnect in %d seconds\n"),
-                     tdata->fromreq->hostname != NULL ? 
-                           tdata->fromreq->hostname : tdata->toreq->hostname, 
-                     tdata->fromreq->sleep_time);
-        }
-
-      while (tdata->fromreq->retries == 0 || 
-             tdata->current_file_retries <= tdata->fromreq->retries)
-        {
-          if (!tdata->skip_file)
-            {
-              tv.tv_sec = tdata->fromreq->sleep_time;
-              tv.tv_usec = 0;
-              select (0, NULL, NULL, NULL, &tv);
-            }
-
-          if ((ret1 = gftp_connect (tdata->fromreq)) == 0 &&
-              (ret2 = gftp_connect (tdata->toreq)) == 0)
-            {
-              pthread_mutex_lock (tdata->structmutex);
-              tdata->resumed_bytes = tdata->resumed_bytes + tdata->trans_bytes - tdata->curresumed - tdata->curtrans;
-              tdata->trans_bytes = 0;
-              if (tdata->skip_file)
-                {
-                  tdata->total_bytes -= tempfle->size;
-                  tdata->curtrans = 0;
-
-                  tdata->curfle = tdata->curfle->next;
-                  tdata->next_file = 1;
-                  tdata->skip_file = 0;
-                  tdata->cancel = 0;
-                  tdata->fromreq->cancel = 0;
-                  tdata->toreq->cancel = 0;
-                }
-              else
-                {
-                  tempfle->transfer_action = GFTP_TRANS_ACTION_RESUME;
-                  tempfle->startsize = tdata->curtrans + tdata->curresumed;
-                  /* We decrement this here because it will be incremented in 
-                     the loop again */
-                  tdata->curresumed = 0;
-                  tdata->current_file_number--; /* Decrement this because it 
-                                                   will be incremented when we 
-                                                   continue in the loop */
-                }
-              gettimeofday (&tdata->starttime, NULL);
-              pthread_mutex_unlock (tdata->structmutex);
-              return (1);
-            }
-          else if (ret1 == GFTP_EFATAL || ret2 == GFTP_EFATAL)
-            {
-              gftp_disconnect (tdata->fromreq);
-              gftp_disconnect (tdata->toreq);
-              return (-1);
-            }
-          else
-            tdata->current_file_retries++;
-        }
-    }
-  else if (tdata->cancel)
-    return (-1);
-
-  return (0);
-}
-
-
-static mode_t
-parse_attribs (char *attribs)
-{
-  mode_t mode;
-  int cur;
-
-  cur = 0;
-  if (attribs[1] == 'r')
-    cur += 4;
-  if (attribs[2] == 'w')
-    cur += 2;
-  if (attribs[3] == 'x' ||
-      attribs[3] == 's')
-    cur += 1;
-  mode = cur;
-
-  cur = 0;
-  if (attribs[4] == 'r')
-    cur += 4;
-  if (attribs[5] == 'w')
-    cur += 2;
-  if (attribs[6] == 'x' ||
-      attribs[6] == 's')
-    cur += 1;
-  mode = (mode * 10) + cur;
-
-  cur = 0;
-  if (attribs[7] == 'r')
-    cur += 4;
-  if (attribs[8] == 'w')
-    cur += 2;
-  if (attribs[9] == 'x' ||
-      attribs[9] == 's')
-    cur += 1;
-  mode = (mode * 10) + cur;
-
-  return (mode);
-}
-
-
 void * 
 gftp_gtk_transfer_files (void *data)
 {
-  int i, mode, dl_type, tofd, fromfd, old_from_datatype;
+  int i, mode, tofd, fromfd;
   gftp_transfer * transfer;
-  char *tempstr, buf[8192];
+  char buf[8192];
   off_t fromsize, total;
   gftp_file * curfle; 
   ssize_t num_read, ret;
@@ -760,22 +558,20 @@
   memcpy (&transfer->lasttime, &transfer->starttime, 
           sizeof (transfer->lasttime));
 
-  dl_type = transfer->fromreq->data_type;
-  old_from_datatype = transfer->fromreq->data_type;
-
   while (transfer->curfle != NULL)
     {
-      pthread_mutex_lock (transfer->structmutex);
+      num_read = -1;
+      g_static_mutex_lock (&transfer->structmutex);
       curfle = transfer->curfle->data;
       transfer->current_file_number++; 
-      pthread_mutex_unlock (transfer->structmutex);
+      g_static_mutex_unlock (&transfer->structmutex);
  
       if (curfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
         {
-          pthread_mutex_lock (transfer->structmutex);
+          g_static_mutex_lock (&transfer->structmutex);
           transfer->next_file = 1;
           transfer->curfle = transfer->curfle->next;
-          pthread_mutex_unlock (transfer->structmutex);
+          g_static_mutex_unlock (&transfer->structmutex);
           continue;
         }
 
@@ -792,21 +588,13 @@
                     break;
                 }
 
-              pthread_mutex_lock (transfer->structmutex);
+              g_static_mutex_lock (&transfer->structmutex);
               transfer->next_file = 1;
               transfer->curfle = transfer->curfle->next;
-              pthread_mutex_unlock (transfer->structmutex);
+              g_static_mutex_unlock (&transfer->structmutex);
               continue;
             }
 
-          if (transfer->fromreq->maxkbs > 0)
-            {
-              transfer->fromreq->logging_function (gftp_logging_misc, 
-                            transfer->fromreq->user_data, 
-                            _("File transfer will be throttled to %.2f KB/s\n"),
-                            transfer->fromreq->maxkbs);
-            }
-
           if (curfle->is_fd)
             {
               if (transfer->transfer_direction == GFTP_DIRECTION_DOWNLOAD)
@@ -835,27 +623,6 @@
           if (GFTP_IS_CONNECTED (transfer->fromreq) &&
               GFTP_IS_CONNECTED (transfer->toreq))
             {
-              if (!curfle->ascii && old_from_datatype == GFTP_TYPE_BINARY)
-                dl_type = GFTP_TYPE_BINARY;
-              else
-                dl_type = GFTP_GET_DATA_TYPE (transfer->fromreq) == GFTP_TYPE_ASCII || curfle->ascii ? GFTP_TYPE_ASCII : GFTP_TYPE_BINARY;
-
-              if (dl_type != transfer->fromreq->data_type)
-                {
-                   if (gftp_set_data_type (transfer->fromreq, dl_type) != 0)
-                     gftp_disconnect (transfer->fromreq);
-                 }
-
-              if (dl_type != transfer->toreq->data_type)
-                {
-                   if (gftp_set_data_type (transfer->toreq, dl_type) != 0)
-                     gftp_disconnect (transfer->toreq);
-                 }
-            }
-
-          if (GFTP_IS_CONNECTED (transfer->fromreq) &&
-              GFTP_IS_CONNECTED (transfer->toreq))
-            {
               fromsize = gftp_transfer_file (transfer->fromreq, curfle->file, 
                           fromfd,
                           curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
@@ -872,7 +639,6 @@
           transfer->fromreq->logging_function (gftp_logging_misc, 
                          transfer->fromreq->user_data, 
                          _("Error: Remote site disconnected after trying to transfer file\n"));
-          num_read = -1;
         }
       else if (fromsize < 0)
         {
@@ -884,20 +650,20 @@
                 transfer->fromreq->datafd = -1;
             }
 
-          pthread_mutex_lock (transfer->structmutex);
+          g_static_mutex_lock (&transfer->structmutex);
           curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
           transfer->next_file = 1;
           transfer->curfle = transfer->curfle->next;
-          pthread_mutex_unlock (transfer->structmutex);
+          g_static_mutex_unlock (&transfer->structmutex);
           continue;
         }
       else
         {
-          pthread_mutex_lock (transfer->structmutex);
+          g_static_mutex_lock (&transfer->structmutex);
           transfer->curtrans = 0;
           transfer->curresumed = curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? curfle->startsize : 0;
           transfer->resumed_bytes += transfer->curresumed;
-          pthread_mutex_unlock (transfer->structmutex);
+          g_static_mutex_unlock (&transfer->structmutex);
   
           total = 0;
           i = 0;
@@ -906,25 +672,14 @@
                                                        buf, sizeof (buf))) > 0)
             {
               total += num_read;
-              gftp_gtk_calc_kbs (transfer, num_read);
+              gftp_calc_kbs (transfer, num_read);
 
-              if (dl_type == GFTP_TYPE_ASCII)
-                tempstr = gftp_convert_ascii (buf, &num_read, 1);
-              else
-                tempstr = buf;
-
-              if ((ret = gftp_put_next_file_chunk (transfer->toreq, tempstr, 
+              if ((ret = gftp_put_next_file_chunk (transfer->toreq, buf, 
                                                    num_read)) < 0)
                 {
                   num_read = (int) ret;
                   break;
                 }
-
-              /* We don't have to free tempstr for a download because new 
-                 memory is not allocated for it in that case */
-              if (dl_type == GFTP_TYPE_ASCII &&
-                  transfer->transfer_direction == GFTP_DIRECTION_UPLOAD)
-                g_free (tempstr);
             }
         }
 
@@ -944,7 +699,7 @@
                                         curfle->file,
                                         transfer->fromreq->hostname);
 
-          if (get_status (transfer, num_read) == 1)
+          if (gftp_get_transfer_status (transfer, num_read) == GFTP_ERETRYABLE)
             continue;
 
           break;
@@ -963,7 +718,7 @@
 
           if (gftp_end_transfer (transfer->fromreq) != 0)
             {
-              if (get_status (transfer, -1) == 1)
+              if (gftp_get_transfer_status (transfer, -1) == GFTP_ERETRYABLE)
                 continue;
 
               break;
@@ -980,10 +735,9 @@
         {
           if (curfle->attribs)
             {
-              mode = parse_attribs (curfle->attribs);
+              mode = gftp_parse_attribs (curfle->attribs);
               if (mode != 0)
-                gftp_chmod (transfer->toreq, curfle->destfile,
-                            parse_attribs (curfle->attribs));
+                gftp_chmod (transfer->toreq, curfle->destfile, mode);
             }
 
           if (curfle->datetime != 0)
@@ -991,11 +745,11 @@
                                 curfle->datetime);
         }
 
-      pthread_mutex_lock (transfer->structmutex);
+      g_static_mutex_lock (&transfer->structmutex);
       transfer->next_file = 1;
       curfle->transfer_done = 1;
       transfer->curfle = transfer->curfle->next;
-      pthread_mutex_unlock (transfer->structmutex);
+      g_static_mutex_unlock (&transfer->structmutex);
 
       if (transfer->cancel && !transfer->skip_file)
         break;
@@ -1013,12 +767,12 @@
                    gftp_window_data * fromwdata, gftp_window_data * towdata, 
                    GList * files, int copy_req)
 {
+  int dialog, append_file_transfers;
   gftp_curtrans_data * transdata;
   GList * templist, *curfle;
   gftp_transfer * tdata;
   gftp_file * tempfle;
   char *pos, *text[2];
-  int dialog;
 
   for (templist = files; templist != NULL; templist = templist->next)
     { 
@@ -1028,13 +782,16 @@
     }
   dialog = templist != NULL;
 
+  gftp_lookup_request_option (fromreq, "append_file_transfers", 
+                              &append_file_transfers);
+
   if (append_file_transfers)
     {
       pthread_mutex_lock (&transfer_mutex);
-      for (templist = file_transfers; templist != NULL; templist = templist->next)
+      for (templist = gftp_file_transfers; templist != NULL; templist = templist->next)
         {
           tdata = templist->data;
-          pthread_mutex_lock (tdata->structmutex);
+          g_static_mutex_lock (&tdata->structmutex);
           if (compare_request (tdata->fromreq, fromreq, 0) &&
               compare_request (tdata->toreq, toreq, 0) &&
               tdata->curfle != NULL)
@@ -1082,20 +839,20 @@
                       text[1] = _("Waiting...");
                     }
 
-                  tempfle->node = gtk_ctree_insert_node (GTK_CTREE (dlwdw),  
-                                                         tdata->node, NULL, text, 5,
-                                                         NULL, NULL, NULL, NULL, 
-                                                         FALSE, FALSE);
+                  tempfle->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw),  
+                                             tdata->user_data, NULL, text, 5,
+                                             NULL, NULL, NULL, NULL, 
+                                             FALSE, FALSE);
                   transdata = g_malloc (sizeof (*transdata));
                   transdata->transfer = tdata;
                   transdata->curfle = curfle;
-                  gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->node, 
+                  gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->user_data, 
                                                transdata);
                 }
-              pthread_mutex_unlock (tdata->structmutex);
+              g_static_mutex_unlock (&tdata->structmutex);
               break; 
             }
-          pthread_mutex_unlock (tdata->structmutex);
+          g_static_mutex_unlock (&tdata->structmutex);
         }
       pthread_mutex_unlock (&transfer_mutex);
     }
@@ -1104,7 +861,7 @@
     
   if (templist == NULL)
     {
-      tdata = g_malloc0 (sizeof (*tdata));
+      tdata = gftp_tdata_new ();
       if (copy_req)
         {
           tdata->fromreq = copy_request (fromreq);
@@ -1130,13 +887,11 @@
           else
             tdata->numfiles++;
         }
-      tdata->structmutex = g_malloc (sizeof (pthread_mutex_t));
-      pthread_mutex_init (tdata->structmutex, NULL);
-      tdata->statmutex = g_malloc (sizeof (pthread_mutex_t));
-      pthread_mutex_init (tdata->statmutex, NULL);
+
       pthread_mutex_lock (&transfer_mutex);
-      file_transfers = g_list_append (file_transfers, tdata);
+      gftp_file_transfers = g_list_append (gftp_file_transfers, tdata);
       pthread_mutex_unlock (&transfer_mutex);
+
       if (dialog)
         gftp_gtk_ask_transfer (tdata);
     }
@@ -1269,8 +1024,8 @@
 static void
 on_next_transfer (gftp_transfer * tdata)
 {
+  int fd, refresh_files;
   gftp_file * tempfle;
-  int fd;
 
   tdata->next_file = 0;
   for (; tdata->updfle != tdata->curfle; tdata->updfle = tdata->updfle->next)
@@ -1310,13 +1065,15 @@
 	tdata->fromreq->rmfile (tdata->fromreq, tempfle->file);
       
       if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
-        gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1,
+        gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1,
   			         _("Skipped"));
       else
-        gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1,
+        gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1,
   			         _("Finished"));
     }
 
+  gftp_lookup_request_option (tdata->fromreq, "refresh_files", &refresh_files);
+
   if (refresh_files && tdata->curfle && tdata->curfle->next &&
       compare_request (tdata->toreq, 
                        ((gftp_window_data *) tdata->towdata)->request, 1))
@@ -1338,7 +1095,7 @@
   if (tdata->fromreq->stopable == 0)
     return;
 
-  pthread_mutex_lock (tdata->structmutex);
+  g_static_mutex_lock (&tdata->structmutex);
   if (tdata->started)
     {
       tdata->cancel = 1;
@@ -1350,7 +1107,7 @@
 
   tdata->fromreq->stopable = 0;
   tdata->toreq->stopable = 0;
-  pthread_mutex_unlock (tdata->structmutex);
+  g_static_mutex_unlock (&tdata->structmutex);
 
   ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer of %s\n"),
 	   ((gftp_file *) tdata->curfle->data)->file);
@@ -1370,9 +1127,10 @@
   gftp_get_pixmap (dlwdw, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
   gftp_get_pixmap (dlwdw, "dir.xpm", &closedir_pixmap, &closedir_bitmap);
 
-  text[0] = GFTP_GET_HOSTNAME (tdata->fromreq);
+  text[0] = tdata->fromreq->hostname;
   text[1] = _("Waiting...");
-  tdata->node = gtk_ctree_insert_node (GTK_CTREE (dlwdw), NULL, NULL, text, 5,
+  tdata->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw), NULL, NULL, 
+                                       text, 5,
                                        closedir_pixmap, closedir_bitmap, 
                                        opendir_pixmap, opendir_bitmap, 
                                        FALSE, 
@@ -1380,7 +1138,7 @@
   transdata = g_malloc (sizeof (*transdata));
   transdata->transfer = tdata;
   transdata->curfle = NULL;
-  gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tdata->node, transdata);
+  gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tdata->user_data, transdata);
   tdata->show = 0;
   tdata->curfle = tdata->updfle = tdata->files;
 
@@ -1401,13 +1159,15 @@
           text[1] = _("Waiting...");
         }
 
-      tempfle->node = gtk_ctree_insert_node (GTK_CTREE (dlwdw), tdata->node, 
+      tempfle->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw), 
+                                             tdata->user_data, 
                                              NULL, text, 5, NULL, NULL, NULL, 
                                              NULL, FALSE, FALSE);
       transdata = g_malloc (sizeof (*transdata));
       transdata->transfer = tdata;
       transdata->curfle = templist;
-      gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->node, transdata);
+      gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->user_data, 
+                                   transdata);
     }
 
   if (!tdata->toreq->stopable && tdata->toreq->need_userpass &&
@@ -1467,30 +1227,32 @@
                            ((gftp_window_data *) tdata->towdata)->request, 1)) 
 	refresh (tdata->towdata);
 
-      transfer_in_progress--;
+      num_transfers_in_progress--;
     }
 
   if (!tdata->show && tdata->started)
     {
-      transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), tdata->node);
+      transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), 
+                                               tdata->user_data);
       if (transdata != NULL)
         g_free (transdata);
 
       for (templist = tdata->files; templist != NULL; templist = templist->next)
         {
           tempfle = templist->data;
-          transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), tempfle->node);
+          transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), 
+                                                   tempfle->user_data);
           if (transdata != NULL)
             g_free (transdata);
         }
           
-      gtk_ctree_remove_node (GTK_CTREE (dlwdw), tdata->node);
+      gtk_ctree_remove_node (GTK_CTREE (dlwdw), tdata->user_data);
     }
+
   pthread_mutex_lock (&transfer_mutex);
-  file_transfers = g_list_remove_link (file_transfers, node);
+  gftp_file_transfers = g_list_remove_link (gftp_file_transfers, node);
   pthread_mutex_unlock (&transfer_mutex);
-  pthread_mutex_destroy (tdata->structmutex);
-  pthread_mutex_destroy (tdata->statmutex);
+
   free_tdata (tdata);
 }
 
@@ -1514,10 +1276,10 @@
                            ((gftp_window_data *) tdata->fromwdata)->request);
 	  update_window_info ();
 	}
-      transfer_in_progress++;
+      num_transfers_in_progress++;
       tdata->started = 1;
       tdata->stalled = 1;
-      gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->node, 1,
+      gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1,
 			       _("Connecting..."));
       pthread_create (&tid, NULL, gftp_gtk_transfer_files, tdata);
     }
@@ -1533,7 +1295,7 @@
   gftp_file * tempfle;
   struct timeval tv;
 
-  pthread_mutex_lock (tdata->statmutex);
+  g_static_mutex_lock (&tdata->statmutex);
   tempfle = tdata->curfle->data;
 
   gettimeofday (&tv, NULL);
@@ -1549,7 +1311,7 @@
 
   if (hours < 0 || mins < 0 || secs < 0)
     {
-      pthread_mutex_unlock (tdata->statmutex);
+      g_static_mutex_unlock (&tdata->statmutex);
       return;
     }
 
@@ -1597,12 +1359,12 @@
         }
     }
 
-  pthread_mutex_unlock (tdata->statmutex);
+  g_static_mutex_unlock (&tdata->statmutex);
 
-  gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->node, 1, totstr);
+  gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tdata->user_data, 1, totstr);
 
   if (*dlstr != '\0')
-    gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1, dlstr);
+    gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->user_data, 1, dlstr);
 }
 
 static void
@@ -1630,10 +1392,11 @@
 gint
 update_downloads (gpointer data)
 {
+  int do_one_transfer_at_a_time, start_file_transfers;
   GList * templist, * next;
   gftp_transfer * tdata;
 
-  if (file_transfer_logs != NULL)
+  if (gftp_file_transfer_logs != NULL)
     display_cached_logs ();
 
   if (window1.request->gotbytes != 0)
@@ -1644,12 +1407,12 @@
   if (viewedit_process_done)
     check_done_process ();
 
-  for (templist = file_transfers; templist != NULL;)
+  for (templist = gftp_file_transfers; templist != NULL;)
     {
       tdata = templist->data;
       if (tdata->ready)
         {
-          pthread_mutex_lock (tdata->structmutex);
+          g_static_mutex_lock (&tdata->structmutex);
 
 	  if (tdata->next_file)
 	    on_next_transfer (tdata);
@@ -1658,7 +1421,7 @@
 	  else if (tdata->done)
 	    {
 	      next = templist->next;
-              pthread_mutex_unlock (tdata->structmutex);
+              g_static_mutex_unlock (&tdata->structmutex);
 	      transfer_done (templist);
 	      templist = next;
 	      continue;
@@ -1666,14 +1429,19 @@
 
 	  if (tdata->curfle != NULL)
 	    {
+              gftp_lookup_global_option ("do_one_transfer_at_a_time", 
+                                         &do_one_transfer_at_a_time);
+              gftp_lookup_global_option ("start_file_transfers",  /* FIXME - this is gone now */
+                                         &start_file_transfers);
+
 	      if (!tdata->started && start_file_transfers &&
-                  (transfer_in_progress == 0 || !do_one_transfer_at_a_time))
+                 (num_transfers_in_progress == 0 || !do_one_transfer_at_a_time))
                 create_transfer (tdata);
 
 	      if (tdata->started)
                 update_file_status (tdata);
 	    }
-          pthread_mutex_unlock (tdata->structmutex);
+          g_static_mutex_unlock (&tdata->structmutex);
         }
       templist = templist->next;
     }
@@ -1698,10 +1466,10 @@
   node = GTK_CLIST (dlwdw)->selection->data;
   transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
 
-  pthread_mutex_lock (transdata->transfer->structmutex);
+  g_static_mutex_lock (&transdata->transfer->structmutex);
   if (!transdata->transfer->started)
     create_transfer (transdata->transfer);
-  pthread_mutex_unlock (transdata->transfer->structmutex);
+  g_static_mutex_unlock (&transdata->transfer->structmutex);
 }
 
 
@@ -1720,7 +1488,7 @@
   node = GTK_CLIST (dlwdw)->selection->data;
   transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
 
-  pthread_mutex_lock (transdata->transfer->structmutex);
+  g_static_mutex_lock (&transdata->transfer->structmutex);
   if (transdata->transfer->started)
     {
       transdata->transfer->cancel = 1;
@@ -1730,7 +1498,7 @@
     }
   else
     transdata->transfer->done = 1;
-  pthread_mutex_unlock (transdata->transfer->structmutex);
+  g_static_mutex_unlock (&transdata->transfer->structmutex);
 
   ftp_log (gftp_logging_misc, NULL, _("Stopping the transfer on host %s\n"),
 	   transdata->transfer->fromreq->hostname);
@@ -1754,7 +1522,7 @@
   node = GTK_CLIST (dlwdw)->selection->data;
   transdata = gtk_ctree_node_get_row_data (GTK_CTREE (dlwdw), node);
 
-  pthread_mutex_lock (transdata->transfer->structmutex);
+  g_static_mutex_lock (&transdata->transfer->structmutex);
   if (transdata->transfer->curfle != NULL)
     {
       curfle = transdata->transfer->curfle->data;
@@ -1771,7 +1539,7 @@
     }
   else
     file = NULL;
-  pthread_mutex_unlock (transdata->transfer->structmutex);
+  g_static_mutex_unlock (&transdata->transfer->structmutex);
 
   ftp_log (gftp_logging_misc, NULL, _("Skipping file %s on host %s\n"), 
            file, transdata->transfer->fromreq->hostname);
@@ -1804,7 +1572,7 @@
   if (curfle->transfer_action & GFTP_TRANS_ACTION_SKIP)
     return;
 
-  pthread_mutex_lock (transdata->transfer->structmutex);
+  g_static_mutex_lock (&transdata->transfer->structmutex);
 
   curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
 
@@ -1819,12 +1587,12 @@
   else if (transdata->curfle != transdata->transfer->curfle &&
            !curfle->transfer_done)
     {
-      gtk_ctree_node_set_text (GTK_CTREE (dlwdw), curfle->node, 1,
+      gtk_ctree_node_set_text (GTK_CTREE (dlwdw), curfle->user_data, 1,
                                _("Skipped"));
       transdata->transfer->total_bytes -= curfle->size;
     }
 
-  pthread_mutex_unlock (transdata->transfer->structmutex);
+  g_static_mutex_unlock (&transdata->transfer->structmutex);
 
   ftp_log (gftp_logging_misc, NULL, _("Skipping file %s on host %s\n"),
            curfle->file, transdata->transfer->fromreq->hostname);
@@ -1850,7 +1618,7 @@
   if (transdata->curfle == NULL)
     return;
 
-  pthread_mutex_lock (transdata->transfer->structmutex);
+  g_static_mutex_lock (&transdata->transfer->structmutex);
   if (transdata->curfle->prev != NULL && (!transdata->transfer->started ||
       (transdata->transfer->curfle != transdata->curfle && 
        transdata->transfer->curfle != transdata->curfle->prev)))
@@ -1882,13 +1650,12 @@
         }
 
       gtk_ctree_move (GTK_CTREE (dlwdw), 
-                      ((gftp_file *) transdata->curfle->data)->node,
-                      transdata->transfer->node, 
+                      ((gftp_file *) transdata->curfle->data)->user_data,
+                      transdata->transfer->user_data, 
                       transdata->curfle->next != NULL ?
-                          ((gftp_file *) transdata->curfle->next->data)->node :
-                          NULL);
+                          ((gftp_file *) transdata->curfle->next->data)->user_data: NULL);
     }
-  pthread_mutex_unlock (transdata->transfer->structmutex);
+  g_static_mutex_unlock (&transdata->transfer->structmutex);
 }
 
 void
@@ -1910,7 +1677,7 @@
   if (transdata->curfle == NULL)
     return;
 
-  pthread_mutex_lock (transdata->transfer->structmutex);
+  g_static_mutex_lock (&transdata->transfer->structmutex);
   if (transdata->curfle->next != NULL && (!transdata->transfer->started ||
       (transdata->transfer->curfle != transdata->curfle && 
        transdata->transfer->curfle != transdata->curfle->next)))
@@ -1942,13 +1709,12 @@
         }
 
       gtk_ctree_move (GTK_CTREE (dlwdw), 
-                      ((gftp_file *) transdata->curfle->data)->node,
-                      transdata->transfer->node, 
+                      ((gftp_file *) transdata->curfle->data)->user_data,
+                      transdata->transfer->user_data, 
                       transdata->curfle->next != NULL ?
-                          ((gftp_file *) transdata->curfle->next->data)->node :
-                          NULL);
+                          ((gftp_file *) transdata->curfle->next->data)->user_data: NULL);
     }
-  pthread_mutex_unlock (transdata->transfer->structmutex);
+  g_static_mutex_unlock (&transdata->transfer->structmutex);
 }
 
 
@@ -2046,7 +1812,7 @@
   GList * templist;
 
   tdata = data;
-  pthread_mutex_lock ((pthread_mutex_t *) tdata->structmutex);
+  g_static_mutex_lock (&tdata->structmutex);
   for (templist = tdata->files; templist != NULL; templist = templist->next)
     {
       tempfle = templist->data;
@@ -2061,7 +1827,7 @@
     }
   else
     tdata->show = tdata->ready = 1;
-  pthread_mutex_unlock ((pthread_mutex_t *) tdata->structmutex);
+  g_static_mutex_unlock (&tdata->structmutex);
 }
 
 
@@ -2071,10 +1837,10 @@
   gftp_transfer * tdata;
 
   tdata = data;
-  pthread_mutex_lock ((pthread_mutex_t *) tdata->structmutex);
+  g_static_mutex_lock (&tdata->structmutex);
   tdata->show = 0;
   tdata->done = tdata->ready = 1;
-  pthread_mutex_unlock ((pthread_mutex_t *) tdata->structmutex);
+  g_static_mutex_unlock (&tdata->structmutex);
 }
 
 
@@ -2104,10 +1870,10 @@
   char *dltitles[4], *add_data[4] = { NULL, NULL, NULL, NULL },
        tempstr[50], temp1str[50], *pos, *title;
   GtkWidget * tempwid, * scroll, * hbox;
+  int i, overwrite_by_default;
   gftp_file * tempfle;
   GList * templist;
   size_t len;
-  int i;
 
   dltitles[0] = _("Filename");
   dltitles[1] = _("Local Size");
@@ -2173,6 +1939,9 @@
   gtk_widget_show (tdata->clist);
   gtk_widget_show (scroll);
 
+  gftp_lookup_request_option (tdata->fromreq, "overwrite_by_default",
+                              &overwrite_by_default);
+
   for (templist = tdata->files; templist != NULL; 
        templist = templist->next)
     {
@@ -2185,8 +1954,8 @@
       tempfle->shown = 1;
 
       pos = tempfle->destfile;
-      len = strlen (GFTP_GET_DIRECTORY (tdata->toreq));
-      if (strncmp (pos, GFTP_GET_DIRECTORY (tdata->toreq), len) == 0)
+      len = strlen (tdata->toreq->directory);
+      if (strncmp (pos, tdata->toreq->directory, len) == 0)
         pos = tempfle->destfile + len + 1;
       add_data[0] = pos;
 
--- a/src/gtk/view_dialog.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/gtk/view_dialog.c	Sun Apr 13 15:21:13 2003 +0000
@@ -48,7 +48,7 @@
       return;
     }
 
-  if (strcmp (GFTP_GET_PROTOCOL_NAME (fromwdata->request), "Local") == 0)
+  if (strcmp (gftp_protocols[fromwdata->request->protonum].name, "Local") == 0)
     view_file (curfle->file, 0, 1, 0, 1, 1, NULL, fromwdata);
   else
     {
@@ -83,6 +83,7 @@
   gftp_window_data * fromwdata, * towdata;
   GList * templist, * filelist, * newfile;
   gftp_file * new_fle;
+  char *edit_program;
   int num;
 
   fromwdata = data;
@@ -90,6 +91,9 @@
   if (!check_status (_("Edit"), fromwdata, 0, 1, 1, 1))
     return;
 
+  gftp_lookup_request_option (fromwdata->request, "edit_program", 
+                              &edit_program);
+
   if (*edit_program == '\0')
     {
       ftp_log (gftp_logging_misc, NULL,
@@ -110,7 +114,7 @@
       return;
     }
 
-  if (strcmp (GFTP_GET_PROTOCOL_NAME (fromwdata->request), "Local") == 0)
+  if (strcmp (gftp_protocols[fromwdata->request->protonum].name, "Local") == 0)
     view_file (curfle->file, 0, 0, 0, 1, 1, NULL, fromwdata);
   else
     {
@@ -157,16 +161,13 @@
       *endpos = '\0';
       n++;
       argv = g_realloc (argv, n * sizeof (char *));
-      argv[n - 1] = g_malloc (strlen (pos) + 1);
-      strcpy (argv[n - 1], pos);
+      argv[n - 1] = g_strdup (pos);
       *endpos = ' ';
       pos = endpos + 1;
     }
   argv = g_realloc (argv, (n + 3) * sizeof (char *));
-  argv[n] = g_malloc (strlen (pos) + 1);
-  strcpy (argv[n], pos);
-  argv[n + 1] = g_malloc (strlen (filename) + 1);
-  strcpy (argv[n + 1], filename);
+  argv[n] = g_strdup (pos);
+  argv[n + 1] = g_strdup (filename);
   argv[n + 2] = NULL;
 
   newproc = NULL;
@@ -198,13 +199,9 @@
           newproc->fromwdata = &window1;
           newproc->towdata = &window2;
         }
-      newproc->filename = g_malloc (strlen (filename) + 1);
-      strcpy (newproc->filename, filename);
+      newproc->filename = g_strdup (filename);
       if (remote_filename != NULL)
-	{
-	  newproc->remote_filename = g_malloc (strlen (remote_filename) + 1);
-	  strcpy (newproc->remote_filename, remote_filename);
-	}
+	newproc->remote_filename = g_strdup (remote_filename);
       newproc->view = viewedit;
       newproc->rm = del_file;
       newproc->dontupload = dontupload;
@@ -219,12 +216,13 @@
 	   int dontupload, char *remote_filename, gftp_window_data * wdata)
 {
   GtkWidget * dialog, * view, * table, * tempwid;
+  char buf[8192], *view_program, *edit_program;
+  gftp_config_list_vars * tmplistvar;
   gftp_file_extensions * tempext;
   gftp_viewedit_data * newproc;
   GtkAdjustment * vadj;
   int stlen, doclose;
   GList * templist;
-  char buf[8192];
   ssize_t n;
 #if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
@@ -234,7 +232,8 @@
 
   doclose = 1;
   stlen = strlen (filename);
-  for (templist = registered_exts; templist != NULL; templist = templist->next)
+  gftp_lookup_global_option ("ext", &tmplistvar);
+  for (templist = tmplistvar->list; templist != NULL; templist = templist->next)
     {
       tempext = templist->data;
       if (stlen >= tempext->stlen &&
@@ -250,6 +249,17 @@
         }
     }
 
+  if (wdata != NULL)
+    {
+      gftp_lookup_request_option (wdata->request, "view_program", &view_program);
+      gftp_lookup_request_option (wdata->request, "edit_program", &edit_program);
+    }
+  else
+    {
+      gftp_lookup_global_option ("view_program", &view_program);
+      gftp_lookup_global_option ("edit_program", &edit_program);
+    }
+
   if (viewedit && *view_program != '\0')
     {
       /* Open the file with the default file viewer */
@@ -257,7 +267,7 @@
                     del_file, dontupload, wdata);
       return;
     }
-  else if (!viewedit)
+  else if (!viewedit && *edit_program != '\0')
     {
       /* Open the file with the default file editor */
       newproc = fork_process (edit_program, filename, fd, remote_filename, 
--- a/src/text/gftp-text.c	Fri Apr 11 06:35:43 2003 +0000
+++ b/src/text/gftp-text.c	Sun Apr 13 15:21:13 2003 +0000
@@ -726,7 +726,7 @@
       return (1);
     }
 
-  transfer = g_malloc0 (sizeof (*transfer));
+  transfer = gftp_tdata_new ();
   transfer->fromreq = gftp_text_remreq;
   transfer->toreq = gftp_text_locreq;
   transfer->transfer_direction = GFTP_DIRECTION_DOWNLOAD;
@@ -799,7 +799,7 @@
       return (1);
     }
 
-  transfer = g_malloc0 (sizeof (*transfer));
+  transfer = gftp_tdata_new ();
   transfer->fromreq = gftp_text_locreq;
   transfer->toreq = gftp_text_remreq;
   transfer->transfer_direction = GFTP_DIRECTION_UPLOAD;