Kaynağa Gözat

Merge branch 'master' of ssh://git.debian.org/git/dpkg/dpkg

Christian PERRIER 14 yıl önce
ebeveyn
işleme
c5b7a16749
65 değiştirilmiş dosya ile 552 ekleme ve 222 silme
  1. 2 3
      doc/Doxyfile.in
  2. 3 3
      dpkg-deb/extract.c
  3. 1 1
      dpkg-deb/info.c
  4. 1 1
      dpkg-split/queue.c
  5. 1 1
      dpkg-split/split.c
  6. 1 1
      dselect/basecmds.cc
  7. 2 2
      dselect/bindings.cc
  8. 1 1
      dselect/pkgcmds.cc
  9. 8 0
      lib/dpkg/ar.h
  10. 8 0
      lib/dpkg/arch.h
  11. 8 0
      lib/dpkg/atomic-file.h
  12. 8 0
      lib/dpkg/buffer.h
  13. 8 0
      lib/dpkg/command.h
  14. 6 0
      lib/dpkg/compress.c
  15. 7 3
      lib/dpkg/compress.h
  16. 8 0
      lib/dpkg/debug.h
  17. 8 0
      lib/dpkg/dir.h
  18. 9 5
      lib/dpkg/dpkg-db.h
  19. 17 0
      lib/dpkg/dpkg.h
  20. 81 77
      lib/dpkg/dump.c
  21. 8 0
      lib/dpkg/ehandle.h
  22. 8 0
      lib/dpkg/error.h
  23. 8 0
      lib/dpkg/fdio.h
  24. 52 48
      lib/dpkg/fields.c
  25. 8 0
      lib/dpkg/file.h
  26. 8 0
      lib/dpkg/glob.h
  27. 8 0
      lib/dpkg/i18n.h
  28. 13 0
      lib/dpkg/macros.h
  29. 8 0
      lib/dpkg/namevalue.h
  30. 8 5
      lib/dpkg/options.c
  31. 8 0
      lib/dpkg/options.h
  32. 4 4
      lib/dpkg/parse.c
  33. 10 2
      lib/dpkg/parsedump.h
  34. 8 0
      lib/dpkg/path.h
  35. 8 0
      lib/dpkg/pkg-array.h
  36. 27 26
      lib/dpkg/pkg-db.c
  37. 3 3
      lib/dpkg/pkg-format.c
  38. 9 1
      lib/dpkg/pkg-format.h
  39. 8 0
      lib/dpkg/pkg-list.h
  40. 8 0
      lib/dpkg/pkg-queue.h
  41. 8 0
      lib/dpkg/pkg-show.h
  42. 8 0
      lib/dpkg/pkg-spec.h
  43. 8 0
      lib/dpkg/pkg.h
  44. 8 0
      lib/dpkg/progname.h
  45. 8 0
      lib/dpkg/progress.h
  46. 8 0
      lib/dpkg/string.h
  47. 8 0
      lib/dpkg/subproc.h
  48. 8 0
      lib/dpkg/tarfn.h
  49. 8 0
      lib/dpkg/test.h
  50. 8 0
      lib/dpkg/trigdeferred.h
  51. 5 5
      lib/dpkg/triglib.c
  52. 8 0
      lib/dpkg/triglib.h
  53. 1 1
      lib/dpkg/trignote.c
  54. 8 0
      lib/dpkg/varbuf.h
  55. 8 0
      lib/dpkg/version.h
  56. 9 9
      src/archives.c
  57. 5 5
      src/configure.c
  58. 2 1
      src/filesdb.c
  59. 2 2
      src/help.c
  60. 3 2
      src/main.c
  61. 2 2
      src/processarc.c
  62. 5 4
      src/remove.c
  63. 2 2
      src/trigcmd.c
  64. 1 1
      src/trigproc.c
  65. 1 1
      utils/start-stop-daemon.c

+ 2 - 3
doc/Doxyfile.in

@@ -591,8 +591,7 @@ INPUT_ENCODING         = UTF-8
 # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
 
 FILE_PATTERNS          = *.c \
-                         *.h \
-                         *.l
+                         *.h
 
 # The RECURSIVE tag can be used to turn specify whether or not subdirectories
 # should be searched for input files as well. Possible values are YES and NO.
@@ -604,7 +603,7 @@ RECURSIVE              = YES
 # excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
-EXCLUDE                = lib/dpkg/trigdeferred.c
+EXCLUDE                =
 
 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or
 # directories that are symbolic links (a Unix filesystem feature) are excluded

+ 3 - 3
dpkg-deb/extract.c

@@ -130,7 +130,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
   if (r < 0)
     read_fail(r, debar, _("archive magic version number"));
 
-  if (!strcmp(versionbuf, DPKG_AR_MAGIC)) {
+  if (strcmp(versionbuf, DPKG_AR_MAGIC) == 0) {
     oldformat = false;
 
     ctrllennum= 0;
@@ -216,7 +216,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
              versionbuf, (intmax_t)stab.st_size, (intmax_t)ctrllennum);
       m_output(stdout, _("<standard output>"));
     }
