summaryrefslogtreecommitdiff
path: root/token.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-11-20 22:26:29 +0000
committerAndrew Tridgell <tridge@samba.org>1998-11-20 22:26:29 +0000
commit83fff1aa6036f38a3d2daf6d809bd9c10d28fae6 (patch)
treef5968d22e163a95536b60003ca3bd9c2c0cc83ab /token.c
parent055af776668c0878dd830f82d4bc6ca6aaca8e7a (diff)
downloadrsync-83fff1aa6036f38a3d2daf6d809bd9c10d28fae6.tar.gz
added "dont compress" option with the default setting of
*.gz *.tgz *.zip *.z *.rpm *.deb
Diffstat (limited to 'token.c')
-rw-r--r--token.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/token.c b/token.c
index 7d496132..e1039e2e 100644
--- a/token.c
+++ b/token.c
@@ -21,7 +21,38 @@
#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)
@@ -104,7 +135,7 @@ send_deflated_token(int f, int token,
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");