]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
import: add generic enum for choosing between tar + raw downloads
authorLennart Poettering <lennart@poettering.net>
Sat, 11 May 2024 12:00:25 +0000 (14:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Jun 2024 07:49:26 +0000 (09:49 +0200)
src/shared/import-util.c
src/shared/import-util.h

index 9057b78d286164d6aedafbd407f9e0000caf1e9d..bcdc21f79ec67f1bbe52b54a62041a6351da1071 100644 (file)
@@ -126,9 +126,16 @@ int import_url_change_suffix(
         return 0;
 }
 
+static const char* const import_type_table[_IMPORT_TYPE_MAX] = {
+        [IMPORT_RAW] = "raw",
+        [IMPORT_TAR] = "tar",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(import_type, ImportType);
+
 static const char* const import_verify_table[_IMPORT_VERIFY_MAX] = {
-        [IMPORT_VERIFY_NO] = "no",
-        [IMPORT_VERIFY_CHECKSUM] = "checksum",
+        [IMPORT_VERIFY_NO]        = "no",
+        [IMPORT_VERIFY_CHECKSUM]  = "checksum",
         [IMPORT_VERIFY_SIGNATURE] = "signature",
 };
 
index 3b2425b916537cdb499375844c0aff39fab61e7a..98b99e371fc42f8b4dcac9a547d6be35d976a7a8 100644 (file)
@@ -5,6 +5,13 @@
 
 #include "macro.h"
 
+typedef enum ImportType {
+        IMPORT_RAW,
+        IMPORT_TAR,
+        _IMPORT_TYPE_MAX,
+        _IMPORT_TYPE_INVALID = -EINVAL,
+} ImportType;
+
 typedef enum ImportVerify {
         IMPORT_VERIFY_NO,
         IMPORT_VERIFY_CHECKSUM,
@@ -25,6 +32,9 @@ static inline int import_url_append_component(const char *url, const char *suffi
         return import_url_change_suffix(url, 0, suffix, ret);
 }
 
+const char* import_type_to_string(ImportType v) _const_;
+ImportType import_type_from_string(const char *s) _pure_;
+
 const char* import_verify_to_string(ImportVerify v) _const_;
 ImportVerify import_verify_from_string(const char *s) _pure_;