The following commit has been merged in the master branch:
commit 94e25a0380033654d2140ebf8149268b9bf446f8
Author: Guillem Jover <[email protected]>
Date:   Thu Nov 4 06:39:28 2010 +0100

    Refactor setpipe() into statusfd_add() to stop exposing status_pipes

diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 0c0fb44..71b60d1 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -121,13 +121,7 @@ DPKG_BEGIN_DECLS
 extern const char *log_file;
 void log_message(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
 
-/* FIXME: pipef and status_pipes should not be publicly exposed. */
-struct pipef {
-  int fd;
-  struct pipef *next;
-};
-extern struct pipef *status_pipes;
-
+void statusfd_add(int fd);
 void statusfd_send(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
 
 /*** cleanup.c ***/
diff --git a/lib/dpkg/libdpkg.Versions b/lib/dpkg/libdpkg.Versions
index 92ab7d5..3c1401d 100644
--- a/lib/dpkg/libdpkg.Versions
+++ b/lib/dpkg/libdpkg.Versions
@@ -139,7 +139,7 @@ LIBDPKG_PRIVATE {
        log_message;
 
        # Action logging
-       status_pipes;           # XXX variable, do not export
+       statusfd_add;
        statusfd_send;
 
        # Progress report support
diff --git a/lib/dpkg/log.c b/lib/dpkg/log.c
index 8efb7bc..a6a056c 100644
--- a/lib/dpkg/log.c
+++ b/lib/dpkg/log.c
@@ -70,7 +70,25 @@ log_message(const char *fmt, ...)
        fprintf(logfd, "%s %s\n", time_str, log.buf);
 }
 
-struct pipef *status_pipes = NULL;
+struct pipef {
+       struct pipef *next;
+       int fd;
+};
+
+static struct pipef *status_pipes = NULL;
+
+void
+statusfd_add(int fd)
+{
+       struct pipef *pipe_new;
+
+       setcloexec(fd, _("<package status and progress file descriptor>"));
+
+       pipe_new = nfmalloc(sizeof(struct pipef));
+       pipe_new->fd = fd;
+       pipe_new->next = status_pipes;
+       status_pipes = pipe_new;
+}
 
 void
 statusfd_send(const char *fmt, ...)
diff --git a/src/main.c b/src/main.c
index 9df3e75..8b5f5fd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -306,8 +306,6 @@ static void setinteger(const struct cmdinfo *cip, const 
char *value) {
 }
 
 static void setpipe(const struct cmdinfo *cip, const char *value) {
-  struct pipef **pipe_head = cip->parg;
-  struct pipef *pipe_new;
   unsigned long v;
   char *ep;
 
@@ -315,12 +313,7 @@ static void setpipe(const struct cmdinfo *cip, const char 
*value) {
   if (value == ep || *ep || v > INT_MAX)
     badusage(_("invalid integer for --%s: `%.250s'"),cip->olong,value);
 
-  setcloexec(v, _("<package status and progress file descriptor>"));
-
-  pipe_new = nfmalloc(sizeof(struct pipef));
-  pipe_new->fd = v;
-  pipe_new->next = *pipe_head;
-  *pipe_head = pipe_new;
+  statusfd_add(v);
 }
 
 static bool
@@ -494,7 +487,7 @@ static const struct cmdinfo cmdinfos[]= {
   { "post-invoke",       0,   1, NULL,          NULL,      set_invoke_hook, 0, 
&post_invoke_hooks_tail },
   { "path-exclude",      0,   1, NULL,          NULL,      setfilter,     0 },
   { "path-include",      0,   1, NULL,          NULL,      setfilter,     1 },
-  { "status-fd",         0,   1, NULL,          NULL,      setpipe, 0, 
&status_pipes },
+  { "status-fd",         0,   1, NULL,          NULL,      setpipe, 0 },
   { "log",               0,   1, NULL,          &log_file, NULL,    0 },
   { "pending",           'a', 0, &f_pending,    NULL,      NULL,    1 },
   { "recursive",         'R', 0, &f_recursive,  NULL,      NULL,    1 },

-- 
dpkg's main repository


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

Reply via email to