save some more bytes by making the checksum smaller
authorAndrew Tridgell <tridge@samba.org>
Tue, 2 Jul 1996 06:02:36 +0000 (06:02 +0000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 2 Jul 1996 06:02:36 +0000 (06:02 +0000)
checksum.c
compat.c
main.c

index 809b09f..2344b63 100644 (file)
@@ -24,6 +24,7 @@ int csum_length=SUM_LENGTH;
 #define CSUM_CHUNK 64
 
 int checksum_seed = 0;
 #define CSUM_CHUNK 64
 
 int checksum_seed = 0;
+extern int remote_version;
 
 /*
   a simple 32 bit checksum that can be upadted from either end
 
 /*
   a simple 32 bit checksum that can be upadted from either end
@@ -127,6 +128,10 @@ void file_checksum(char *fname,char *sum,off_t size)
 
 void checksum_init(void)
 {
 
 void checksum_init(void)
 {
+  if (remote_version >= 14)
+    csum_length = 2; /* adaptive */
+  else
+    csum_length = SUM_LENGTH;
 }
 
 
 }
 
 
@@ -180,22 +185,3 @@ void sum_end(char *sum)
 }
 
 
 }
 
 
-#ifdef CHECKSUM_MAIN
- int main(int argc,char *argv[])
-{
-  char sum[SUM_LENGTH];
-  int i,j;
-
-  checksum_init();
-
-  for (i=1;i<argc;i++) {
-    struct stat st;
-    if (stat(argv[i],&st) == 0) {
-      file_checksum(argv[i],sum,st.st_size);
-      for (j=0;j<SUM_LENGTH;j++)
-       printf("%02X",(unsigned char)sum[j]);
-      printf("  %s\n",argv[i]);
-    }
-  }
-}
-#endif
index 293bbc6..1c28c25 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -217,5 +217,7 @@ void setup_protocol(int f_out,int f_in)
       checksum_seed = read_int(f_in);
     }
   }
       checksum_seed = read_int(f_in);
     }
   }
+
+  checksum_init();
 }
 
 }
 
diff --git a/main.c b/main.c
index 038a2d2..d6389f1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -93,7 +93,6 @@ static void server_options(char **args,int *argc)
   int ac = *argc;
   static char argstr[50];
   static char bsize[30];
   int ac = *argc;
   static char argstr[50];
   static char bsize[30];
-  static char slength[30];
   int i, x;
 
   args[ac++] = "--server";
   int i, x;
 
   args[ac++] = "--server";
@@ -146,11 +145,6 @@ static void server_options(char **args,int *argc)
     args[ac++] = bsize;
   }    
 
     args[ac++] = bsize;
   }    
 
-  if (csum_length != SUM_LENGTH) {
-    sprintf(slength,"--csum-length=%d",csum_length);
-    args[ac++] = slength;
-  }    
-  
   if (delete_mode)
     args[ac++] = "--delete";
 
   if (delete_mode)
     args[ac++] = "--delete";
 
@@ -417,7 +411,7 @@ static void usage(FILE *f)
 }
 
 enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
 }
 
 enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
-      OPT_EXCLUDE_FROM,OPT_DELETE,OPT_RSYNC_PATH,OPT_CSUM_LENGTH};
+      OPT_EXCLUDE_FROM,OPT_DELETE,OPT_RSYNC_PATH};
 
 static char *short_options = "oblHpguDCtcahvrIxnSe:B:";
 
 
 static char *short_options = "oblHpguDCtcahvrIxnSe:B:";
 
@@ -429,7 +423,6 @@ static struct option long_options[] = {
   {"exclude",     1,     0,    OPT_EXCLUDE},
   {"exclude-from",1,     0,    OPT_EXCLUDE_FROM},
   {"rsync-path",  1,     0,    OPT_RSYNC_PATH},
   {"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'},
   {"one-file-system",0,  0,    'x'},
   {"ignore-times",0,     0,    'I'},
   {"help",        0,     0,    'h'},
@@ -470,8 +463,6 @@ int main(int argc,char *argv[])
 
     starttime = time(NULL);
 
 
     starttime = time(NULL);
 
-    checksum_init();
-
     while ((opt = getopt_long(argc, argv, 
                              short_options, long_options, &option_index)) 
           != -1) {
     while ((opt = getopt_long(argc, argv, 
                              short_options, long_options, &option_index)) 
           != -1) {
@@ -490,11 +481,6 @@ int main(int argc,char *argv[])
          rsync_path = optarg;
          break;
 
          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;
        case 'I':
          ignore_times = 1;
          break;