url = pakfire_config_get(config, "client", "url", "https://pakfire.ipfire.org/");
// Connect to the build service
- r = pakfire_client_create(client, args->ctx, url);
+ r = pakfire_client_create(client, args->ctx, NULL, url);
if (r < 0) {
fprintf(stderr, "Could not setup the build service: %s\n", strerror(-r));
goto ERROR;
struct pakfire_ctx* ctx;
int nrefs;
+ // HTTP Client
+ struct pakfire_httpclient* httpclient;
+
// URL
char url[PATH_MAX];
}
static void pakfire_client_free(struct pakfire_client* self) {
+ if (self->httpclient)
+ pakfire_httpclient_unref(self->httpclient);
if (self->ctx)
pakfire_ctx_unref(self->ctx);
}
int pakfire_client_create(struct pakfire_client** client,
- struct pakfire_ctx* ctx, const char* url) {
+ struct pakfire_ctx* ctx, sd_event* loop, const char* url) {
struct pakfire_client* self = NULL;
int r;
// Initialize the reference counter
self->nrefs = 1;
+ // Create a new HTTP client
+ r = pakfire_httpclient_create(&self->httpclient, self->ctx, loop);
+ if (r < 0)
+ goto ERROR;
+
// Store the URL
r = pakfire_string_set(self->url, url);
if (r < 0)
struct pakfire_client;
#include <json.h>
+#include <systemd/sd-event.h>
#include <pakfire/ctx.h>
int pakfire_client_create(struct pakfire_client** client,
- struct pakfire_ctx* ctx, const char* url);
+ struct pakfire_ctx* ctx, sd_event* loop, const char* url);
struct pakfire_client* pakfire_client_ref(struct pakfire_client* client);
struct pakfire_client* pakfire_client_unref(struct pakfire_client* client);
goto ERROR;
// Connect to the build service
- r = pakfire_client_create(&d->client, d->ctx, d->url);
+ r = pakfire_client_create(&d->client, d->ctx, d->loop, d->url);
if (r < 0)
goto ERROR;