The following commit has been merged in the master branch:
commit 9db4a822bb62b739e71c0a59c5ba46a27d121e32
Author: Guillem Jover <[email protected]>
Date:   Sat Oct 23 05:37:33 2010 +0200

    libdpkg: Namespace package database functions with pkg_db_ prefix

diff --git a/TODO b/TODO
index d31ef5d..5027dd3 100644
--- a/TODO
+++ b/TODO
@@ -46,7 +46,6 @@ TODO
    - Replace raw write and read calls with safe variants (signals etc).
    - Make deb build version a version instead of doing checks over a string.
    - Use enums for currently hardcoded literals (tdus, dependtry, etc).
-   - Namespace pkg_db funcs.
    - Do not use nfmalloc (and friends) for non in-core db memory.
    - Call nffreeall on exit (need to detangle nfmalloc from non-db first).
    - Add a size parameter to the buffer api to avoid some useless
diff --git a/dselect/main.cc b/dselect/main.cc
index 601f40c..73ede2b 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -365,7 +365,7 @@ urqresult urq_list(void) {
   delete l;
 
   modstatdb_shutdown();
-  resetpackages();
+  pkg_db_reset();
   return urqr_normal;
 }
 
diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc
index ea9b15a..ed25ac4 100644
--- a/dselect/pkglist.cc
+++ b/dselect/pkglist.cc
@@ -356,7 +356,7 @@ void packagelist::initialsetup() {
   if (debug)
     fprintf(debug,"packagelist[%p]::initialsetup()\n",this);
 
-  int allpackages= countpackages();
+  int allpackages = pkg_db_count();
   datatable= new struct perpackagestate[allpackages];
 
   nallocated= allpackages+150; // will realloc if necessary, so 150 not 
critical
@@ -386,8 +386,9 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) {
   struct pkginfo *pkg;
   
   nitems = 0;
-  iter = iterpkgstart();
-  while ((pkg = iterpkgnext(iter))) {
+
+  iter = pkg_db_iter_new();
+  while ((pkg = pkg_db_iter_next(iter))) {
     struct perpackagestate *state= &datatable[nitems];
     state->pkg= pkg;
     if (pkg->status == pkginfo::stat_notinstalled &&
@@ -415,7 +416,7 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) {
     table[nitems]= state;
     nitems++;
   }
-  iterpkgend(iter);
+  pkg_db_iter_free(iter);
 
   if (!nitems)
     ohshit(_("There are no packages."));
diff --git a/lib/dpkg/database.c b/lib/dpkg/database.c
index c5282cc..866c8b0 100644
--- a/lib/dpkg/database.c
+++ b/lib/dpkg/database.c
@@ -120,7 +120,9 @@ informative(struct pkginfo *pkg, struct pkginfoperfile 
*info)
   return false;
 }
 
-struct pkginfo *findpackage(const char *inname) {
+struct pkginfo *
+pkg_db_find(const char *inname)
+{
   struct pkginfo **pointerp, *newpkg;
   char *name = m_strdup(inname), *p;
 
@@ -143,7 +145,9 @@ struct pkginfo *findpackage(const char *inname) {
   return newpkg;
 }
 
-int countpackages(void) {
+int
+pkg_db_count(void)
+{
   return npackages;
 }
 
@@ -152,7 +156,9 @@ struct pkgiterator {
   int nbinn;
 };
 
-struct pkgiterator *iterpkgstart(void) {
+struct pkgiterator *
+pkg_db_iter_new(void)
+{
   struct pkgiterator *i;
   i= m_malloc(sizeof(struct pkgiterator));
   i->pigp= NULL;
@@ -160,7 +166,9 @@ struct pkgiterator *iterpkgstart(void) {
   return i;
 }
 
-struct pkginfo *iterpkgnext(struct pkgiterator *i) {
+struct pkginfo *
+pkg_db_iter_next(struct pkgiterator *i)
+{
   struct pkginfo *r;
   while (!i->pigp) {
     if (i->nbinn >= BINS) return NULL;
@@ -169,11 +177,15 @@ struct pkginfo *iterpkgnext(struct pkgiterator *i) {
   r= i->pigp; i->pigp= r->next; return r;
 }
 
-void iterpkgend(struct pkgiterator *i) {
+void
+pkg_db_iter_free(struct pkgiterator *i)
+{
   free(i);
 }
 
-void resetpackages(void) {
+void
+pkg_db_reset(void)
+{
   int i;
   nffreeall();
   npackages= 0;
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 89f6da1..9cc5533 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -213,17 +213,18 @@ const char *pkgadminfile(struct pkginfo *pkg, const char 
*whichfile);
 
 /*** from database.c ***/
 
-struct pkginfo *findpackage(const char *name);
 void blankpackage(struct pkginfo *pp);
 void blankpackageperfile(struct pkginfoperfile *pifp);
 void blankversion(struct versionrevision*);
 bool informative(struct pkginfo *pkg, struct pkginfoperfile *info);
-int countpackages(void);
-void resetpackages(void);
 
-struct pkgiterator *iterpkgstart(void);
-struct pkginfo *iterpkgnext(struct pkgiterator*);
-void iterpkgend(struct pkgiterator*);
+struct pkginfo *pkg_db_find(const char *name);
+int pkg_db_count(void);
+void pkg_db_reset(void);
+
+struct pkgiterator *pkg_db_iter_new(void);
+struct pkginfo *pkg_db_iter_next(struct pkgiterator *iter);
+void pkg_db_iter_free(struct pkgiterator *iter);
 
 void hashreport(FILE*);
 
diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index 448737c..0d3a587 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -382,8 +382,8 @@ writedb(const char *filename, bool available, bool mustsync)
   if (setvbuf(file,writebuf,_IOFBF,sizeof(writebuf)))
     ohshite(_("unable to set buffering on %s database file"), which);
 
-  it= iterpkgstart();
-  while ((pigp= iterpkgnext(it)) != NULL) {
+  it = pkg_db_iter_new();
+  while ((pigp = pkg_db_iter_next(it)) != NULL) {
     pifp= available ? &pigp->available : &pigp->installed;
     /* Don't dump records which have no useful content. */
     if (!informative(pigp,pifp)) continue;
@@ -394,7 +394,7 @@ writedb(const char *filename, bool available, bool mustsync)
               which, pigp->name, filename);
     varbufreset(&vb);      
   }
-  iterpkgend(it);
+  pkg_db_iter_free(it);
   varbuf_destroy(&vb);
   if (mustsync) {
     if (fflush(file))
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 223f28d..47fc811 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -73,10 +73,8 @@ f_name(struct pkginfo *pigp, struct pkginfoperfile *pifp,
   const char *e;
   if ((e= illegal_packagename(value,NULL)) != NULL)
     parse_error(ps, pigp, _("invalid package name (%.250s)"), e);
-  pigp->name= findpackage(value)->name;
-  /* We use the new name, as findpackage() may have
-     done a tolower for us.
-   */
+  /* We use the new name, as pkg_db_find() may have done a tolower for us. */
+  pigp->name = pkg_db_find(value)->name;
 }
 
 void f_filecharf(struct pkginfo *pigp, struct pkginfoperfile *pifp,
@@ -331,7 +329,7 @@ void f_dependency(struct pkginfo *pigp, struct 
pkginfoperfile *pifp,
                     fip->name, depname.buf, emsg);
       dop= nfmalloc(sizeof(struct deppossi));
       dop->up= dyp;
-      dop->ed = findpackage(depname.buf);
+      dop->ed = pkg_db_find(depname.buf);
       dop->next= NULL; *ldopp= dop; ldopp= &dop->next;
 
       /* Don't link this (which is after all only ‘newpig’ from
@@ -524,7 +522,7 @@ f_trigaw(struct pkginfo *aw, struct pkginfoperfile *pifp,
       parse_error(ps, aw,
                   _("illegal package name in awaited trigger `%.255s': %s"),
                   word, emsg);
-    pend = findpackage(word);
+    pend = pkg_db_find(word);
 
     if (!trig_note_aw(pend, aw))
       parse_error(ps, aw,
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index ca94428..b7d5103 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -194,12 +194,12 @@ LIBDPKG_PRIVATE {
        pkg_format_free;
 
        # Package in-core database functions
-       findpackage;
-       countpackages;
-       resetpackages;
-       iterpkgstart;
-       iterpkgnext;
-       iterpkgend;
+       pkg_db_find;
+       pkg_db_count;
+       pkg_db_reset;
+       pkg_db_iter_new;
+       pkg_db_iter_next;
+       pkg_db_iter_free;
 
        # Package on-disk database functions
        statusinfos;            # XXX variable, do not export
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index c140287..7e2bc35 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -331,7 +331,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
       newpig.want = want_unknown;
     }
 
-    pigp= findpackage(newpig.name);
+    pigp = pkg_db_find(newpig.name);
     pifp= (flags & pdb_recordavailable) ? &pigp->available : &pigp->installed;
 
     if ((flags & pdb_ignoreolder) &&
@@ -375,7 +375,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
       for (ta = pigp->trigaw.head; ta; ta = ta->sameaw.next) {
         assert(ta->aw == &newpig);
         ta->aw = pigp;
-        /* ->othertrigaw_head is updated by trig_note_aw in *(findpackage())
+        /* ->othertrigaw_head is updated by trig_note_aw in *(pkg_db_find())
          * rather than in newpig */
       }
 
diff --git a/lib/dpkg/pkg-array.c b/lib/dpkg/pkg-array.c
index 2ed1db7..19e95b8 100644
--- a/lib/dpkg/pkg-array.c
+++ b/lib/dpkg/pkg-array.c
@@ -42,13 +42,13 @@ pkg_array_init_from_db(struct pkg_array *a)
        struct pkginfo *pkg;
        int i;
 
-       a->n_pkgs = countpackages();
+       a->n_pkgs = pkg_db_count();
        a->pkgs = m_malloc(sizeof(a->pkgs[0]) * a->n_pkgs);
 
-       it = iterpkgstart();
-       for (i = 0; (pkg = iterpkgnext(it)); i++)
+       it = pkg_db_iter_new();
+       for (i = 0; (pkg = pkg_db_iter_next(it)); i++)
                a->pkgs[i] = pkg;
-       iterpkgend(it);
+       pkg_db_iter_free(it);
 
        assert(i == a->n_pkgs);
 }
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 142719f..2869c8c 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -155,7 +155,7 @@ trig_note_pend(struct pkginfo *pend, const char *trig /*not 
copied!*/)
 
 /* Returns: true for done, false for already noted. */
 /* NB that this is called also from fields.c where *aw is a temporary
- * but pend is from findpackage()! */
+ * but pend is from pkg_db_find()! */
 bool
 trig_note_aw(struct pkginfo *pend, struct pkginfo *aw)
 {
@@ -390,7 +390,7 @@ trk_explicit_activate_awaiter(struct pkginfo *aw)
                        ohshit(_("trigger interest file `%.250s' syntax error; "
                                 "illegal package name `%.250s': %.250s"),
                               trk_explicit_fn.buf, buf, emsg);
-               pend = findpackage(buf);
+               pend = pkg_db_find(buf);
                trig_record_activation(pend, aw, trk_explicit_trig);
        }
 }
@@ -584,7 +584,7 @@ trig_file_interests_ensure(void)
                        ohshit(_("file triggers record mentions illegal "
                                 "package name `%.250s' (for interest in file "
                                 "`%.250s'): %.250s"), space, linebuf, emsg);
-               pkg = findpackage(space);
+               pkg = pkg_db_find(space);
                trk_file_interest_change(linebuf, pkg, +2);
        }
        pop_cleanup(ehflag_normaltidy);
@@ -742,7 +742,7 @@ tdm_incorp_trig_begin(const char *trig)
 static void
 tdm_incorp_package(const char *awname)
 {
-       struct pkginfo *aw = strcmp(awname, "-") ? findpackage(awname) : NULL;
+       struct pkginfo *aw = strcmp(awname, "-") ? pkg_db_find(awname) : NULL;
 
        dtki->activate_awaiter(aw);
 }
diff --git a/src/depcon.c b/src/depcon.c
index bc8a743..7e318f9 100644
--- a/src/depcon.c
+++ b/src/depcon.c
@@ -158,11 +158,11 @@ findbreakcycle(struct pkginfo *pkg)
   struct pkginfo *tpkg;
        
   /* Clear the visited flag of all packages before we traverse them. */
-  iter = iterpkgstart();
-  while ((tpkg = iterpkgnext(iter))) {
+  iter = pkg_db_iter_new();
+  while ((tpkg = pkg_db_iter_next(iter))) {
     tpkg->clientdata->color = white;
   }
-  iterpkgend(iter);
+  pkg_db_iter_free(iter);
 
   return findbreakcyclerecursive(pkg, NULL);
 }
diff --git a/src/divertcmd.c b/src/divertcmd.c
index 94fd085..f42d2b1 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -453,7 +453,7 @@ diversion_add(const char *const *argv)
        if (opt_pkgname == NULL)
                pkg = NULL;
        else
-               pkg = findpackage(opt_pkgname);
+               pkg = pkg_db_find(opt_pkgname);
 
        /* Check we are not stomping over an existing diversion. */
        if (fnn_from->divert || fnn_to->divert) {
@@ -528,7 +528,7 @@ diversion_remove(const char *const *argv)
        if (opt_pkgname == NULL)
                pkg = NULL;
        else
-               pkg = findpackage(opt_pkgname);
+               pkg = pkg_db_find(opt_pkgname);
 
        contest = namenode->divert;
        altname = contest->useinstead->divert;
diff --git a/src/divertdb.c b/src/divertdb.c
index 2214492..1449c64 100644
--- a/src/divertdb.c
+++ b/src/divertdb.c
@@ -108,7 +108,7 @@ ensure_diversions(void)
 
                fgets_must(linebuf, sizeof(linebuf), file, vb.buf);
                oicontest->pkg = oialtname->pkg = strcmp(linebuf, ":") ?
-                                                 findpackage(linebuf) : NULL;
+                                                 pkg_db_find(linebuf) : NULL;
 
                if (oialtname->camefrom->divert ||
                    oicontest->useinstead->divert)
diff --git a/src/enquiry.c b/src/enquiry.c
index 8d23d41..09332fe 100644
--- a/src/enquiry.c
+++ b/src/enquiry.c
@@ -140,8 +140,8 @@ void audit(const char *const *argv) {
     struct pkginfo *pkg;
     bool head = false;
 
-    it= iterpkgstart(); 
-    while ((pkg= iterpkgnext(it))) {
+    it = pkg_db_iter_new();
+    while ((pkg = pkg_db_iter_next(it))) {
       if (!bsi->yesno(pkg,bsi)) continue;
       if (!head_running) {
         if (modstatdb_is_locked(admindir))
@@ -156,7 +156,7 @@ void audit(const char *const *argv) {
       }
       describebriefly(pkg);
     }
-    iterpkgend(it);
+    pkg_db_iter_free(it);
     if (head) putchar('\n');
   }
 
@@ -207,8 +207,8 @@ void unpackchk(const char *const *argv) {
   totalcount= 0;
   sectionentries = NULL;
   sects= 0;
-  it= iterpkgstart(); 
-  while ((pkg= iterpkgnext(it))) {
+  it = pkg_db_iter_new();
+  while ((pkg = pkg_db_iter_next(it))) {
     if (!yettobeunpacked(pkg, &thissect)) continue;
     for (se= sectionentries; se && strcasecmp(thissect,se->name); se= 
se->next);
     if (!se) {
@@ -224,33 +224,33 @@ void unpackchk(const char *const *argv) {
     }
     se->count++; totalcount++;
   }
-  iterpkgend(it);
+  pkg_db_iter_free(it);
 
   if (totalcount == 0) exit(0);
   
   if (totalcount <= 12) {
-    it= iterpkgstart(); 
-    while ((pkg= iterpkgnext(it))) {
+    it = pkg_db_iter_new();
+    while ((pkg = pkg_db_iter_next(it))) {
       if (!yettobeunpacked(pkg, NULL))
         continue;
       describebriefly(pkg);
     }
-    iterpkgend(it);
+    pkg_db_iter_free(it);
   } else if (sects <= 12) {
     for (se= sectionentries; se; se= se->next) {
       sprintf(buf,"%d",se->count);
       printf(_(" %d in %s: "),se->count,se->name);
       width= 70-strlen(se->name)-strlen(buf);
       while (width > 59) { putchar(' '); width--; }
-      it= iterpkgstart(); 
-      while ((pkg= iterpkgnext(it))) {
+      it = pkg_db_iter_new();
+      while ((pkg = pkg_db_iter_next(it))) {
         if (!yettobeunpacked(pkg,&thissect)) continue;
         if (strcasecmp(thissect,se->name)) continue;
         width -= strlen(pkg->name); width--;
         if (width < 4) { printf(" ..."); break; }
         printf(" %s",pkg->name);
       }
-      iterpkgend(it);
+      pkg_db_iter_free(it);
       putchar('\n');
     }
   } else {
@@ -282,7 +282,7 @@ assert_version_support(const char *const *argv,
 
   modstatdb_init(admindir,msdbrw_readonly|msdbrw_noavail);
 
-  pkg= findpackage("dpkg");
+  pkg = pkg_db_find("dpkg");
   switch (pkg->status) {
   case stat_installed:
   case stat_triggerspending:
@@ -347,8 +347,8 @@ void predeppackage(const char *const *argv) {
   clear_istobes(); /* We use clientdata->istobe to detect loops */
 
   dep = NULL;
-  it = iterpkgstart();
-  while (!dep && (pkg = iterpkgnext(it))) {
+  it = pkg_db_iter_new();
+  while (!dep && (pkg = pkg_db_iter_next(it))) {
     if (pkg->want != want_install) continue; /* Ignore packages user doesn't 
want */
     if (!pkg->files) continue; /* Ignore packages not available */
     pkg->clientdata->istobe= itb_preinstall;
@@ -361,7 +361,7 @@ void predeppackage(const char *const *argv) {
     pkg->clientdata->istobe= itb_normal;
     /* If dep is NULL we go and get the next package. */
   }
-  iterpkgend(it);
+  pkg_db_iter_free(it);
 
   if (!dep) exit(1); /* Not found */
   assert(pkg);
diff --git a/src/filesdb.c b/src/filesdb.c
index 5565216..56a1b2b 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -419,7 +419,7 @@ void ensure_allinstfiles_available(void) {
 
   if (allpackagesdone) return;
   if (saidread<2) {
-    int max = countpackages();
+    int max = pkg_db_count();
 
     saidread=1;
     progress_init(&progress, _("(Reading database ... "), max);
diff --git a/src/help.c b/src/help.c
index bcacda7..eae14b0 100644
--- a/src/help.c
+++ b/src/help.c
@@ -443,13 +443,13 @@ void clear_istobes(void) {
   struct pkgiterator *it;
   struct pkginfo *pkg;
 
-  it= iterpkgstart();
-  while ((pkg = iterpkgnext(it)) != NULL) {
+  it = pkg_db_iter_new();
+  while ((pkg = pkg_db_iter_next(it)) != NULL) {
     ensure_package_clientdata(pkg);
     pkg->clientdata->istobe= itb_normal;
     pkg->clientdata->replacingfilesandsaid= 0;
   }
-  iterpkgend(it);
+  pkg_db_iter_free(it);
 }
 
 void debug(int which, const char *fmt, ...) {
diff --git a/src/main.c b/src/main.c
index 6694497..cf4029d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -285,7 +285,7 @@ static void ignoredepends(const struct cmdinfo *cip, const 
char *value) {
     if (pnerr) ohshite(_("--ignore-depends requires a legal package name. "
                        "`%.250s' is not; %s"), p, pnerr);
 
-    pkg_list_prepend(&ignoredependss, findpackage(p));
+    pkg_list_prepend(&ignoredependss, pkg_db_find(p));
 
     p+= strlen(p)+1;
   }
diff --git a/src/packages.c b/src/packages.c
index 5bcf421..f0082d9 100644
--- a/src/packages.c
+++ b/src/packages.c
@@ -60,8 +60,8 @@ enqueue_pending(void)
   struct pkgiterator *it;
   struct pkginfo *pkg;
 
-  it = iterpkgstart();
-  while ((pkg = iterpkgnext(it)) != NULL) {
+  it = pkg_db_iter_new();
+  while ((pkg = pkg_db_iter_next(it)) != NULL) {
     switch (cipaction->arg) {
     case act_configure:
       if (!(pkg->status == stat_unpacked ||
@@ -93,7 +93,7 @@ enqueue_pending(void)
     }
     add_to_queue(pkg);
   }
-  iterpkgend(it);
+  pkg_db_iter_free(it);
 }
 
 static void
@@ -104,7 +104,7 @@ enqueue_specified(const char *const *argv)
   while ((thisarg = *argv++) != NULL) {
     struct pkginfo *pkg;
 
-    pkg = findpackage(thisarg);
+    pkg = pkg_db_find(thisarg);
     if (pkg->status == stat_notinstalled) {
       size_t l = strlen(pkg->name);
       const char *extension = pkg->name + l - sizeof(DEBEXT) + 1;
diff --git a/src/processarc.c b/src/processarc.c
index 2199e68..2cca061 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -1029,8 +1029,8 @@ void process_archive(const char *filename) {
    * Conffiles are ignored (the new package had better do something
    * with them !).
    */
-  it= iterpkgstart();
-  while ((otherpkg = iterpkgnext(it)) != NULL) {
+  it = pkg_db_iter_new();
+  while ((otherpkg = pkg_db_iter_next(it)) != NULL) {
     ensure_package_clientdata(otherpkg);
     if (otherpkg == pkg ||
         otherpkg->status == stat_notinstalled ||
@@ -1149,7 +1149,7 @@ void process_archive(const char *filename) {
     modstatdb_note(otherpkg);
 
   } /* while (otherpkg= ... */
-  iterpkgend(it);
+  pkg_db_iter_free(it);
   
   /* Delete files from any other packages' lists.
    * We have to do this before we claim this package is in any
diff --git a/src/querycmd.c b/src/querycmd.c
index 77cb381..8a5a71b 100644
--- a/src/querycmd.c
+++ b/src/querycmd.c
@@ -322,7 +322,7 @@ enqperpackage(const char *const *argv)
     modstatdb_init(admindir,msdbrw_readonly);
 
   while ((thisarg = *argv++) != NULL) {
-    pkg= findpackage(thisarg);
+    pkg = pkg_db_find(thisarg);
 
     switch (cipaction->arg) {
       
@@ -574,7 +574,7 @@ control_path(const char *const *argv)
 
   modstatdb_init(admindir, msdbrw_readonly | msdbrw_noavail);
 
-  pkg = findpackage(pkg_name);
+  pkg = pkg_db_find(pkg_name);
   if (pkg->status == stat_notinstalled)
     badusage(_("Package `%s' is not installed.\n"), pkg->name);
 
diff --git a/src/select.c b/src/select.c
index 050950b..631fd3c 100644
--- a/src/select.c
+++ b/src/select.c
@@ -129,7 +129,7 @@ void setselections(const char *const *argv) {
     if (e) ohshit(_("illegal package name at line %d: %.250s"),lno,e);
     for (nvp=wantinfos; nvp->name && strcmp(nvp->name,selvb.buf); nvp++);
     if (!nvp->name) ohshit(_("unknown wanted status at line %d: 
%.250s"),lno,selvb.buf);
-    pkg= findpackage(namevb.buf);
+    pkg = pkg_db_find(namevb.buf);
     pkg->want= nvp->value;
     if (c == EOF) break;
     lno++;
@@ -150,12 +150,12 @@ void clearselections(const char *const *argv)
 
   modstatdb_init(admindir, msdbrw_write);
 
-  it = iterpkgstart();
-  while ((pkg = iterpkgnext(it))) {
+  it = pkg_db_iter_new();
+  while ((pkg = pkg_db_iter_next(it))) {
     if (!pkg->installed.essential)
       pkg->want = want_deinstall;
   }
-  iterpkgend(it);
+  pkg_db_iter_free(it);
 
   modstatdb_shutdown();
 }
diff --git a/src/trigproc.c b/src/trigproc.c
index acf8d08..74e36a9 100644
--- a/src/trigproc.c
+++ b/src/trigproc.c
@@ -178,8 +178,8 @@ check_trigger_cycle(struct pkginfo *processing_now)
        tcn->pkgs = NULL;
        tcn->then_processed = processing_now;
 
-       it = iterpkgstart();
-       while ((pkg = iterpkgnext(it))) {
+       it = pkg_db_iter_new();
+       while ((pkg = pkg_db_iter_next(it))) {
                if (!pkg->trigpend_head)
                        continue;
                tcpp = nfmalloc(sizeof(*tcpp));
@@ -188,7 +188,7 @@ check_trigger_cycle(struct pkginfo *processing_now)
                tcpp->next = tcn->pkgs;
                tcn->pkgs = tcpp;
        }
-       iterpkgend(it);
+       pkg_db_iter_free(it);
        if (!hare) {
                debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s first",
                      processing_now->name);
@@ -368,9 +368,8 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
        struct pkgiterator *it;
        struct pkginfo *pkg;
 
-       it = iterpkgstart();
-
-       while ((pkg = iterpkgnext(it))) {
+       it = pkg_db_iter_new();
+       while ((pkg = pkg_db_iter_next(it))) {
                if (pkg->status <= stat_halfinstalled)
                        continue;
                debug(dbg_triggersdetail, "trig_transitional_activate %s %s",
@@ -381,7 +380,8 @@ trig_transitional_activate(enum modstatdb_rw cstatus)
                              transitional_interest_callback :
                              transitional_interest_callback_ro, NULL, pkg);
        }
-       iterpkgend(it);
+       pkg_db_iter_free(it);
+
        if (cstatus >= msdbrw_write) {
                modstatdb_checkpoint();
                trig_file_interests_save();

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to