]> git.ipfire.org Git - pakfire.git/commitdiff
parser: Add more string attributes to the package
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Mar 2021 16:51:21 +0000 (16:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Mar 2021 16:51:21 +0000 (16:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index 09c503824de72adb34a382a5c155121f1b340980..d9d43de53175314f9feeaf3b9e3b7645f75d4c0b 100644 (file)
@@ -784,6 +784,30 @@ PAKFIRE_EXPORT int pakfire_parser_create_package(PakfireParser parser,
        pakfire_package_set_uuid(*pkg, uuid);
        free(uuid);
 
+       // Assign more attributes
+       const struct attribute {
+               const char* name;
+               void(*func)(PakfirePackage pkg, const char* value);
+       } attributes[] = {
+               { "summary", pakfire_package_set_summary, },
+               { "description", pakfire_package_set_description, },
+               { "license", pakfire_package_set_license, },
+               { "url", pakfire_package_set_url, },
+               { "groups", pakfire_package_set_groups, },
+               { "vendor", pakfire_package_set_vendor, },
+               { "maintainer", pakfire_package_set_maintainer, },
+               { NULL },
+       };
+
+       for (const struct attribute* a = attributes; a->name; a++) {
+               char* value = pakfire_parser_get(parser, namespace, a->name);
+               if (!value)
+                       continue;
+
+               a->func(*pkg, value);
+               free(value);
+       }
+
        // All okay
        r = 0;