changeset 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 27ae88b5a55e
children 7d7d8299610d
files ChangeLog TODO configure.in lib/config_file.c lib/gftp.h lib/misc.c lib/options.h lib/protocols.c lib/rfc2068.c lib/rfc959.c m4/Makefile.am src/gtk/bookmarks.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/misc-gtk.c src/text/gftp-text.c
diffstat 16 files changed, 294 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 25 10:57:06 2003 +0000
+++ b/ChangeLog	Thu Jun 26 01:04:12 2003 +0000
@@ -1,3 +1,32 @@
+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
+	
 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 
@@ -1082,7 +1111,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.99 2003/06/25 01:53:44 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.100 2003/06/26 01:04:08 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/TODO	Wed Jun 25 10:57:06 2003 +0000
+++ b/TODO	Thu Jun 26 01:04:12 2003 +0000
@@ -3,11 +3,13 @@
 version of gFTP, please email me about it.
 
 *** TODO FOR 2.0.15 ***
+* socklen_t to configure.in
+* Check for memory leaks with dmalloc
+* text port - cd .. is busted
 * DND - be able to resume transfers
 * HTTP - keepalive
 * HTTP - chdir .. is busted
 * HTTP - I am getting complaints about HTTP proxy support is busted
-* Finish generic SSL layer
 * Profile SSHV2 transfers, they seem really slow to me
 * Override options on a per site basis (backend is done, I just have to make
   a user interface for the text and gtk+ port)
--- a/configure.in	Wed Jun 25 10:57:06 2003 +0000
+++ b/configure.in	Thu Jun 26 01:04:12 2003 +0000
@@ -24,7 +24,7 @@
 AC_SUBST(VERSION)
 AC_SUBST(PREFIX)
 
-ALL_LINGUAS="am ar bg ca cs da de es fi fr hu it ja ko ms nl no pl pt pt_BR ro ru sr sr@Latn sv tr uk zh_CN zh_TW"
+ALL_LINGUAS="am ar bg ca cs da de es fi fr hu it ja ko mk ms nl no pl pt pt_BR ro ru sr sr@Latn sv tr uk zh_CN zh_TW"
 
 AC_DEFINE(_GNU_SOURCE, 1, [Define for setting a GNU environment])
 
@@ -261,4 +261,4 @@
 
 AM_GNU_GETTEXT
 
-AC_OUTPUT(Makefile docs/Makefile docs/sample.gftp/Makefile lib/Makefile src/gftp src/Makefile src/gtk/Makefile src/text/Makefile gftp.spec intl/Makefile po/Makefile.in  intl/Makefile po/Makefile.in  intl/Makefile po/Makefile.in )
+AC_OUTPUT(Makefile docs/Makefile docs/sample.gftp/Makefile lib/Makefile src/gftp src/Makefile src/gtk/Makefile src/text/Makefile gftp.spec)
--- a/lib/config_file.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/config_file.c	Thu Jun 26 01:04:12 2003 +0000
@@ -413,15 +413,11 @@
 gftp_config_read_ext (char *buf, int line)
 {
   gftp_file_extensions * tempext;
-  char *tempstr;
 
   tempext = g_malloc (sizeof (*tempext));
   gftp_config_parse_args (buf, 4, line, &tempext->ext, &tempext->filename,
                           &tempext->ascii_binary, &tempext->view_program);
  
-  if ((tempstr = get_xpm_path (tempext->filename, 1)) != NULL)
-    g_free (tempstr);
-
   tempext->stlen = strlen (tempext->ext);
 
   return (tempext);
@@ -508,7 +504,10 @@
 
   if ((tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
                                            "default_protocol")) != NULL)
-    tmpconfigvar->listdata = protocol_list;
+    {
+      tmpconfigvar->listdata = protocol_list;
+      tmpconfigvar->flags |= GFTP_CVARS_FLAGS_DYNLISTMEM;
+    }
 
   gftp_config_list_htable = g_hash_table_new (string_hash_function, 
                                               string_hash_compare);
@@ -1122,7 +1121,12 @@
   if (gftp_global_options_htable != NULL &&
       (tmpconfigvar = g_hash_table_lookup (gftp_global_options_htable,
                                            key)) != NULL)
