+ f_name(file, fname + offset);
+ if (remove_source_files && do_unlink(fname) == 0 && verbose > 1)
+ rprintf(FINFO, "sender removed %s\n", fname + offset);
+}
+
+static void write_ndx_and_attrs(int f_out, int ndx, int iflags,
+ uchar fnamecmp_type, char *buf, int len)
+{
+ write_int(f_out, ndx);
+ if (protocol_version < 29)
+ return;
+ write_shortint(f_out, iflags);
+ if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
+ write_byte(f_out, fnamecmp_type);
+ if (iflags & ITEM_XNAME_FOLLOWS)
+ write_vstring(f_out, buf, len);
+}
+
+/* This is also used by receive.c with f_out = -1. */
+int read_item_attrs(int f_in, int f_out, int ndx, uchar *type_ptr,
+ char *buf, int *len_ptr)
+{
+ int len;
+ uchar fnamecmp_type = FNAMECMP_FNAME;
+ int iflags = protocol_version >= 29 ? read_shortint(f_in)
+ : ITEM_TRANSFER | ITEM_MISSING_DATA;
+
+ /* Handle the new keep-alive (no-op) packet. */
+ if (ndx == the_file_list->count && iflags == ITEM_IS_NEW)
+ ;
+ else if (ndx < 0 || ndx >= the_file_list->count) {
+ rprintf(FERROR, "Invalid file index: %d (count=%d) [%s]\n",
+ ndx, the_file_list->count, who_am_i());
+ exit_cleanup(RERR_PROTOCOL);
+ } else if (iflags == ITEM_IS_NEW) {
+ rprintf(FERROR, "Invalid itemized flag word: %x [%s]\n",
+ iflags, who_am_i());
+ exit_cleanup(RERR_PROTOCOL);