A slightly better reset mechanism for send_file_entry() and
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index a746f32..0601901 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -351,17 +351,15 @@ static void flist_expand(struct file_list *flist)
        }
 }
 
-
-static void send_file_entry(struct file_struct *file, int f,
-                           unsigned short base_flags)
+void send_file_entry(struct file_struct *file, int f, unsigned short base_flags)
 {
        unsigned short flags;
        static time_t modtime;
        static mode_t mode;
        static DEV64_T rdev;    /* just high bytes in p28 onward */
+       static DEV64_T dev;
        static uid_t uid;
        static gid_t gid;
-       static DEV64_T dev;
        static char lastname[MAXPATHLEN];
        char *fname, fbuf[MAXPATHLEN];
        int l1, l2;
@@ -371,6 +369,10 @@ static void send_file_entry(struct file_struct *file, int f,
 
        if (!file) {
                write_byte(f, 0);
+               modtime = 0, mode = 0;
+               rdev = 0, dev = 0;
+               uid = 0, gid = 0;
+               *lastname = '\0';
                return;
        }
 
@@ -515,21 +517,28 @@ static void send_file_entry(struct file_struct *file, int f,
 
 
 
-static void receive_file_entry(struct file_struct **fptr,
-                              unsigned short flags, int f)
+void receive_file_entry(struct file_struct **fptr, unsigned short flags, int f)
 {
        static time_t modtime;
        static mode_t mode;
        static DEV64_T rdev;    /* just high bytes in p28 onward */
+       static DEV64_T dev;
        static uid_t uid;
        static gid_t gid;
-       static DEV64_T dev;
        static char lastname[MAXPATHLEN];
        char thisname[MAXPATHLEN];
        unsigned int l1 = 0, l2 = 0;
        char *p;
        struct file_struct *file;
 
+       if (!fptr) {
+               modtime = 0, mode = 0;
+               rdev = 0, dev = 0;
+               uid = 0, gid = 0;
+               *lastname = '\0';
+               return;
+       }
+
        if (flags & SAME_NAME)
                l1 = read_byte(f);
 
@@ -1184,7 +1193,7 @@ struct file_list *recv_file_list(int f)
                                f_name(flist->files[i]));
                }
        }
-
+       receive_file_entry(NULL, 0, 0); /* Signal that we're done. */
 
        if (verbose > 2)
                rprintf(FINFO, "received %d names\n", flist->count);