comparison lib/misc.c @ 199:75eebb3b0592

2003-6-24 Brian Masney <masneyb@gftp.org> * lib/config_file.c lib/gftp.h lib/protocols.c - added backend for overriding options on a per bookmark basis. Also added gftp_copy_local_options() to config_file.c * lib/gftp.h lib/misc.c src/gtk/bookmarks.c - added gftp_free_bookmark() to misc.c. It was taken from the function free_bookmark_entry_items() in bookmarks.c * lib/sslcommon.c - formatting fixes. Added thread functions (mostly from the OReilly SSL book)
author masneyb
date Wed, 25 Jun 2003 01:53:45 +0000
parents 65eb40fb4f03
children 0098dae654a5
comparison
equal deleted inserted replaced
198:8fea1b1a2ec6 199:75eebb3b0592
547 free_file_list (tdata->files); 547 free_file_list (tdata->files);
548 g_free (tdata); 548 g_free (tdata);
549 } 549 }
550 550
551 551
552 void
553 gftp_copy_local_options (gftp_request * dest, gftp_request * source)
554 {
555 int i;
556
557 if (source->local_options_vars == NULL)
558 {
559 dest->local_options_vars = NULL;
560 dest->num_local_options_vars = 0;
561 dest->local_options_hash = NULL;
562 return;
563 }
564
565 dest->local_options_hash = g_hash_table_new (string_hash_function,
566 string_hash_compare);
567
568 for (i=0; source->local_options_vars[i].key != NULL; i++);
569
570 dest->local_options_vars = g_malloc (sizeof (gftp_config_vars) * (i + 1));
571 memcpy (dest, source, sizeof (gftp_config_vars) * (i + 1));
572 dest->num_local_options_vars = i;
573
574 for (i=0; dest->local_options_vars[i].key != NULL; i++)
575 {
576 g_hash_table_insert (dest->local_options_hash,
577 dest->local_options_vars[i].key,
578 &dest->local_options_vars[i]);
579 }
580 }
581
582
583 gftp_request * 552 gftp_request *
584 copy_request (gftp_request * req, int copy_local_options) 553 copy_request (gftp_request * req, int copy_local_options)
585 { 554 {
586 gftp_request * newreq; 555 gftp_request * newreq;
587 556
602 newreq->logging_function = req->logging_function; 571 newreq->logging_function = req->logging_function;
603 newreq->free_hostp = 0; 572 newreq->free_hostp = 0;
604 newreq->hostp = req->hostp; 573 newreq->hostp = req->hostp;
605 574
606 if (copy_local_options) 575 if (copy_local_options)
607 gftp_copy_local_options (newreq, req); 576 gftp_copy_local_options (&newreq->local_options_vars,
577 &newreq->local_options_hash,
578 req->local_options_vars,
579 req->num_local_options_vars);
608 580
609 if (req->init (newreq) < 0) 581 if (req->init (newreq) < 0)
610 { 582 {
611 gftp_request_destroy (newreq, 1); 583 gftp_request_destroy (newreq, 1);
612 return (NULL); 584 return (NULL);
1041 fillpos[++i] = '='; 1013 fillpos[++i] = '=';
1042 } 1014 }
1043 return (newstr); 1015 return (newstr);
1044 } 1016 }
1045 1017
1018
1019 void
1020 gftp_free_bookmark (gftp_bookmarks_var * entry)
1021 {
1022 if (entry->hostname)
1023 g_free (entry->hostname);
1024 if (entry->remote_dir)
1025 g_free (entry->remote_dir);
1026 if (entry->local_dir)
1027 g_free (entry->local_dir);
1028 if (entry->user)
1029 g_free (entry->user);
1030 if (entry->pass)
1031 g_free (entry->pass);
1032 if (entry->acct)
1033 g_free (entry->acct);
1034 if (entry->protocol)
1035 g_free (entry->protocol);
1036
1037 if (entry->local_options_vars != NULL)
1038 {
1039 g_free (entry->local_options_vars);
1040 entry->local_options_vars = NULL;
1041
1042 entry->num_local_options_vars = 0;
1043
1044 g_hash_table_destroy (entry->local_options_hash);
1045 entry->local_options_hash = NULL;
1046 }
1047 }
1048