Explorar o código

libdpkg: Add status to name mapping functions

Guillem Jover %!s(int64=12) %!d(string=hai) anos
pai
achega
6f82877d87
Modificáronse 3 ficheiros con 48 adicións e 2 borrados
  1. 5 1
      lib/dpkg/dpkg-db.h
  2. 3 0
      lib/dpkg/libdpkg.map
  3. 40 1
      lib/dpkg/pkg-show.c

+ 5 - 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-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2006-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
@@ -357,6 +357,10 @@ const char *pkgbin_name(struct pkginfo *pkg, struct pkgbin *pkgbin,
                         enum pkg_name_arch_when pnaw);
 const char *pkg_name(struct pkginfo *pkg, enum pkg_name_arch_when pnaw);
 
+const char *pkg_want_name(const struct pkginfo *pkg);
+const char *pkg_status_name(const struct pkginfo *pkg);
+const char *pkg_eflag_name(const struct pkginfo *pkg);
+
 /*** from dump.c ***/
 
 void writerecord(FILE*, const char*,

+ 3 - 0
lib/dpkg/libdpkg.map

@@ -244,6 +244,9 @@ LIBDPKG_PRIVATE {
 	pkg_abbrev_want;
 	pkg_abbrev_status;
 	pkg_abbrev_eflag;
+	pkg_want_name;
+	pkg_eflag_name;
+	pkg_status_name;
 
 	# Package list handling
 	pkg_list_new;

+ 40 - 1
lib/dpkg/pkg-show.c

@@ -3,7 +3,7 @@
  * pkg-show.c - primitives for pkg information display
  *
  * Copyright © 1995,1996 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-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
@@ -167,6 +167,45 @@ pkg_abbrev_eflag(const struct pkginfo *pkg)
 	return " R"[pkg->eflag];
 }
 
+/**
+ * Return a string representation of the package want status name.
+ *
+ * @param pkg The package to consider.
+ *
+ * @return The string representation.
+ */
+const char *
+pkg_want_name(const struct pkginfo *pkg)
+{
+	return wantinfos[pkg->want].name;
+}
+
+/**
+ * Return a string representation of the package eflag status name.
+ *
+ * @param pkg The package to consider.
+ *
+ * @return The string representation.
+ */
+const char *
+pkg_eflag_name(const struct pkginfo *pkg)
+{
+	return eflaginfos[pkg->eflag].name;
+}
+
+/**
+ * Return a string representation of the package current status name.
+ *
+ * @param pkg The package to consider.
+ *
+ * @return The string representation.
+ */
+const char *
+pkg_status_name(const struct pkginfo *pkg)
+{
+	return statusinfos[pkg->status].name;
+}
+
 /**
  * Compare a package to be sorted by non-ambiguous name and architecture.
  *