+ flist_free(dirlist);
+}
+
+/* This deletes any files on the receiving side that are not present on the
+ * sending side. This is used by --delete-before and --delete-after. */
+static void do_delete_pass(struct file_list *flist)
+{
+ char fbuf[MAXPATHLEN];
+ int j;
+
+ if (dry_run > 1) /* destination doesn't exist yet */
+ return;
+
+ for (j = 0; j < flist->count; j++) {
+ struct file_struct *file = flist->files[j];
+
+ if (!(file->flags & FLAG_DEL_HERE))
+ continue;
+
+ f_name_to(file, fbuf);
+ if (verbose > 1 && file->flags & FLAG_TOP_DIR)
+ rprintf(FINFO, "deleting in %s\n", safe_fname(fbuf));
+
+ delete_in_dir(flist, fbuf, file);
+ }
+}
+
+static int unchanged_attrs(struct file_struct *file, STRUCT_STAT *st)
+{
+ if (preserve_perms
+ && (st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS))
+ return 0;
+
+ if (am_root && preserve_uid && st->st_uid != file->uid)
+ return 0;
+
+ if (preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid)
+ return 0;
+
+ return 1;
+}
+
+
+void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st,
+ int32 iflags, uchar fnamecmp_type, char *xname)
+{
+ if (statret == 0) {
+ if (S_ISREG(file->mode) && file->length != st->st_size)
+ iflags |= ITEM_REPORT_SIZE;
+ if (!(iflags & ITEM_NO_DEST_AND_NO_UPDATE)) {
+ int keep_time = !preserve_times ? 0
+ : S_ISDIR(file->mode) ? !omit_dir_times
+ : !S_ISLNK(file->mode);
+
+ if ((iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !keep_time)
+ || (keep_time && file->modtime != st->st_mtime))
+ iflags |= ITEM_REPORT_TIME;
+ if (preserve_perms && file->mode != st->st_mode)
+ iflags |= ITEM_REPORT_PERMS;
+ if (preserve_uid && am_root && file->uid != st->st_uid)
+ iflags |= ITEM_REPORT_OWNER;
+ if (preserve_gid && file->gid != GID_NONE
+ && st->st_gid != file->gid)
+ iflags |= ITEM_REPORT_GROUP;
+ }
+ } else
+ iflags |= ITEM_IS_NEW;
+
+ iflags &= 0xffff;
+ if ((iflags & SIGNIFICANT_ITEM_FLAGS || verbose > 1
+ || (xname && *xname)) && !read_batch) {
+ if (protocol_version >= 29) {
+ if (ndx >= 0)
+ write_int(sock_f_out, ndx);
+ write_shortint(sock_f_out, iflags);
+ if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
+ write_byte(sock_f_out, fnamecmp_type);
+ if (iflags & ITEM_XNAME_FOLLOWS)
+ write_vstring(sock_f_out, xname, strlen(xname));
+ } else if (ndx >= 0)
+ log_item(file, &stats, iflags, xname);
+ }