Saved 9 more bytes per file in a typical transfer by making the length
[rsync/rsync.git] / log.c
diff --git a/log.c b/log.c
index c69482d..79c3f29 100644 (file)
--- a/log.c
+++ b/log.c
@@ -37,6 +37,10 @@ extern int msg_fd_out;
 extern int allow_8bit_chars;
 extern int protocol_version;
 extern int preserve_times;
+extern int preserve_uid;
+extern int preserve_gid;
+extern int flist_extra_ndx;
+extern int file_struct_len;
 extern int stdout_format_has_i;
 extern int stdout_format_has_o_or_i;
 extern int logfile_format_has_i;
@@ -300,15 +304,18 @@ void rwrite(enum logcode code, const char *buf, int len)
                          ? buf[--len] : 0;
 
 #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
+#ifndef ICONV_CONST
+#define ICONV_CONST
+#endif
        if (ic_chck != (iconv_t)-1) {
                char convbuf[1024];
-               const char *in_buf = buf;
+               ICONV_CONST char *in_buf = (ICONV_CONST char *)buf;
                char *out_buf = convbuf;
                size_t in_cnt = len, out_cnt = sizeof convbuf - 1;
 
                iconv(ic_chck, NULL, 0, NULL, 0);
                while (iconv(ic_chck, &in_buf,&in_cnt,
-                                &out_buf,&out_cnt) == (size_t)-1) {
+                            &out_buf,&out_cnt) == (size_t)-1) {
                        if (out_buf != convbuf) {
                                filtered_fwrite(f, convbuf, out_buf - convbuf, 0);
                                out_buf = convbuf;
@@ -472,16 +479,16 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                case 'U':
                        strlcat(fmt, "ld", sizeof fmt);
                        snprintf(buf2, sizeof buf2, fmt,
-                                (long)file->uid);
+                                preserve_uid ? (long)F_UID(file) : 0);
                        n = buf2;
                        break;
                case 'G':
-                       if (file->gid == GID_NONE)
+                       if (!preserve_gid || F_GID(file) == GID_NONE)
                                n = "DEFAULT";
                        else {
                                strlcat(fmt, "ld", sizeof fmt);
                                snprintf(buf2, sizeof buf2, fmt,
-                                        (long)file->gid);
+                                        (long)F_GID(file));
                                n = buf2;
                        }
                        break;
@@ -541,8 +548,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                        if (hlink && *hlink) {
                                n = hlink;
                                strlcpy(buf2, " => ", sizeof buf2);
-                       } else if (S_ISLNK(file->mode) && file->u.link) {
-                               n = file->u.link;
+                       } else if (S_ISLNK(file->mode)) {
+                               n = F_SYMLINK(file);
                                strlcpy(buf2, " -> ", sizeof buf2);
                        } else {
                                n = "";