The following commit has been merged in the master branch:
commit 3e919df71f0e67366cc8d40dc8bad953394a5d6e
Author: Guillem Jover <[EMAIL PROTECTED]>
Date:   Thu Mar 20 06:14:06 2008 +0200

    Move duplicate cleanup close functions to lib/cleanup.c

diff --git a/ChangeLog b/ChangeLog
index b977679..51d972f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-03-20  Ian Jackson  <[EMAIL PROTECTED]>,
+            Guillem Jover  <[EMAIL PROTECTED]>
+
+       * src/query.c (cu_closepipe, cu_closefile, cu_closefd): Remove
+       duplicated functions.
+       * src/help.c (cu_closepipe, cu_closefile, cu_closedir)
+       (cu_closefd): Move function definitions to ...
+       * lib/cleanup.c: ... here. New file.
+       * src/main.h (cu_closefile, cu_closepipe, cu_closedir)
+       (cu_closefd): Move prototypes to ...
+       * lib/dpkg.h: ... here.
+       * lib/Makefile.am (libdpkg_a_SOURCES): Add 'cleanup.c'.
+
 2008-03-20  Ian Jackson  <[EMAIL PROTECTED]>
 
        * lib/dpkg-db.h (modstatdb_checkpoint): New prototype.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 2c34bb2..ab34a3f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -15,6 +15,7 @@ libdpkg_a_SOURCES = \
        dpkg-def.h \
        dpkg.h \
        dpkg-db.h \
+       cleanup.c \
        compat.c \
        compression.c \
        database.c \
diff --git a/lib/myopt-util.c b/lib/cleanup.c
similarity index 60%
copy from lib/myopt-util.c
copy to lib/cleanup.c
index 6620aeb..4337062 100644
--- a/lib/myopt-util.c
+++ b/lib/cleanup.c
@@ -1,8 +1,8 @@
 /*
  * libdpkg - Debian packaging suite library routines
- * myopt-util.c - command line option utilities
+ * cleanup.c - cleanup functions, used when we need to unwind
  *
- * Copyright (C) 1994,1995 Ian Jackson <[EMAIL PROTECTED]>
+ * Copyright (C) 1995 Ian Jackson <[EMAIL PROTECTED]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as
@@ -18,37 +18,42 @@
  * License along with dpkg; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#include <config.h>
 
-#include <stdlib.h>
+#include <dpkg.h>
+#include <stdio.h>
 #include <unistd.h>
-#include <fcntl.h>
+#include <dirent.h>
 
-#include <dpkg.h>
+void
+cu_closepipe(int argc, void **argv)
+{
+       int *p1 = (int *)argv[0];
+
+       close(p1[0]);
+       close(p1[1]);
+}
 
 void
-helponly(const struct cmdinfo *cip, const char *value)
+cu_closefile(int argc, void **argv)
 {
-       usage();
-       exit(0);
+       FILE *f = (FILE *)(argv[0]);
+
+       fclose(f);
 }
 
 void
-versiononly(const struct cmdinfo *cip, const char *value)
+cu_closedir(int argc, void **argv)
 {
-       printversion();
-       exit(0);
+       DIR *d = (DIR *)(argv[0]);
+
+       closedir(d);
 }
 
 void
-showcopyright(const struct cmdinfo *cip, const char *value)
+cu_closefd(int argc, void **argv)
 {
-       int fd;
+       int ip = *(int *)argv[0];
 
-       fd = open(COPYINGFILE, O_RDONLY);
-       if (fd < 0)
-               ohshite(_("cannot open GPL file"));
-       fd_fd_copy(fd, 1, -1, "showcopyright");
-       exit(0);
+       close(ip);
 }
 
diff --git a/lib/dpkg.h b/lib/dpkg.h
index 7e2e428..17b8f28 100644
--- a/lib/dpkg.h
+++ b/lib/dpkg.h
@@ -207,6 +207,13 @@ void badusage(const char *fmt, ...) NONRETURNING 
PRINTFFORMAT(1, 2);
 void werr(const char *what) NONRETURNING;
 void warningf(const char *fmt, ...) PRINTFFORMAT(1, 2);
 
+/*** cleanup.c ***/
+
+void cu_closefile(int argc, void **argv);
+void cu_closepipe(int argc, void **argv);
+void cu_closedir(int argc, void **argv);
+void cu_closefd(int argc, void **argv);
+
 /*** from mlib.c ***/
 
 void setcloexec(int fd, const char* fn);
diff --git a/src/help.c b/src/help.c
index 78e3b29..5103ecb 100644
--- a/src/help.c
+++ b/src/help.c
@@ -121,26 +121,6 @@ void ensure_package_clientdata(struct pkginfo *pkg) {
   pkg->clientdata->files = NULL;
 }
 
-void cu_closepipe(int argc, void **argv) {
-  int *p1= (int*)argv[0];
-  close(p1[0]); close(p1[1]);
-}
-
-void cu_closefile(int argc, void **argv) {
-  FILE *f= (FILE*)(argv[0]);
-  fclose(f);
-}
-
-void cu_closedir(int argc, void **argv) {
-  DIR *d= (DIR*)(argv[0]);
-  closedir(d);
-}
-
-void cu_closefd(int argc, void **argv) {
-  int ip= *(int*)argv[0];
-  close(ip);
-}
-
 int ignore_depends(struct pkginfo *pkg) {
   struct packageinlist *id;
   for (id= ignoredependss; id; id= id->next)
diff --git a/src/main.h b/src/main.h
index 15a8303..59cc9f8 100644
--- a/src/main.h
+++ b/src/main.h
@@ -173,11 +173,6 @@ int skip_due_to_hold(struct pkginfo *pkg);
 
 /* from help.c */
 
-void cu_closefile(int argc, void **argv);
-void cu_closepipe(int argc, void **argv);
-void cu_closedir(int argc, void **argv);
-void cu_closefd(int argc, void **argv);
-
 struct stat;
 
 int ignore_depends(struct pkginfo *pkg);
diff --git a/src/query.c b/src/query.c
index 2e524cf..91b9111 100644
--- a/src/query.c
+++ b/src/query.c
@@ -66,21 +66,6 @@ const char *pkgadminfile(struct pkginfo *pkg, const char 
*whichfile) {
   return vb.buf;
 }
 
-void cu_closepipe(int argc, void **argv) {
-  int *p1= (int*)argv[0];
-  close(p1[0]); close(p1[1]);
-}
-
-void cu_closefile(int argc, void **argv) {
-  FILE *f= (FILE*)(argv[0]);
-  fclose(f);
-}
-
-void cu_closefd(int argc, void **argv) {
-  int ip= *(int*)argv;
-  close(ip);
-}
-
 int pkglistqsortcmp(const void *a, const void *b) {
   const struct pkginfo *pa= *(const struct pkginfo**)a;
   const struct pkginfo *pb= *(const struct pkginfo**)b;

-- 
dpkg's main repository


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

Reply via email to