// Builder
struct pakfire_builder* builder;
- // URL
- char url[PATH_MAX];
-
// Event Loop
sd_event* loop;
return 0;
}
-static int pakfire_daemon_configure(struct pakfire_daemon* daemon) {
+static int pakfire_daemon_setup_client(struct pakfire_daemon* self) {
struct pakfire_config* config = NULL;
const char* url = NULL;
int r;
// Fetch the configuration
- config = pakfire_ctx_get_config(daemon->ctx);
+ config = pakfire_ctx_get_config(self->ctx);
if (!config) {
- ERROR(daemon->ctx, "Could not fetch configuration: %m\n");
+ ERROR(self->ctx, "Could not fetch configuration: %m\n");
r = -errno;
goto ERROR;
}
// Fetch the URL
url = pakfire_config_get(config, "daemon", "url", "https://pakfire.ipfire.org");
- // Store the URL
- r = pakfire_string_set(daemon->url, url);
+ // Create a new client
+ r = pakfire_client_create(&self->client, self->ctx, url, NULL);
if (r < 0)
goto ERROR;
+ // Register the ready callback
+ pakfire_client_set_ready_callback(self->client, pakfire_daemon_ready, self);
+
ERROR:
if (config)
pakfire_config_unref(config);
// Initialize file descriptors
d->inhibitfd = -EBADF;
- // Read configuration
- r = pakfire_daemon_configure(d);
- if (r < 0)
- goto ERROR;
-
// Setup the event loop
r = pakfire_daemon_setup_loop(d);
if (r)
if (r < 0)
goto ERROR;
- // Connect to the build service
- r = pakfire_client_create(&d->client, d->ctx, d->url, NULL);
+ // Setup client
+ r = pakfire_daemon_setup_client(d);
if (r < 0)
goto ERROR;
- // Register the ready callback
- pakfire_client_set_ready_callback(d->client, pakfire_daemon_ready, d);
-
// Create builder
r = pakfire_client_builder(&d->builder, d->client);
if (r < 0)
// Return the pointer
*daemon = d;
-
return 0;
ERROR: