#############################################################################*/
#include <errno.h>
+#include <limits.h>
#include <stdlib.h>
#include <pakfire/buildservice.h>
+#include <pakfire/config.h>
#include <pakfire/ctx.h>
+#include <pakfire/logging.h>
#include <pakfire/private.h>
+#include <pakfire/string.h>
struct pakfire_buildservice {
struct pakfire_ctx* ctx;
int nrefs;
+
+ char url[PATH_MAX];
};
+static int pakfire_buildservice_setup(struct pakfire_buildservice* service) {
+ struct pakfire_config* config = NULL;
+ const char* url = NULL;
+ int r;
+
+ // Fetch the configuration
+ config = pakfire_ctx_get_config(service->ctx);
+ if (!config) {
+ r = 1;
+ goto ERROR;
+ }
+
+ // Fetch the URL
+ url = pakfire_config_get(config, "client", "url", NULL);
+ if (!url) {
+ CTX_ERROR(service->ctx, "Build Service URL is not configured\n");
+ r = 1;
+ goto ERROR;
+ }
+
+ // Store the URL
+ r = pakfire_string_set(service->url, url);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ if (config)
+ pakfire_config_unref(config);
+
+ return r;
+}
+
static void pakfire_buildservice_free(struct pakfire_buildservice* service) {
if (service->ctx)
pakfire_ctx_unref(service->ctx);
PAKFIRE_EXPORT int pakfire_buildservice_create(
struct pakfire_buildservice** service, struct pakfire_ctx* ctx) {
struct pakfire_buildservice* s = NULL;
+ int r;
// Allocate some memory
s = calloc(1, sizeof(*s));
// Initialize the reference counter
s->nrefs = 1;
+ // Setup everything
+ r = pakfire_buildservice_setup(s);
+ if (r)
+ goto ERROR;
+
// Return the pointer
*service = s;
return 0;
+
+ERROR:
+ pakfire_buildservice_free(s);
+
+ return r;
}
PAKFIRE_EXPORT struct pakfire_buildservice* pakfire_buildservice_ref(