-    memcpy (&tmpconfigvar->value, value, sizeof (tmpconfigvar->value));
+    {
+      memcpy (&tmpconfigvar->value, value, sizeof (tmpconfigvar->value));
+
+      /* FIXME - only set this variable if the value has changed */
+      gftp_configuration_changed = 1;
+    }
   else
     {
       fprintf (stderr, _("FATAL gFTP Error: Config option '%s' not found in global hash table\n"), key);
@@ -1201,7 +1205,85 @@
       g_hash_table_insert (*new_options_hash, (*new_options_vars)[i].key,
                            &(*new_options_vars)[i]);
 
-      /* FIXME - copy option values */
+      /* FIXME 2.0.15 - copy option values */
     }
 }
 
+
+void
+gftp_config_free_options (gftp_config_vars * options_vars,
+                          GHashTable * options_hash,
+                          int num_options_vars)
+{
+  int i;
+
+  if (num_options_vars == 0)
+    return;
+
+  if (num_options_vars > 0)
+    {
+      /* If num_options_vars is 0, then the options was allocated with malloc */
+
+      for (i=0; i<num_options_vars; i++)
+        {
+          if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNMEM &&
+              options_vars[i].value != NULL)
+            g_free (options_vars[i].value);
+        }
+
+      g_free (options_vars);
+    }
+  else if (num_options_vars < 0)
+    {
+      /* Otherwise we are freeing the global options */
+
+      for (i=0; options_vars[i].key != NULL; i++)
+        {
+          if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNMEM &&
+              options_vars[i].value != NULL)
+            g_free (options_vars[i].value);
+
+          if (options_vars[i].flags & GFTP_CVARS_FLAGS_DYNLISTMEM &&
+              options_vars[i].listdata != NULL)
+            g_free (options_vars[i].listdata);
+        }
+    }
+
+  if (options_hash != NULL)
+    g_hash_table_destroy (options_hash);
+}
+
+
+void
+gftp_bookmarks_destroy (gftp_bookmarks_var * bookmarks)
+{
+  gftp_bookmarks_var * tempentry, * delentry;
+  
+  if (bookmarks == NULL)
+    return;
+
+  tempentry = bookmarks;
+  while (tempentry != NULL)
+    {
+      gftp_free_bookmark (tempentry);
+      g_free (tempentry->path);
+
+      if (tempentry->children != NULL)
+        {
+          tempentry = tempentry->children;
+          continue;
+        }
+
+      while (tempentry->next == NULL && tempentry->prev != NULL)
+        {
+          delentry = tempentry;
+          tempentry = tempentry->prev;
+          g_free (delentry);
+        }
+
+      delentry = tempentry;
+      tempentry = tempentry->next;
+      g_free (delentry);
+    }
+}
+
--- a/lib/gftp.h	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/gftp.h	Thu Jun 26 01:04:12 2003 +0000
@@ -103,6 +103,10 @@
 #define GFTP_GET_AI_FAMILY(request)	AF_INET
 #endif
 
+#ifndef HAVE_SOCKLEN_T
+typedef int socklen_t;
+#endif 
+
 /* We need the major() and minor() macros in the user interface. If they aren't
    defined by the system, we'll just define them here. */
 #ifndef major
@@ -115,8 +119,30 @@
 #define minor(dev) ((dev) & 0xff)
 #endif
 
-#ifdef HAVE_DMALLOC
+#ifdef WITH_DMALLOC
+
+#undef g_malloc
+#define g_malloc(size) \
+  _malloc_leap(__FILE__, __LINE__, size)
+
+#undef g_malloc0
+#define g_malloc0(size) \
+  _calloc_leap(__FILE__, __LINE__, 1, size)
+
+#undef g_realloc
+#define g_realloc(ptr, size) \
+  _realloc_leap(__FILE__, __LINE__, ptr, size)
+
+#undef g_strdup
+#define g_strdup(str) \
+  _strdup_leap(__FILE__, __LINE__, str)
+
+#undef g_free
+#define g_free(ptr) \
+  _free_leap(__FILE__, __LINE__, ptr)
+
 #include <dmalloc.h>
