]> git.ipfire.org Git - pakfire.git/commitdiff
buildservice: Use new URL formatting feature
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Oct 2024 13:32:29 +0000 (13:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Oct 2024 13:32:29 +0000 (13:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/buildservice.c

index 64dfc07b1271cbf70bdd08be0d5fff6dbf119172..0758c26243aa5be4d22b9de0a5ee06a8c6305ee4 100644 (file)
@@ -355,16 +355,10 @@ ERROR:
 static int pakfire_buildservice_upload_payload(struct pakfire_buildservice* service,
                const char* filename, const char* uuid, FILE* f) {
        struct pakfire_xfer* xfer = NULL;
-       char url[PATH_MAX];
        int r;
 
-       // Make the URL
-       r = pakfire_string_format(url, "/api/v1/uploads/%s", uuid);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/uploads/%s", uuid);
        if (r)
                goto ERROR;
 
@@ -488,16 +482,10 @@ PAKFIRE_EXPORT int pakfire_buildservice_delete_upload(
                struct pakfire_buildservice* service, const char* uuid) {
        struct pakfire_xfer* xfer = NULL;
        struct json_object* response = NULL;
-       char url[PATH_MAX];
        int r;
 
-       // Compose the URL
-       r = pakfire_string_format(url, "/api/v1/uploads/%s", uuid);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/uploads/%s", uuid);
        if (r)
                goto ERROR;
 
@@ -532,20 +520,14 @@ PAKFIRE_EXPORT int pakfire_buildservice_list_repos(struct pakfire_buildservice*
        struct pakfire_xfer* xfer = NULL;
        struct json_object* response = NULL;
        struct json_object* repos = NULL;
-       char url[PATH_MAX];
        int r;
 
        // Check inputs
        if (!distro)
                return -EINVAL;
 
-       // Compose path
-       r = pakfire_string_format(url, "/api/v1/repos/%s", distro);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/repos/%s", distro);
        if (r)
                goto ERROR;
 
@@ -582,20 +564,14 @@ PAKFIRE_EXPORT int pakfire_buildservice_get_repo(struct pakfire_buildservice* se
                const char* distro, const char* name, struct json_object** p) {
        struct pakfire_xfer* xfer = NULL;
        struct json_object* response = NULL;
-       char url[PATH_MAX];
        int r;
 
        // Check inputs
        if (!distro || !name)
                return -EINVAL;
 
-       // Compose URL
-       r = pakfire_string_format(url, "/api/v1/repos/%s/%s", distro, name);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/repos/%s/%s", distro, name);
        if (r)
                goto ERROR;
 
@@ -625,20 +601,14 @@ PAKFIRE_EXPORT int pakfire_buildservice_create_repo(struct pakfire_buildservice*
                const char* distro, const char* name, const char* description, struct json_object** p) {
        struct pakfire_xfer* xfer = NULL;
        struct json_object* response = NULL;
-       char url[PATH_MAX];
        int r;
 
        // Check inputs
        if (!distro)
                return -EINVAL;
 
-       // Compose path
-       r = pakfire_string_format(url, "/api/v1/repos/%s", distro);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/repos/%s", distro);
        if (r)
                goto ERROR;
 
@@ -680,16 +650,10 @@ ERROR:
 PAKFIRE_EXPORT int pakfire_buildservice_delete_repo(struct pakfire_buildservice* service,
                const char* distro, const char* name) {
        struct pakfire_xfer* xfer = NULL;
-       char url[PATH_MAX];
        int r;
 
-       // Compose the URL
-       r = pakfire_string_format(url, "/api/v1/repos/%s/%s", distro, name);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/repos/%s/%s", distro, name);
        if (r)
                goto ERROR;
 
@@ -718,7 +682,6 @@ ERROR:
 PAKFIRE_EXPORT int pakfire_buildservice_job_finished(struct pakfire_buildservice* service,
                const char* uuid, int success, const char* logfile, const char** packages) {
        struct pakfire_xfer* xfer = NULL;
-       char url[PATH_MAX];
        int r;
 
        unsigned int num_packages = 0;
@@ -727,13 +690,8 @@ PAKFIRE_EXPORT int pakfire_buildservice_job_finished(struct pakfire_buildservice
        for (const char** package = packages; *package; packages++)
                num_packages++;
 
-       // Compose the URL
-       r = pakfire_string_format(url, "/api/v1/jobs/%s", uuid);
-       if (r)
-               goto ERROR;
-
        // Create a new xfer
-       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, service->httpclient, "/api/v1/jobs/%s", uuid);
        if (r)
                goto ERROR;