- Changed the calling args to delete_file() to take an st_mode instead
[rsync/rsync.git] / log.c
diff --git a/log.c b/log.c
index eb54cb5..42ad470 100644 (file)
--- a/log.c
+++ b/log.c
@@ -87,7 +87,7 @@ static char const *rerr_name(int code)
        return NULL;
 }
 
-static void log_open(void)
+void log_open(void)
 {
        if (logfname && !logfile) {
                extern int orig_umask;
@@ -102,6 +102,14 @@ static void log_open(void)
        }
 }
 
+void log_close(void)
+{
+       if (logfile) {
+               fclose(logfile);
+               logfile = NULL;
+       }
+}
+
 static void logit(int priority, char *buf)
 {
        if (logfname) {
@@ -155,14 +163,6 @@ void log_init(void)
 #endif
 }
 
-void log_close(void)
-{
-       if (logfile) {
-               fclose(logfile);
-               logfile = NULL;
-       }
-}
-
 /* this is the underlying (unformatted) rsync debugging function. Call
  * it with FINFO, FERROR or FLOG */
 void rwrite(enum logcode code, char *buf, int len)
@@ -343,7 +343,7 @@ static void log_formatted(enum logcode code,
                          struct stats *initial_stats, int iflags)
 {
        char buf[MAXPATHLEN+1024];
-       char buf2[1024];
+       char buf2[MAXPATHLEN];
        char *p, *n;
        size_t len, total;
        int64 b;
@@ -380,6 +380,11 @@ static void log_formatted(enum logcode code,
                        break;
                case 'n':
                        n = (char*)safe_fname(f_name(file));
+                       if (S_ISDIR(file->mode)) {
+                               /* The buffer from safe_fname() has more
+                                * room than MAXPATHLEN, so this is safe. */
+                               strcat(n, "/");
+                       }
                        break;
                case 'L':
                        if (S_ISLNK(file->mode)) {
@@ -417,18 +422,19 @@ static void log_formatted(enum logcode code,
                        break;
                case 'i':
                        n = buf2;
-                       n[0] = !(iflags & ITEM_UPDATING) ? ' ' : dry_run
-                            ? '*' : *op == 's' ? '>' : '<';
+                       n[0] = !(iflags & ITEM_UPDATING) ? ' '
+                            : dry_run ? '*'
+                            : *op == 's' ? '>' : '<';
                        n[1] = S_ISDIR(file->mode) ? 'd' : IS_DEVICE(file->mode) ? 'D'
                             : S_ISLNK(file->mode) ? 'L' : 'f';
-                       n[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '-' : 'c';
-                       n[3] = !(iflags & ITEM_REPORT_SIZE) ? '-' : 's';
-                       n[4] = !(iflags & ITEM_REPORT_TIME) ? '-'
+                       n[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '.' : 'c';
+                       n[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
+                       n[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
                             : !preserve_times || IS_DEVICE(file->mode)
                                               || S_ISLNK(file->mode) ? 'T' : 't';
-                       n[5] = !(iflags & ITEM_REPORT_PERMS) ? '-' : 'p';
-                       n[6] = !(iflags & ITEM_REPORT_OWNER) ? '-' : 'o';
-                       n[7] = !(iflags & ITEM_REPORT_GROUP) ? '-' : 'g';
+                       n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
+                       n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
+                       n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
                        n[8] = '\0';
 
                        if (iflags & (ITEM_IS_NEW|ITEM_MISSING_DATA)) {