}
int pakfire_httpclient_create_xfer(struct pakfire_xfer** xfer,
- struct pakfire_httpclient* client, const char* url) {
+ struct pakfire_httpclient* client, const char* url, ...) {
struct pakfire_xfer* x = NULL;
+ va_list args;
int r;
// Create a new transfer
- r = pakfire_xfer_create(&x, client->ctx, client, url);
+ va_start(args, url);
+ r = __pakfire_xfer_create(&x, client->ctx, client, url, args);
+ va_end(args);
if (r)
goto ERROR;
int pakfire_httpclient_set_baseurl(struct pakfire_httpclient* client, const char* baseurl);
int pakfire_httpclient_create_xfer(struct pakfire_xfer** xfer,
- struct pakfire_httpclient* downloader, const char* url);
+ struct pakfire_httpclient* downloader, const char* url, ...);
int pakfire_httpclient_enqueue_xfer(
struct pakfire_httpclient* downloader, struct pakfire_xfer* xfer);
#ifdef PAKFIRE_PRIVATE
+#include <stdarg.h>
+
#include <curl/curl.h>
#include <json.h>
} pakfire_xfer_method_t;
int pakfire_xfer_create(struct pakfire_xfer** transfer, struct pakfire_ctx* ctx,
- struct pakfire_httpclient* httpclient, const char* url);
+ struct pakfire_httpclient* httpclient, const char* url, ...);
+int __pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx,
+ struct pakfire_httpclient* client, const char* url, va_list args);
struct pakfire_xfer* pakfire_xfer_ref(struct pakfire_xfer* xfer);
struct pakfire_xfer* pakfire_xfer_unref(struct pakfire_xfer* xfer);
}
int pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx,
- struct pakfire_httpclient* client, const char* url) {
+ struct pakfire_httpclient* client, const char* url, ...) {
+ va_list args;
+ int r;
+
+ va_start(args, url);
+ r = __pakfire_xfer_create(xfer, ctx, client, url, args);
+ va_end(args);
+
+ return r;
+}
+
+int __pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx,
+ struct pakfire_httpclient* client, const char* url, va_list args) {
struct pakfire_xfer* x = NULL;
+ char buffer[PATH_MAX];
int r;
+ // Format the URL
+ r = __pakfire_string_vformat(buffer, sizeof(buffer), url, args);
+ if (r < 0)
+ return r;
+
// Allocate a new xfer
x = calloc(1, sizeof(*x));
if (!x)
x->client = pakfire_httpclient_ref(client);
// Store the URL
- r = pakfire_string_set(x->url, url);
+ r = pakfire_string_set(x->url, buffer);
if (r)
goto ERROR;