Let compression backend check the compression flags.

Closes #214.
diff --git a/lib/zip_algorithm_xz.c b/lib/zip_algorithm_xz.c
index 09d9f74..3f588af 100644
--- a/lib/zip_algorithm_xz.c
+++ b/lib/zip_algorithm_xz.c
@@ -107,11 +107,6 @@
 allocate(bool compress, int compression_flags, zip_error_t *error, zip_uint16_t method) {
     struct ctx *ctx;
 
-    if (compression_flags < 0) {
-        zip_error_set(error, ZIP_ER_INVAL, 0);
-        return NULL;
-    }
-
     if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) {
         zip_error_set(error, ZIP_ER_MEMORY, 0);
         return NULL;
@@ -119,6 +114,9 @@
 
     ctx->error = error;
     ctx->compress = compress;
+    if (ctx->compression_flags < 0 || ctx->compression_flags > 9) {
+        ctx->compression_flags = 6; /* default value */
+    }
     ctx->compression_flags = (zip_uint32_t)compression_flags;
     ctx->compression_flags |= LZMA_PRESET_EXTREME;
     ctx->end_of_input = false;
diff --git a/lib/zip_algorithm_zstd.c b/lib/zip_algorithm_zstd.c
index c27e9fb..a921f6e 100644
--- a/lib/zip_algorithm_zstd.c
+++ b/lib/zip_algorithm_zstd.c
@@ -60,7 +60,7 @@
     struct ctx *ctx;
 
     /* 0: let zstd choose */
-    if (compression_flags < 0 || compression_flags > 9) {
+    if (compression_flags < ZSTD_minCLevel() || compression_flags > ZSTD_maxCLevel()) {
         compression_flags = 0;
     }
 
diff --git a/lib/zip_set_file_compression.c b/lib/zip_set_file_compression.c
index 511c7d5..166c0c7 100644
--- a/lib/zip_set_file_compression.c
+++ b/lib/zip_set_file_compression.c
@@ -40,7 +40,7 @@
     zip_entry_t *e;
     zip_int32_t old_method;
 
-    if (idx >= za->nentry || flags > 9) {
+    if (idx >= za->nentry) {
         zip_error_set(&za->error, ZIP_ER_INVAL, 0);
         return -1;
     }
diff --git a/man/zip_set_file_compression.mdoc b/man/zip_set_file_compression.mdoc
index 1e30417..03d8bf3 100644
--- a/man/zip_set_file_compression.mdoc
+++ b/man/zip_set_file_compression.mdoc
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 2, 2020
+.Dd March 19, 2021
 .Dt ZIP_SET_FILE_COMPRESSION 3
 .Os
 .Sh NAME
@@ -74,6 +74,14 @@
 Deflate the file with the
 .Xr zlib 3
 algorithm and default options.
+.It Dv ZIP_CM_XZ
+Use the
+.Xr xz 1
+algorithm for compression
+.It Dv ZIP_CM_ZSTD
+Use the
+.Xr zstd 1
+algorithm for compression
 .El
 .Pp
 .Em NOTE :
@@ -82,10 +90,23 @@
 .Pp
 The
 .Ar comp_flags
-argument defines the compression level, 1 being fastest compression
-and 9 highest.
-Allowed values are 0 (which uses the default compression for the
-algorithm) and 1-9, other values are undefined.
+argument defines the compression level.
+This value is dependent on the compression algorithm.
+In general, lower numbers mean faster de/compression and higher
+numbers mean slower de/compression.
+For
+.Dv ZIP_CM_BZIP ,
+.Dv ZIP_CM_DEFLATE ,
+and
+.Dv ZIP_CM_XZ
+1 is the fastest compression and 9 the best, 0 chooses the default.
+For
+.Dv ZIP_CM_ZSTD
+the value go from
+.Xr ZSTD_minCLevel 3
+to
+.Xr ZSTD_maxCLevel 3 .
+.Pp
 Further compression method specific flags might be added over time.
 .Pp
 The current compression method for a file in a zip archive can be