changeset 179:8d933999bba6

2003-6-14 Brian Masney <masneyb@gftp.org> * lib/cache.c (gftp_delete_cache_entry) - fix for restoring newlines * lib/gftp.h lib/protocols.c - added EOF flag for gftp_get_line() * lib/gftp.h lib/pty.c - added get_pty_impl() function for each PTY type * src/text/gftp-text.c - after removing files, clear the cache for that directory
author masneyb
date Sat, 14 Jun 2003 14:14:01 +0000
parents 8beb7bfca92b
children 27dfb8a5ad2a
files ChangeLog lib/cache.c lib/gftp.h lib/protocols.c lib/pty.c src/text/gftp-text.c
diffstat 6 files changed, 65 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 11 22:02:26 2003 +0000
+++ b/ChangeLog	Sat Jun 14 14:14:01 2003 +0000
@@ -1,3 +1,14 @@
+2003-6-14 Brian Masney <masneyb@gftp.org>
+	* lib/cache.c (gftp_delete_cache_entry) - fix for restoring newlines
+
+	* lib/gftp.h lib/protocols.c - added EOF flag for gftp_get_line()
+
+	* lib/gftp.h lib/pty.c - added get_pty_impl() function for each PTY
+	type
+
+	* src/text/gftp-text.c - after removing files, clear the cache for
+	that directory
+
 2003-6-11 Brian Masney <masneyb@gftp.org>
 	* lib/configure.in lib/gftp.h - portability fix for openpty(). (from 
 	Nathan Robertson <nathanr@nathanr.net>, which he took from 
@@ -957,7 +968,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.87 2003/06/11 22:02:25 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.88 2003/06/14 14:13:59 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/cache.c	Wed Jun 11 22:02:26 2003 +0000
+++ b/lib/cache.c	Sat Jun 14 14:14:01 2003 +0000
@@ -324,15 +324,15 @@
         unlink (centry.file);
       else
         {
-          /* Make sure when we call gftp_get_line() that we pass the read size
-             as sizeof(buf) - 1 so that we'll have room to put the newline */
-          buf[strlen (buf)] = '\n';
-
           /* Make sure we put the tabs back in the line. I do it this way 
              so that I don't have to allocate memory again for each line 
              as we read it */
           gftp_restore_cache_line (&centry, buf);
 
+          /* Make sure when we call gftp_get_line() that we pass the read size
+             as sizeof(buf) - 1 so that we'll have room to put the newline */
+          buf[strlen (buf)] = '\n';
+
           if (gftp_fd_write (NULL, buf, strlen (buf), newfd) < 0)
             break;
         }
--- a/lib/gftp.h	Wed Jun 11 22:02:26 2003 +0000
+++ b/lib/gftp.h	Sat Jun 14 14:14:01 2003 +0000
@@ -538,6 +538,7 @@
        *curpos;
   size_t max_bufsize,
          cur_bufsize;
+  unsigned int eof : 1;
 } gftp_getline_buffer;
 
 
@@ -875,6 +876,8 @@
 					  ssize_t num_read );
 
 /* pty.c */
+char * get_pty_impl 			( void );
+
 int open_ptys 				( gftp_request * request, 
 					  int *fdm, 
 					  int *fds );
--- a/lib/protocols.c	Wed Jun 11 22:02:26 2003 +0000
+++ b/lib/protocols.c	Sat Jun 14 14:14:01 2003 +0000
@@ -1875,6 +1875,7 @@
   char *pos, *nextpos;
   ssize_t (*read_function) (gftp_request * request, void *ptr, size_t size,
                             int fd);
+  int end_of_buffer;
 
   if (request == NULL || request->read_function == NULL)
     read_function = gftp_fd_read;
@@ -1893,7 +1894,6 @@
           gftp_free_getline_buffer (rbuf);
           return (ret);
         }
-
       (*rbuf)->buffer[ret] = '\0';
       (*rbuf)->cur_bufsize = ret;
       (*rbuf)->curpos = (*rbuf)->buffer;
@@ -1902,10 +1902,11 @@
   retval = GFTP_ERETRYABLE;
   do
     {
-      if ((*rbuf)->cur_bufsize > 0 &&
-          ((pos = strchr ((*rbuf)->curpos, '\n')) != NULL ||
-           ((*rbuf)->curpos == (*rbuf)->buffer && 
-            (*rbuf)->max_bufsize == (*rbuf)->cur_bufsize)))
+      pos = strchr ((*rbuf)->curpos, '\n');
+      end_of_buffer = (*rbuf)->curpos == (*rbuf)->buffer && 
+            ((*rbuf)->max_bufsize == (*rbuf)->cur_bufsize || (*rbuf)->eof);
+
+      if ((*rbuf)->cur_bufsize > 0 && (pos != NULL || end_of_buffer))
         {
           if (pos != NULL)
             retval = pos - (*rbuf)->curpos + 1;
@@ -1952,10 +1953,15 @@
               gftp_free_getline_buffer (rbuf);
               return (ret);
             }
-          else if (ret == 0 && (*rbuf)->cur_bufsize == 0)
+          else if (ret == 0)
             {
-              gftp_free_getline_buffer (rbuf);
-              return (ret);
+              if ((*rbuf)->cur_bufsize == 0)
+                {
+                  gftp_free_getline_buffer (rbuf);
+                  return (ret);
+                }
+
+              (*rbuf)->eof = 1;
             }
 
           (*rbuf)->buffer[ret + (*rbuf)->cur_bufsize] = '\0';
--- a/lib/pty.c	Wed Jun 11 22:02:26 2003 +0000
+++ b/lib/pty.c	Sat Jun 14 14:14:01 2003 +0000
@@ -21,8 +21,14 @@
 
 #include "gftp.h"
 
+#ifdef __sgi
 
-#ifdef __sgi
+char *
+get_pty_impl (void)
+{
+  return ("sgi");
+}
+
 
 int
 open_ptys (gftp_request * request, int *fdm, int *fds)
@@ -43,6 +49,13 @@
 
 #elif HAVE_GRANTPT
 
+char *
+get_pty_impl (void)
+{
+  return ("unix98");
+}
+
+
 int
 open_ptys (gftp_request * request, int *fdm, int *fds)
 {
@@ -75,16 +88,25 @@
       return (GFTP_ERETRYABLE);
     }
 
+#ifdef SYSV
   /* I intentionally ignore these errors */
   ioctl (*fds, I_PUSH, "ptem");
   ioctl (*fds, I_PUSH, "ldterm");
   ioctl (*fds, I_PUSH, "ttcompat");
+#endif
 
   return (0);
 }
 
 #elif HAVE_OPENPTY
 
+char *
+get_pty_impl (void)
+{
+  return ("openpty");
+}
+
+
 int
 open_ptys (gftp_request * request, int *fdm, int *fds)
 {
@@ -102,6 +124,13 @@
 
 /* Fall back to *BSD... */
 
+char *
+get_pty_impl (void)
+{
+  return ("bsd");
+}
+
+
 int
 open_ptys (gftp_request * request, int *fdm, int *fds)
 {
--- a/src/text/gftp-text.c	Wed Jun 11 22:02:26 2003 +0000
+++ b/src/text/gftp-text.c	Sat Jun 14 14:14:01 2003 +0000
@@ -501,7 +501,8 @@
     }
   else
     {
-      gftp_remove_file (request, command);
+      if (gftp_remove_file (request, command) == 0)
+        gftp_delete_cache_entry (request, 0);
     }
   return (1);
 }