changeset 56:a12bcbc2fce4

2002-11-11 Brian Masney <masneyb@gftp.org> * src/gtk/dnd.c - fixes to DnD code * src/gtk/gftp-gtk.[ch] - added main_thread_id variable * src/gtk/misc-gtk.c (ftp_log) - don't check the user_data to see if we're in a child thread, instead compare the value of pthread_self() with main_thread_id * src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/menu-items.c src/gtk/mkdir_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c - don't set user_data to 0x1 if we're in a child thread * lib/gftp.h src/gtk/misc-gtk.c src/text/gftp-text.c - make r_getservbyname() available even if HAVE_GERADDRINFO is defined * lib/misc.c (make_ssh_exec_args) - if port is zero, lookup the default port for the ssh service * lib/protocols.c (gftp_connect_server) - if the port is zero, store the default port for that protocol there * src/gtk/transfer.c - added function update_window_transfer_bytes(). Be able to update the directory download progress in window1 now * lib/config_file.c lib/misc.c lib/protocols.c lib/ssh.c lib/sshv2.c src/text/gftp-text.c - use g_strdup() instead of g_strconcat() where needed
author masneyb
date Mon, 11 Nov 2002 23:16:12 +0000
parents 518c3872d198
children 72f6ca02c83a
files ChangeLog lib/config_file.c lib/gftp.h lib/misc.c lib/protocols.c lib/ssh.c lib/sshv2.c src/gtk/chmod_dialog.c src/gtk/delete_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/rename_dialog.c src/gtk/transfer.c src/text/gftp-text.c
diffstat 18 files changed, 144 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Nov 11 11:20:13 2002 +0000
+++ b/ChangeLog	Mon Nov 11 23:16:12 2002 +0000
@@ -1,5 +1,33 @@
+2002-11-11 Brian Masney <masneyb@gftp.org>
+	* src/gtk/dnd.c - fixes to DnD code
+
+	* src/gtk/gftp-gtk.[ch] - added main_thread_id variable
+
+	* src/gtk/misc-gtk.c (ftp_log) - don't check the user_data to see if 
+	we're in a child thread, instead compare the value of pthread_self()
+	with main_thread_id
+
+	* src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/menu-items.c
+	src/gtk/mkdir_dialog.c src/gtk/rename_dialog.c src/gtk/transfer.c -
+	don't set user_data to 0x1 if we're in a child thread
+
+	* lib/gftp.h src/gtk/misc-gtk.c src/text/gftp-text.c - make 
+	r_getservbyname() available even if HAVE_GERADDRINFO is defined
+	
+	* lib/misc.c (make_ssh_exec_args) - if port is zero, lookup the default
+	port for the ssh service
+
+	* lib/protocols.c (gftp_connect_server) - if the port is zero, store
+	the default port for that protocol there
+
+	* src/gtk/transfer.c - added function update_window_transfer_bytes().
+	Be able to update the directory download progress in window1 now
+
+	* lib/config_file.c lib/misc.c lib/protocols.c lib/ssh.c lib/sshv2.c
+	src/text/gftp-text.c - use g_strdup() instead of g_strconcat() where
+	needed
+
 2002-11-11 Andras Timar <timar@gnome.hu>
-
 	* configure.in: added 'hu' to ALL_LINGUAS
 
 2002-11-6 Brian Masney <masneyb@gftp.org>
@@ -171,7 +199,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.30 2002/11/10 23:09:11 bansz Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.31 2002/11/11 23:16:10 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/config_file.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/lib/config_file.c	Mon Nov 11 23:16:12 2002 +0000
@@ -474,8 +474,7 @@
           ssh_extra_params_list = g_realloc (ssh_extra_params_list,
                                              (num_ssh_extra_params + 1) * 
                                              sizeof (char *));
-          ssh_extra_params_list[num_ssh_extra_params - 1] = 
-                                                  g_strconcat (curpos, NULL);
+          ssh_extra_params_list[num_ssh_extra_params - 1] = g_strdup (curpos);
           ssh_extra_params_list[num_ssh_extra_params] = NULL;
           *endpos = ' ';
           curpos = endpos + 1;
