summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 0d8ea34a..dd284ac5 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -37,6 +37,7 @@
#include "delta.h"
#include "trans.h"
#include "alpm.h"
+#include "deps.h"
alpm_handle_t *_alpm_handle_new(void)
{
@@ -85,6 +86,10 @@ void _alpm_handle_free(alpm_handle_t *handle)
FREELIST(handle->noextract);
FREELIST(handle->ignorepkg);
FREELIST(handle->ignoregroup);
+
+ alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
+ alpm_list_free(handle->assumeinstalled);
+
FREE(handle);
}
@@ -251,6 +256,12 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregroups(alpm_handle_t *handle)
return handle->ignoregroup;
}
+alpm_list_t SYMEXPORT *alpm_option_get_assumeinstalled(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->assumeinstalled;
+}
+
const char SYMEXPORT *alpm_option_get_arch(alpm_handle_t *handle)
{
CHECK_HANDLE(handle, return NULL);
@@ -557,6 +568,51 @@ int SYMEXPORT alpm_option_remove_ignoregroup(alpm_handle_t *handle, const char *
return _alpm_option_strlist_rem(handle, &(handle->ignoregroup), grp);
}
+int SYMEXPORT alpm_option_add_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep)
+{
+ CHECK_HANDLE(handle, return -1);
+
+ handle->assumeinstalled = alpm_list_add(handle->assumeinstalled, (void *)dep);
+ return 0;
+}
+
+int SYMEXPORT alpm_option_set_assumeinstalled(alpm_handle_t *handle, alpm_list_t *deps)
+{
+ CHECK_HANDLE(handle, return -1);
+ if(handle->assumeinstalled) {
+ alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
+ alpm_list_free(handle->assumeinstalled);
+ }
+ handle->assumeinstalled = deps;
+ return 0;
+}
+
+static int assumeinstalled_cmp(const void *d1, const void *d2)
+{
+ const alpm_depend_t *dep1 = d1;
+ const alpm_depend_t *dep2 = d2;
+
+ if(strcmp(dep1->name, dep2->name) == 0 && strcmp(dep1->version, dep2->version) == 0) {
+ return 0;
+ }
+
+ return -1;
+}
+
+int SYMEXPORT alpm_option_remove_assumeinstalled(alpm_handle_t *handle, const alpm_depend_t *dep)
+{
+ alpm_depend_t *vdata = NULL;
+ CHECK_HANDLE(handle, return -1);
+
+ handle->assumeinstalled = alpm_list_remove(handle->assumeinstalled, dep, &assumeinstalled_cmp, (void **)&vdata);
+ if(vdata != NULL) {
+ alpm_dep_free(vdata);
+ return 1;
+ }
+
+ return 0;
+}
+
int SYMEXPORT alpm_option_set_arch(alpm_handle_t *handle, const char *arch)
{
CHECK_HANDLE(handle, return -1);