if no local destination is provided for the transfer then provide
authorAndrew Tridgell <tridge@samba.org>
Mon, 2 Nov 1998 00:52:01 +0000 (00:52 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 2 Nov 1998 00:52:01 +0000 (00:52 +0000)
a "ls -l" style listing of the files that would be transferred

flist.c
generator.c
log.c
main.c
options.c
rsync.h
rsync.yo
util.c

diff --git a/flist.c b/flist.c
index f5c69b9..664f26e 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -51,6 +51,36 @@ static struct exclude_struct **local_exclude_list;
 
 static void clean_flist(struct file_list *flist, int strip_root);
 
+
+static void list_file_entry(struct file_struct *f)
+{
+       char perms[11] = "----------";
+       char *perm_map = "rwxrwxrwx";
+       int i;
+
+       for (i=0;i<9;i++) {
+               if (f->mode & (1<<i)) perms[9-i] = perm_map[8-i];
+       }
+       if (S_ISLNK(f->mode)) perms[0] = 'l';
+       if (S_ISDIR(f->mode)) perms[0] = 'd';
+       if (S_ISBLK(f->mode)) perms[0] = 'b';
+       if (S_ISCHR(f->mode)) perms[0] = 'c';
+       if (S_ISSOCK(f->mode)) perms[0] = 's';
+       if (S_ISFIFO(f->mode)) perms[0] = 'p';
+       
+       if (preserve_links && S_ISLNK(f->mode)) {
+               rprintf(FINFO,"%s %11.0f %s %s -> %s\n", 
+                       perms, 
+                       (double)f->length, timestring(f->modtime), 
+                       f_name(f), f->link);
+       } else {
+               rprintf(FINFO,"%s %11.0f %s %s\n", 
+                       perms, 
+                       (double)f->length, timestring(f->modtime), f_name(f));
+       }
+}
+
+
 int link_stat(const char *Path, STRUCT_STAT *Buffer) 
 {
 #if SUPPORT_LINKS
@@ -699,6 +729,7 @@ struct file_list *recv_file_list(int f)
   struct file_list *flist;
   unsigned char flags;
   int64 start_read;
+  extern int list_only;
 
   if (verbose && recurse && !am_server) {
     rprintf(FINFO,"receiving file list ... ");
@@ -765,6 +796,14 @@ struct file_list *recv_file_list(int f)
          io_error |= read_int(f);
   }
 
+  if (list_only) {
+         int i;
+         for (i=0;i<flist->count;i++) {
+                 list_file_entry(flist->files[i]);
+         }
+  }
+
+
   if (verbose > 2)
     rprintf(FINFO,"recv_file_list done\n");
 
index 9905222..06c1fa4 100644 (file)
@@ -165,6 +165,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
        char *fnamecmp;
        char fnamecmpbuf[MAXPATHLEN];
        extern char *compare_dest;
+       extern int list_only;
+
+       if (list_only) return;
 
        if (verbose > 2)
                rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);
diff --git a/log.c b/log.c
index 32ae355..732a96b 100644 (file)
--- a/log.c
+++ b/log.c
 static FILE *logfile;
 
 
-/****************************************************************************
-  return the date and time as a string
-****************************************************************************/
-static char *timestring(void )
-{
-       static char TimeBuf[200];
-       time_t t = time(NULL);
-       struct tm *tm = localtime(&t);
-
-#ifdef HAVE_STRFTIME
-       strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
-#else
-       strlcpy(TimeBuf, asctime(tm), sizeof(TimeBuf)-1);
-#endif
-
-       if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
-               TimeBuf[strlen(TimeBuf)-1] = 0;
-       }
-
-       return(TimeBuf);
-}
-
 static void logit(int priority, char *buf)
 {
        if (logfile) {
                fprintf(logfile,"%s [%d] %s", 
-                       timestring(), (int)getpid(), buf);
+                       timestring(time(NULL)), (int)getpid(), buf);
                fflush(logfile);
        } else {
                syslog(priority, "%s", buf);
diff --git a/main.c b/main.c
index 00ccd8e..0e379aa 100644 (file)
--- a/main.c
+++ b/main.c
@@ -384,6 +384,7 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
        int status = 0, status2 = 0;
        char *local_name = NULL;
        extern int am_sender;
+       extern int list_only;
 
        setup_protocol(f_out,f_in);
        
@@ -412,6 +413,8 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
                report(-1);
                exit_cleanup(status);
        }
+
+       if (argc == 0) list_only = 1;
        
        send_exclude_list(f_out);
        
@@ -462,6 +465,20 @@ static int start_client(int argc, char *argv[])
        extern int am_sender;
        extern char *shell_cmd;
 
+       if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) == 0) {
+               char *host, *path;
+
+               host = argv[0] + strlen(URL_PREFIX);
+               p = strchr(host,'/');
+               if (p) {
+                       *p = 0;
+                       path = p+1;
+               } else {
+                       path="";
+               }
+               return start_socket_client(host, path, argc-1, argv+1);
+       }
+
        p = find_colon(argv[0]);
 
        if (p) {
@@ -470,7 +487,7 @@ static int start_client(int argc, char *argv[])
                        return start_socket_client(argv[0], p+2, argc-1, argv+1);
                }
 
-               if (argc < 2) {
+               if (argc < 1) {
                        usage(FERROR);
                        exit_cleanup(1);
                }
@@ -525,7 +542,7 @@ static int start_client(int argc, char *argv[])
                        shell_path?shell_path:"");
        }
        
-       if (!am_sender && argc != 1) {
+       if (!am_sender && argc > 1) {
                usage(FERROR);
                exit_cleanup(1);
        }
index a79443f..082aad7 100644 (file)
--- a/options.c
+++ b/options.c
@@ -73,7 +73,7 @@ int rsync_port = RSYNC_PORT;
 
 int verbose = 0;
 int always_checksum = 0;
-
+int list_only = 0;
 
 void usage(int F)
 {
diff --git a/rsync.h b/rsync.h
index 7485e5d..6bde7a4 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -23,6 +23,8 @@
 #define RSYNC_NAME "rsync"
 #define RSYNCD_CONF "/etc/rsyncd.conf"
 
+#define URL_PREFIX "rsync://"
+
 #define BACKUP_SUFFIX "~"
 
 /* a non-zero CHAR_OFFSET makes the rolling sum stronger, but is
index 236aca5..411a8ce 100644 (file)
--- a/rsync.yo
+++ b/rsync.yo
@@ -140,6 +140,9 @@ itemize(
 
        it() if you specify no path name on the remote server then the
        list of accessible paths on the server will be shown.
+       
+       it() if you specify no local destination then a listing of the
+       specified files on the remote server is provided
 )
 
 Some paths on the remote server may require authentication. If so then
diff --git a/util.c b/util.c
index 7be0be3..216bb10 100644 (file)
--- a/util.c
+++ b/util.c
@@ -762,3 +762,25 @@ char *sanitize_path(char *p)
        return(copy);
 }
 
+
+/****************************************************************************
+  return the date and time as a string
+****************************************************************************/
+char *timestring(time_t t)
+{
+       static char TimeBuf[200];
+       struct tm *tm = localtime(&t);
+
+#ifdef HAVE_STRFTIME
+       strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
+#else
+       strlcpy(TimeBuf, asctime(tm), sizeof(TimeBuf)-1);
+#endif
+
+       if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
+               TimeBuf[strlen(TimeBuf)-1] = 0;
+       }
+
+       return(TimeBuf);
+}
+