-  } else if (!strncmp(versionbuf,"0.93",4) &&
+  } else if (strncmp(versionbuf, "0.93", 4) == 0 &&
              sscanf(versionbuf,"%f%c%d",&versionnum,&nlc,&dummy) == 2 &&
              nlc == '\n') {
     char ctrllenbuf[40];
@@ -250,7 +250,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
       m_output(stdout, _("<standard output>"));
     }
   } else {
-    if (!strncmp(versionbuf,"!<arch>",7)) {
+    if (strncmp(versionbuf, "!<arch>", 7) == 0) {
       fprintf(stderr,
               _("dpkg-deb: file looks like it might be an archive which has been\n"
                 "dpkg-deb:    corrupted by being downloaded in ASCII mode\n"));

+ 1 - 1
dpkg-deb/info.c

@@ -240,7 +240,7 @@ info_field(const char *debar, const char *dir, const char *const *fields,
       *pf = '\0';
       doing= fnl >= MAXFIELDNAME || c=='\n' || c==EOF;
       for (fp=fields; !doing && *fp; fp++)
-        if (!strcasecmp(*fp, fieldname))
+        if (strcasecmp(*fp, fieldname) == 0)
           doing = true;
       if (showfieldname) {
         if (doing)

+ 1 - 1
dpkg-split/queue.c

@@ -115,7 +115,7 @@ static bool
 partmatches(struct partinfo *pi, struct partinfo *refi)
 {
   return (pi->md5sum &&
-          !strcmp(pi->md5sum,refi->md5sum) &&
+          strcmp(pi->md5sum, refi->md5sum) == 0 &&
           pi->maxpartn == refi->maxpartn &&
           pi->maxpartlen == refi->maxpartlen);
 }

+ 1 - 1
dpkg-split/split.c

@@ -257,7 +257,7 @@ do_split(const char *const *argv)
 		l = strlen(sourcefile);
 		palloc = nfmalloc(l + 1);
 		strcpy(palloc, sourcefile);
-		if (!strcmp(palloc + l - (sizeof(DEBEXT) - 1), DEBEXT)) {
+		if (strcmp(palloc + l - (sizeof(DEBEXT) - 1), DEBEXT) == 0) {
 			l -= (sizeof(DEBEXT) - 1);
 			palloc[l] = '\0';
 		}

+ 1 - 1
dselect/basecmds.cc

@@ -112,7 +112,7 @@ baselist::matchsearch(int index)
   searchlen=strlen(searchstring);
   lendiff = strlen(name) - searchlen;
   for (i=0; i<=lendiff; i++)
-    if (!strncasecmp(name + i, searchstring, searchlen))
+    if (strncasecmp(name + i, searchstring, searchlen) == 0)
       return true;
 
   return false;

+ 2 - 2
dselect/bindings.cc

@@ -97,7 +97,7 @@ const char **keybindings::describenext() {
   for (;;) {
     if (!iterate->action) return 0;
     for (count=0, search=bindings; search; search=search->next)
-      if (!strcmp(search->interp->action,iterate->action))
+      if (strcmp(search->interp->action, iterate->action) == 0)
         count++;
     if (count) break;
     iterate++;
@@ -105,7 +105,7 @@ const char **keybindings::describenext() {
   const char **retarray= new const char *[count+2];
   retarray[0]= iterate->desc;
   for (count=1, search=bindings; search; search=search->next)
-    if (!strcmp(search->interp->action,iterate->action))
+    if (strcmp(search->interp->action, iterate->action) == 0)
       retarray[count++]= key2name(search->key);
   retarray[count]= 0;
   iterate++;

+ 1 - 1
dselect/pkgcmds.cc

@@ -195,7 +195,7 @@ void packagelist::resortredisplay() {
     int index;
     for (index=0; index<nitems; index++) {
       if (table[index]->pkg->set->name &&
-          !strcasecmp(oldname, table[index]->pkg->set->name)) {
+          strcasecmp(oldname, table[index]->pkg->set->name) == 0) {
         newcursor= index;
         break;
       }

+ 8 - 0
lib/dpkg/ar.h

@@ -30,6 +30,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup ar Ar archive handling
+ * @ingroup dpkg-public
+ * @{
+ */
+
 #define DPKG_AR_MAGIC "!<arch>\n"
 
 void dpkg_ar_normalize_name(struct ar_hdr *arh);
@@ -44,6 +50,8 @@ void dpkg_ar_member_put_mem(const char *ar_name, int ar_fd, const char *name,
                             const void *data, size_t size);
 off_t dpkg_ar_member_get_size(const char *ar_name, struct ar_hdr *arh);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_AR_H */

+ 8 - 0
lib/dpkg/arch.h

@@ -28,6 +28,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup arch Architecture database
+ * @ingroup dpkg-public
+ * @{
+ */
+
 enum dpkg_arch_type {
 	arch_none,
 	arch_empty,
@@ -58,6 +64,8 @@ void dpkg_arch_save_list(void);
 
 void varbuf_add_archqual(struct varbuf *vb, const struct dpkg_arch *arch);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_ARCH_H */

+ 8 - 0
lib/dpkg/atomic-file.h

@@ -27,6 +27,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup atomic-file Atomic file operations
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 enum atomic_file_flags {
 	aff_backup = 01,
 };
@@ -47,6 +53,8 @@ void atomic_file_commit(struct atomic_file *file);
 void atomic_file_remove(struct atomic_file *file);
 void atomic_file_free(struct atomic_file *file);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_ATOMIC_FILE_H */

+ 8 - 0
lib/dpkg/buffer.h

@@ -30,6 +30,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup buffer Buffer I/O
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 #define DPKG_BUFFER_SIZE 4096
 
 #define BUFFER_WRITE_VBUF		1
@@ -90,6 +96,8 @@ off_t buffer_skip_Int(int I, int T, off_t limit, const char *desc_fmt, ...)
 	DPKG_ATTR_PRINTF(4);
 off_t buffer_filter(const void *buf, void *hash, int typeFilter, off_t length);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_BUFFER_H */

+ 8 - 0
lib/dpkg/command.h

@@ -25,6 +25,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup command Command execution
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 /**
  * Describe a command to execute.
  */
@@ -50,6 +56,8 @@ void command_exec(struct command *cmd) DPKG_ATTR_NORET;
 
 void command_shell(const char *cmd, const char *name);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_COMMAND_H */

+ 6 - 0
lib/dpkg/compress.c

@@ -132,6 +132,8 @@ static const struct compressor compressor_none = {
  * Gzip compressor.
  */
 
+#define GZIP		"gzip"
+
 static void
 fixup_gzip_params(struct compress_params *params)
 {
@@ -250,6 +252,8 @@ static const struct compressor compressor_gzip = {
  * Bzip2 compressor.
  */
 
+#define BZIP2		"bzip2"
+
 static void
 fixup_bzip2_params(struct compress_params *params)
 {
@@ -373,6 +377,8 @@ static const struct compressor compressor_bzip2 = {
  * Xz compressor.
  */
 
+#define XZ		"xz"
+
 static bool
 check_xz_params(struct compress_params *params, struct dpkg_error *err)
 {

+ 7 - 3
lib/dpkg/compress.h

@@ -29,9 +29,11 @@
 
 DPKG_BEGIN_DECLS
 
-#define GZIP		"gzip"
-#define XZ		"xz"
-#define BZIP2		"bzip2"
+/**
+ * @defgroup compress Compression
+ * @ingroup dpkg-internal
+ * @{
+ */
 
 enum compressor_type {
 	compressor_type_unknown = -1,
@@ -63,6 +65,8 @@ void compress_filter(struct compress_params *params, int fd_in, int fd_out,
                      const char *desc, ...)
                      DPKG_ATTR_PRINTF(4);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_COMPRESS_H */

+ 8 - 0
lib/dpkg/debug.h

@@ -28,6 +28,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup debug Debugging
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 enum debugflags {
 	dbg_general = 01,
 	dbg_scripts = 02,
@@ -49,6 +55,8 @@ void debug_set_mask(int mask);
 bool debug_has_flag(int flag);
 void debug(int flag, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_DEBUG_H */

+ 8 - 0
lib/dpkg/dir.h

@@ -27,10 +27,18 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup dir Directory handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 void dir_sync_path(const char *path);
 void dir_sync_path_parent(const char *path);
 void dir_sync_contents(const char *path);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_DIR_H */

+ 9 - 5
lib/dpkg/dpkg-db.h

@@ -35,6 +35,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup dpkg-db In-core package database management
+ * @ingroup dpkg-public
+ * @{
+ */
+
 enum deptype {
   dep_suggests,
   dep_recommends,
@@ -104,8 +110,6 @@ struct filedetails {
  * Node describing a binary package file.
  *
  * This structure holds information contained on each binary package.
- *
- * Note: Usually referred in the code as ‘pif’ for historical reasons.
  */
 struct pkgbin {
   struct dependency *depends;
@@ -162,8 +166,6 @@ struct perpackagestate;
  * Node describing an architecture package instance.
  *
  * This structure holds state information.
- *
- * Note: Usually referred in the code as pig.
  */
 struct pkginfo {
   struct pkgset *set;
@@ -271,7 +273,7 @@ void pkgset_blank(struct pkgset *set);
 int pkgset_installed_instances(struct pkgset *set);
 
 void pkg_blank(struct pkginfo *pp);
-void pkgbin_blank(struct pkgbin *pifp);
+void pkgbin_blank(struct pkgbin *pkgbin);
 bool pkg_is_informative(struct pkginfo *pkg, struct pkgbin *info);
 
 struct pkgset *pkg_db_find_set(const char *name);
@@ -405,6 +407,8 @@ char *nfstrsave(const char*);
 char *nfstrnsave(const char*, size_t);
 void nffreeall(void);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_DPKG_DB_H */

+ 17 - 0
lib/dpkg/dpkg.h

@@ -32,6 +32,23 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @mainpage libdpkg C API
+ *
+ * This is the documentation for the libdpkg C API. It is divided in an
+ * @ref dpkg-internal "internal API" and a @ref dpkg-public "public API".
+ * Applications closely tied to dpkg can make use of the internal API, the
+ * rest should only assume the availability of the public API.
+ *
+ * Applications need to define the LIBDPKG_VOLATILE_API macro to acknowledge
+ * that the API is to be considered volatile, please read doc/README.api for
+ * more information.
+ *
+ * @defgroup dpkg-internal Internal libdpkg C API
+ *
+ * @defgroup dpkg-public Public libdpkg C API
+ */
+
 #define MAXCONFFILENAME     1000
 #define MAXDIVERTFILENAME   1024
 #define MAXCONTROLFILENAME  100

+ 81 - 77
lib/dpkg/dump.c

@@ -47,63 +47,64 @@
 
 void
 w_name(struct varbuf *vb,
-       const struct pkginfo *pigp, const struct pkgbin *pifp,
+       const struct pkginfo *pkg, const struct pkgbin *pkgbin,
        enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  assert(pigp->set->name);
+  assert(pkg->set->name);
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Package: ");
-  varbuf_add_str(vb, pigp->set->name);
+  varbuf_add_str(vb, pkg->set->name);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
 
 void
 w_version(struct varbuf *vb,
-          const struct pkginfo *pigp, const struct pkgbin *pifp,
+          const struct pkginfo *pkg, const struct pkgbin *pkgbin,
           enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  if (!dpkg_version_is_informative(&pifp->version))
+  if (!dpkg_version_is_informative(&pkgbin->version))
     return;
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Version: ");
-  varbufversion(vb,&pifp->version,vdew_nonambig);
+  varbufversion(vb, &pkgbin->version, vdew_nonambig);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
 
 void
 w_configversion(struct varbuf *vb,
-                const struct pkginfo *pigp, const struct pkgbin *pifp,
+                const struct pkginfo *pkg, const struct pkgbin *pkgbin,
                 enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  if (pifp != &pigp->installed) return;
-  if (!dpkg_version_is_informative(&pigp->configversion))
+  if (pkgbin != &pkg->installed)
     return;
-  if (pigp->status == stat_installed ||
-      pigp->status == stat_notinstalled ||
-      pigp->status == stat_triggerspending)
+  if (!dpkg_version_is_informative(&pkg->configversion))
+    return;
+  if (pkg->status == stat_installed ||
+      pkg->status == stat_notinstalled ||
+      pkg->status == stat_triggerspending)
     return;
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Config-Version: ");
-  varbufversion(vb,&pigp->configversion,vdew_nonambig);
+  varbufversion(vb, &pkg->configversion, vdew_nonambig);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
 
 void
 w_null(struct varbuf *vb,
-       const struct pkginfo *pigp, const struct pkgbin *pifp,
+       const struct pkginfo *pkg, const struct pkgbin *pkgbin,
        enum fwriteflags flags, const struct fieldinfo *fip)
 {
 }
 
 void
 w_section(struct varbuf *vb,
-          const struct pkginfo *pigp, const struct pkgbin *pifp,
+          const struct pkginfo *pkg, const struct pkgbin *pkgbin,
           enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  const char *value= pigp->section;
+  const char *value = pkg->section;
   if (!value || !*value) return;
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Section: ");
@@ -114,10 +115,10 @@ w_section(struct varbuf *vb,
 
 void
 w_charfield(struct varbuf *vb,
-            const struct pkginfo *pigp, const struct pkgbin *pifp,
+            const struct pkginfo *pkg, const struct pkgbin *pkgbin,
             enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  const char *value = PKGPFIELD(pifp, fip->integer, const char *);
+  const char *value = PKGPFIELD(pkgbin, fip->integer, const char *);
   if (!value || !*value) return;
   if (flags&fw_printheader) {
     varbuf_add_str(vb, fip->name);
@@ -130,13 +131,14 @@ w_charfield(struct varbuf *vb,
 
 void
 w_filecharf(struct varbuf *vb,
-            const struct pkginfo *pigp, const struct pkgbin *pifp,
+            const struct pkginfo *pkg, const struct pkgbin *pkgbin,
             enum fwriteflags flags, const struct fieldinfo *fip)
 {
   struct filedetails *fdp;
 
-  if (pifp != &pigp->available) return;
-  fdp= pigp->files;
+  if (pkgbin != &pkg->available)
+    return;
+  fdp = pkg->files;
   if (!fdp || !FILEFFIELD(fdp,fip->integer,const char*)) return;
 
   if (flags&fw_printheader) {
@@ -156,10 +158,10 @@ w_filecharf(struct varbuf *vb,
 
 void
 w_booleandefno(struct varbuf *vb,
-               const struct pkginfo *pigp, const struct pkgbin *pifp,
+               const struct pkginfo *pkg, const struct pkgbin *pkgbin,
                enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  bool value = PKGPFIELD(pifp, fip->integer, bool);
+  bool value = PKGPFIELD(pkgbin, fip->integer, bool);
   if (!(flags&fw_printheader)) {
     varbuf_add_str(vb, value ? "yes" : "no");
     return;
@@ -172,10 +174,10 @@ w_booleandefno(struct varbuf *vb,
 
 void
 w_multiarch(struct varbuf *vb,
-            const struct pkginfo *pigp, const struct pkgbin *pifp,
+            const struct pkginfo *pkg, const struct pkgbin *pkgbin,
             enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  int value = PKGPFIELD(pifp, fip->integer, int);
+  int value = PKGPFIELD(pkgbin, fip->integer, int);
 
   if (!(flags & fw_printheader)) {
     varbuf_add_str(vb, multiarchinfos[value].name);
@@ -192,53 +194,55 @@ w_multiarch(struct varbuf *vb,
 
 void
 w_architecture(struct varbuf *vb,
-               const struct pkginfo *pigp, const struct pkgbin *pifp,
+               const struct pkginfo *pkg, const struct pkgbin *pkgbin,
                enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  if (!pifp->arch)
+  if (!pkgbin->arch)
     return;
-  if (pifp->arch->type == arch_none)
+  if (pkgbin->arch->type == arch_none)
     return;
-  if (pifp->arch->type == arch_empty)
+  if (pkgbin->arch->type == arch_empty)
     return;
 
   if (flags & fw_printheader) {
     varbuf_add_str(vb, fip->name);
     varbuf_add_str(vb, ": ");
   }
-  varbuf_add_str(vb, pifp->arch->name);
+  varbuf_add_str(vb, pkgbin->arch->name);
   if (flags & fw_printheader)
     varbuf_add_char(vb, '\n');
 }
 
 void
 w_priority(struct varbuf *vb,
-           const struct pkginfo *pigp, const struct pkgbin *pifp,
+           const struct pkginfo *pkg, const struct pkgbin *pkgbin,
            enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  if (pigp->priority == pri_unknown) return;
-  assert(pigp->priority <= pri_unknown);
+  if (pkg->priority == pri_unknown)
+    return;
+  assert(pkg->priority <= pri_unknown);
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Priority: ");
-  varbuf_add_str(vb, pigp->priority == pri_other ?
-                     pigp->otherpriority :
-                     priorityinfos[pigp->priority].name);
+  varbuf_add_str(vb, pkg->priority == pri_other ?
+                     pkg->otherpriority :
+                     priorityinfos[pkg->priority].name);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
 
 void
 w_status(struct varbuf *vb,
-         const struct pkginfo *pigp, const struct pkgbin *pifp,
+         const struct pkginfo *pkg, const struct pkgbin *pkgbin,
          enum fwriteflags flags, const struct fieldinfo *fip)
 {
-  if (pifp != &pigp->installed) return;
-  assert(pigp->want <= want_purge);
-  assert(pigp->eflag <= eflag_reinstreq);
+  if (pkgbin != &pkg->installed)
+    return;
+  assert(pkg->want <= want_purge);
+  assert(pkg->eflag <= eflag_reinstreq);
 
-#define PEND pigp->trigpend_head
-#define AW pigp->trigaw.head
-  switch (pigp->status) {
+#define PEND pkg->trigpend_head
+#define AW pkg->trigaw.head
+  switch (pkg->status) {
   case stat_notinstalled:
   case stat_configfiles:
     assert(!PEND);
@@ -261,18 +265,18 @@ w_status(struct varbuf *vb,
     assert(!AW);
     break;
   default:
-    internerr("unknown package status '%d'", pigp->status);
+    internerr("unknown package status '%d'", pkg->status);
   }
 #undef PEND
 #undef AW
 
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Status: ");
-  varbuf_add_str(vb, wantinfos[pigp->want].name);
+  varbuf_add_str(vb, wantinfos[pkg->want].name);
   varbuf_add_char(vb, ' ');
-  varbuf_add_str(vb, eflaginfos[pigp->eflag].name);
+  varbuf_add_str(vb, eflaginfos[pkg->eflag].name);
   varbuf_add_char(vb, ' ');
-  varbuf_add_str(vb, statusinfos[pigp->status].name);
+  varbuf_add_str(vb, statusinfos[pkg->status].name);
   if (flags&fw_printheader)
     varbuf_add_char(vb, '\n');
 }
@@ -319,7 +323,7 @@ void varbufdependency(struct varbuf *vb, struct dependency *dep) {
 
 void
 w_dependency(struct varbuf *vb,
-             const struct pkginfo *pigp, const struct pkgbin *pifp,
+             const struct pkginfo *pkg, const struct pkgbin *pkgbin,
              enum fwriteflags flags, const struct fieldinfo *fip)
 {
   char fnbuf[50];
@@ -332,9 +336,9 @@ w_dependency(struct varbuf *vb,
     fnbuf[0] = '\0';
 
   depdel= fnbuf;
-  for (dyp= pifp->depends; dyp; dyp= dyp->next) {
+  for (dyp = pkgbin->depends; dyp; dyp = dyp->next) {
     if (dyp->type != fip->integer) continue;
-    assert(dyp->up == pigp);
+    assert(dyp->up == pkg);
     varbuf_add_str(vb, depdel);
     depdel = ", ";
     varbufdependency(vb,dyp);
@@ -345,17 +349,17 @@ w_dependency(struct varbuf *vb,
 
 void
 w_conffiles(struct varbuf *vb,
-            const struct pkginfo *pigp, const struct pkgbin *pifp,
+            const struct pkginfo *pkg, const struct pkgbin *pkgbin,
             enum fwriteflags flags, const struct fieldinfo *fip)
 {
   struct conffile *i;
 
-  if (!pifp->conffiles || pifp == &pigp->available)
+  if (!pkgbin->conffiles || pkgbin == &pkg->available)
     return;
   if (flags&fw_printheader)
     varbuf_add_str(vb, "Conffiles:\n");
-  for (i=pifp->conffiles; i; i= i->next) {
-    if (i != pifp->conffiles)
+  for (i = pkgbin->conffiles; i; i = i->next) {
+    if (i != pkgbin->conffiles)
       varbuf_add_char(vb, '\n');
     varbuf_add_char(vb, ' ');
     varbuf_add_str(vb, i->name);
@@ -370,20 +374,20 @@ w_conffiles(struct varbuf *vb,
 
 void
 w_trigpend(struct varbuf *vb,
-           const struct pkginfo *pigp, const struct pkgbin *pifp,
+           const struct pkginfo *pkg, const struct pkgbin *pkgbin,
            enum fwriteflags flags, const struct fieldinfo *fip)
 {
   struct trigpend *tp;
 
-  if (pifp == &pigp->available || !pigp->trigpend_head)
+  if (pkgbin == &pkg->available || !pkg->trigpend_head)
     return;
 
-  assert(pigp->status >= stat_triggersawaited &&
-         pigp->status <= stat_triggerspending);
+  assert(pkg->status >= stat_triggersawaited &&
+         pkg->status <= stat_triggerspending);
 
   if (flags & fw_printheader)
     varbuf_add_str(vb, "Triggers-Pending:");
-  for (tp = pigp->trigpend_head; tp; tp = tp->next) {
+  for (tp = pkg->trigpend_head; tp; tp = tp->next) {
     varbuf_add_char(vb, ' ');
     varbuf_add_str(vb, tp->name);
   }
@@ -393,20 +397,20 @@ w_trigpend(struct varbuf *vb,
 
 void
 w_trigaw(struct varbuf *vb,
-         const struct pkginfo *pigp, const struct pkgbin *pifp,
+         const struct pkginfo *pkg, const struct pkgbin *pkgbin,
          enum fwriteflags flags, const struct fieldinfo *fip)
 {
   struct trigaw *ta;
 
-  if (pifp == &pigp->available || !pigp->trigaw.head)
+  if (pkgbin == &pkg->available || !pkg->trigaw.head)
     return;
 
-  assert(pigp->status > stat_configfiles &&
-         pigp->status <= stat_triggersawaited);
+  assert(pkg->status > stat_configfiles &&
+         pkg->status <= stat_triggersawaited);
 
   if (flags & fw_printheader)
     varbuf_add_str(vb, "Triggers-Awaited:");
-  for (ta = pigp->trigaw.head; ta; ta = ta->sameaw.next) {
+  for (ta = pkg->trigaw.head; ta; ta = ta->sameaw.next) {
     varbuf_add_char(vb, ' ');
     varbuf_add_pkgbin_name(vb, ta->pend, &ta->pend->installed, pnaw_nonambig);
   }
@@ -416,15 +420,15 @@ w_trigaw(struct varbuf *vb,
 
 void
 varbufrecord(struct varbuf *vb,
-             const struct pkginfo *pigp, const struct pkgbin *pifp)
+             const struct pkginfo *pkg, const struct pkgbin *pkgbin)
 {
   const struct fieldinfo *fip;
   const struct arbitraryfield *afp;
 
   for (fip= fieldinfos; fip->name; fip++) {
-    fip->wcall(vb,pigp,pifp,fw_printheader,fip);
+    fip->wcall(vb, pkg, pkgbin, fw_printheader, fip);
   }
-  for (afp = pifp->arbs; afp; afp = afp->next) {
+  for (afp = pkgbin->arbs; afp; afp = afp->next) {
     varbuf_add_str(vb, afp->name);
     varbuf_add_str(vb, ": ");
     varbuf_add_str(vb, afp->value);
@@ -434,17 +438,17 @@ varbufrecord(struct varbuf *vb,
 
 void
 writerecord(FILE *file, const char *filename,
-            const struct pkginfo *pigp, const struct pkgbin *pifp)
+            const struct pkginfo *pkg, const struct pkgbin *pkgbin)
 {
   struct varbuf vb = VARBUF_INIT;
 
-  varbufrecord(&vb,pigp,pifp);
+  varbufrecord(&vb, pkg, pkgbin);
   varbuf_end_str(&vb);
   if (fputs(vb.buf,file) < 0) {
     struct varbuf pkgname = VARBUF_INIT;
     int errno_saved = errno;
 
-    varbuf_add_pkgbin_name(&pkgname, pigp, pifp, pnaw_nonambig);
+    varbuf_add_pkgbin_name(&pkgname, pkg, pkgbin, pnaw_nonambig);
 
     errno = errno_saved;
     ohshite(_("failed to write details of `%.50s' to `%.250s'"),
@@ -460,8 +464,8 @@ writedb(const char *filename, enum writedb_flags flags)
   static char writebuf[8192];
 
   struct pkgiterator *it;
-  struct pkginfo *pigp;
-  struct pkgbin *pifp;
+  struct pkginfo *pkg;
+  struct pkgbin *pkgbin;
   const char *which;
   struct atomic_file *file;
   struct varbuf vb = VARBUF_INIT;
@@ -474,17 +478,17 @@ writedb(const char *filename, enum writedb_flags flags)
     ohshite(_("unable to set buffering on %s database file"), which);
 
   it = pkg_db_iter_new();
-  while ((pigp = pkg_db_iter_next_pkg(it)) != NULL) {
-    pifp = (flags & wdb_dump_available) ? &pigp->available : &pigp->installed;
+  while ((pkg = pkg_db_iter_next_pkg(it)) != NULL) {
+    pkgbin = (flags & wdb_dump_available) ? &pkg->available : &pkg->installed;
     /* Don't dump records which have no useful content. */
-    if (!pkg_is_informative(pigp, pifp))
+    if (!pkg_is_informative(pkg, pkgbin))
       continue;
-    varbufrecord(&vb,pigp,pifp);
+    varbufrecord(&vb, pkg, pkgbin);
     varbuf_add_char(&vb, '\n');
     varbuf_end_str(&vb);
     if (fputs(vb.buf, file->fp) < 0)
       ohshite(_("failed to write %s database record about '%.50s' to '%.250s'"),
-              which, pkgbin_name(pigp, pifp, pnaw_nonambig), filename);
+              which, pkgbin_name(pkg, pkgbin, pnaw_nonambig), filename);
     varbuf_reset(&vb);
   }
   pkg_db_iter_free(it);

+ 8 - 0
lib/dpkg/ehandle.h

@@ -30,6 +30,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup ehandle Error context handling
+ * @ingroup dpkg-public
+ * @{
+ */
+
 extern volatile int onerr_abort;
 
 enum {
@@ -70,6 +76,8 @@ void do_internerr(const char *file, int line, const char *fmt, ...)
 	DPKG_ATTR_NORET DPKG_ATTR_PRINTF(3);
 #define internerr(...) do_internerr(__FILE__, __LINE__, __VA_ARGS__)
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_EHANDLE_H */

+ 8 - 0
lib/dpkg/error.h

@@ -25,6 +25,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup dpkg_error Error message reporting
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct dpkg_error {
 	enum dpkg_msg_type {
 		DPKG_MSG_NONE,
@@ -46,6 +52,8 @@ int dpkg_put_errno(struct dpkg_error *err, const char *fmt, ...)
 
 void dpkg_error_destroy(struct dpkg_error *err);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_ERROR_H */

+ 8 - 0
lib/dpkg/fdio.h

@@ -27,9 +27,17 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup fdio File descriptor I/O
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 ssize_t fd_read(int fd, void *buf, size_t len);
 ssize_t fd_write(int fd, const void *buf, size_t len);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_FDIO_H */

+ 52 - 48
lib/dpkg/fields.c

@@ -82,7 +82,7 @@ parse_nv_last(struct parsedb_state *ps,
 }
 
 void
-f_name(struct pkginfo *pigp, struct pkgbin *pifp,
+f_name(struct pkginfo *pkg, struct pkgbin *pkgbin,
        struct parsedb_state *ps,
        const char *value, const struct fieldinfo *fip)
 {
@@ -92,11 +92,11 @@ f_name(struct pkginfo *pigp, struct pkgbin *pifp,
   if (e != NULL)
     parse_error(ps, _("invalid package name (%.250s)"), e);
   /* We use the new name, as pkg_db_find_set() may have done a tolower for us. */
-  pigp->set->name = pkg_db_find_set(value)->name;
+  pkg->set->name = pkg_db_find_set(value)->name;
 }
 
 void
-f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
+f_filecharf(struct pkginfo *pkg, struct pkgbin *pkgbin,
             struct parsedb_state *ps,
             const char *value, const struct fieldinfo *fip)
 {
@@ -110,8 +110,8 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
     parse_error(ps,
                 _("file details field `%s' not allowed in status file"),
                fip->name);
-  allowextend= !pigp->files;
-  fdpp= &pigp->files;
+  allowextend = !pkg->files;
+  fdpp = &pkg->files;
   cpos= nfstrsave(value);
   while (*cpos) {
     space= cpos; while (*space && !isspace(*space)) space++;
@@ -140,15 +140,16 @@ f_filecharf(struct pkginfo *pigp, struct pkgbin *pifp,
 }
 
 void
-f_charfield(struct pkginfo *pigp, struct pkgbin *pifp,
+f_charfield(struct pkginfo *pkg, struct pkgbin *pkgbin,
             struct parsedb_state *ps,
             const char *value, const struct fieldinfo *fip)
 {
-  if (*value) PKGPFIELD(pifp,fip->integer,char*)= nfstrsave(value);
+  if (*value)
+    PKGPFIELD(pkgbin, fip->integer, char *) = nfstrsave(value);
 }
 
 void
-f_boolean(struct pkginfo *pigp, struct pkgbin *pifp,
+f_boolean(struct pkginfo *pkg, struct pkgbin *pkgbin,
           struct parsedb_state *ps,
           const char *value, const struct fieldinfo *fip)
 {
@@ -159,11 +160,11 @@ f_boolean(struct pkginfo *pigp, struct pkgbin *pifp,
 
   boolean = parse_nv_last(ps, _("yes/no in boolean field"),
                           booleaninfos, value);
-  PKGPFIELD(pifp, fip->integer, bool) = boolean;
+  PKGPFIELD(pkgbin, fip->integer, bool) = boolean;
 }
 
 void
-f_multiarch(struct pkginfo *pigp, struct pkgbin *pifp,
+f_multiarch(struct pkginfo *pkg, struct pkgbin *pkgbin,
             struct parsedb_state *ps,
             const char *value, const struct fieldinfo *fip)
 {
@@ -174,42 +175,43 @@ f_multiarch(struct pkginfo *pigp, struct pkgbin *pifp,
 
   multiarch = parse_nv_last(ps, _("foreign/allowed/same/no in quadstate field"),
                             multiarchinfos, value);
-  PKGPFIELD(pifp, fip->integer, int) = multiarch;
+  PKGPFIELD(pkgbin, fip->integer, int) = multiarch;
 }
 
 void
-f_architecture(struct pkginfo *pigp, struct pkgbin *pifp,
+f_architecture(struct pkginfo *pkg, struct pkgbin *pkgbin,
                struct parsedb_state *ps,
                const char *value, const struct fieldinfo *fip)
 {
-  pifp->arch = dpkg_arch_find(value);
-  if (pifp->arch->type == arch_illegal)
+  pkgbin->arch = dpkg_arch_find(value);
+  if (pkgbin->arch->type == arch_illegal)
     parse_warn(ps, _("'%s' is not a valid architecture name: %s"),
                value, dpkg_arch_name_is_illegal(value));
 }
 
 void
-f_section(struct pkginfo *pigp, struct pkgbin *pifp,
+f_section(struct pkginfo *pkg, struct pkgbin *pkgbin,
           struct parsedb_state *ps,
           const char *value, const struct fieldinfo *fip)
 {
   if (!*value) return;
-  pigp->section= nfstrsave(value);
+  pkg->section = nfstrsave(value);
 }
 
 void
-f_priority(struct pkginfo *pigp, struct pkgbin *pifp,
+f_priority(struct pkginfo *pkg, struct pkgbin *pkgbin,
            struct parsedb_state *ps,
            const char *value, const struct fieldinfo *fip)
 {
   if (!*value) return;
-  pigp->priority = parse_nv_last(ps, _("word in `priority' field"),
-                                 priorityinfos, value);
-  if (pigp->priority == pri_other) pigp->otherpriority= nfstrsave(value);
+  pkg->priority = parse_nv_last(ps, _("word in `priority' field"),
+                                priorityinfos, value);
+  if (pkg->priority == pri_other)
+    pkg->otherpriority = nfstrsave(value);
 }
 
 void
-f_status(struct pkginfo *pigp, struct pkgbin *pifp,
+f_status(struct pkginfo *pkg, struct pkgbin *pkgbin,
          struct parsedb_state *ps,
          const char *value, const struct fieldinfo *fip)
 {
@@ -219,28 +221,25 @@ f_status(struct pkginfo *pigp, struct pkgbin *pifp,
   if (ps->flags & pdb_recordavailable)
     return;
 
-  pigp->want = parse_nv_next(ps,
-                             _("first (want) word in `status' field"),
-                             wantinfos, &value);
-  pigp->eflag = parse_nv_next(ps,
-                              _("second (error) word in `status' field"),
-                              eflaginfos, &value);
-  pigp->status = parse_nv_last(ps,
-                               _("third (status) word in `status' field"),
-                               statusinfos, value);
+  pkg->want = parse_nv_next(ps, _("first (want) word in `status' field"),
+                            wantinfos, &value);
+  pkg->eflag = parse_nv_next(ps, _("second (error) word in `status' field"),
+                             eflaginfos, &value);
+  pkg->status = parse_nv_last(ps, _("third (status) word in `status' field"),
+                              statusinfos, value);
 }
 
 void
-f_version(struct pkginfo *pigp, struct pkgbin *pifp,
+f_version(struct pkginfo *pkg, struct pkgbin *pkgbin,
           struct parsedb_state *ps,
           const char *value, const struct fieldinfo *fip)
 {
-  parse_db_version(ps, &pifp->version, value,
+  parse_db_version(ps, &pkgbin->version, value,
                    _("error in Version string '%.250s'"), value);
 }
 
 void
-f_revision(struct pkginfo *pigp, struct pkgbin *pifp,
+f_revision(struct pkginfo *pkg, struct pkgbin *pkgbin,
            struct parsedb_state *ps,
            const char *value, const struct fieldinfo *fip)
 {
@@ -249,16 +248,18 @@ f_revision(struct pkginfo *pigp, struct pkgbin *pifp,
   parse_warn(ps,
              _("obsolete `Revision' or `Package-Revision' field used"));
   if (!*value) return;
-  if (pifp->version.revision && *pifp->version.revision) {
-    newversion= nfmalloc(strlen(pifp->version.version)+strlen(pifp->version.revision)+2);
-    sprintf(newversion,"%s-%s",pifp->version.version,pifp->version.revision);
-    pifp->version.version= newversion;
+  if (pkgbin->version.revision && *pkgbin->version.revision) {
+    newversion = nfmalloc(strlen(pkgbin->version.version) +
+                          strlen(pkgbin->version.revision) + 2);
+    sprintf(newversion, "%s-%s", pkgbin->version.version,
+                                 pkgbin->version.revision);
+    pkgbin->version.version = newversion;
   }
-  pifp->version.revision= nfstrsave(value);
+  pkgbin->version.revision = nfstrsave(value);
 }
 
 void
-f_configversion(struct pkginfo *pigp, struct pkgbin *pifp,
+f_configversion(struct pkginfo *pkg, struct pkgbin *pkgbin,
                 struct parsedb_state *ps,
                 const char *value, const struct fieldinfo *fip)
 {
@@ -268,7 +269,7 @@ f_configversion(struct pkginfo *pigp, struct pkgbin *pifp,
   if (ps->flags & pdb_recordavailable)
     return;
 
-  parse_db_version(ps, &pigp->configversion, value,
+  parse_db_version(ps, &pkg->configversion, value,
                    _("error in Config-Version string '%.250s'"), value);
 
 }
@@ -300,7 +301,7 @@ malformed:
 }
 
 void
-f_conffiles(struct pkginfo *pigp, struct pkgbin *pifp,
+f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
             struct parsedb_state *ps,
             const char *value, const struct fieldinfo *fip)
 {
@@ -311,7 +312,7 @@ f_conffiles(struct pkginfo *pigp, struct pkgbin *pifp,
   bool obsolete;
   char *newptr;
 
-  lastp= &pifp->conffiles;
+  lastp = &pkgbin->conffiles;
   while (*value) {
     c= *value++;
     if (c == '\n') continue;
@@ -324,7 +325,7 @@ f_conffiles(struct pkginfo *pigp, struct pkgbin *pifp,
 			&hashstart, &hashlen, &endfn,
                         ps);
     obsolete= (hashlen == sizeof(obsolete_str)-1 &&
-	       !memcmp(hashstart, obsolete_str, hashlen));
+               memcmp(hashstart, obsolete_str, hashlen) == 0);
     if (obsolete)
       conffvalue_lastword(value, endfn, endent,
 			  &hashstart, &hashlen, &endfn,
@@ -353,7 +354,7 @@ f_conffiles(struct pkginfo *pigp, struct pkgbin *pifp,
 }
 
 void
-f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
+f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
              struct parsedb_state *ps,
              const char *value, const struct fieldinfo *fip)
 {
@@ -370,7 +371,10 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
   if (!*value)
     return;
   p= value;
-  ldypp= &pifp->depends; while (*ldypp) ldypp= &(*ldypp)->next;
+
+  ldypp = &pkgbin->depends;
+  while (*ldypp)
+    ldypp = &(*ldypp)->next;
 
    /* Loop creating new struct dependency's. */
   for (;;) {
@@ -409,7 +413,7 @@ f_dependency(struct pkginfo *pigp, struct pkgbin *pifp,
       dop->ed = pkg_db_find_set(depname.buf);
       dop->next= NULL; *ldopp= dop; ldopp= &dop->next;
 
-      /* Don't link this (which is after all only ‘newpig’ from
+      /* Don't link this (which is after all only ‘new_pkg’ from
        * the main parsing loop in parsedb) into the depended on
        * packages' lists yet. This will be done later when we
        * install this (in parse.c). For the moment we do the
@@ -602,7 +606,7 @@ scan_word(const char **valp)
 }
 
 void
-f_trigpend(struct pkginfo *pend, struct pkgbin *pifp,
+f_trigpend(struct pkginfo *pend, struct pkgbin *pkgbin,
            struct parsedb_state *ps,
            const char *value, const struct fieldinfo *fip)
 {
@@ -626,7 +630,7 @@ f_trigpend(struct pkginfo *pend, struct pkgbin *pifp,
 }
 
 void
-f_trigaw(struct pkginfo *aw, struct pkgbin *pifp,
+f_trigaw(struct pkginfo *aw, struct pkgbin *pkgbin,
          struct parsedb_state *ps,
          const char *value, const struct fieldinfo *fip)
 {

+ 8 - 0
lib/dpkg/file.h

@@ -29,6 +29,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup file File handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 struct file_stat {
 	uid_t uid;
 	gid_t gid;
@@ -47,6 +53,8 @@ void file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
                const char *desc);
 void file_unlock(int fd, const char *desc);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_FILE_H */

+ 8 - 0
lib/dpkg/glob.h

@@ -25,6 +25,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup glob File globbing
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 struct glob_node {
 	struct glob_node *next;
 	char *pattern;
@@ -33,6 +39,8 @@ struct glob_node {
 void glob_list_prepend(struct glob_node **list, char *pattern);
 void glob_list_free(struct glob_node *head);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_GLOB_H */

+ 8 - 0
lib/dpkg/i18n.h

@@ -25,6 +25,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup i18n Internationalization support
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 #include <gettext.h>
 
 /* We need to include this because pgettext() uses LC_MESSAGES, but libintl.h
@@ -36,6 +42,8 @@ DPKG_BEGIN_DECLS
 #define N_(str) gettext_noop(str)
 #define C_(ctxt, str) pgettext(ctxt, str)
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_I18N_H */

+ 13 - 0
lib/dpkg/macros.h

@@ -21,6 +21,12 @@
 #ifndef LIBDPKG_MACROS_H
 #define LIBDPKG_MACROS_H
 
+/**
+ * @defgroup macros C language support macros
+ * @ingroup dpkg-public
+ * @{
+ */
+
 #ifndef LIBDPKG_VOLATILE_API
 #error "The libdpkg API is to be considered volatile, please read 'README.api'."
 #endif
@@ -73,6 +79,11 @@
 #define DPKG_END_DECLS
 #endif
 
+/**
+ * @def array_count
+ *
+ * Returns the amount of items in an array.
+ */
 #ifndef array_count
 #define array_count(a) (sizeof(a) / sizeof((a)[0]))
 #endif
@@ -88,4 +99,6 @@
 #endif
 #endif
 
+/** @} */
+
 #endif /* LIBDPKG_MACROS_H */

+ 8 - 0
lib/dpkg/namevalue.h

@@ -26,6 +26,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup namevalue Name/Value data
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct namevalue {
 	const char *name;
 	int value;
@@ -40,6 +46,8 @@ struct namevalue {
 const struct namevalue *namevalue_find_by_name(const struct namevalue *head,
                                                const char *str);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_NAMEVALUE_H */

+ 8 - 5
lib/dpkg/options.c

@@ -106,10 +106,11 @@ myfileopt(const char *fn, const struct cmdinfo *cmdinfos)
 
     for (cip=cmdinfos; cip->olong || cip->oshort; cip++) {
       if (!cip->olong) continue;
-      if (!strcmp(cip->olong,linebuf)) break;
+      if (strcmp(cip->olong, linebuf) == 0)
+        break;
       l=strlen(cip->olong);
       if ((cip->takesvalue==2) && (linebuf[l]=='-') &&
-	  !opt && !strncmp(linebuf,cip->olong,l)) {
+          !opt && strncmp(linebuf, cip->olong, l) == 0) {
 	opt=linebuf+l+1;
 	break;
       }
@@ -217,16 +218,18 @@ myopt(const char *const **argvp, const struct cmdinfo *cmdinfos,
   ++(*argvp);
   while ((p= **argvp) && *p == '-') {
     ++(*argvp);
-    if (!strcmp(p,"--")) break;
+    if (strcmp(p, "--") == 0)
+      break;
     if (*++p == '-') {
       ++p; value=NULL;
       for (cip= cmdinfos;
            cip->olong || cip->oshort;
            cip++) {
         if (!cip->olong) continue;
-        if (!strcmp(p,cip->olong)) break;
+        if (strcmp(p, cip->olong) == 0)
+          break;
         l= strlen(cip->olong);
-        if (!strncmp(p,cip->olong,l) &&
+        if (strncmp(p, cip->olong, l) == 0 &&
             (p[l]== ((cip->takesvalue==2) ? '-' : '='))) { value=p+l+1; break; }
       }
       if (!cip->olong) badusage(_("unknown option --%s"),p);

+ 8 - 0
lib/dpkg/options.h

@@ -25,6 +25,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup options Option parsing
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 typedef int action_func(const char *const *argv);
 
 struct cmdinfo {
@@ -70,6 +76,8 @@ void setobsolete(const struct cmdinfo *cip, const char *value);
 #define OBSOLETE(longopt, shortopt) \
  { longopt, shortopt, 0, NULL, NULL, setobsolete, 0, NULL, NULL }
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_OPTIONS_H */

+ 4 - 4
lib/dpkg/parse.c

@@ -150,7 +150,7 @@ pkg_parse_field(struct parsedb_state *ps, struct field_state *fs,
                   fs->fieldlen, fs->fieldstart);
     larpp = &pkg_obj->pkgbin->arbs;
     while ((arp = *larpp) != NULL) {
-      if (!strncasecmp(arp->name, fs->fieldstart, fs->fieldlen))
+      if (strncasecmp(arp->name, fs->fieldstart, fs->fieldlen) == 0)
         parse_error(ps,
                    _("duplicate value for user-defined field `%.*s'"),
                    fs->fieldlen, fs->fieldstart);
@@ -363,7 +363,7 @@ parse_find_set_slot(struct parsedb_state *ps,
  * Most of the time each pkginfo in a pkgset has the same architecture for
  * both the installed and available pkgbin members. But when cross-grading
  * there's going to be a temporary discrepancy, because we reuse the single
- * instance and fill the available pkgbin with the candiadate pkgbin, until
+ * instance and fill the available pkgbin with the candidate pkgbin, until
  * that is copied over the installed pkgbin.
  *
  * If there's 0 or > 1 package instances, then we match against the pkginfo
@@ -372,7 +372,7 @@ parse_find_set_slot(struct parsedb_state *ps,
  * If there's 1 instance, we are cross-grading and both installed and
  * candidate are not multiarch_same, we have to reuse the existing single
  * slot regardless of the arch differing between the two. If we are not
- * cross-grading, then we use the entry with the matchin arch.
+ * cross-grading, then we use the entry with the matching arch.
  */
 static struct pkginfo *
 parse_find_pkg_slot(struct parsedb_state *ps,
@@ -385,7 +385,7 @@ parse_find_pkg_slot(struct parsedb_state *ps,
 
   if (ps->type == pdb_file_available) {
     /* If there's a single package installed and the new package is not
-     * “Multi-Aarch: same”, then we preserve the previous behaviour of
+     * “Multi-Arch: same”, then we preserve the previous behaviour of
      * possible architecture switch, for example from native to all. */
     if (pkgset_installed_instances(db_set) == 1 &&
         new_pkgbin->multiarch != multiarch_same)

+ 10 - 2
lib/dpkg/parsedump.h

@@ -23,6 +23,12 @@
 #ifndef LIBDPKG_PARSEDUMP_H
 #define LIBDPKG_PARSEDUMP_H
 
+/**
+ * @defgroup parsedump In-core package database parsing and reading
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct fieldinfo;
 
 /**
@@ -71,12 +77,12 @@ bool parse_stanza(struct parsedb_state *ps, struct field_state *fs,
                   parse_field_func *parse_field, void *parse_obj);
 
 #define PKGIFPOFF(f) (offsetof(struct pkgbin, f))
-#define PKGPFIELD(pifp,of,type) (*(type*)((char*)(pifp)+(of)))
+#define PKGPFIELD(pkgbin, of, type) (*(type *)((char *)(pkgbin) + (of)))
 
 #define FILEFOFF(f) (offsetof(struct filedetails, f))
 #define FILEFFIELD(filedetail,of,type) (*(type*)((char*)(filedetail)+(of)))
 
-typedef void freadfunction(struct pkginfo *pigp, struct pkgbin *pifp,
+typedef void freadfunction(struct pkginfo *pkg, struct pkgbin *pkgbin,
                            struct parsedb_state *ps,
                            const char *value, const struct fieldinfo *fip);
 freadfunction f_name, f_charfield, f_priority, f_section, f_status, f_filecharf;
@@ -130,4 +136,6 @@ struct nickname {
 
 extern const struct fieldinfo fieldinfos[];
 
+/** @} */
+
 #endif /* LIBDPKG_PARSEDUMP_H */

+ 8 - 0
lib/dpkg/path.h

@@ -27,6 +27,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup path Path handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 size_t path_trim_slash_slashdot(char *path);
 const char *path_skip_slash_dotslash(const char *path);
 const char *path_basename(const char *path);
@@ -34,6 +40,8 @@ char *path_quote_filename(char *dst, const char *src, size_t size);
 
 char *path_make_temp_template(const char *suffix);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_PATH_H */

+ 8 - 0
lib/dpkg/pkg-array.h

@@ -26,6 +26,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg-array Package array primitives
+ * @ingroup dpkg-public
+ * @{
+ */
+
 /**
  * Holds an array of pointers to package data.
  */
@@ -38,6 +44,8 @@ void pkg_array_init_from_db(struct pkg_array *a);
 void pkg_array_sort(struct pkg_array *a, pkg_sorter_func *pkg_sort);
 void pkg_array_destroy(struct pkg_array *a);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_PKG_ARRAY_H */

+ 27 - 26
lib/dpkg/pkg-db.c

@@ -80,30 +80,31 @@ static unsigned int hash(const char *name) {
 struct pkgset *
 pkg_db_find_set(const char *inname)
 {
-  struct pkgset **pointerp, *newpkg;
+  struct pkgset **setp, *new_set;
   char *name = m_strdup(inname), *p;
 
   p= name;
   while(*p) { *p= tolower(*p); p++; }
 
-  pointerp= bins + (hash(name) % (BINS));
-  while (*pointerp && strcasecmp((*pointerp)->name,name))
-    pointerp= &(*pointerp)->next;
-  if (*pointerp) {
+  setp = bins + (hash(name) % (BINS));
+  while (*setp && strcasecmp((*setp)->name, name))
+    setp = &(*setp)->next;
+  if (*setp) {
     free(name);
-    return *pointerp;
+    return *setp;
   }
 
-  newpkg = nfmalloc(sizeof(struct pkgset));
-  pkgset_blank(newpkg);
-  newpkg->name= nfstrsave(name);
-  newpkg->next= NULL;
-  *pointerp= newpkg;
+  new_set = nfmalloc(sizeof(struct pkgset));
+  pkgset_blank(new_set);
+  new_set->name = nfstrsave(name);
+  new_set->next = NULL;
+  *setp = new_set;
   nset++;
   npkg++;
 
   free(name);
-  return newpkg;
+
+  return new_set;
 }
 
 /**
@@ -131,7 +132,7 @@ pkg_db_get_singleton(struct pkgset *set)
       if (arch->type == arch_native || arch->type == arch_all)
         return pkg;
     }
-    /* Or falling that the first entry. */
+    /* Or failing that, the first entry. */
     return &set->pkg;
   case 1:
     for (pkg = &set->pkg; pkg; pkg = pkg->arch_next) {
@@ -260,7 +261,7 @@ pkg_db_count_pkg(void)
 }
 
 struct pkgiterator {
-  struct pkginfo *pigp;
+  struct pkginfo *pkg;
   int nbinn;
 };
 
@@ -277,7 +278,7 @@ pkg_db_iter_new(void)
   struct pkgiterator *iter;
 
   iter = m_malloc(sizeof(struct pkgiterator));
-  iter->pigp = NULL;
+  iter->pkg = NULL;
   iter->nbinn = 0;
 
   return iter;
@@ -297,19 +298,19 @@ pkg_db_iter_next_set(struct pkgiterator *iter)
 {
   struct pkgset *set;
 
-  while (!iter->pigp) {
+  while (!iter->pkg) {
     if (iter->nbinn >= BINS)
       return NULL;
     if (bins[iter->nbinn])
-      iter->pigp = &bins[iter->nbinn]->pkg;
+      iter->pkg = &bins[iter->nbinn]->pkg;
     iter->nbinn++;
   }
 
-  set = iter->pigp->set;
+  set = iter->pkg->set;
   if (set->next)
-    iter->pigp = &set->next->pkg;
+    iter->pkg = &set->next->pkg;
   else
-    iter->pigp = NULL;
+    iter->pkg = NULL;
 
   return set;
 }
@@ -332,21 +333,21 @@ pkg_db_iter_next_pkg(struct pkgiterator *iter)
 {
   struct pkginfo *r;
 
-  while (!iter->pigp) {
+  while (!iter->pkg) {
     if (iter->nbinn >= BINS)
       return NULL;
     if (bins[iter->nbinn])
-      iter->pigp = &bins[iter->nbinn]->pkg;
+      iter->pkg = &bins[iter->nbinn]->pkg;
     iter->nbinn++;
   }
 
-  r = iter->pigp;
+  r = iter->pkg;
   if (r->arch_next)
-    iter->pigp = r->arch_next;
+    iter->pkg = r->arch_next;
   else if (r->set->next)
-    iter->pigp = &r->set->next->pkg;
+    iter->pkg = &r->set->next->pkg;
   else
-    iter->pigp = NULL;
+    iter->pkg = NULL;
 
   return r;
 }

+ 3 - 3
lib/dpkg/pkg-format.c

@@ -305,7 +305,7 @@ find_field_info(const struct fieldinfo *fields_head,
 
 void
 pkg_format_show(const struct pkg_format_node *head,
-                struct pkginfo *pkg, struct pkgbin *pif)
+                struct pkginfo *pkg, struct pkgbin *pkgbin)
 {
 	struct varbuf vb = VARBUF_INIT, fb = VARBUF_INIT, wb = VARBUF_INIT;
 
@@ -333,7 +333,7 @@ pkg_format_show(const struct pkg_format_node *head,
 				fip = find_field_info(virtinfos, head);
 
 			if (fip->name) {
-				fip->wcall(&wb, pkg, pif, 0, fip);
+				fip->wcall(&wb, pkg, pkgbin, 0, fip);
 
 				varbuf_end_str(&wb);
 				varbuf_printf(&fb, fmt, wb.buf);
@@ -342,7 +342,7 @@ pkg_format_show(const struct pkg_format_node *head,
 			} else {
 				const struct arbitraryfield *afp;
 
-				for (afp = pif->arbs; afp; afp = afp->next)
+				for (afp = pkgbin->arbs; afp; afp = afp->next)
 					if (strcasecmp(head->data, afp->name) == 0) {
 						varbuf_printf(&fb, fmt, afp->value);
 						ok = true;

+ 9 - 1
lib/dpkg/pkg-format.h

@@ -26,12 +26,20 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg-format Package information formatting
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct pkg_format_node;
 
 struct pkg_format_node *pkg_format_parse(const char *fmt);
 void pkg_format_free(struct pkg_format_node *head);
 void pkg_format_show(const struct pkg_format_node *head,
-                     struct pkginfo *pkg, struct pkgbin *pif);
+                     struct pkginfo *pkg, struct pkgbin *pkgbin);
+
+/** @} */
 
 DPKG_END_DECLS
 

+ 8 - 0
lib/dpkg/pkg-list.h

@@ -25,6 +25,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg-list Package linked lists
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct pkg_list {
 	struct pkg_list *next;
 	struct pkginfo *pkg;
@@ -34,6 +40,8 @@ struct pkg_list *pkg_list_new(struct pkginfo *pkg, struct pkg_list *next);
 void pkg_list_free(struct pkg_list *head);
 void pkg_list_prepend(struct pkg_list **head, struct pkginfo *pkg);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_PKG_LIST_H */

+ 8 - 0
lib/dpkg/pkg-queue.h

@@ -26,6 +26,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg-queue Package queues
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct pkg_queue {
 	struct pkg_list *head, *tail;
 	int length;
@@ -45,6 +51,8 @@ int pkg_queue_is_empty(struct pkg_queue *queue);
 struct pkg_list *pkg_queue_push(struct pkg_queue *queue, struct pkginfo *pkg);
 struct pkginfo *pkg_queue_pop(struct pkg_queue *queue);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* DPKG_PKG_QUEUE_H */

+ 8 - 0
lib/dpkg/pkg-show.h

@@ -26,6 +26,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg-show Package information display
+ * @ingroup dpkg-public
+ * @{
+ */
+
 int pkg_sorter_by_nonambig_name_arch(const void *a, const void *b);
 
 const char *pkg_summary(const struct pkginfo *pkg, const struct pkgbin *pkgbin,
@@ -34,6 +40,8 @@ int pkg_abbrev_want(const struct pkginfo *pkg);
 int pkg_abbrev_status(const struct pkginfo *pkg);
 int pkg_abbrev_eflag(const struct pkginfo *pkg);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* DPKG_PKG_SHOW_H */

+ 8 - 0
lib/dpkg/pkg-spec.h

@@ -32,6 +32,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg-spec Package specifiers
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct pkg_spec {
 	char *name;
 	const struct dpkg_arch *arch;
@@ -76,6 +82,8 @@ void pkg_spec_iter_init(struct pkg_spec *ps);
 struct pkginfo *pkg_spec_iter_next_pkg(struct pkg_spec *ps);
 void pkg_spec_iter_destroy(struct pkg_spec *ps);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif

+ 8 - 0
lib/dpkg/pkg.h

@@ -26,6 +26,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup pkg Package handling primitives
+ * @ingroup dpkg-public
+ * @{
+ */
+
 typedef int pkg_sorter_func(const void *a, const void *b);
 
 void pkgset_link_pkg(struct pkgset *set, struct pkginfo *pkg);
@@ -37,6 +43,8 @@ void pkg_reset_eflags(struct pkginfo *pkg);
 void pkg_copy_eflags(struct pkginfo *pkg_dst, struct pkginfo *pkg_src);
 void pkg_set_want(struct pkginfo *pkg, enum pkgwant want);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_PKG_H */

+ 8 - 0
lib/dpkg/progname.h

@@ -25,9 +25,17 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup progname Program name handling
+ * @ingroup dpkg-public
+ * @{
+ */
+
 void dpkg_set_progname(const char *name);
 const char *dpkg_get_progname(void);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif

+ 8 - 0
lib/dpkg/progress.h

@@ -27,6 +27,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup progress Progress reporting
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 struct progress {
 	const char *text;
 
@@ -41,6 +47,8 @@ void progress_init(struct progress *progress, const char *text, int max);
 void progress_step(struct progress *progress);
 void progress_done(struct progress *progress);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif

+ 8 - 0
lib/dpkg/string.h

@@ -25,10 +25,18 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup string String handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 char *str_escape_fmt(char *dest, const char *src, size_t n);
 char *str_quote_meta(const char *src);
 char *str_strip_quotes(char *str);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_STRING_H */

+ 8 - 0
lib/dpkg/subproc.h

@@ -27,6 +27,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup subproc Sub-process handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 void subproc_signals_setup(const char *name);
 void subproc_signals_cleanup(int argc, void **argv);
 
@@ -39,6 +45,8 @@ int subproc_wait(pid_t pid, const char *desc);
 int subproc_check(int status, const char *desc, int flags);
 int subproc_wait_check(pid_t pid, const char *desc, int flags);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_SUBPROC_H */

+ 8 - 0
lib/dpkg/tarfn.h

@@ -29,6 +29,12 @@
 
 #include <dpkg/file.h>
 
+/**
+ * @defgroup tar Tar archive handling
+ * @ingroup dpkg-public
+ * @{
+ */
+
 #define TARBLKSZ	512
 
 enum tar_format {
@@ -86,4 +92,6 @@ struct tar_operations {
 
 int tar_extractor(void *ctx, const struct tar_operations *ops);
 
+/** @} */
+
 #endif

+ 8 - 0
lib/dpkg/test.h

@@ -31,11 +31,19 @@
 /* Make sure NDEBUG is never defined, as we rely on the assert() macro. */
 #undef NDEBUG
 
+/**
+ * @defgroup dpkg_test Test suite support
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 #define test_pass(a)			assert((a))
 #define test_fail(a)			assert(!(a))
 #define test_str(a, op, b)		assert(strcmp((a), (b)) op 0)
 #define test_mem(a, op, b, size)	assert(memcmp((a), (b), (size)) op 0)
 
+/** @} */
+
 #ifndef TEST_MAIN_PROVIDED
 static void test(void);
 

+ 8 - 0
lib/dpkg/trigdeferred.h

@@ -26,6 +26,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup trigdeferred Trigger deferred file handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 enum trigdef_updateflags {
 	tduf_nolockok =           001,
 	tduf_write =              002,
@@ -56,6 +62,8 @@ void trigdef_update_printf(const char *format, ...) DPKG_ATTR_PRINTF(1);
 int trigdef_parse(void);
 void trigdef_process_done(void);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_TRIGDEFERRED_H */

+ 5 - 5
lib/dpkg/triglib.c

@@ -667,13 +667,13 @@ trig_parse_ci(const char *file, trig_parse_cicb *interest,
 		*spc++ = '\0';
 		while (cisspace(*spc))
 			spc++;
-		if (!strcmp(cmd, "interest")) {
+		if (strcmp(cmd, "interest") == 0) {
 			parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, trig_await);
-		} else if (!strcmp(cmd, "interest-noawait")) {
+		} else if (strcmp(cmd, "interest-noawait") == 0) {
 			parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, trig_noawait);
-		} else if (!strcmp(cmd, "activate")) {
+		} else if (strcmp(cmd, "activate") == 0) {
 			parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, trig_await);
-		} else if (!strcmp(cmd, "activate-noawait")) {
+		} else if (strcmp(cmd, "activate-noawait") == 0) {
 			parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, trig_noawait);
 		} else {
 			ohshit(_("triggers ci file contains unknown directive `%.250s'"),
@@ -789,7 +789,7 @@ th_simple_nn_find(const char *name, bool nonew)
 	struct filenamenode *search;
 
 	for (search = trigger_files; search; search = search->next)
-		if (!strcmp(search->name, name))
+		if (strcmp(search->name, name) == 0)
 			return search;
 
 	/* Not found. */

+ 8 - 0
lib/dpkg/triglib.h

@@ -27,6 +27,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup triglib Trigger handling
+ * @ingroup dpkg-internal
+ * @{
+ */
+
 /*
  * Hooks for more sophisticated processing in dpkg proper.
  *
@@ -111,6 +117,8 @@ void trig_parse_ci(const char *file, trig_parse_cicb *interest,
 
 void trig_incorporate(enum modstatdb_rw cstatus);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_TRIGLIB_H */

+ 1 - 1
lib/dpkg/trignote.c

@@ -41,7 +41,7 @@ trig_note_pend_core(struct pkginfo *pend, const char *trig)
 	struct trigpend *tp;
 
 	for (tp = pend->trigpend_head; tp; tp = tp->next)
-		if (!strcmp(tp->name, trig))
+		if (strcmp(tp->name, trig) == 0)
 			return false;
 
 	tp = nfmalloc(sizeof(*tp));

+ 8 - 0
lib/dpkg/varbuf.h

@@ -29,6 +29,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup varbuf Variable length buffers
+ * @ingroup dpkg-public
+ * @{
+ */
+
 /**
  * varbuf_init must be called exactly once before the use of each varbuf
  * (including before any call to varbuf_destroy), or the variable must be
@@ -82,6 +88,8 @@ int varbuf_printf(struct varbuf *v, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
 int varbuf_vprintf(struct varbuf *v, const char *fmt, va_list va)
 	DPKG_ATTR_VPRINTF(2);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #ifdef __cplusplus

+ 8 - 0
lib/dpkg/version.h

@@ -27,6 +27,12 @@
 
 DPKG_BEGIN_DECLS
 
+/**
+ * @defgroup version Version handling
+ * @ingroup dpkg-public
+ * @{
+ */
+
 struct versionrevision {
 	unsigned long epoch;
 	const char *version;
@@ -36,6 +42,8 @@ struct versionrevision {
 void dpkg_version_blank(struct versionrevision *version);
 bool dpkg_version_is_informative(const struct versionrevision *version);
 
+/** @} */
+
 DPKG_END_DECLS
 
 #endif /* LIBDPKG_VERSION_H */

+ 9 - 9
src/archives.c

@@ -268,25 +268,25 @@ struct pkg_deconf_list *deconfigure = NULL;
 static time_t currenttime;
 
 static int
-does_replace(struct pkginfo *newpigp, struct pkgbin *newpifp,
-             struct pkginfo *oldpigp, struct pkgbin *oldpifp)
+does_replace(struct pkginfo *new_pkg, struct pkgbin *new_pkgbin,
+             struct pkginfo *old_pkg, struct pkgbin *old_pkgbin)
 {
   struct dependency *dep;
 
   debug(dbg_depcon,"does_replace new=%s old=%s (%s)",
-        pkgbin_name(newpigp, newpifp, pnaw_always),
-        pkgbin_name(oldpigp, oldpifp, pnaw_always),
-        versiondescribe(&oldpifp->version, vdew_always));
-  for (dep= newpifp->depends; dep; dep= dep->next) {
-    if (dep->type != dep_replaces || dep->list->ed != oldpigp->set)
+        pkgbin_name(new_pkg, new_pkgbin, pnaw_always),
+        pkgbin_name(old_pkg, old_pkgbin, pnaw_always),
+        versiondescribe(&old_pkgbin->version, vdew_always));
+  for (dep = new_pkgbin->depends; dep; dep = dep->next) {
+    if (dep->type != dep_replaces || dep->list->ed != old_pkg->set)
       continue;
     debug(dbg_depcondetail,"does_replace ... found old, version %s",
           versiondescribe(&dep->list->version,vdew_always));
-    if (!versionsatisfied(oldpifp, dep->list))
+    if (!versionsatisfied(old_pkgbin, dep->list))
       continue;
     /* The test below can only trigger if dep_replaces start having
      * arch qualifiers different from “any”. */
-    if (!archsatisfied(oldpifp, dep->list))
+    if (!archsatisfied(old_pkgbin, dep->list))
       continue;
     debug(dbg_depcon,"does_replace ... yes");
     return true;

+ 5 - 5
src/configure.c

@@ -118,13 +118,13 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 		        cdr.buf);
 
 	/* Select what to do. */
-	if (!strcmp(currenthash, newdisthash)) {
+	if (strcmp(currenthash, newdisthash) == 0) {
 		/* They're both the same so there's no point asking silly
 		 * questions. */
 		useredited = -1;
 		distedited = -1;
 		what = cfo_identical;
-	} else if (!strcmp(currenthash, NONEXISTENTFLAG) && fc_conff_miss) {
+	} else if (strcmp(currenthash, NONEXISTENTFLAG) == 0&& fc_conff_miss) {
 		fprintf(stderr,
 		        _("\n"
 		          "Configuration file `%s', does not exist on system.\n"
@@ -133,8 +133,8 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 		what = cfo_newconff;
 		useredited = -1;
 		distedited = -1;
-	} else if (!strcmp(conff->hash, NEWCONFFILEFLAG)) {
-		if (!strcmp(currenthash, NONEXISTENTFLAG)) {
+	} else if (strcmp(conff->hash, NEWCONFFILEFLAG) == 0) {
+		if (strcmp(currenthash, NONEXISTENTFLAG) == 0) {
 			what = cfo_newconff;
 			useredited = -1;
 			distedited = -1;
@@ -153,7 +153,7 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
 		else
 			what = conffoptcells[useredited][distedited];
 
-		if (!strcmp(currenthash, NONEXISTENTFLAG))
+		if (strcmp(currenthash, NONEXISTENTFLAG) == 0)
 			what |= cfof_userrmd;
 	}
 

+ 2 - 1
src/filesdb.c

@@ -673,7 +673,8 @@ struct filenamenode *findnamenode(const char *name, enum fnnflags flags) {
   while (*pointerp) {
     /* XXX: Why is the assert needed? It's checking already added entries. */
     assert((*pointerp)->name[0] == '/');
-    if (!strcmp((*pointerp)->name+1,name)) break;
+    if (strcmp((*pointerp)->name + 1, name) == 0)
+      break;
     pointerp= &(*pointerp)->next;
   }
   if (*pointerp) return *pointerp;

+ 2 - 2
src/help.c

@@ -283,7 +283,7 @@ static void setexecute(const char *path, struct stat *stab) {
 }
 
 static int
-do_script(struct pkginfo *pkg, struct pkgbin *pif,
+do_script(struct pkginfo *pkg, struct pkgbin *pkgbin,
           struct command *cmd, struct stat *stab, int warn)
 {
   pid_t pid;
@@ -296,7 +296,7 @@ do_script(struct pkginfo *pkg, struct pkgbin *pif,
   pid = subproc_fork();
   if (pid == 0) {
     if (setenv("DPKG_MAINTSCRIPT_PACKAGE", pkg->set->name, 1) ||
-        setenv("DPKG_MAINTSCRIPT_ARCH", pif->arch->name, 1) ||
+        setenv("DPKG_MAINTSCRIPT_ARCH", pkgbin->arch->name, 1) ||
         setenv("DPKG_MAINTSCRIPT_NAME", cmd->argv[0], 1) ||
         setenv("DPKG_RUNNING_VERSION", PACKAGE_VERSION, 1))
       ohshite(_("unable to setenv for maintainer script"));

+ 3 - 2
src/main.c

@@ -557,7 +557,7 @@ static void setforce(const struct cmdinfo *cip, const char *value) {
   size_t l;
   const struct forceinfo *fip;
 
-  if (!strcmp(value,"help")) {
+  if (strcmp(value, "help") == 0) {
     printf(_(
 "%s forcing options - control behaviour when problems found:\n"
 "  warn but continue:  --force-<thing>,<thing>,...\n"
@@ -580,7 +580,8 @@ static void setforce(const struct cmdinfo *cip, const char *value) {
     comma= strchr(value,',');
     l = comma ? (size_t)(comma - value) : strlen(value);
     for (fip=forceinfos; fip->name; fip++)
-      if (!strncmp(fip->name,value,l) && strlen(fip->name)==l) break;
+      if (strncmp(fip->name, value, l) == 0 && strlen(fip->name) == l)
+        break;
 
     if (!fip->name) {
       badusage(_("unknown force/refuse option `%.*s'"),

+ 2 - 2
src/processarc.c

@@ -1065,7 +1065,7 @@ void process_archive(const char *filename) {
       if ((namenode->flags & fnnf_old_conff)) {
 	if (sameas) {
 	  if (sameas->namenode->flags & fnnf_new_conff) {
-	    if (!strcmp(sameas->namenode->oldhash, NEWCONFFILEFLAG)) {
+	    if (strcmp(sameas->namenode->oldhash, NEWCONFFILEFLAG) == 0) {
 	      sameas->namenode->oldhash= namenode->oldhash;
 	      debug(dbg_eachfile, "process_archive: old conff %s"
 		    " is same as new conff %s, copying hash",
@@ -1244,7 +1244,7 @@ void process_archive(const char *filename) {
     assert(otherpkg->clientdata->istobe == itb_normal ||
            otherpkg->clientdata->istobe == itb_deconfigure);
     for (cfile= otherpkg->clientdata->files;
-         cfile && !strcmp(cfile->namenode->name,"/.");
+         cfile && strcmp(cfile->namenode->name, "/.") == 0;
          cfile= cfile->next);
     if (!cfile) {
       debug(dbg_stupidlyverbose, "process_archive no non-root, no disappear");

+ 5 - 4
src/remove.c

@@ -538,10 +538,11 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry='%s'"
               " conffbasename='%s' conffnameused=%d conffbasenamelen=%d",
               de->d_name, conffbasename, conffnameused, conffbasenamelen);
-        if (!strncmp(de->d_name,conffbasename,conffbasenamelen)) {
+        if (strncmp(de->d_name, conffbasename, conffbasenamelen) == 0) {
           debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry starts right");
           for (ext= removeconffexts; *ext; ext++)
-            if (!strcmp(*ext,de->d_name+conffbasenamelen)) goto yes_remove;
+            if (strcmp(*ext, de->d_name + conffbasenamelen) == 0)
+              goto yes_remove;
           p= de->d_name+conffbasenamelen;
           if (*p++ == '~') {
             while (*p && cisdigit(*p)) p++;
@@ -550,8 +551,8 @@ static void removal_bulk_remove_configfiles(struct pkginfo *pkg) {
         }
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry starts wrong");
         if (de->d_name[0] == '#' &&
-            !strncmp(de->d_name+1,conffbasename,conffbasenamelen) &&
-            !strcmp(de->d_name+1+conffbasenamelen,"#"))
+            strncmp(de->d_name + 1, conffbasename, conffbasenamelen) == 0 &&
+            strcmp(de->d_name + 1 + conffbasenamelen, "#") == 0)
           goto yes_remove;
         debug(dbg_stupidlyverbose, "removal_bulk conffile dsd entry not it");
         continue;

+ 2 - 2
src/trigcmd.c

@@ -144,7 +144,7 @@ parse_awaiter_package(void)
 static void
 tdm_add_trig_begin(const char *trig)
 {
-	ctrig = !strcmp(trig, activate);
+	ctrig = strcmp(trig, activate) == 0;
 	trigdef_update_printf("%s", trig);
 	if (!ctrig || done_trig)
 		return;
@@ -155,7 +155,7 @@ tdm_add_trig_begin(const char *trig)
 static void
 tdm_add_package(const char *awname)
 {
-	if (ctrig && !strcmp(awname, bypackage))
+	if (ctrig && strcmp(awname, bypackage) == 0)
 		return;
 	yespackage(awname);
 }

+ 1 - 1
src/trigproc.c

@@ -244,7 +244,7 @@ check_trigger_cycle(struct pkginfo *processing_now)
 				      " tortoisetrig=%s haretrig=%s",
 				      processing_now_name, tortoise_name,
 				      tortoise_trig->name, hare_trig->name);
-				if (!strcmp(hare_trig->name, tortoise_trig->name))
+				if (strcmp(hare_trig->name, tortoise_trig->name) == 0)
 					goto found_in_hare;
 			}
 			/* Not found in hare, yay! */

+ 1 - 1
utils/start-stop-daemon.c

@@ -667,7 +667,7 @@ parse_schedule_item(const char *string, struct schedule_item *item)
 {
 	const char *after_hyph;
 
-	if (!strcmp(string, "forever")) {
+	if (strcmp(string, "forever") == 0) {
 		item->type = sched_forever;
 	} else if (isdigit(string[0])) {
 		item->type = sched_timeout;