Browse Source

Move enum definitions out of structs

This untangles the types, and makes it possible to use functions that
use such enums as arguments from C++ code, as otherwise the enum would
need to be declared within the struct namespace.
Guillem Jover 12 years ago
parent
commit
c7ad73d0a9
11 changed files with 216 additions and 166 deletions
  1. 38 25
      dselect/pkgcmds.cc
  2. 18 17
      dselect/pkgdepcon.cc
  3. 33 32
      dselect/pkglist.cc
  4. 10 9
      dselect/pkglist.h
  5. 4 1
      dselect/pkgsublist.cc
  6. 6 5
      dselect/pkgtop.cc
  7. 49 33
      lib/dpkg/dpkg-db.h
  8. 8 6
      lib/dpkg/error.h
  9. 12 10
      lib/dpkg/pkg-spec.h
  10. 22 20
      src/filesdb.h
  11. 16 8
      src/main.h

+ 38 - 25
dselect/pkgcmds.cc

@@ -3,6 +3,7 @@
  * pkgcmds.cc - package list keyboard commands
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * 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
@@ -46,9 +47,9 @@ packagelist::affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith) {
   default:
     internerr("unknown statsortorder %d", statsortorder);
   }
-  if (comparewith->priority != pkginfo::pri_unset &&
+  if (comparewith->priority != pri_unset &&
       (comparewith->priority != pkg->priority ||
-       (comparewith->priority == pkginfo::pri_other &&
+       (comparewith->priority == pri_other &&
         strcasecmp(comparewith->otherpriority, pkg->otherpriority))))
     return false;
   if (comparewith->section &&
@@ -87,18 +88,24 @@ void packagelist::movecursorafter(int ncursor) {
   refreshlist(); redrawthisstate();
 }
 
-pkginfo::pkgwant packagelist::reallywant(pkginfo::pkgwant nwarg,
-                                         struct perpackagestate *pkgstate) {
-  if (nwarg != pkginfo::want_sentinel) return nwarg;
-  pkginfo::pkgstatus status= pkgstate->pkg->status;
-  if (status == pkginfo::stat_notinstalled) return pkginfo::want_purge;
-  if (status == pkginfo::stat_configfiles) return pkginfo::want_deinstall;
-  return pkginfo::want_install;
+pkgwant
+packagelist::reallywant(pkgwant nwarg, struct perpackagestate *pkgstate)
+{
+  if (nwarg != want_sentinel)
+    return nwarg;
+  pkgstatus status = pkgstate->pkg->status;
+  if (status == stat_notinstalled)
+    return want_purge;
+  if (status == stat_configfiles)
+    return want_deinstall;
+  return want_install;
 }
 
-void packagelist::setwant(pkginfo::pkgwant nwarg) {
+void
+packagelist::setwant(pkgwant nwarg)
+{
   int index, top, bot;
-  pkginfo::pkgwant nw;
+  pkgwant nw;
 
   if (modstatdb_get_status() == msdbrw_readonly) {
     beep();
@@ -120,8 +127,8 @@ void packagelist::setwant(pkginfo::pkgwant nwarg) {
         continue;
       nw= reallywant(nwarg,table[index]);
       if (table[index]->selected == nw ||
-          (table[index]->selected == pkginfo::want_purge &&
-           nw == pkginfo::want_deinstall))
+          (table[index]->selected == want_purge &&
+           nw == want_deinstall))
         continue;
       sub->add(table[index]->pkg,nw);
     }
@@ -137,24 +144,30 @@ bool manual_install = false;
 
 void packagelist::kd_select()   {
 	manual_install = true;
-	setwant(pkginfo::want_install);
+	setwant(want_install);
 	manual_install = false;
 }
-void packagelist::kd_hold()     { setwant(pkginfo::want_hold);      }
-void packagelist::kd_deselect() { setwant(pkginfo::want_deinstall); }
-void packagelist::kd_unhold()   { setwant(pkginfo::want_sentinel);  }
-void packagelist::kd_purge()    { setwant(pkginfo::want_purge);     }
+void packagelist::kd_hold()     { setwant(want_hold);      }
+void packagelist::kd_deselect() { setwant(want_deinstall); }
+void packagelist::kd_unhold()   { setwant(want_sentinel);  }
+void packagelist::kd_purge()    { setwant(want_purge);     }
 
-int would_like_to_install(pkginfo::pkgwant wantvalue, pkginfo *pkg) {
+int
+would_like_to_install(pkgwant wantvalue, pkginfo *pkg)
+{
   /* Returns: 1 for yes, 0 for no, -1 for if they want to preserve an error condition. */
   debug(dbg_general, "would_like_to_install(%d, %s) status %d",
         wantvalue, pkg_name(pkg, pnaw_always), pkg->status);
 
-  if (wantvalue == pkginfo::want_install) return 1;
-  if (wantvalue != pkginfo::want_hold) return 0;
-  if (pkg->status == pkginfo::stat_installed) return 1;
-  if (pkg->status == pkginfo::stat_notinstalled ||
-      pkg->status == pkginfo::stat_configfiles) return 0;
+  if (wantvalue == want_install)
+    return 1;
+  if (wantvalue != want_hold)
+    return 0;
+  if (pkg->status == stat_installed)
+    return 1;
+  if (pkg->status == stat_notinstalled ||
+      pkg->status == stat_configfiles)
+    return 0;
   return -1;
 }
 
@@ -280,7 +293,7 @@ packagelist::kd_revertinstalled()
 
   for (i = 0; i < nitems; i++) {
     if (table[i]->pkg->set->name)
-      table[i]->selected = reallywant(pkginfo::want_sentinel, table[i]);
+      table[i]->selected = reallywant(want_sentinel, table[i]);
     ldrawnstart = ldrawnend = -1;
   }
 

+ 18 - 17
dselect/pkgdepcon.cc

@@ -3,6 +3,7 @@
  * pkgdepcon.cc - dependency and conflict resolution
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * 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
@@ -35,11 +36,11 @@ bool
 packagelist::useavailable(pkginfo *pkg)
 {
   if (pkg->clientdata &&
-      pkg->clientdata->selected == pkginfo::want_install &&
+      pkg->clientdata->selected == want_install &&
       pkg_is_informative(pkg, &pkg->available) &&
-      (!(pkg->status == pkginfo::stat_installed ||
-         pkg->status == pkginfo::stat_triggersawaited ||
-         pkg->status == pkginfo::stat_triggerspending) ||
+      (!(pkg->status == stat_installed ||
+         pkg->status == stat_triggersawaited ||
+         pkg->status == stat_triggerspending) ||
        dpkg_version_compare(&pkg->available.version,
                             &pkg->installed.version) > 0))
     return true;
@@ -185,9 +186,9 @@ packagelist::deselect_one_of(pkginfo *per, pkginfo *ped, dependency *dep)
   perpackagestate *best;
 
   // Try not keep packages needing reinstallation.
-  if (per->eflag & pkginfo::eflag_reinstreq)
+  if (per->eflag & eflag_reinstreq)
     best = ed;
-  else if (ped->eflag & pkginfo::eflag_reinstreq)
+  else if (ped->eflag & eflag_reinstreq)
     best = er;
   else if (er->spriority < ed->spriority) best= er; // We'd rather change the
   else if (er->spriority > ed->spriority) best= ed; // one with the lowest priority.
@@ -203,8 +204,8 @@ packagelist::deselect_one_of(pkginfo *per, pkginfo *ped, dependency *dep)
 
   if (best->spriority >= sp_deselecting) return 0;
   best->suggested=
-    best->pkg->status == pkginfo::stat_notinstalled
-      ? pkginfo::want_purge : pkginfo::want_deinstall; // FIXME: configurable.
+    best->pkg->status == stat_notinstalled
+      ? want_purge : want_deinstall; // FIXME: configurable.
   best->selected= best->suggested;
   best->spriority= sp_deselecting;
 
@@ -311,7 +312,7 @@ int packagelist::resolvedepcon(dependency *depends) {
     /* Always select depends. Only select recommends if we got here because
      * of a manually-initiated install request. */
     if (depends->type != dep_recommends || manual_install) {
-      best->selected= best->suggested= pkginfo::want_install;
+      best->selected = best->suggested = want_install;
       best->spriority= sp_selecting;
     }
     return rc ? 2 : 0;
@@ -327,8 +328,8 @@ int packagelist::resolvedepcon(dependency *depends) {
     /* Always remove depends, but never remove recommends. */
     if (depends->type != dep_recommends) {
       best->selected= best->suggested=
-        best->pkg->status == pkginfo::stat_notinstalled
-          ? pkginfo::want_purge : pkginfo::want_deinstall; // FIXME: configurable
+        best->pkg->status == stat_notinstalled
+          ? want_purge : want_deinstall; // FIXME: configurable
       best->spriority= sp_deselecting;
     }
     return rc ? 2 : 0;
@@ -383,7 +384,7 @@ packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade)
   // ‘satisfied’ here for Conflicts and Breaks means that the
   //  restriction is violated ie that the target package is wanted
   int would;
-  pkginfo::pkgwant want= pkginfo::want_purge;
+  pkgwant want = want_purge;
 
   if (possi->ed->pkg.clientdata) {
     want = possi->ed->pkg.clientdata->selected;
@@ -400,12 +401,12 @@ packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade)
     // been specified, in which case we don't need to look at the rest
     // anyway.
     if (useavailable(&possi->ed->pkg)) {
-      assert(want == pkginfo::want_install);
+      assert(want == want_install);
       return versionsatisfied(&possi->ed->pkg.available, possi);
     } else {
       if (versionsatisfied(&possi->ed->pkg.installed, possi))
         return true;
-      if (want == pkginfo::want_hold && fixbyupgrade && !*fixbyupgrade &&
+      if (want == want_hold && fixbyupgrade && !*fixbyupgrade &&
           versionsatisfied(&possi->ed->pkg.available, possi) &&
           dpkg_version_compare(&possi->ed->pkg.available.version,
                                &possi->ed->pkg.installed.version) > 1)
@@ -442,9 +443,9 @@ packagelist::deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade)
     if (useavailable(provider->up->up))
       return true;
     if (fixbyupgrade && !*fixbyupgrade &&
-        (!(provider->up->up->status == pkginfo::stat_installed ||
-           provider->up->up->status == pkginfo::stat_triggerspending ||
-           provider->up->up->status == pkginfo::stat_triggersawaited) ||
+        (!(provider->up->up->status == stat_installed ||
+           provider->up->up->status == stat_triggerspending ||
+           provider->up->up->status == stat_triggersawaited) ||
          dpkg_version_compare(&provider->up->up->available.version,
                               &provider->up->up->installed.version) > 1))
       *fixbyupgrade = provider->up->up->clientdata;

+ 33 - 32
dselect/pkglist.cc

@@ -4,6 +4,7 @@
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2001 Wichert Akkerman <wakkerma@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
@@ -65,7 +66,7 @@ int packagelist::compareentries(const struct perpackagestate *a,
     strcasecmp(asection,bsection);
   int c_priority=
     a->pkg->priority - b->pkg->priority;
-  if (!c_priority && a->pkg->priority == pkginfo::pri_other)
+  if (!c_priority && a->pkg->priority == pri_other)
     c_priority= strcasecmp(a->pkg->otherpriority, b->pkg->otherpriority);
   int c_name=
     a->pkg->set->name && b->pkg->set->name ?
@@ -109,7 +110,7 @@ void packagelist::discardheadings() {
 
 void packagelist::addheading(enum ssavailval ssavail,
                              enum ssstateval ssstate,
-                             pkginfo::pkgpriority priority,
+                             pkgpriority priority,
                              const char *otherpriority,
                              const char *section) {
   assert(nitems <= nallocated);
@@ -182,28 +183,28 @@ void packagelist::ensurestatsortinfo() {
             this, index, pkg_name(table[index]->pkg, pnaw_always));
       pkg= table[index]->pkg;
       switch (pkg->status) {
-      case pkginfo::stat_unpacked:
-      case pkginfo::stat_halfconfigured:
-      case pkginfo::stat_halfinstalled:
-      case pkginfo::stat_triggersawaited:
-      case pkginfo::stat_triggerspending:
+      case stat_unpacked:
+      case stat_halfconfigured:
+      case stat_halfinstalled:
+      case stat_triggersawaited:
+      case stat_triggerspending:
         table[index]->ssavail= ssa_broken;
         break;
-      case pkginfo::stat_notinstalled:
-      case pkginfo::stat_configfiles:
+      case stat_notinstalled:
+      case stat_configfiles:
         if (!dpkg_version_is_informative(&pkg->available.version)) {
           table[index]->ssavail= ssa_notinst_gone;
 // FIXME: Disable for now as a workaround, until dselect knows how to properly
 //        store seen packages.
 #if 0
-        } else if (table[index]->original == pkginfo::want_unknown) {
+        } else if (table[index]->original == want_unknown) {
           table[index]->ssavail= ssa_notinst_unseen;
 #endif
         } else {
           table[index]->ssavail= ssa_notinst_seen;
         }
         break;
-      case pkginfo::stat_installed:
+      case stat_installed:
         veri= &table[index]->pkg->installed.version;
         vera= &table[index]->pkg->available.version;
         if (!dpkg_version_is_informative(vera)) {
@@ -231,20 +232,20 @@ void packagelist::ensurestatsortinfo() {
       debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s",
             this, index, pkg_name(table[index]->pkg, pnaw_always));
       switch (table[index]->pkg->status) {
-      case pkginfo::stat_unpacked:
-      case pkginfo::stat_halfconfigured:
-      case pkginfo::stat_halfinstalled:
-      case pkginfo::stat_triggersawaited:
-      case pkginfo::stat_triggerspending:
+      case stat_unpacked:
+      case stat_halfconfigured:
+      case stat_halfinstalled:
+      case stat_triggersawaited:
+      case stat_triggerspending:
         table[index]->ssstate= sss_broken;
         break;
-      case pkginfo::stat_notinstalled:
+      case stat_notinstalled:
         table[index]->ssstate= sss_notinstalled;
         break;
-      case pkginfo::stat_configfiles:
+      case stat_configfiles:
         table[index]->ssstate= sss_configfiles;
         break;
-      case pkginfo::stat_installed:
+      case stat_installed:
         table[index]->ssstate= sss_installed;
         break;
       default:
@@ -272,7 +273,7 @@ void packagelist::sortmakeheads() {
         this, sortorder, statsortorder);
 
   int nrealitems= nitems;
-  addheading(ssa_none, sss_none, pkginfo::pri_unset, nullptr, nullptr);
+  addheading(ssa_none, sss_none, pri_unset, nullptr, nullptr);
 
   assert(sortorder != so_unsorted);
   if (sortorder == so_alpha && statsortorder == sso_unsorted) { sortinplace(); return; }
@@ -307,7 +308,7 @@ void packagelist::sortmakeheads() {
 
     int prioritydiff= (!lastpkg ||
                        thispkg->priority != lastpkg->priority ||
-                       (thispkg->priority == pkginfo::pri_other &&
+                       (thispkg->priority == pri_other &&
                         strcasecmp(thispkg->otherpriority,lastpkg->otherpriority)));
     int sectiondiff= (!lastpkg ||
                       strcasecmp(thispkg->section ? thispkg->section : "",
@@ -320,7 +321,7 @@ void packagelist::sortmakeheads() {
           thispkg->clientdata->ssavail, thispkg->clientdata->ssstate,
           ssdiff ? "*diff" : "same",
           thispkg->priority,
-          thispkg->priority != pkginfo::pri_other ? "<none>" :
+          thispkg->priority != pri_other ? "<none>" :
           thispkg->otherpriority ? thispkg->otherpriority : "<null>",
           prioritydiff ? "*diff*" : "same",
           thispkg->section ? thispkg->section : "<null>",
@@ -328,11 +329,11 @@ void packagelist::sortmakeheads() {
 
     if (ssdiff)
       addheading(ssavail,ssstate,
-                 pkginfo::pri_unset, nullptr, nullptr);
+                 pri_unset, nullptr, nullptr);
 
     if (sortorder == so_section && sectiondiff)
       addheading(ssavail,ssstate,
-                 pkginfo::pri_unset, nullptr,
+                 pri_unset, nullptr,
                  thispkg->section ? thispkg->section : "");
 
     if (sortorder == so_priority && prioritydiff)
@@ -391,20 +392,20 @@ packagelist::packagelist(keybindings *kb) : baselist(kb) {
   while ((pkg = pkg_db_iter_next_pkg(iter))) {
     struct perpackagestate *state= &datatable[nitems];
     state->pkg= pkg;
-    if (pkg->status == pkginfo::stat_notinstalled &&
+    if (pkg->status == stat_notinstalled &&
         !pkg->files &&
-        pkg->want != pkginfo::want_install) {
+        pkg->want != want_install) {
       pkg->clientdata = nullptr;
       continue;
     }
     // treat all unknown packages as already seen
-    state->direct= state->original= (pkg->want == pkginfo::want_unknown ? pkginfo::want_purge : pkg->want);
+    state->direct = state->original = (pkg->want == want_unknown ? want_purge : pkg->want);
     if (modstatdb_get_status() == msdbrw_write &&
-        state->original == pkginfo::want_unknown) {
+        state->original == want_unknown) {
       state->suggested=
-        pkg->status == pkginfo::stat_installed ||
-          pkg->priority <= pkginfo::pri_standard /* FIXME: configurable */
-            ? pkginfo::want_install : pkginfo::want_purge;
+        pkg->status == stat_installed ||
+          pkg->priority <= pri_standard /* FIXME: configurable */
+            ? want_install : want_purge;
       state->spriority= sp_inherit;
     } else {
       state->suggested= state->original;
@@ -459,7 +460,7 @@ perpackagestate::free(bool recursive)
       } else {
         assert(!recursive);
         if (pkg->want != selected &&
-            !(pkg->want == pkginfo::want_unknown && selected == pkginfo::want_purge)) {
+            !(pkg->want == want_unknown && selected == want_purge)) {
           pkg->want= selected;
         }
         pkg->clientdata = nullptr;

+ 10 - 9
dselect/pkglist.h

@@ -4,6 +4,7 @@
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2001 Wichert Akkerman <wakkerma@debian.org>
+ * Copyright © 2007-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
@@ -70,10 +71,10 @@ struct perpackagestate {
    * uprec is used when constructing the list initially and when tearing it
    * down and should not otherwise be used; other fields are undefined.
    */
-  pkginfo::pkgwant original;         // set by caller
-  pkginfo::pkgwant direct;           // set by caller
-  pkginfo::pkgwant suggested;        // set by caller, modified by resolvesuggest
-  pkginfo::pkgwant selected;         // not set by caller, will be set by packagelist
+  pkgwant original;                  // set by caller
+  pkgwant direct;                    // set by caller
+  pkgwant suggested;                 // set by caller, modified by resolvesuggest
+  pkgwant selected;                  // not set by caller, will be set by packagelist
   selpriority spriority;             // monotonically increases (used by sublists)
   showpriority dpriority;            // monotonically increases (used by sublists)
   struct perpackagestate *uprec;     // 0 if this is not part of a recursive list
@@ -154,7 +155,7 @@ protected:
   void redraw1package(int index, int selected);
   int compareentries(const struct perpackagestate *a, const struct perpackagestate *b);
   friend int qsort_compareentries(const void *a, const void *b);
-  pkginfo::pkgwant reallywant(pkginfo::pkgwant, struct perpackagestate*);
+  pkgwant reallywant(pkgwant, struct perpackagestate *);
   int describemany(char buf[], const char *prioritystring, const char *section,
                    const struct perpackagestate *pps);
   bool deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade);
@@ -169,11 +170,11 @@ protected:
   // To do with building the list, with heading lines in it
   void discardheadings();
   void addheading(enum ssavailval, enum ssstateval,
-                  pkginfo::pkgpriority, const char*, const char *section);
+                  pkgpriority, const char *, const char *section);
   void sortinplace();
   bool affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith);
   void affectedrange(int *startp, int *endp);
-  void setwant(pkginfo::pkgwant nw);
+  void setwant(pkgwant nw);
   void sethold(int hold);
 
  public:
@@ -202,7 +203,7 @@ protected:
   packagelist(keybindings *kb, pkginfo **pkgltab); // recursive
   void add(pkginfo **arry) { while (*arry) add(*arry++); }
   void add(pkginfo*);
-  void add(pkginfo*, pkginfo::pkgwant);
+  void add(pkginfo *, pkgwant);
   void add(pkginfo*, const char *extrainfo, showpriority displayimportance);
   bool add(dependency *, showpriority displayimportance);
   void addunavailable(deppossi*);
@@ -217,7 +218,7 @@ protected:
 
 void repeatedlydisplay(packagelist *sub, showpriority,
                        packagelist *unredisplay = nullptr);
-int would_like_to_install(pkginfo::pkgwant, pkginfo *pkg);
+int would_like_to_install(pkgwant, pkginfo *pkg);
 
 extern const char *const wantstrings[];
 extern const char *const eflagstrings[];

+ 4 - 1
dselect/pkgsublist.cc

@@ -3,6 +3,7 @@
  * pkgsublist.cc - status modification and recursive package list handling
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2007-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
@@ -53,7 +54,9 @@ void packagelist::add(pkginfo *pkg) {
   nitems++;
 }
 
-void packagelist::add(pkginfo *pkg, pkginfo::pkgwant nw) {
+void
+packagelist::add(pkginfo *pkg, pkgwant nw)
+{
   debug(dbg_general, "packagelist[%p]::add(pkginfo %s, %s)",
         this, pkg_name(pkg, pnaw_always), wantstrings[nw]);
   add(pkg);  if (!pkg->clientdata) return;

+ 6 - 5
dselect/pkgtop.cc

@@ -3,6 +3,7 @@
  * pkgtop.cc - handles (re)draw of package list windows colheads, list, thisstate
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2007-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
@@ -36,12 +37,12 @@
 static const char *
 pkgprioritystring(const struct pkginfo *pkg)
 {
-  if (pkg->priority == pkginfo::pri_unset) {
+  if (pkg->priority == pri_unset) {
     return nullptr;
-  } else if (pkg->priority == pkginfo::pri_other) {
+  } else if (pkg->priority == pri_other) {
     return pkg->otherpriority;
   } else {
-    assert(pkg->priority <= pkginfo::pri_unknown);
+    assert(pkg->priority <= pri_unknown);
     return gettext(prioritystrings[pkg->priority]);
   }
 }
@@ -166,7 +167,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
 
       mvwprintw(listpad, screenline, priority_column - 1, " %-*.*s",
                 priority_width, priority_width,
-                pkg->priority == pkginfo::pri_other ? pkg->otherpriority :
+                pkg->priority == pri_other ? pkg->otherpriority :
                 gettext(prioritystrings[pkg->priority]));
     } else {
       mvwaddch(listpad, screenline, 0, eflagchars[pkg->eflag]);
@@ -182,7 +183,7 @@ void packagelist::redraw1itemsel(int index, int selected) {
 
       wmove(listpad, screenline, priority_column - 1);
       waddch(listpad, ' ');
-      if (pkg->priority == pkginfo::pri_other) {
+      if (pkg->priority == pri_other) {
         for (i=priority_width, p=pkg->otherpriority;
              i > 0 && *p;
              i--, p++)

+ 49 - 33
lib/dpkg/dpkg-db.h

@@ -92,6 +92,13 @@ struct filedetails {
   const char *md5sum;
 };
 
+enum pkgmultiarch {
+	multiarch_no,
+	multiarch_same,
+	multiarch_allowed,
+	multiarch_foreign,
+};
+
 /**
  * Node describing a binary package file.
  *
@@ -101,12 +108,7 @@ struct pkgbin {
   struct dependency *depends;
   /** The ‘essential’ flag, true = yes, false = no (absent). */
   bool essential;
-  enum pkgmultiarch {
-    multiarch_no,
-    multiarch_same,
-    multiarch_allowed,
-    multiarch_foreign,
-  } multiarch;
+  enum pkgmultiarch multiarch;
   const struct dpkg_arch *arch;
   /** The following is the "pkgname:archqual" cached string, if this was a
    * C++ class this member would be mutable. */
@@ -148,6 +150,43 @@ struct trigaw {
 /* Note: dselect and dpkg have different versions of this. */
 struct perpackagestate;
 
+enum pkgwant {
+	want_unknown,
+	want_install,
+	want_hold,
+	want_deinstall,
+	want_purge,
+	/** Not allowed except as special sentinel value in some places. */
+	want_sentinel,
+};
+
+enum pkgeflag {
+	eflag_ok		= 0,
+	eflag_reinstreq		= 1,
+};
+
+enum pkgstatus {
+	stat_notinstalled,
+	stat_configfiles,
+	stat_halfinstalled,
+	stat_unpacked,
+	stat_halfconfigured,
+	stat_triggersawaited,
+	stat_triggerspending,
+	stat_installed,
+};
+
+enum pkgpriority {
+	pri_required,
+	pri_important,
+	pri_standard,
+	pri_optional,
+	pri_extra,
+	pri_other,
+	pri_unknown,
+	pri_unset = -1,
+};
+
 /**
  * Node describing an architecture package instance.
  *
@@ -157,34 +196,11 @@ struct pkginfo {
   struct pkgset *set;
   struct pkginfo *arch_next;
 
-  enum pkgwant {
-    want_unknown, want_install, want_hold, want_deinstall, want_purge,
-    /** Not allowed except as special sentinel value in some places. */
-    want_sentinel,
-  } want;
+  enum pkgwant want;
   /** The error flag bitmask. */
-  enum pkgeflag {
-    eflag_ok		= 0,
-    eflag_reinstreq	= 1,
-  } eflag;
-  enum pkgstatus {
-    stat_notinstalled,
-    stat_configfiles,
-    stat_halfinstalled,
-    stat_unpacked,
-    stat_halfconfigured,
-    stat_triggersawaited,
-    stat_triggerspending,
-    stat_installed
-  } status;
-  enum pkgpriority {
-    pri_required,
-    pri_important,
-    pri_standard,
-    pri_optional,
-    pri_extra,
-    pri_other, pri_unknown, pri_unset=-1
-  } priority;
+  enum pkgeflag eflag;
+  enum pkgstatus status;
+  enum pkgpriority priority;
   const char *otherpriority;
   const char *section;
   struct dpkg_version configversion;

+ 8 - 6
lib/dpkg/error.h

@@ -2,7 +2,7 @@
  * libdpkg - Debian packaging suite library routines
  * error.h - error message reporting
  *
- * Copyright © 2011-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2011-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
@@ -31,12 +31,14 @@ DPKG_BEGIN_DECLS
  * @{
  */
 
+enum dpkg_msg_type {
+	DPKG_MSG_NONE,
+	DPKG_MSG_WARN,
+	DPKG_MSG_ERROR,
+};
+
 struct dpkg_error {
-	enum dpkg_msg_type {
-		DPKG_MSG_NONE,
-		DPKG_MSG_WARN,
-		DPKG_MSG_ERROR,
-	} type;
+	enum dpkg_msg_type type;
 
 	char *str;
 };

+ 12 - 10
lib/dpkg/pkg-spec.h

@@ -4,7 +4,7 @@
  *
  * Copyright © 2011 Linaro Limited
  * Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
- * Copyright © 2011-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2011-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
@@ -38,19 +38,21 @@ DPKG_BEGIN_DECLS
  * @{
  */
 
+enum pkg_spec_flags {
+	/** Recognize glob patterns. */
+	psf_patterns		= DPKG_BIT(0),
+
+	/* How to consider the lack of an arch qualifier. */
+	psf_arch_def_single	= DPKG_BIT(8),
+	psf_arch_def_wildcard	= DPKG_BIT(9),
+	psf_arch_def_mask	= 0xff00,
+};
+
 struct pkg_spec {
 	char *name;
 	const struct dpkg_arch *arch;
 
-	enum pkg_spec_flags {
-		/** Recognize glob patterns. */
-		psf_patterns		= DPKG_BIT(0),
-
-		/* How to consider the lack of an arch qualifier. */
-		psf_arch_def_single	= DPKG_BIT(8),
-		psf_arch_def_wildcard	= DPKG_BIT(9),
-		psf_arch_def_mask	= 0xff00,
-	} flags;
+	enum pkg_spec_flags flags;
 
 	/* Members below are private state. */
 

+ 22 - 20
src/filesdb.h

@@ -56,6 +56,27 @@ enum fnnflags {
     fnn_nonew			= DPKG_BIT(1),
 };
 
+enum filenamenode_flags {
+	/** In the newconffiles list. */
+	fnnf_new_conff			= DPKG_BIT(0),
+	/** In the new filesystem archive. */
+	fnnf_new_inarchive		= DPKG_BIT(1),
+	/** In the old package's conffiles list. */
+	fnnf_old_conff			= DPKG_BIT(2),
+	/** Obsolete conffile. */
+	fnnf_obs_conff			= DPKG_BIT(3),
+	/** Must remove from other packages' lists. */
+	fnnf_elide_other_lists		= DPKG_BIT(4),
+	/** >= 1 instance is a dir, cannot rename over. */
+	fnnf_no_atomic_overwrite	= DPKG_BIT(5),
+	/** New file has been placed on the disk. */
+	fnnf_placed_on_disk		= DPKG_BIT(6),
+	fnnf_deferred_fsync		= DPKG_BIT(7),
+	fnnf_deferred_rename		= DPKG_BIT(8),
+	/** Path being filtered. */
+	fnnf_filtered			= DPKG_BIT(9),
+};
+
 struct filenamenode {
   struct filenamenode *next;
   const char *name;
@@ -75,26 +96,7 @@ struct filenamenode {
    */
 
   /** Set to zero when a new node is created. */
-  enum filenamenode_flags {
-    /** In the newconffiles list. */
-    fnnf_new_conff		= DPKG_BIT(0),
-    /** In the new filesystem archive. */
-    fnnf_new_inarchive		= DPKG_BIT(1),
-    /** In the old package's conffiles list. */
-    fnnf_old_conff		= DPKG_BIT(2),
-    /** Obsolete conffile. */
-    fnnf_obs_conff		= DPKG_BIT(3),
-    /** Must remove from other packages' lists. */
-    fnnf_elide_other_lists	= DPKG_BIT(4),
-    /** >= 1 instance is a dir, cannot rename over. */
-    fnnf_no_atomic_overwrite	= DPKG_BIT(5),
-    /** New file has been placed on the disk. */
-    fnnf_placed_on_disk		= DPKG_BIT(6),
-    fnnf_deferred_fsync		= DPKG_BIT(7),
-    fnnf_deferred_rename	= DPKG_BIT(8),
-    /** Path being filtered. */
-    fnnf_filtered		= DPKG_BIT(9),
-  } flags;
+  enum filenamenode_flags flags;
 
   /** Valid iff this namenode is in the newconffiles list. */
   const char *oldhash;

+ 16 - 8
src/main.h

@@ -29,17 +29,25 @@
 struct fileinlist;
 struct filenamenode;
 
+enum istobes {
+	itb_normal,
+	itb_remove,
+	itb_installnew,
+	itb_deconfigure,
+	itb_preinstall
+};
+
+enum pkg_cycle_color {
+	white,
+	gray,
+	black,
+};
+
 struct perpackagestate {
-  enum istobes {
-    itb_normal, itb_remove, itb_installnew, itb_deconfigure, itb_preinstall
-  } istobe;
+  enum istobe istobe;
 
   /** Used during cycle detection. */
-  enum pkg_cycle_color {
-    white,
-    gray,
-    black,
-  } color;
+  enum pkg_cycle_color color;
 
   /**
    * filelistvalid  files  Meaning