+
 #endif
 
 /* Server types (used by FTP protocol from SYST command) */
@@ -247,7 +273,8 @@
 } gftp_config_list_vars;
 
 
-#define GFTP_CVARS_FLAGS_DYNMEM		(1 << 1)
+#define GFTP_CVARS_FLAGS_DYNMEM			(1 << 1)
+#define GFTP_CVARS_FLAGS_DYNLISTMEM		(1 << 2)
 
 
 typedef struct gftp_config_vars_tag
@@ -560,6 +587,7 @@
 extern gftp_bookmarks_var * gftp_bookmarks;
 extern char gftp_version[];
 extern FILE * gftp_logfd;
+extern int gftp_configuration_changed;
 
 /* This is defined in config_file.c */
 
@@ -616,6 +644,17 @@
 
 void gftp_register_config_vars 		( gftp_config_vars *config_vars );
 
+void gftp_copy_local_options 		( gftp_config_vars ** new_options_vars, 
+					  GHashTable ** new_options_hash,
+					  gftp_config_vars * orig_options,
+					  int num_local_options_vars );
+
+void gftp_config_free_options 		( gftp_config_vars * options_vars,
+					  GHashTable * options_hash,
+					  int num_options_vars );
+
+void gftp_bookmarks_destroy 		( gftp_bookmarks_var * bookmarks );
+
 /* misc.c */
 char *insert_commas 			( off_t number, 
 					  char *dest_str, 
@@ -632,9 +671,6 @@
 int copyfile				( char *source,
 					  char *dest );
 
-char *get_xpm_path 			( char *filename, 
-					  int quit_on_err );
-
 int gftp_match_filespec 		( char *filename, 
 					  char *filespec );
 
@@ -679,10 +715,7 @@
 
 void gftp_free_bookmark 		( gftp_bookmarks_var * entry );
 
-void gftp_copy_local_options 		( gftp_config_vars ** new_options_vars, 
-					  GHashTable ** new_options_hash,
-					  gftp_config_vars * orig_options,
-					  int num_local_options_vars );
+void gftp_shutdown			( void );
 
 /* protocols.c */
 #define GFTP_FTP_NUM				0
@@ -869,6 +902,7 @@
 
 void print_file_list 			( GList * list );
 
+void gftp_free_getline_buffer 		( gftp_getline_buffer ** rbuf );
 
 ssize_t gftp_get_line 			( gftp_request * request, 
 					  gftp_getline_buffer ** rbuf,
--- 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);
+}
+
--- a/lib/options.h	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/options.h	Thu Jun 26 01:04:12 2003 +0000
@@ -212,3 +212,5 @@
 
 FILE * gftp_logfd = NULL;
 
+int gftp_configuration_changed = 0;
+
--- a/lib/protocols.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/protocols.c	Thu Jun 26 01:04:12 2003 +0000
@@ -66,8 +66,9 @@
 
   if (request->local_options_vars != NULL)
     {
-      g_free (request->local_options_vars);
-      g_hash_table_destroy (request->local_options_hash);
+      gftp_config_free_options (request->local_options_vars,
+                                request->local_options_hash,
+                                request->num_local_options_vars);
     }
 
   memset (request, 0, sizeof (*request));
@@ -407,7 +408,7 @@
           break;
         }
 
-      /* FIXME - fix NUL character in remote_charsets */
+      /* FIXME 2.0.15 - fix NUL character in remote_charsets */
     }
 
   return (ret);
@@ -1943,7 +1944,7 @@
 }
 
 
-static void
+void
 gftp_free_getline_buffer (gftp_getline_buffer ** rbuf)
 {
   g_free ((*rbuf)->buffer);
--- a/lib/rfc2068.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/rfc2068.c	Thu Jun 26 01:04:12 2003 +0000
@@ -109,7 +109,7 @@
 
       if (params->chunk_size < 0)
         {
-          request->logging_function (gftp_logging_recv, request, "FIXME - the chunk size is negative. aborting directory listing\n");
+          request->logging_function (gftp_logging_recv, request, "FIXME 2.0.15 - the chunk size is negative. aborting directory listing\n");
           return (GFTP_EFATAL);
         }
 
@@ -724,7 +724,7 @@
                *endpos != '\n'; 
                endpos++);
     
