Bladeren bron

libdpkg: Move non pkg_db related functions to the pkg module

The pkgbin_blank, pkg_blank and pkg_is_informative are not strictly
part of the pkg_db module, and can be used w/o the latter.
Guillem Jover 15 jaren geleden
bovenliggende
commit
69a2c708c0
2 gewijzigde bestanden met toevoegingen van 77 en 65 verwijderingen
  1. 0 65
      lib/dpkg/database.c
  2. 77 0
      lib/dpkg/pkg.c

+ 0 - 65
lib/dpkg/database.c

@@ -56,71 +56,6 @@ static unsigned int hash(const char *name) {
   return h;
 }
 
-void
-pkg_blank(struct pkginfo *pigp)
-{
-  pigp->name= NULL;
-  pigp->status= stat_notinstalled;
-  pigp->eflag = eflag_ok;
-  pigp->want= want_unknown;
-  pigp->priority= pri_unknown;
-  pigp->otherpriority = NULL;
-  pigp->section= NULL;
-  blankversion(&pigp->configversion);
-  pigp->files= NULL;
-  pigp->clientdata= NULL;
-  pigp->trigaw.head = pigp->trigaw.tail = NULL;
-  pigp->othertrigaw_head = NULL;
-  pigp->trigpend_head = NULL;
-  pkgbin_blank(&pigp->installed);
-  pkgbin_blank(&pigp->available);
-}
-
-void
-pkgbin_blank(struct pkgbin *pifp)
-{
-  pifp->essential = false;
-  pifp->depends= NULL;
-  pifp->depended= NULL;
-  pifp->description= pifp->maintainer= pifp->source= pifp->installedsize= pifp->bugs= pifp->origin= NULL;
-  pifp->arch = NULL;
-  blankversion(&pifp->version);
-  pifp->conffiles= NULL;
-  pifp->arbs= NULL;
-}
-
-static int nes(const char *s) { return s && *s; }
-
-/**
- * Check if a pkg is informative.
- *
- * Used by dselect and dpkg query options as an aid to decide whether to
- * display things, and by dump to decide whether to write them out.
- */
-bool
-pkg_is_informative(struct pkginfo *pkg, struct pkgbin *info)
-{
-  if (info == &pkg->installed &&
-      (pkg->want != want_unknown ||
-       pkg->eflag != eflag_ok ||
-       pkg->status != stat_notinstalled ||
-       informativeversion(&pkg->configversion)))
-    /* We ignore Section and Priority, as these tend to hang around. */
-    return true;
-  if (info->depends ||
-      nes(info->description) ||
-      nes(info->maintainer) ||
-      nes(info->origin) ||
-      nes(info->bugs) ||
-      nes(info->installedsize) ||
-      nes(info->source) ||
-      informativeversion(&info->version) ||
-      info->conffiles ||
-      info->arbs)
-    return true;
-  return false;
-}
-
 struct pkginfo *
 pkg_db_find(const char *inname)
 {

+ 77 - 0
lib/dpkg/pkg.c

@@ -27,6 +27,83 @@
 #include <dpkg/dpkg-db.h>
 #include <dpkg/pkg.h>
 
+void
+pkgbin_blank(struct pkgbin *pkgbin)
+{
+	pkgbin->essential = false;
+	pkgbin->depends = NULL;
+	pkgbin->depended = NULL;
+	pkgbin->description = NULL;
+	pkgbin->maintainer = NULL;
+	pkgbin->source = NULL;
+	pkgbin->installedsize = NULL;
+	pkgbin->bugs = NULL;
+	pkgbin->origin = NULL;
+	pkgbin->arch = NULL;
+	blankversion(&pkgbin->version);
+	pkgbin->conffiles = NULL;
+	pkgbin->arbs = NULL;
+}
+
+void
+pkg_blank(struct pkginfo *pkg)
+{
+	pkg->name = NULL;
+	pkg->status = stat_notinstalled;
+	pkg->eflag = eflag_ok;
+	pkg->want = want_unknown;
+	pkg->priority = pri_unknown;
+	pkg->otherpriority = NULL;
+	pkg->section = NULL;
+	blankversion(&pkg->configversion);
+	pkg->files = NULL;
+	pkg->clientdata = NULL;
+	pkg->trigaw.head = NULL;
+	pkg->trigaw.tail = NULL;
+	pkg->othertrigaw_head = NULL;
+	pkg->trigpend_head = NULL;
+	pkgbin_blank(&pkg->installed);
+	pkgbin_blank(&pkg->available);
+}
+
+static int
+nes(const char *s)
+{
+	return s && *s;
+}
+
+/**
+ * Check if a pkg is informative.
+ *
+ * Used by dselect and dpkg query options as an aid to decide whether to
+ * display things, and by dump to decide whether to write them out.
+ */
+bool
+pkg_is_informative(struct pkginfo *pkg, struct pkgbin *pkgbin)
+{
+	/* We ignore Section and Priority, as these tend to hang around. */
+	if (pkgbin == &pkg->installed &&
+	    (pkg->want != want_unknown ||
+	     pkg->eflag != eflag_ok ||
+	     pkg->status != stat_notinstalled ||
+	     informativeversion(&pkg->configversion)))
+		return true;
+
+	if (pkgbin->depends ||
+	    nes(pkgbin->description) ||
+	    nes(pkgbin->maintainer) ||
+	    nes(pkgbin->origin) ||
+	    nes(pkgbin->bugs) ||
+	    nes(pkgbin->installedsize) ||
+	    nes(pkgbin->source) ||
+	    informativeversion(&pkgbin->version) ||
+	    pkgbin->conffiles ||
+	    pkgbin->arbs)
+		return true;
+
+	return false;
+}
+
 /**
  * Compare a package to be sorted by name.
  *