diff lib/misc.c @ 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 4bcfaf6307b5
children c01d91c10f6c
line wrap: on
line diff
--- 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)
     {