Просмотр исходного кода

libdpkg: Add new pkg_db_get_pkg()

Guillem Jover лет назад: 14
Родитель
Сommit
905e3ecfea
2 измененных файлов с 22 добавлено и 2 удалено
  1. 2 1
      lib/dpkg/dpkg-db.h
  2. 20 1
      lib/dpkg/pkg-db.c

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

@@ -4,7 +4,7 @@
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2000,2001 Wichert Akkerman
- * Copyright © 2006-2011 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-2012 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
@@ -273,6 +273,7 @@ bool pkg_is_informative(struct pkginfo *pkg, struct pkgbin *info);
 
 struct pkginfo *pkg_db_find(const char *name);
 struct pkgset *pkg_db_find_set(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);
 int pkg_db_count_set(void);
 int pkg_db_count_pkg(void);

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

@@ -3,6 +3,7 @@
  * pkg-db.c - Low level package database routines (hash tables, etc.)
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  * Copyright © 2011 Linaro Limited
  * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
  *
@@ -104,6 +105,24 @@ pkg_db_find_set(const char *inname)
   return newpkg;
 }
 
+/**
+ * Return the package instance in a set with the given architecture.
+ *
+ * @param set  The package set to use.
+ * @param arch The requested architecture.
+ *
+ * @return The package instance.
+ */
+struct pkginfo *
+pkg_db_get_pkg(struct pkgset *set, const struct dpkg_arch *arch)
+{
+  struct pkginfo *pkg;
+
+  pkg = &set->pkg;
+
+  return pkg;
+}
+
 /**
  * Return the package instance with the given name and architecture.
  *
@@ -119,7 +138,7 @@ pkg_db_find_pkg(const char *name, const struct dpkg_arch *arch)
   struct pkginfo *pkg;
 
   set = pkg_db_find_set(name);
-  pkg = &set->pkg;
+  pkg = pkg_db_get_pkg(set, arch);
 
   return pkg;
 }