Switch over to Matt's idea of using FLAG_OWNED_BY_US.
[rsync.git] / log.c
diff --git a/log.c b/log.c
index c7007dbbdd6ba333a226bf6a4e1d368a4ee29b2e..46161fe1e6d2afc03deaffa2ee579197c24ea4e9 100644 (file)
--- a/log.c
+++ b/log.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
  * Copyright (C) 2000-2001 Martin Pool <mbp@samba.org>
- * Copyright (C) 2003-2007 Wayne Davison
+ * Copyright (C) 2003-2009 Wayne Davison
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,12 +35,12 @@ extern int msg_fd_out;
 extern int allow_8bit_chars;
 extern int protocol_version;
 extern int preserve_times;
-extern int uid_ndx;
-extern int gid_ndx;
+extern int progress_is_active;
 extern int stdout_format_has_i;
 extern int stdout_format_has_o_or_i;
 extern int logfile_format_has_i;
 extern int logfile_format_has_o_or_i;
+extern int receiver_symlink_times;
 extern mode_t orig_umask;
 extern char *auth_user;
 extern char *stdout_format;
@@ -50,10 +50,10 @@ extern char *logfile_name;
 extern iconv_t ic_chck;
 #endif
 #ifdef ICONV_OPTION
-extern iconv_t ic_send, ic_recv;
+extern iconv_t ic_recv;
 #endif
-extern char curr_dir[];
-extern char *module_dir;
+extern char curr_dir[MAXPATHLEN];
+extern char *full_module_path;
 extern unsigned int module_dirlen;
 
 static int log_initialised;
@@ -83,7 +83,7 @@ struct {
        { RERR_SIGNAL     , "received SIGINT, SIGTERM, or SIGHUP" },
        { RERR_WAITCHILD  , "waitpid() failed" },
        { RERR_MALLOC     , "error allocating core memory buffers" },
-       { RERR_PARTIAL    , "some files could not be transferred" },
+       { RERR_PARTIAL    , "some files/attrs were not transferred (see previous errors)" },
        { RERR_VANISHED   , "some files vanished before they could be transferred" },
        { RERR_TIMEOUT    , "timeout in data send/receive" },
        { RERR_CONTIMEOUT , "timeout waiting for daemon connection" },
@@ -255,13 +255,17 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
 
        if (am_server && msg_fd_out >= 0) {
                assert(!is_utf8);
-               /* Pass the message to our sibling. */
+               /* Pass the message to our sibling in native charset. */
                send_msg((enum msgcode)code, buf, len, 0);
                return;
        }
 
        if (code == FERROR_SOCKET) /* This gets simplified for a non-sibling. */
                code = FERROR;
+       else if (code == FERROR_UTF8) {
+               is_utf8 = 1;
+               code = FERROR;
+       }
 
        if (code == FCLIENT)
                code = FINFO;
@@ -319,6 +323,11 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
                exit_cleanup(RERR_MESSAGEIO);
        }
 
+       if (progress_is_active && !am_server) {
+               fputc('\n', f);
+               progress_is_active = 0;
+       }
+
        trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r')
                          ? buf[--len] : 0;
 
@@ -516,7 +525,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                        break;
                case 'M':
                        n = c = timestring(file->modtime);
-                       while ((c = strchr(p, ' ')) != NULL)
+                       while ((c = strchr(c, ' ')) != NULL)
                                *c = '-';
                        break;
                case 'B':
@@ -592,7 +601,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                        n = timestring(time(NULL));
                        break;
                case 'P':
-                       n = module_dir;
+                       n = full_module_path;
                        break;
                case 'u':
                        n = auth_user;
@@ -631,14 +640,21 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                              ? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c'
                             : !(iflags & ITEM_TRANSFER) ? '.'
                             : !local_server && *op == 's' ? '<' : '>';
-                       c[1] = S_ISDIR(file->mode) ? 'd'
-                            : IS_SPECIAL(file->mode) ? 'S'
-                            : IS_DEVICE(file->mode) ? 'D'
-                            : S_ISLNK(file->mode) ? 'L' : 'f';
-                       c[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '.' : 'c';
-                       c[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
-                       c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
-                            : !preserve_times || S_ISLNK(file->mode) ? 'T' : 't';
+                       if (S_ISLNK(file->mode)) {
+                               c[1] = 'L';
+                               c[3] = '.';
+                               c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
+                                    : !preserve_times || !receiver_symlink_times
+                                   || (iflags & ITEM_REPORT_TIMEFAIL) ? 'T' : 't';
+                       } else {
+                               c[1] = S_ISDIR(file->mode) ? 'd'
+                                    : IS_SPECIAL(file->mode) ? 'S'
+                                    : IS_DEVICE(file->mode) ? 'D' : 'f';
+                               c[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
+                               c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
+                                    : !preserve_times ? 'T' : 't';
+                       }
+                       c[2] = !(iflags & ITEM_REPORT_CHANGE) ? '.' : 'c';
                        c[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
                        c[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
                        c[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';