- handle no mmap for munmap
[rsync/rsync.git] / main.c
diff --git a/main.c b/main.c
index 3cd2a13..d0583d6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -43,6 +43,8 @@ int local_server=0;
 int ignore_times=0;
 int delete_mode=0;
 int one_file_system=0;
+int remote_version=0;
+int csum_length=SUM_LENGTH;
 
 int am_server = 0;
 static int sender = 0;
@@ -87,6 +89,7 @@ static void server_options(char **args,int *argc)
   int ac = *argc;
   static char argstr[50];
   static char bsize[30];
+  static char slength[30];
   int i, x;
 
   args[ac++] = "--server";
@@ -134,6 +137,11 @@ static void server_options(char **args,int *argc)
     sprintf(bsize,"-B%d",block_size);
     args[ac++] = bsize;
   }    
+
+  if (csum_length != SUM_LENGTH) {
+    sprintf(slength,"--csum-length=%d",csum_length);
+    args[ac++] = slength;
+  }    
   
   if (delete_mode)
     args[ac++] = "--delete";
@@ -368,6 +376,7 @@ static void usage(FILE *f)
   fprintf(f,"    --exclude FILE       exclude file FILE\n");
   fprintf(f,"    --exclude-from FILE  exclude files listed in FILE\n");
   fprintf(f,"    --suffix SUFFIX      override backup suffix\n");  
+  fprintf(f,"    --csum-length LENGTH set the checksum length\n");  
   fprintf(f,"    --version            print version number\n");  
 
   fprintf(f,"\n");
@@ -376,7 +385,7 @@ static void usage(FILE *f)
 }
 
 enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
-      OPT_EXCLUDE_FROM,OPT_DELETE,OPT_RSYNC_PATH};
+      OPT_EXCLUDE_FROM,OPT_DELETE,OPT_RSYNC_PATH,OPT_CSUM_LENGTH};
 
 static char *short_options = "oblpguDCtcahvrIxne:B:";
 
@@ -388,6 +397,7 @@ static struct option long_options[] = {
   {"exclude",     1,     0,    OPT_EXCLUDE},
   {"exclude-from",1,     0,    OPT_EXCLUDE_FROM},
   {"rsync-path",  1,     0,    OPT_RSYNC_PATH},
+  {"csum-length", 1,     0,    OPT_CSUM_LENGTH},
   {"one-file-system",0,  0,    'x'},
   {"ignore-times",0,     0,    'I'},
   {"help",        0,     0,    'h'},
@@ -444,6 +454,11 @@ int main(int argc,char *argv[])
          rsync_path = optarg;
          break;
 
+       case OPT_CSUM_LENGTH:
+         csum_length = atoi(optarg);
+         csum_length = MIN(csum_length,SUM_LENGTH);
+         break;
+
        case 'I':
          ignore_times = 1;
          break;
@@ -581,14 +596,16 @@ int main(int argc,char *argv[])
       verbose = MAX(verbose,1);
 
     if (am_server) {
-      int version = read_int(STDIN_FILENO);
-      if (version < MIN_PROTOCOL_VERSION) {
-       fprintf(stderr,"protocol version mismatch %d %d\n",
-               version,PROTOCOL_VERSION);
+      remote_version = read_int(STDIN_FILENO);
+      if (remote_version < MIN_PROTOCOL_VERSION ||
+         remote_version > MAX_PROTOCOL_VERSION) {
+       fprintf(stderr,"protocol version mismatch - is your shell clean?\n");
        exit(1);
       }
       write_int(STDOUT_FILENO,PROTOCOL_VERSION);
       write_flush(STDOUT_FILENO);
+
+      setup_protocol();
        
       if (sender) {
        recv_exclude_list(STDIN_FILENO);
@@ -665,13 +682,16 @@ int main(int argc,char *argv[])
     write_int(f_out,PROTOCOL_VERSION);
     write_flush(f_out);
     {
-      int version = read_int(f_in);
-      if (version < MIN_PROTOCOL_VERSION) {
-       fprintf(stderr,"protocol version mismatch\n");
+      remote_version = read_int(f_in);
+      if (remote_version < MIN_PROTOCOL_VERSION ||
+         remote_version > MAX_PROTOCOL_VERSION) {
+       fprintf(stderr,"protocol version mismatch - is your shell clean?\n");
        exit(1);
       }        
     }
 
+    setup_protocol();
+
     if (verbose > 3) 
       fprintf(stderr,"parent=%d child=%d sender=%d recurse=%d\n",
              (int)getpid(),pid,sender,recurse);