Преглед на файлове

libdpkg: Move warning functions to a new report module

Guillem Jover преди 14 години
родител
ревизия
ed609ddb44
променени са 7 файла, в които са добавени 108 реда и са изтрити 32 реда
  1. 2 0
      lib/dpkg/Makefile.am
  2. 1 0
      lib/dpkg/dpkg.h
  3. 0 28
      lib/dpkg/ehandle.c
  4. 0 4
      lib/dpkg/ehandle.h
  5. 59 0
      lib/dpkg/report.c
  6. 45 0
      lib/dpkg/report.h
  7. 1 0
      po/POTFILES.in

+ 2 - 0
lib/dpkg/Makefile.am

@@ -64,6 +64,7 @@ libdpkg_a_SOURCES = \
 	pkg-spec.c \
 	progname.c \
 	progress.c \
+	report.c \
 	string.c \
 	subproc.c \
 	tarfn.c \
@@ -107,6 +108,7 @@ pkginclude_HEADERS = \
 	pkg-spec.h \
 	progname.h \
 	progress.h \
+	report.h \
 	string.h \
 	subproc.h \
 	tarfn.h \

+ 1 - 0
lib/dpkg/dpkg.h

@@ -118,6 +118,7 @@ DPKG_BEGIN_DECLS
 
 #include <dpkg/progname.h>
 #include <dpkg/ehandle.h>
+#include <dpkg/report.h>
 
 /*** from startup.c ***/
 

+ 0 - 28
lib/dpkg/ehandle.c

@@ -375,34 +375,6 @@ void ohshite(const char *fmt, ...) {
   run_error_handler();
 }
 
-static int warn_count = 0;
-
-int
-warning_get_count(void)
-{
-  return warn_count;
-}
-
-void
-warningv(const char *fmt, va_list args)
-{
-  char buf[1024];
-
-  warn_count++;
-  vsnprintf(buf, sizeof(buf), fmt, args);
-  fprintf(stderr, _("%s: warning: %s\n"), dpkg_get_progname(), buf);
-}
-
-void
-warning(const char *fmt, ...)
-{
-  va_list args;
-
-  va_start(args, fmt);
-  warningv(fmt, args);
-  va_end(args);
-}
-
 void
 do_internerr(const char *file, int line, const char *func, const char *fmt, ...)
 {

+ 0 - 4
lib/dpkg/ehandle.h

@@ -63,10 +63,6 @@ void push_cleanup(void (*f1)(int argc, void **argv), int flagmask1,
 void push_checkpoint(int mask, int value);
 void pop_cleanup(int flagset);
 
-int warning_get_count(void);
-void warningv(const char *fmt, va_list args) DPKG_ATTR_VPRINTF(1);
-void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
-
 void ohshitv(const char *fmt, va_list args)
 	DPKG_ATTR_NORET DPKG_ATTR_VPRINTF(1);
 void ohshit(const char *fmt, ...) DPKG_ATTR_NORET DPKG_ATTR_PRINTF(1);

+ 59 - 0
lib/dpkg/report.c

@@ -0,0 +1,59 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * reoport.c - message reporting
+ *
+ * Copyright © 2004-2005 Scott James Remnant <scott@netsplit.com>
+ * Copyright © 2008-2012 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <compat.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <dpkg/macros.h>
+#include <dpkg/i18n.h>
+#include <dpkg/progname.h>
+#include <dpkg/report.h>
+
+static int warn_count = 0;
+
+int
+warning_get_count(void)
+{
+	return warn_count;
+}
+
+void
+warningv(const char *fmt, va_list args)
+{
+	char buf[1024];
+
+	warn_count++;
+	vsnprintf(buf, sizeof(buf), fmt, args);
+	fprintf(stderr, _("%s: warning: %s\n"), dpkg_get_progname(), buf);
+}
+
+void
+warning(const char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	warningv(fmt, args);
+	va_end(args);
+}

+ 45 - 0
lib/dpkg/report.h

@@ -0,0 +1,45 @@
+/*
+ * libdpkg - Debian packaging suite library routines
+ * report.h - message reporting
+ *
+ * Copyright © 2004 Scott James Remnant <scott@netsplit.com>
+ * Copyright © 2008-2012 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBDPKG_REPORT_H
+#define LIBDPKG_REPORT_H
+
+#include <stdarg.h>
+
+#include <dpkg/macros.h>
+
+DPKG_BEGIN_DECLS
+
+/**
+ * @defgroup report Message reporting
+ * @ingroup dpkg-private
+ * @{
+ */
+
+int warning_get_count(void);
+void warningv(const char *fmt, va_list args) DPKG_ATTR_VPRINTF(1);
+void warning(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
+
+/** @} */
+
+DPKG_END_DECLS
+
+#endif /* LIBDPKG_REPORT_H */

+ 1 - 0
po/POTFILES.in

@@ -32,6 +32,7 @@ lib/dpkg/pkg-queue.c
 lib/dpkg/pkg-show.c
 lib/dpkg/pkg-spec.c
 lib/dpkg/progress.c
+lib/dpkg/report.c
 lib/dpkg/string.c
 lib/dpkg/subproc.c
 lib/dpkg/tarfn.c