-          /* FIXME extra checks */
+          /* FIXME 2.0.15 extra checks */
 
           *endpos = '\0';
           if (*(endpos - 1) == '\r')
--- a/lib/rfc959.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/lib/rfc959.c	Thu Jun 26 01:04:12 2003 +0000
@@ -1654,6 +1654,21 @@
 }
 
 
+void
+rfc959_request_destroy (gftp_request * request)
+{
+  rfc959_parms * parms;
+
+  parms = request->protocol_data;
+
+  if (parms->datafd_rbuf != NULL)
+    gftp_free_getline_buffer (&parms->datafd_rbuf);
+
+  if (parms->dataconn_rbuf != NULL)
+    gftp_free_getline_buffer (&parms->dataconn_rbuf);
+}
+
+
 int
 rfc959_init (gftp_request * request)
 {
@@ -1663,7 +1678,7 @@
 
   request->protonum = GFTP_FTP_NUM;
   request->init = rfc959_init;
-  request->destroy = NULL; 
+  request->destroy = rfc959_request_destroy; 
   request->read_function = gftp_fd_read;
   request->write_function = gftp_fd_write;
   request->connect = rfc959_connect;
--- a/m4/Makefile.am	Wed Jun 25 10:57:06 2003 +0000
+++ b/m4/Makefile.am	Thu Jun 26 01:04:12 2003 +0000
@@ -1,1 +1,1 @@
-EXTRA_DIST = codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
+EXTRA_DIST = inttypes-pri.m4  codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
--- a/src/gtk/bookmarks.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/src/gtk/bookmarks.c	Thu Jun 26 01:04:12 2003 +0000
@@ -350,37 +350,15 @@
 static void
 bm_close_dialog (GtkWidget * widget, GtkWidget * dialog)
 {
-  gftp_bookmarks_var * tempentry, * delentry;
-
-  if (new_bookmarks_htable)
-    g_hash_table_destroy (new_bookmarks_htable);
-
-  tempentry = new_bookmarks;
-  while (tempentry != NULL)
+  if (new_bookmarks_htable != NULL)
     {
-      gftp_free_bookmark (tempentry);
-      g_free (tempentry->path);
-
-      if (tempentry->children != NULL)
-	{
-	  tempentry = tempentry->children;
-	  continue;
-	}
-
-      while (tempentry->next == NULL && tempentry->prev != NULL)
-        {
-          delentry = tempentry;
-	  tempentry = tempentry->prev;
-          g_free (delentry);
-        }
-
-      delentry = tempentry;
-      tempentry = tempentry->next;
-      g_free (delentry);
+      g_hash_table_destroy (new_bookmarks_htable);
+      new_bookmarks_htable = NULL;
     }
 
+  gftp_bookmarks_destroy (new_bookmarks);
   new_bookmarks = NULL;
-  new_bookmarks_htable = NULL;
+
   gtk_widget_destroy (dialog);
 }
 
--- a/src/gtk/gftp-gtk.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/src/gtk/gftp-gtk.c	Thu Jun 26 01:04:12 2003 +0000
@@ -101,8 +101,7 @@
   ret = get_column (&GTK_CLIST (window2.listbox)->column[6]);
   gftp_set_global_option ("remote_attribs_width", &ret);
 
-  gftp_write_config_file ();
-  gftp_clear_cache_files ();
+  gftp_shutdown ();
   exit (0);
 }
 
--- a/src/gtk/gftp-gtk.h	Wed Jun 25 10:57:06 2003 +0000
+++ b/src/gtk/gftp-gtk.h	Thu Jun 26 01:04:12 2003 +0000
@@ -359,6 +359,9 @@
 
 RETSIGTYPE signal_handler			(int signo);
 
+char * get_xpm_path 				( char *filename, 
+						  int quit_on_err );
+
 /* mkdir_dialog.c */
 void mkdir_dialog 				( gpointer data );
 