@@ -487,8 +486,7 @@
           ssh_extra_params_list = g_realloc (ssh_extra_params_list,
                                              (num_ssh_extra_params + 1) * 
                                              sizeof (char *));
-          ssh_extra_params_list[num_ssh_extra_params - 1] = 
-                                                  g_strconcat (curpos, NULL);
+          ssh_extra_params_list[num_ssh_extra_params - 1] = g_strdup (curpos);
           ssh_extra_params_list[num_ssh_extra_params] = NULL;
         }
     }
--- a/lib/gftp.h	Mon Nov 11 11:20:13 2002 +0000
+++ b/lib/gftp.h	Mon Nov 11 23:16:12 2002 +0000
@@ -799,12 +799,12 @@
 					  struct hostent *result_buf, 
 					  int *h_errnop );
 
+#endif
+
 struct servent *r_getservbyname 	( const char *name, 
 					  const char *proto,
 					  struct servent *result_buf, 
 					  int *h_errnop );
-#endif
-
 void gftp_set_config_options 		( gftp_request * request );
 
 void print_file_list 			( GList * list );
--- a/lib/misc.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/lib/misc.c	Mon Nov 11 23:16:12 2002 +0000
@@ -29,14 +29,14 @@
 
   if (dest_str != NULL)
     *dest_str = '\0';
-  len = (number > 0 ? log10 (number) : 0) + 1;
+  len = (number > 0 ? log10 (number) : 0) + 2;
 
   if (len <= 0) 
     {
       if (dest_str != NULL)
         strncpy (dest_str, "0", dest_len);
       else
-        dest_str = g_strconcat ("0", NULL);
+        dest_str = g_strdup ("0");
       return (dest_str);
     }
 
