]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
export: use table to parse --format=
authorDavid Tardon <dtardon@redhat.com>
Fri, 26 Sep 2025 13:25:02 +0000 (15:25 +0200)
committerDavid Tardon <dtardon@redhat.com>
Mon, 29 Sep 2025 14:04:12 +0000 (16:04 +0200)
src/import/export.c

index b3edc1a787ea517b6c831def9f735a8467af8a1d..d891ca18168482aff3a83251e129169086d1dbc2 100644 (file)
@@ -249,17 +249,8 @@ static int parse_argv(int argc, char *argv[]) {
                         return version();
 
                 case ARG_FORMAT:
-                        if (streq(optarg, "uncompressed"))
-                                arg_compress = IMPORT_COMPRESS_UNCOMPRESSED;
-                        else if (streq(optarg, "xz"))
-                                arg_compress = IMPORT_COMPRESS_XZ;
-                        else if (streq(optarg, "gzip"))
-                                arg_compress = IMPORT_COMPRESS_GZIP;
-                        else if (streq(optarg, "bzip2"))
-                                arg_compress = IMPORT_COMPRESS_BZIP2;
-                        else if (streq(optarg, "zstd"))
-                                arg_compress = IMPORT_COMPRESS_ZSTD;
-                        else
+                        arg_compress = import_compress_type_from_string(optarg);
+                        if (arg_compress < 0 || arg_compress == IMPORT_COMPRESS_UNKNOWN)
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                        "Unknown format: %s", optarg);
                         break;