--- a/src/gtk/misc-gtk.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/src/gtk/misc-gtk.c	Thu Jun 26 01:04:12 2003 +0000
@@ -525,7 +525,6 @@
 }
 
 
-/* FIXME - check this */
 static gchar *
 gftp_item_factory_translate (const char *path, gpointer func_data)
 {
@@ -552,7 +551,7 @@
 		  GtkAccelGroup *accel_group, const char *strip_prefix)
 {
   GtkItemFactory *result = gtk_item_factory_new (container_type, path, accel_group);
-  gchar *strip_prefix_dup = g_strdup (g_strdup (strip_prefix));
+  gchar *strip_prefix_dup = g_strdup (strip_prefix);
   
   gtk_item_factory_set_translate_func (result, gftp_item_factory_translate,
 				       strip_prefix_dup, NULL);
@@ -1288,3 +1287,37 @@
     exit (1);
 }
 
+
+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);
+}
+
--- a/src/text/gftp-text.c	Wed Jun 25 10:57:06 2003 +0000
+++ b/src/text/gftp-text.c	Thu Jun 26 01:04:12 2003 +0000
@@ -23,8 +23,7 @@
 static gftp_request * gftp_text_locreq = NULL;
 static gftp_request * gftp_text_remreq = NULL;
 static volatile int cancel = 0;
-static int configuration_changed = 0,
-           number_commands = 30;
+static int number_commands = 30;
 
 struct _gftp_text_methods gftp_text_methods[] = {
         {N_("about"), 	2, gftp_text_about,	NULL,
@@ -107,7 +106,6 @@
 #ifdef HAVE_GETTEXT
   setlocale (LC_ALL, "");
   bindtextdomain ("gftp", LOCALE_DIR);
-  textdomain ("gftp");
 #endif
 
   signal (SIGCHLD, sig_child);
@@ -239,8 +237,6 @@
 #endif
     }
  
-  if (gftp_logfd != NULL)
-    fclose (gftp_logfd);
   gftp_text_quit (NULL, NULL, NULL);
 
   return (0);
@@ -401,9 +397,10 @@
 int
 gftp_text_quit (gftp_request * request, char *command, gpointer *data)
 {
-  gftp_clear_cache_files ();
-  if (configuration_changed)
-    gftp_write_config_file ();
+  gftp_request_destroy (gftp_text_locreq, 1);
+  gftp_request_destroy (gftp_text_remreq, 1);
+  gftp_shutdown();
+
   return (0);
 }
 
@@ -1097,10 +1094,7 @@
         }
 
       if (gftp_option_types[cv->otype].read_function != NULL)
-        {
-          configuration_changed = 1;
-          gftp_option_types[cv->otype].read_function (pos, cv, 1);
-        }
+        gftp_option_types[cv->otype].read_function (pos, cv, 1);
     }
 
   return (1);
@@ -1124,7 +1118,7 @@
   struct termios term, oldterm;
   sigset_t sig, sigsave;
   char *pos, *termname;
-  FILE *infd, *outfd;
+  FILE *infd;
 
   if (!echo)
     {
@@ -1141,7 +1135,6 @@
                          _("Cannot open controlling terminal %s\n"), termname);
           return (NULL);
         }
-      outfd = infd;
 
       tcgetattr (0, &term);
       oldterm = term;
@@ -1149,12 +1142,9 @@
       tcsetattr (fileno (infd), TCSAFLUSH, &term);
     }
   else
-    {
-      infd = stdin;
-      outfd = stdout;
-    }
+    infd = stdin;
 
-  fprintf (outfd, "%s%s%s: ", COLOR_BLUE, question, COLOR_DEFAULT);
+  printf ("%s%s%s: ", COLOR_BLUE, question, COLOR_DEFAULT);
 
   if (fgets (buf, size, infd) == NULL)
     return (NULL);
@@ -1162,9 +1152,9 @@
 
   if (!echo)
     {
-      fprintf (outfd, "\n");
+      printf ("\n");
       tcsetattr (fileno (infd), TCSAFLUSH, &oldterm);
-      fclose (outfd);
+      fclose (infd);
       sigprocmask (SIG_SETMASK, &sigsave, NULL);
     }