|
|
@@ -3,7 +3,7 @@
|
|
|
* pkg-array.c - primitives for pkg array handling
|
|
|
*
|
|
|
* Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
|
|
|
- * Copyright © 2009 Guillem Jover <guillem@debian.org>
|
|
|
+ * Copyright © 2009-2014 Guillem Jover <guillem@debian.org>
|
|
|
*
|
|
|
* This is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
@@ -28,8 +28,32 @@
|
|
|
|
|
|
#include <dpkg/dpkg.h>
|
|
|
#include <dpkg/dpkg-db.h>
|
|
|
+#include <dpkg/pkg-spec.h>
|
|
|
#include <dpkg/pkg-array.h>
|
|
|
|
|
|
+/**
|
|
|
+ * Initialize a package array from package names.
|
|
|
+ *
|
|
|
+ * @param a The array to initialize.
|
|
|
+ * @param pkg_mapper A function that maps a package name to a package instance.
|
|
|
+ * @param pkg_names The package names list.
|
|
|
+ */
|
|
|
+void
|
|
|
+pkg_array_init_from_names(struct pkg_array *a, pkg_mapper_func pkg_mapper,
|
|
|
+ const char **pkg_names)
|
|
|
+{
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ while (pkg_names[i])
|
|
|
+ i++;
|
|
|
+
|
|
|
+ a->n_pkgs = i;
|
|
|
+ a->pkgs = m_malloc(sizeof(a->pkgs[0]) * a->n_pkgs);
|
|
|
+
|
|
|
+ for (i = 0; pkg_names[i]; i++)
|
|
|
+ a->pkgs[i] = pkg_mapper(pkg_names[i]);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Initialize a package array from the package database.
|
|
|
*
|