X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/055af776668c0878dd830f82d4bc6ca6aaca8e7a..83fff1aa6036f38a3d2daf6d809bd9c10d28fae6:/token.c 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");