@@ -186,7 +186,7 @@
       else if (strcmp (pos, ".") != 0)
 	{
 	  if (newstr == NULL)
-	    newstr = g_strconcat (pos - 1, NULL);
+	    newstr = g_strdup (pos - 1);
 	  else
 	    {
 	      tempstr = g_strconcat (newstr, pos - 1, NULL);
@@ -564,15 +564,15 @@
   memcpy (newreq, req, sizeof (*newreq));
 
   if (req->hostname)
-    newreq->hostname = g_strconcat (req->hostname, NULL);
+    newreq->hostname = g_strdup (req->hostname);
   if (req->username)
-    newreq->username = g_strconcat (req->username, NULL);
+    newreq->username = g_strdup (req->username);
   if (req->password)
-    newreq->password = g_strconcat (req->password, NULL);
+    newreq->password = g_strdup (req->password);
   if (req->account)
-    newreq->account = g_strconcat (req->account, NULL);
+    newreq->account = g_strdup (req->account);
   if (req->directory)
-    newreq->directory = g_strconcat (req->directory, NULL);
+    newreq->directory = g_strdup (req->directory);
 
   newreq->url_prefix = NULL;
   newreq->protocol_name = NULL;
@@ -592,7 +592,7 @@
   newreq->protocol_data = NULL;
   
   if (req->proxy_config != NULL)
-    newreq->proxy_config = g_strconcat (req->proxy_config, NULL);
+    newreq->proxy_config = g_strdup (req->proxy_config);
 
   req->init (newreq);
 
@@ -763,14 +763,15 @@
                     int use_sftp_subsys, char *portstring)
 {
   char **args, *oldstr, *tempstr;
+  struct servent serv_struct;
   int i, j;
 
-  args = g_malloc (sizeof (char *) * (num_ssh_extra_params + 10));
+  args = g_malloc (sizeof (char *) * (num_ssh_extra_params + 15));
 
   args[0] = ssh_prog_name != NULL && *ssh_prog_name != '\0' ? 
             ssh_prog_name : "ssh";
   i = 1;
-  tempstr = g_strconcat (args[0], NULL);
+  tempstr = g_strdup (args[0]);
 
   if (ssh_extra_params_list != NULL)
     {
@@ -807,6 +808,13 @@
       args[i++] = "-p";
       args[i++] = portstring;
     }
+  else
+    {
+      if (!r_getservbyname ("ssh", "tcp", &serv_struct, NULL))
+        request->port = 22;
+      else
+        request->port = ntohs (serv_struct.s_port);
+    }
 
   if (use_sftp_subsys)
     {
--- a/lib/protocols.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/lib/protocols.c	Mon Nov 11 23:16:12 2002 +0000
@@ -109,13 +109,14 @@
 
   if (request->sftpserv_path == NULL)
     {
+      /* FIXME - move this to per protocol files */
       switch (request->protonum)
         {
           case GFTP_SSH_NUM:
-            request->sftpserv_path = g_strconcat (ssh1_sftp_path, NULL);
+            request->sftpserv_path = g_strdup (ssh1_sftp_path);
             break;
           case GFTP_SSHV2_NUM:
-            request->sftpserv_path = g_strconcat (ssh2_sftp_path, NULL);
+            request->sftpserv_path = g_strdup (ssh2_sftp_path);
             break;
         }
     }
@@ -1792,6 +1793,9 @@
     {
       disphost = res->ai_canonname ? res->ai_canonname : connect_host;
       port = get_port (res);
+      if (!request->use_proxy)
+        request->port = port;
+
       if ((sock = socket (res->ai_family, res->ai_socktype, 
                           res->ai_protocol)) < 0)
         {
@@ -1862,6 +1866,9 @@
           port = serv_struct.s_port;
           request->port = ntohs (serv_struct.s_port);
         }
+
+      if (!request->use_proxy)
+        request->port = ntohs (port);
     }
   remote_address.sin_port = port;
 
@@ -1917,6 +1924,7 @@
 void
 gftp_set_config_options (gftp_request * request)
 {
+  /* FIXME - move this to per protocol files */
   request->transfer_type = passive_transfer ? gftp_transfer_passive : gftp_transfer_active;
   request->network_timeout = network_timeout;
   request->retries = retries;
--- a/lib/ssh.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/lib/ssh.c	Mon Nov 11 23:16:12 2002 +0000
@@ -763,7 +763,7 @@
   request->logging_function (gftp_logging_misc, request->user_data,
 			     _("Retrieving directory listing...\n"));
 
-  tempstr = g_strconcat ("/bin/ls -al", NULL);
+  tempstr = g_strdup ("/bin/ls -al");
   len = ssh_remove_spaces (tempstr);
 
   if (ssh_send_command (request, EXEC, tempstr, len) < 0) 
--- a/lib/sshv2.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/lib/sshv2.c	Mon Nov 11 23:16:12 2002 +0000
@@ -1351,7 +1351,7 @@
   if (*oldname == '/')
     {
       oldlen = strlen (oldname); 
-      oldstr = g_strconcat (oldname, NULL);
+      oldstr = g_strdup (oldname);
     }
   else
     {
@@ -1362,7 +1362,7 @@
   if (*newname == '/')
     {
       newlen = strlen (newname); 
-      newstr = g_strconcat (newname, NULL);
+      newstr = g_strdup (newname);
     }
   else
     {
--- a/src/gtk/chmod_dialog.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/chmod_dialog.c	Mon Nov 11 23:16:12 2002 +0000
@@ -34,7 +34,6 @@
   gftp_file * tempfle;
 
   wdata = data;
-  wdata->request->user_data = (void *) 0x01;
 
   if (wdata->request->use_threads)
     {
@@ -74,7 +73,6 @@
   if (wdata->request->use_threads)
     use_jmp_environment = 0;
 
-  wdata->request->user_data = NULL;
   wdata->request->stopable = 0;
   return ((void *) success);
 }
--- a/src/gtk/delete_dialog.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/delete_dialog.c	Mon Nov 11 23:16:12 2002 +0000
@@ -46,7 +46,6 @@
   int success, sj;
 
   transfer = data;
-  transfer->fromreq->user_data = (void *) 0x01;
 
   if (transfer->fromreq->use_threads)
     {
@@ -98,7 +97,6 @@
                                         _("Operation canceled\n"));
     }
 
-  transfer->fromreq->user_data = NULL;
   transfer->fromreq->stopable = 0;
 
   if (transfer->fromreq->use_threads)
--- a/src/gtk/dnd.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/dnd.c	Mon Nov 11 23:16:12 2002 +0000
@@ -24,13 +24,19 @@
 static int
 dnd_remote_file (char *url, gftp_window_data * wdata)
 {
+  gftp_window_data * other_wdata, * fromwdata;
   gftp_request * current_ftpdata;
   gftp_file * newfle;
-  char *str, *pos;
-  GList templist;
-  int i;
+  GList * templist;
+  char *pos;
 
-  printf ("FIXME - in dnd_remote file\n");
+  if (wdata == &window1)
+    other_wdata = &window2;
+  else if (wdata == &window2)
+    other_wdata = &window1;
+  else 
+    other_wdata = NULL;
+    
   newfle = g_malloc0 (sizeof (*newfle));
   newfle->shown = 1;
   if (url[strlen (url) - 1] == '/') 
@@ -42,7 +48,9 @@
   current_ftpdata = gftp_request_new ();
   current_ftpdata->logging_function = ftp_log;
 
-  if (gftp_parse_url (current_ftpdata, url) != 0) 
+  if (gftp_parse_url (current_ftpdata, url) != 0 ||
+      current_ftpdata->directory == NULL ||
+      (pos = strrchr (current_ftpdata->directory, '/')) == NULL) 
     {
       ftp_log (gftp_logging_misc, NULL, 
                _("Drag-N-Drop: Ignoring url %s: Not a valid url\n"), url);
@@ -51,53 +59,42 @@
       return (0);
     }
 
-  if ((str = GFTP_GET_DIRECTORY (current_ftpdata)) != NULL) 
-    {
-      if ((pos = strrchr (str, '/')) == NULL) 
-        pos = str;
-      else pos++;
-      *(pos - 1) = '\0';
-      i = 1;
-    }
-  else 
-    {
-      pos = str = GFTP_GET_DIRECTORY (current_ftpdata);
-      i = 0;
-    }
-
+  *pos++ = '\0';
   if (compare_request (current_ftpdata, wdata->request, 1))
     {
       gftp_request_destroy (current_ftpdata);
       return (0);
     }
 
-  if (i)
+  if (other_wdata != NULL && 
+      compare_request (current_ftpdata, other_wdata->request, 1))
     {
-      *(pos - 1) = '/';
-      newfle->file = g_malloc (strlen (str) + 1);
-      strcpy (newfle->file, str);
-      *(pos - 1) = '\0';
+      gftp_set_password (current_ftpdata, other_wdata->request->password);
+      fromwdata = other_wdata;
     }
   else
-    {
-      newfle->file = g_malloc (strlen (str) + 1);
-      strcpy (newfle->file, str);
-    }
+    fromwdata = NULL;
+
+  *(pos - 1) = '/';
+  newfle->file = g_malloc (strlen (current_ftpdata->directory) + 1);
+  strcpy (newfle->file, current_ftpdata->directory);
+  *(pos - 1) = '\0';
   
   newfle->destfile = g_strconcat (GFTP_GET_DIRECTORY (wdata->request),
                                      "/", pos, NULL);
   newfle->ascii = gftp_get_file_transfer_mode (newfle->file, 
                                 wdata->request->data_type) == GFTP_TYPE_ASCII;
 
-  templist.data = newfle;
-  templist.next = NULL;
-  add_file_transfer (current_ftpdata, wdata->request, NULL,
-                     wdata, &templist, 1);
+  templist = g_malloc0 (sizeof (*templist));
+  templist->data = newfle;
+  templist->next = NULL;
+  add_file_transfer (current_ftpdata, wdata->request, fromwdata,
+                     wdata, templist, 1);
   gftp_request_destroy (current_ftpdata);
 
   if (newfle->isdir)
     {
-/* FIXME - need to fix this
+/* FIXME - need to fix this 
       add_entire_directory (tdata, newfle, 
 		            GFTP_GET_DIRECTORY (tdata->fromhdata->ftpdata), 
 			    GFTP_GET_DIRECTORY (tdata->tohdata->ftpdata), 
@@ -164,36 +161,45 @@
       oldlen = totlen;
       if (GFTP_GET_HOSTNAME (wdata->request) == NULL)
         {
-          tempstr = g_strdup_printf ("%s://%s/%s%c", 
+          tempstr = g_strdup_printf ("%s://%s/%s ", 
                                  GFTP_GET_URL_PREFIX (wdata->request),
                                  GFTP_GET_DIRECTORY (wdata->request), 
-                                 tempfle->file, tempfle->isdir ? '/' : '\0');
+                                 tempfle->file);
         }
       else if (GFTP_GET_USERNAME (wdata->request) == NULL 
                || *GFTP_GET_USERNAME (wdata->request) == '\0')
         {
-          tempstr = g_strdup_printf ("%s://%s:%d%s/%s%c", 
+          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), 
-                                 tempfle->file, tempfle->isdir ? '/' : '\0');
+                                 tempfle->file);
         }
       else
         {
-          tempstr = g_strdup_printf ("%s://%s@%s:%d%s/%s%c", 
+          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), 
-                                 tempfle->file, tempfle->isdir ? '/' : '\0');
+                                 tempfle->file);
         }
+
       if ((pos = strchr (tempstr, ':')) != NULL)
         pos += 2;
       else
         pos = tempstr;
       remove_double_slashes (pos);
+
+      /* Note, I am allocating memory for this byte above. Note the extra space
+         at the end of the g_strdup_printf() format argument */
+      if (tempfle->isdir)
+        tempstr[strlen (tempstr) - 1] = '/';
+      else
+        tempstr[strlen (tempstr) - 1] = '\0';
+
       totlen += strlen (tempstr);
       if (str != NULL)
         {
@@ -236,7 +242,6 @@
   if ((selection_data->length >= 0) && (selection_data->format == 8)) 
     {
       oldpos = (char *) selection_data->data;
-      printf ("FIXME - got data %s\n", oldpos);
       while ((newpos = strchr (oldpos, '\n')) || 
              (newpos = strchr (oldpos, '\0'))) 
         {
--- a/src/gtk/gftp-gtk.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/gftp-gtk.c	Mon Nov 11 23:16:12 2002 +0000
@@ -41,6 +41,7 @@
 int gftp_is_started = 0;
 sigjmp_buf jmp_environment;
 volatile int use_jmp_environment = 0;
+pthread_t main_thread_id;
 
 static int
 get_column (GtkCListColumn * col)
@@ -985,6 +986,7 @@
 #endif
 
   g_thread_init (NULL);
+  main_thread_id = pthread_self ();
   gtk_set_locale ();
   gtk_init (&argc, &argv);
 
--- a/src/gtk/gftp-gtk.h	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/gftp-gtk.h	Mon Nov 11 23:16:12 2002 +0000
@@ -151,6 +151,7 @@
 extern int gftp_is_started;
 extern sigjmp_buf jmp_environment;
 extern volatile int use_jmp_environment;
+extern pthread_t main_thread_id;
 
 /* bookmarks.c */
 void run_bookmark 				( gpointer data );
--- a/src/gtk/menu-items.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/menu-items.c	Mon Nov 11 23:16:12 2002 +0000
@@ -425,7 +425,6 @@
   int success, sj;
 
   wdata = data;
-  wdata->request->user_data = (void *) 0x01;
 
   if (wdata->request->use_threads)
     {
@@ -454,7 +453,6 @@
   if (wdata->request->use_threads)
     use_jmp_environment = 0;
 
-  wdata->request->user_data = NULL;
   wdata->request->stopable = 0;
   return ((void *) success);
 }
--- a/src/gtk/misc-gtk.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/misc-gtk.c	Mon Nov 11 23:16:12 2002 +0000
@@ -20,6 +20,7 @@
 #include <gftp-gtk.h>
 static const char cvsid[] = "$Id$";
 
+static pthread_mutex_t netfunclock = PTHREAD_MUTEX_INITIALIZER;
 static GtkWidget * statuswid;
 
 
@@ -77,7 +78,7 @@
   char *tempstr;
 #endif
 
-  if (ptr == (void *) 0x1)
+  if (pthread_self () != main_thread_id)
     {
       newlog = g_malloc0 (sizeof (*newlog));
       newlog->type = level;
@@ -1260,8 +1261,6 @@
 
 #if !defined (HAVE_GETADDRINFO) || !defined (HAVE_GAI_STRERROR)
 
-static pthread_mutex_t netfunclock = PTHREAD_MUTEX_INITIALIZER;
-
 struct hostent *
 r_gethostbyname (const char *name, struct hostent *result_buf, int *h_errnop)
 {
@@ -1282,6 +1281,7 @@
   return (hent);
 }
 
+#endif /* !HAVE_GETADDRINFO */
 
 struct servent *
 r_getservbyname (const char *name, const char *proto,
@@ -1304,5 +1304,3 @@
   return (sent);
 }
 
-#endif /* !HAVE_GETADDRINFO */
-
--- a/src/gtk/mkdir_dialog.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/mkdir_dialog.c	Mon Nov 11 23:16:12 2002 +0000
@@ -30,7 +30,6 @@
   int success, sj;
 
   wdata = data;
-  wdata->request->user_data = (void *) 0x01;
 
   if (wdata->request->use_threads)
     {
@@ -59,7 +58,6 @@
   if (wdata->request->use_threads)
     use_jmp_environment = 0;
 
-  wdata->request->user_data = NULL;
   wdata->request->stopable = 0;
   return ((void *) success);
 }
--- a/src/gtk/rename_dialog.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/rename_dialog.c	Mon Nov 11 23:16:12 2002 +0000
@@ -31,7 +31,6 @@
   int success, sj;
 
   wdata = data;
-  wdata->request->user_data = (void *) 0x01;
 
   if (wdata->request->use_threads)
     { 
@@ -60,7 +59,6 @@
   if (wdata->request->use_threads)
     use_jmp_environment = 0;
 
-  wdata->request->user_data = NULL;
   wdata->request->stopable = 0;
   return ((void *) success);
 }
--- a/src/gtk/transfer.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/gtk/transfer.c	Mon Nov 11 23:16:12 2002 +0000
@@ -79,7 +79,6 @@
   GList * files;
 
   request = data;
-  request->user_data = (void *) 0x1;
   
   if (request->use_threads)
     {
@@ -97,7 +96,6 @@
           if (request->use_threads)
             use_jmp_environment = 0;
 
-          request->user_data = NULL;
           request->stopable = 0;
           if (request->wakeup_main_thread[1] > 0)
             write (request->wakeup_main_thread[1], " ", 1);
@@ -128,7 +126,6 @@
           if (request->use_threads)
             use_jmp_environment = 0;
 
-          request->user_data = NULL;
           request->stopable = 0;
           if (request->wakeup_main_thread[1] > 0)
             write (request->wakeup_main_thread[1], " ", 1);
@@ -152,7 +149,6 @@
         }
     }
 
-  request->user_data = NULL;
   if (request->use_threads)
     use_jmp_environment = 0;
 
@@ -245,7 +241,6 @@
   int ret, sj;
 
   request = data;
-  request->user_data = (void *) 0x1;
 
   conn_num = 0;
   if (request->use_threads)
@@ -286,7 +281,6 @@
   if (request->use_threads)
     use_jmp_environment = 0;
 
-  request->user_data = NULL;
   request->stopable = 0;
   if (request->wakeup_main_thread[1] > 0)
     write (request->wakeup_main_thread[1], " ", 1);
@@ -514,9 +508,6 @@
   int success, sj;
 
   transfer = data;
-  transfer->fromreq->user_data = (void *) 0x01;
-  if (transfer->toreq)
-    transfer->toreq->user_data = (void *) 0x01;
 
   if (transfer->fromreq->use_threads || 
       (transfer->toreq && transfer->toreq->use_threads))
@@ -544,9 +535,6 @@
       (transfer->toreq && transfer->toreq->use_threads))
     use_jmp_environment = 0;
 
-  transfer->fromreq->user_data = NULL;
-  if (transfer->toreq)
-    transfer->toreq->user_data = NULL;
   transfer->fromreq->stopable = 0;
   return ((void *) success);
 }
@@ -753,8 +741,6 @@
 
   pthread_detach (pthread_self ());
   transfer = data;
-  transfer->fromreq->user_data = (void *) 0x1;
-  transfer->toreq->user_data = (void *) 0x1;
   transfer->curfle = transfer->files;
   gettimeofday (&transfer->starttime, NULL);
   memcpy (&transfer->lasttime, &transfer->starttime, 
@@ -979,8 +965,6 @@
       transfer->toreq->cancel = 0;
     }
   transfer->done = 1; 
-  transfer->fromreq->user_data = NULL;
-  transfer->toreq->user_data = NULL;
   return (NULL);
 }
 
@@ -1423,7 +1407,7 @@
   tdata = node->data;
   if (tdata->started)
     {
-      fromreq = ((gftp_window_data *) tdata->fromwdata)->request;
+      fromreq = tdata->fromwdata != NULL ? ((gftp_window_data *) tdata->fromwdata)->request : NULL;
       if (!tdata->fromreq->stopable && tdata->fromwdata &&
           ((fromreq->sockfd == NULL && fromreq->cached) ||
            fromreq->always_connected) && tdata->fromreq->sockfd != NULL &&
@@ -1581,32 +1565,41 @@
     gtk_ctree_node_set_text (GTK_CTREE (dlwdw), tempfle->node, 1, dlstr);
 }
 
+static void
+update_window_transfer_bytes (gftp_window_data * wdata)
+{
+  char *tempstr, *temp1str;
+
+  if (wdata->request->gotbytes == -1)
+    {
+      update_window_info ();
+      wdata->request->gotbytes = 0;
+    }
+  else
+    {
+      tempstr = insert_commas (wdata->request->gotbytes, NULL, 0);
+      temp1str = g_strdup_printf (_("Retrieving file names...%s bytes"), 
+                                  tempstr);
+      gtk_label_set (GTK_LABEL (wdata->hoststxt), temp1str);
+      g_free (tempstr);
+      g_free (temp1str);
+    }
+}
+
 
 gint
 update_downloads (gpointer data)
 {
-  char tempstr[50], temp1str[127];
   GList * templist, * next;
   gftp_transfer * tdata;
 
   if (file_transfer_logs != NULL)
     display_cached_logs ();
 
+  if (window1.request->gotbytes != 0)
+    update_window_transfer_bytes (&window1);
   if (window2.request->gotbytes != 0)
-    {
-      if (window2.request->gotbytes == -1)
-	{
-	  update_window_info ();
-	  window2.request->gotbytes = 0;
-	}
-      else
-	{
-	  insert_commas (window2.request->gotbytes, tempstr, sizeof (tempstr));
-          g_snprintf (temp1str, sizeof (temp1str),
-	              _("Retrieving file names...%s bytes"), tempstr);
-	  gtk_label_set (GTK_LABEL (window2.hoststxt), temp1str);
-	}
-    }
+    update_window_transfer_bytes (&window2);
 
   if (viewedit_process_done)
     check_done_process ();
--- a/src/text/gftp-text.c	Mon Nov 11 11:20:13 2002 +0000
+++ b/src/text/gftp-text.c	Mon Nov 11 23:16:12 2002 +0000
@@ -1297,6 +1297,8 @@
   return (hent);
 }
 
+#endif /* HAVE_GETADDRINFO */
+
 
 struct servent *
 r_getservbyname (const char *name, const char *proto,
@@ -1317,5 +1319,3 @@
   return (sent);
 }
 
-#endif /* HAVE_GETADDRINFO */
-