diff lib/misc.c @ 201:0098dae654a5

2003-6-25 Brian Masney <masneyb@gftp.org> * configure.in - added mk to ALL_LINGUAS * lib/gftp.h - added several macros for dmalloc * lib/misc.c src/text/gftp-text.c src/gtk/gftp-gtk.c - added gftp_shutdown() to misc.c. This will write out the configuration file, clear the cache, and if dmalloc is enabled, free the memory that was allocated on startup * lib/config_file.c lib/gftp.h lib/misc.c lib/options.h - added gftp_configuration_changed parameter * lib/config_file.c lib/misc.c lib/protocols.c - added gftp_config_free_options() * lib/config_file.c src/gtk/bookmarks.c - added gftp_bookmarks() which is derived mostly from bm_close_dialog() * lib/rfc959.c - added rfc959_request_destroy(). Free the getline buffers in this function * src/gtk/misc-gtk.c (gftp_item_factory_translate) - remove double g_strdup() call * lib/config_file.c lib/gftp.h src/gtk/misc-gtk.c - moved get_xpm_path() to GTK+ port. No longer call it startup when reading the config file
author masneyb
date Thu, 26 Jun 2003 01:04:12 +0000
parents 75eebb3b0592
children 95e669973a84
line wrap: on
line diff
--- a/lib/misc.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/misc.c	Thu Jun 26 01:04:12 2003 +0000
@@ -359,40 +359,6 @@
 }
 
 
-char *
-get_xpm_path (char *filename, int quit_on_err)
-{
-  char *tempstr, *exfile;
-
-  tempstr = g_strconcat (BASE_CONF_DIR, "/", filename, NULL);
-  exfile = expand_path (tempstr);
-  g_free (tempstr);
-  if (access (exfile, F_OK) != 0)
-    {
-      g_free (exfile);
-      tempstr = g_strconcat (SHARE_DIR, "/", filename, NULL);
-      exfile = expand_path (tempstr);
-      g_free (tempstr);
-      if (access (exfile, F_OK) != 0)
-	{
-	  g_free (exfile);
-	  exfile = g_strconcat ("/usr/share/icons/", filename, NULL);
-	  if (access (exfile, F_OK) != 0)
-	    {
-	      g_free (exfile);
-	      if (!quit_on_err)
-		return (NULL);
-
-	      printf (_("gFTP Error: Cannot find file %s in %s or %s\n"),
-		      filename, SHARE_DIR, BASE_CONF_DIR);
-	      exit (1);
-	    }
-	}
-    }
-  return (exfile);
-}
-
-
 gint
 string_hash_compare (gconstpointer path1, gconstpointer path2)
 {
@@ -1036,13 +1002,54 @@
 
   if (entry->local_options_vars != NULL)
     {
-      g_free (entry->local_options_vars);
+      gftp_config_free_options (entry->local_options_vars,
+                                entry->local_options_hash,
+                                entry->num_local_options_vars);
+
       entry->local_options_vars = NULL;
-
+      entry->local_options_hash = NULL;
       entry->num_local_options_vars = 0;
-
-      g_hash_table_destroy (entry->local_options_hash);
-      entry->local_options_hash = NULL;
     }
 }
 
+
+void
+gftp_shutdown (void)
+{
+  gftp_config_vars * cv;
+  GList * templist;
+
+  if (gftp_logfd != NULL)
+    fclose (gftp_logfd);
+
+  gftp_clear_cache_files ();
+
+  if (gftp_configuration_changed)
+    gftp_write_config_file ();
+
+#ifdef WITH_DMALLOC
+  if (gftp_global_options_htable != NULL)
+    g_hash_table_destroy (gftp_global_options_htable);
+
+  if (gftp_config_list_htable != NULL)
+    g_hash_table_destroy (gftp_config_list_htable);
+
+  if (gftp_bookmarks_htable != NULL)
+    g_hash_table_destroy (gftp_bookmarks_htable);
+
+  for (templist = gftp_options_list; 
+       templist != NULL; 
+       templist = templist->next)
+    {
+      cv = templist->data;
+      gftp_config_free_options (cv, NULL, -1);
+    }
+
+  gftp_bookmarks_destroy (gftp_bookmarks);
+
+  dmalloc_shutdown ();
+#endif
+
+  exit (0);
+}
+