MCPcopy Create free account
hub / github.com/RsyncProject/rsync / init_compression_level

Function init_compression_level

token.c:55–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53static struct suffix_tree *suftree;
54
55void init_compression_level(void)
56{
57 int min_level, max_level, def_level, off_level;
58
59 switch (do_compression) {
60 case CPRES_NONE:
61 return;
62 case CPRES_ZLIB:
63 case CPRES_ZLIBX:
64 min_level = 1;
65 max_level = Z_BEST_COMPRESSION;
66 def_level = 6; /* Z_DEFAULT_COMPRESSION is -1, so set it to the real default */
67 off_level = skip_compression_level = Z_NO_COMPRESSION;
68 if (do_compression_level == Z_DEFAULT_COMPRESSION)
69 do_compression_level = def_level;
70 break;
71#ifdef SUPPORT_ZSTD
72 case CPRES_ZSTD:
73 min_level = skip_compression_level = ZSTD_minCLevel();
74 max_level = ZSTD_maxCLevel();
75 def_level = ZSTD_CLEVEL_DEFAULT;
76 off_level = CLVL_NOT_SPECIFIED;
77 if (do_compression_level == 0)
78 do_compression_level = def_level;
79 break;
80#endif
81#ifdef SUPPORT_LZ4
82 case CPRES_LZ4:
83 min_level = skip_compression_level = 0;
84 max_level = 0;
85 def_level = 0;
86 off_level = CLVL_NOT_SPECIFIED;
87 break;
88#endif
89 default: /* paranoia to prevent missing case values */
90 NOISY_DEATH("Unknown do_compression value");
91 }
92
93 if (do_compression_level == CLVL_NOT_SPECIFIED)
94 do_compression_level = def_level;
95 else if (do_compression_level == off_level) {
96 do_compression = CPRES_NONE;
97 return;
98 }
99
100 /* We don't bother with any errors or warnings -- just make sure that the values are valid. */
101 if (do_compression_level < min_level)
102 do_compression_level = min_level;
103 else if (do_compression_level > max_level)
104 do_compression_level = max_level;
105}
106
107static void add_suffix(struct suffix_tree **prior, char ltr, const char *str)
108{

Callers 1

parse_compress_choiceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected