comparison 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
comparison
equal deleted inserted replaced
55:518c3872d198 56:a12bcbc2fce4
27 char *frompos, *topos, src[50], *dest; 27 char *frompos, *topos, src[50], *dest;
28 int len, num, rem, i; 28 int len, num, rem, i;
29 29
30 if (dest_str != NULL) 30 if (dest_str != NULL)
31 *dest_str = '\0'; 31 *dest_str = '\0';
32 len = (number > 0 ? log10 (number) : 0) + 1; 32 len = (number > 0 ? log10 (number) : 0) + 2;
33 33
34 if (len <= 0) 34 if (len <= 0)
35 { 35 {
36 if (dest_str != NULL) 36 if (dest_str != NULL)
37 strncpy (dest_str, "0", dest_len); 37 strncpy (dest_str, "0", dest_len);
38 else 38 else
39 dest_str = g_strconcat ("0", NULL); 39 dest_str = g_strdup ("0");
40 return (dest_str); 40 return (dest_str);
41 } 41 }
42 42
43 len += len / 3; 43 len += len / 3;
44 if (dest_str != NULL && len > dest_len) 44 if (dest_str != NULL && len > dest_len)
184 *prevpos = '\0'; 184 *prevpos = '\0';
185 } 185 }
186 else if (strcmp (pos, ".") != 0) 186 else if (strcmp (pos, ".") != 0)
187 { 187 {
188 if (newstr == NULL) 188 if (newstr == NULL)
189 newstr = g_strconcat (pos - 1, NULL); 189 newstr = g_strdup (pos - 1);
190 else 190 else
191 { 191 {
192 tempstr = g_strconcat (newstr, pos - 1, NULL); 192 tempstr = g_strconcat (newstr, pos - 1, NULL);
193 g_free (newstr); 193 g_free (newstr);
194 newstr = tempstr; 194 newstr = tempstr;
562 562
563 newreq = g_malloc0 (sizeof (*newreq)); 563 newreq = g_malloc0 (sizeof (*newreq));
564 memcpy (newreq, req, sizeof (*newreq)); 564 memcpy (newreq, req, sizeof (*newreq));
565 565
566 if (req->hostname) 566 if (req->hostname)
567 newreq->hostname = g_strconcat (req->hostname, NULL); 567 newreq->hostname = g_strdup (req->hostname);
568 if (req->username) 568 if (req->username)
569 newreq->username = g_strconcat (req->username, NULL); 569 newreq->username = g_strdup (req->username);
570 if (req->password) 570 if (req->password)
571 newreq->password = g_strconcat (req->password, NULL); 571 newreq->password = g_strdup (req->password);
572 if (req->account) 572 if (req->account)
573 newreq->account = g_strconcat (req->account, NULL); 573 newreq->account = g_strdup (req->account);
574 if (req->directory) 574 if (req->directory)
575 newreq->directory = g_strconcat (req->directory, NULL); 575 newreq->directory = g_strdup (req->directory);
576 576
577 newreq->url_prefix = NULL; 577 newreq->url_prefix = NULL;
578 newreq->protocol_name = NULL; 578 newreq->protocol_name = NULL;
579 newreq->sftpserv_path = NULL; 579 newreq->sftpserv_path = NULL;
580 newreq->proxy_config = NULL; 580 newreq->proxy_config = NULL;
590 newreq->cachefd = NULL; 590 newreq->cachefd = NULL;
591 newreq->hostp = NULL; 591 newreq->hostp = NULL;
592 newreq->protocol_data = NULL; 592 newreq->protocol_data = NULL;
593 593
594 if (req->proxy_config != NULL) 594 if (req->proxy_config != NULL)
595 newreq->proxy_config = g_strconcat (req->proxy_config, NULL); 595 newreq->proxy_config = g_strdup (req->proxy_config);
596 596
597 req->init (newreq); 597 req->init (newreq);
598 598
599 return (newreq); 599 return (newreq);
600 } 600 }
761 char ** 761 char **
762 make_ssh_exec_args (gftp_request * request, char *execname, 762 make_ssh_exec_args (gftp_request * request, char *execname,
763 int use_sftp_subsys, char *portstring) 763 int use_sftp_subsys, char *portstring)
764 { 764 {
765 char **args, *oldstr, *tempstr; 765 char **args, *oldstr, *tempstr;
766 struct servent serv_struct;
766 int i, j; 767 int i, j;
767 768
768 args = g_malloc (sizeof (char *) * (num_ssh_extra_params + 10)); 769 args = g_malloc (sizeof (char *) * (num_ssh_extra_params + 15));
769 770
770 args[0] = ssh_prog_name != NULL && *ssh_prog_name != '\0' ? 771 args[0] = ssh_prog_name != NULL && *ssh_prog_name != '\0' ?
771 ssh_prog_name : "ssh"; 772 ssh_prog_name : "ssh";
772 i = 1; 773 i = 1;
773 tempstr = g_strconcat (args[0], NULL); 774 tempstr = g_strdup (args[0]);
774 775
775 if (ssh_extra_params_list != NULL) 776 if (ssh_extra_params_list != NULL)
776 { 777 {
777 for (j=0; ssh_extra_params_list[j] != NULL; j++) 778 for (j=0; ssh_extra_params_list[j] != NULL; j++)
778 { 779 {
804 oldstr = tempstr; 805 oldstr = tempstr;
805 tempstr = g_strconcat (oldstr, " -p ", portstring, NULL); 806 tempstr = g_strconcat (oldstr, " -p ", portstring, NULL);
806 g_free (oldstr); 807 g_free (oldstr);
807 args[i++] = "-p"; 808 args[i++] = "-p";
808 args[i++] = portstring; 809 args[i++] = portstring;
810 }
811 else
812 {
813 if (!r_getservbyname ("ssh", "tcp", &serv_struct, NULL))
814 request->port = 22;
815 else
816 request->port = ntohs (serv_struct.s_port);
809 } 817 }
810 818
811 if (use_sftp_subsys) 819 if (use_sftp_subsys)
812 { 820 {
813 oldstr = tempstr; 821 oldstr = tempstr;