+ rprintf(FINFO, "%s ... ", kind);
+ if (verbose > 1 || do_progress)
+ rprintf(FINFO, "\n");
+ rflush(FINFO);
+}
+
+
+static void emit_filelist_progress(int count)
+{
+ rprintf(FINFO, " %d files...\r", count);
+}
+
+
+static void maybe_emit_filelist_progress(int count)
+{
+ if (do_progress && show_filelist_p() && (count % 100) == 0)
+ emit_filelist_progress(count);
+}
+
+
+static void finish_filelist_progress(const struct file_list *flist)
+{
+ if (do_progress) {
+ /* This overwrites the progress line */
+ rprintf(FINFO, "%d file%sto consider\n",
+ flist->count, flist->count == 1 ? " " : "s ");
+ } else
+ rprintf(FINFO, "done\n");
+}
+
+void show_flist_stats(void)
+{
+ /* Nothing yet */
+}
+
+
+static void list_file_entry(struct file_struct *f)
+{
+ char perms[11];
+
+ if (!f->basename) {
+ /* this can happen if duplicate names were removed */
+ return;
+ }
+
+ permstring(perms, f->mode);
+
+#ifdef SUPPORT_LINKS
+ if (preserve_links && S_ISLNK(f->mode)) {
+ rprintf(FINFO, "%s %11.0f %s %s -> %s\n",
+ perms,
+ (double)f->length, timestring(f->modtime),
+ safe_fname(f_name(f)), safe_fname(f->u.link));
+ } else
+#endif
+ {
+ rprintf(FINFO, "%s %11.0f %s %s\n",
+ perms,
+ (double)f->length, timestring(f->modtime),
+ safe_fname(f_name(f)));
+ }
+}
+
+
+/**
+ * Stat either a symlink or its referent, depending on the settings of
+ * copy_links, copy_unsafe_links, etc.
+ *
+ * @retval -1 on error
+ *
+ * @retval 0 for success
+ *
+ * @post If @p path is a symlink, then @p linkbuf (of size @c
+ * MAXPATHLEN) contains the symlink target.
+ *
+ * @post @p buffer contains information about the link or the
+ * referrent as appropriate, if they exist.
+ **/
+static int readlink_stat(const char *path, STRUCT_STAT *buffer, char *linkbuf)
+{
+#ifdef SUPPORT_LINKS
+ if (copy_links)
+ return do_stat(path, buffer);
+ if (link_stat(path, buffer, 0) < 0)
+ return -1;
+ if (S_ISLNK(buffer->st_mode)) {
+ int l = readlink((char *)path, linkbuf, MAXPATHLEN - 1);
+ if (l == -1)
+ return -1;
+ linkbuf[l] = 0;
+ if (copy_unsafe_links && unsafe_symlink(linkbuf, path)) {
+ if (verbose > 1) {
+ rprintf(FINFO,"copying unsafe symlink \"%s\" -> \"%s\"\n",
+ safe_fname(path), safe_fname(linkbuf));
+ }
+ return do_stat(path, buffer);
+ }
+ }
+ return 0;