added "dont compress" option with the default setting of
authorAndrew Tridgell <tridge@samba.org>
Fri, 20 Nov 1998 22:26:29 +0000 (22:26 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 20 Nov 1998 22:26:29 +0000 (22:26 +0000)
*.gz *.tgz *.zip *.z *.rpm *.deb

loadparm.c
rsyncd.conf.yo
sender.c
token.c

index ea0f9be..03440fe 100644 (file)
@@ -131,6 +131,7 @@ typedef struct
        char *exclude_from;
        char *log_format;
        char *refuse_options;
        char *exclude_from;
        char *log_format;
        char *refuse_options;
+       char *dont_compress;
        int timeout;
 } service;
 
        int timeout;
 } service;
 
@@ -155,6 +156,7 @@ static service sDefault =
        NULL,    /* exclude from */
        "%o %h [%a] %m (%u) %f %l",    /* log format */
        NULL,    /* refuse options */
        NULL,    /* exclude from */
        "%o %h [%a] %m (%u) %f %l",    /* log format */
        NULL,    /* refuse options */
+       "*.gz *.tgz *.zip *.z *.rpm *.deb",    /* dont compress */
        0        /* timeout */
 };
 
        0        /* timeout */
 };
 
@@ -264,6 +266,7 @@ static struct parm_struct parm_table[] =
   {"transfer logging", P_BOOL,    P_LOCAL,  &sDefault.transfer_logging,NULL,0},
   {"log format",       P_STRING,  P_LOCAL,  &sDefault.log_format,  NULL,   0},
   {"refuse options",   P_STRING,  P_LOCAL,  &sDefault.refuse_options,NULL, 0},
   {"transfer logging", P_BOOL,    P_LOCAL,  &sDefault.transfer_logging,NULL,0},
   {"log format",       P_STRING,  P_LOCAL,  &sDefault.log_format,  NULL,   0},
   {"refuse options",   P_STRING,  P_LOCAL,  &sDefault.refuse_options,NULL, 0},
+  {"dont compress",    P_STRING,  P_LOCAL,  &sDefault.dont_compress,NULL,  0},
   {NULL,               P_BOOL,    P_NONE,   NULL,                  NULL,   0}
 };
 
   {NULL,               P_BOOL,    P_NONE,   NULL,                  NULL,   0}
 };
 
@@ -337,6 +340,7 @@ FN_LOCAL_STRING(lp_exclude, exclude)
 FN_LOCAL_STRING(lp_exclude_from, exclude_from)
 FN_LOCAL_STRING(lp_log_format, log_format)
 FN_LOCAL_STRING(lp_refuse_options, refuse_options)
 FN_LOCAL_STRING(lp_exclude_from, exclude_from)
 FN_LOCAL_STRING(lp_log_format, log_format)
 FN_LOCAL_STRING(lp_refuse_options, refuse_options)
+FN_LOCAL_STRING(lp_dont_compress, dont_compress)
 FN_LOCAL_INTEGER(lp_timeout, timeout)
 
 /* local prototypes */
 FN_LOCAL_INTEGER(lp_timeout, timeout)
 
 /* local prototypes */
index 58082a0..7f1bfa0 100644 (file)
@@ -294,6 +294,18 @@ prints an error message and exits.
 The full names of the options must be used (ie. you must use
 "compress" not "z" to disable compression).
 
 The full names of the options must be used (ie. you must use
 "compress" not "z" to disable compression).
 
+dit(bf(dont compress)) The "dont compress" option allows you to select
+filenames based on wildcard patterns that should not be compressed
+during transfer. Compression is expensive in terms of CPU usage so it
+is usually good to not try to compress files that won't compress well,
+such as already compressed files. 
+
+The "dont compress" option takes a space separated list of
+case-insensitive wildcard patterns. Any source filename matching one
+of the patterns will not be compressed during transfer.
+
+The default setting is verb(*.gz *.tgz *.zip *.z *.rpm *.deb)
+
 enddit()
 
 manpagesection(AUTHENTICATION STRENGTH)
 enddit()
 
 manpagesection(AUTHENTICATION STRENGTH)
index 4a344ea..623d995 100644 (file)
--- a/sender.c
+++ b/sender.c
@@ -200,6 +200,8 @@ void send_files(struct file_list *flist,int f_out,int f_in)
                if (!am_server) {
                        log_transfer(file, fname+offset);
                }
                if (!am_server) {
                        log_transfer(file, fname+offset);
                }
+
+               set_compression(fname);
          
                match_sums(f_out,s,buf,st.st_size);
 
          
                match_sums(f_out,s,buf,st.st_size);
 
diff --git a/token.c b/token.c
index 7d49613..e1039e2 100644 (file)
--- a/token.c
+++ b/token.c
 #include "zlib/zlib.h"
 
 extern int do_compression;
 #include "zlib/zlib.h"
 
 extern int do_compression;
+static int compression_level = Z_DEFAULT_COMPRESSION;
 
 
+/* determine the compression level based on a wildcard filename list */
+void set_compression(char *fname)
+{
+       extern int module_id;
+       char *dont;
+       char *tok;
+
+       if (!do_compression) return;
+
+       compression_level = Z_DEFAULT_COMPRESSION;
+       dont = lp_dont_compress(module_id);
+
+       if (!dont || !*dont) return;
+
+       dont = strdup(dont);
+       fname = strdup(fname);
+       if (!dont || !fname) return;
+
+       strlower(dont);
+       strlower(fname);
+
+       for (tok=strtok(dont," ");tok;tok=strtok(NULL," ")) {
+               if (fnmatch(tok, fname, 0) == 0) {
+                       compression_level = 0;
+                       break;
+               }
+       }
+       free(dont);
+       free(fname);
+}
 
 /* non-compressing recv token */
 static int simple_recv_token(int f,char **data)
 
 /* non-compressing recv token */
 static int simple_recv_token(int f,char **data)
@@ -104,7 +135,7 @@ send_deflated_token(int f, int token,
                        tx_strm.next_in = NULL;
                        tx_strm.zalloc = NULL;
                        tx_strm.zfree = NULL;
                        tx_strm.next_in = NULL;
                        tx_strm.zalloc = NULL;
                        tx_strm.zfree = NULL;
-                       if (deflateInit2(&tx_strm, Z_DEFAULT_COMPRESSION,
+                       if (deflateInit2(&tx_strm, compression_level,
                                         Z_DEFLATED, -15, 8,
                                         Z_DEFAULT_STRATEGY) != Z_OK) {
                                rprintf(FERROR, "compression init failed\n");
                                         Z_DEFLATED, -15, 8,
                                         Z_DEFAULT_STRATEGY) != Z_OK) {
                                rprintf(FERROR, "compression init failed\n");