+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
+ && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname))
+ || (keep_time && cmp_modtime(file->modtime, st->st_mtime) != 0))
+ iflags |= ITEM_REPORT_TIME;
+ if (preserve_perms
+ && (file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS))
+ 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);
+ }
+}
+
+
+/* Perform our quick-check heuristic for determining if a file is unchanged. */
+static int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
+{
+ if (st->st_size != file->length)
+ return 0;
+
+ /* if always checksum is set then we use the checksum instead
+ of the file time to determine whether to sync */
+ if (always_checksum && S_ISREG(st->st_mode)) {
+ char sum[MD4_SUM_LENGTH];
+ file_checksum(fn, sum, st->st_size);
+ return memcmp(sum, file->u.sum, protocol_version < 21 ? 2
+ : MD4_SUM_LENGTH) == 0;
+ }
+
+ if (size_only)
+ return 1;
+
+ if (ignore_times)
+ return 0;