#include <pakfire/config.h>
#include <pakfire/pwd.h>
+int pakfire_clone(struct pakfire** clone, struct pakfire* pakfire, const char* path);
+
struct pakfire_ctx* pakfire_ctx(struct pakfire* pakfire);
const char* pakfire_get_effective_arch(struct pakfire* pakfire);
return r;
}
+int pakfire_clone(struct pakfire** clone, struct pakfire* pakfire, const char* path) {
+ struct pakfire* p = NULL;
+ FILE* f = NULL;
+ int r;
+
+ // Dump the configuration
+ f = pakfire_config_fdump(pakfire->config);
+ if (!f) {
+ r = -errno;
+ goto ERROR;
+ }
+
+ // Create a new Pakfire instance
+ r = pakfire_create(&p, pakfire->ctx, path, pakfire->arches.nominal, f, 0);
+ if (r < 0)
+ goto ERROR;
+
+ // Return the pointer
+ *clone = pakfire_ref(p);
+
+ERROR:
+ if (p)
+ pakfire_unref(p);
+ if (f)
+ fclose(f);
+
+ return r;
+}
+
PAKFIRE_EXPORT struct pakfire* pakfire_ref(struct pakfire* pakfire) {
++pakfire->nrefs;