Sfoglia il codice sorgente

libdpkg: Rename pkgset_get_singleton() to pkg_db_get_singleton()

Move it also from the pkg module to the pkg-db one. This private
function might need to allocate a new package instance in the
database in the future so it would belong in the pkg-db module,
but more importantly it's used to access pkg-db objects directly.
Guillem Jover 14 anni fa
parent
commit
63c7ba56e1
4 ha cambiato i file con 28 aggiunte e 29 eliminazioni
  1. 1 1
      lib/dpkg/dpkg-db.h
  2. 0 1
      lib/dpkg/libdpkg.map
  3. 27 1
      lib/dpkg/pkg-db.c
  4. 0 26
      lib/dpkg/pkg.c

+ 1 - 1
lib/dpkg/dpkg-db.h

@@ -269,13 +269,13 @@ void modstatdb_shutdown(void);
 
 void pkgset_blank(struct pkgset *set);
 int pkgset_installed_instances(struct pkgset *set);
-struct pkginfo *pkgset_get_singleton(struct pkgset *set);
 
 void pkg_blank(struct pkginfo *pp);
 void pkgbin_blank(struct pkgbin *pifp);
 bool pkg_is_informative(struct pkginfo *pkg, struct pkgbin *info);
 
 struct pkgset *pkg_db_find_set(const char *name);
+struct pkginfo *pkg_db_get_singleton(struct pkgset *set);
 struct pkginfo *pkg_db_find_singleton(const char *name);
 struct pkginfo *pkg_db_get_pkg(struct pkgset *set, const struct dpkg_arch *arch);
 struct pkginfo *pkg_db_find_pkg(const char *name, const struct dpkg_arch *arch);

+ 0 - 1
lib/dpkg/libdpkg.map

@@ -198,7 +198,6 @@ LIBDPKG_PRIVATE {
 
 	# Package struct handling
 	pkgset_installed_instances;
-	pkgset_get_singleton;
 	pkg_blank;
 	pkgbin_blank;
 	pkg_name_is_illegal;

+ 27 - 1
lib/dpkg/pkg-db.c

@@ -105,6 +105,32 @@ pkg_db_find_set(const char *inname)
   return newpkg;
 }
 
+/**
+ * Return the singleton package instance from a package set.
+ *
+ * This means, either the first instance if none are installed, the single
+ * installed instance, or NULL if more than one instance is installed.
+ *
+ * @param set The package set to use.
+ *
+ * @return The singleton package instance.
+ */
+struct pkginfo *
+pkg_db_get_singleton(struct pkgset *set)
+{
+  struct pkginfo *pkg;
+
+  if (pkgset_installed_instances(set) > 1)
+    return NULL;
+
+  for (pkg = &set->pkg; pkg; pkg = pkg->arch_next) {
+    if (pkg->status > stat_notinstalled)
+      return pkg;
+  }
+
+  return &set->pkg;
+}
+
 /**
  * Return the singleton package instance with the given name.
  *
@@ -119,7 +145,7 @@ pkg_db_find_singleton(const char *name)
   struct pkginfo *pkg;
 
   set = pkg_db_find_set(name);
-  pkg = pkgset_get_singleton(set);
+  pkg = pkg_db_get_singleton(set);
   if (pkg == NULL)
     ohshit(_("ambiguous package name '%s' with more "
              "than one installed instance"), set->name);

+ 0 - 26
lib/dpkg/pkg.c

@@ -174,32 +174,6 @@ pkgset_installed_instances(struct pkgset *set)
 	return set->installed_instances;
 }
 
-/**
- * Get the singleton package instance of a package set.
- *
- * This means, either the first instance if none are installed, the single
- * installed instance, or NULL if more than one instance is installed.
- *
- * @param set The package set to use.
- *
- * @return The singleton package instance.
- */
-struct pkginfo *
-pkgset_get_singleton(struct pkgset *set)
-{
-	struct pkginfo *pkg;
-
-	if (pkgset_installed_instances(set) > 1)
-		return NULL;
-
-	for (pkg = &set->pkg; pkg; pkg = pkg->arch_next) {
-		if (pkg->status > stat_notinstalled)
-			return pkg;
-	}
-
-	return &set->pkg;
-}
-
 static int
 nes(const char *s)
 {