changeset 821:b282e346bd25

2006-10-1 Brian Masney <masneyb@gftp.org> * lib/gftp.h lib/misc.c lib/protocols.c src/gtk/misc-gtk.c src/uicommon/gftpuicallbacks.c (gftp_match_filespec) - look at the show_hidden_files option inside this function. Use the option's value to determine if the file should be shown to the user.
author masneyb
date Sun, 01 Oct 2006 18:41:43 +0000
parents 435b11d2d628
children 879029312f52
files ChangeLog lib/gftp.h lib/misc.c lib/protocols.c src/gtk/misc-gtk.c src/uicommon/gftpuicallbacks.c
diffstat 6 files changed, 29 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Oct 01 18:25:16 2006 +0000
+++ b/ChangeLog	Sun Oct 01 18:41:43 2006 +0000
@@ -1,4 +1,9 @@
 2006-10-1 Brian Masney <masneyb@gftp.org>
+	* lib/gftp.h lib/misc.c lib/protocols.c src/gtk/misc-gtk.c 
+	src/uicommon/gftpuicallbacks.c (gftp_match_filespec) - look at the
+	show_hidden_files option inside this function. Use the option's value
+	to determine if the file should be shown to the user.
+
 	* lib/ftpcommon.h lib/ftps.c lib/rfc959.c - automatically reconnect to
 	the server if a timeout occurs.
 
@@ -3604,7 +3609,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.478 2006/10/01 18:25:00 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.479 2006/10/01 18:41:40 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Sun Oct 01 18:25:16 2006 +0000
+++ b/lib/gftp.h	Sun Oct 01 18:41:43 2006 +0000
@@ -740,7 +740,8 @@
 
 void make_nonnull 			( char **str );
 
-int gftp_match_filespec 		( const char *filename, 
+int gftp_match_filespec 		( gftp_request * request,
+					  const char *filename, 
 					  const char *filespec );
 
 int gftp_parse_command_line 		( int *argc,
--- a/lib/misc.c	Sun Oct 01 18:25:16 2006 +0000
+++ b/lib/misc.c	Sun Oct 01 18:41:43 2006 +0000
@@ -246,34 +246,41 @@
 }
 
 
-/* FIXME - is there a replacement for this */
+/* FIXME - Possible use the libpcre library. If it isn't used, then clean
+   this function up some more. */
 int
-gftp_match_filespec (const char *filename, const char *filespec)
+gftp_match_filespec (gftp_request * request, const char *filename,
+                     const char *filespec)
 {
   const char *filepos, *wcpos, *pos;
   char search_str[20], *newpos;
+  intptr_t show_hidden_files;
   size_t len, curlen;
   
   if (filename == NULL || *filename == '\0' || 
       filespec == NULL || *filespec == '\0') 
-    return(1);
+    return (1);
+
+  gftp_lookup_request_option (request, "show_hidden_files", &show_hidden_files);
+  if (!show_hidden_files && *filename == '.' && strcmp (filename, "..") != 0)
+    return (0);
 
   filepos = filename;
   wcpos = filespec;
-  while(1) 
+  while (1)
     {
       if (*wcpos == '\0') 
         return (1);
       else if (*filepos == '\0') 
-        return(0);
-      else if(*wcpos == '?') 
+        return (0);
+      else if (*wcpos == '?') 
         {
           wcpos++;
           filepos++;
         }
-      else if(*wcpos == '*' && *(wcpos+1) == '\0') 
-        return(1);
-      else if(*wcpos == '*') 
+      else if (*wcpos == '*' && *(wcpos+1) == '\0') 
+        return (1);
+      else if (*wcpos == '*') 
         {
           len = sizeof (search_str);
           for (pos = wcpos + 1, newpos = search_str, curlen = 0;
@@ -282,12 +289,12 @@
           *newpos = '\0';
 
           if ((filepos = strstr (filepos, search_str)) == NULL)
-            return(0);
+            return (0);
           wcpos += curlen + 1;
           filepos += curlen;
         }
       else if(*wcpos++ != *filepos++) 
-        return(0);
+        return (0);
     }
 }
 
--- a/lib/protocols.c	Sun Oct 01 18:25:16 2006 +0000
+++ b/lib/protocols.c	Sun Oct 01 18:41:43 2006 +0000
@@ -649,7 +649,7 @@
               request->cachefd = -1;
             }
         }
-    } while (ret > 0 && !gftp_match_filespec (fle->file, filespec));
+    } while (ret > 0 && !gftp_match_filespec (request, fle->file, filespec));
 
   return (ret);
 }
--- a/src/gtk/misc-gtk.c	Sun Oct 01 18:25:16 2006 +0000
+++ b/src/gtk/misc-gtk.c	Sun Oct 01 18:41:43 2006 +0000
@@ -690,25 +690,19 @@
   char *tempstr, *str, *pos, *attribs;
   gftp_config_list_vars * tmplistvar;
   gftp_file_extensions * tempext;
-  intptr_t show_hidden_files;
   GdkBitmap * bitmap;
   GList * templist;
   GdkPixmap * pix;
   int clist_num;
   size_t stlen;
 
-  gftp_lookup_request_option (wdata->request, "show_hidden_files", 
-                              &show_hidden_files);
-
   if (wdata->show_selected)
     {
       fle->shown = fle->was_sel;
       if (!fle->shown)
         return;
     }
-  else if ((!show_hidden_files && *fle->file == '.' && 
-            strcmp (fle->file, "..") != 0) ||
-           !gftp_match_filespec (fle->file, wdata->filespec))
+  else if (!gftp_match_filespec (wdata->request, fle->file, wdata->filespec))
     {
       fle->shown = 0;
       fle->was_sel = 0;
--- a/src/uicommon/gftpuicallbacks.c	Sun Oct 01 18:25:16 2006 +0000
+++ b/src/uicommon/gftpuicallbacks.c	Sun Oct 01 18:41:43 2006 +0000
@@ -80,7 +80,7 @@
       if (cdata->source_string == NULL)
         matched_filespec = 1;
       else
-        matched_filespec = gftp_match_filespec (fle->file,
+        matched_filespec = gftp_match_filespec (cdata->request, fle->file,
                                                 cdata->source_string);
 
       if (got < 0 || strcmp (fle->file, ".") == 0 || !matched_filespec)