From 8b08deb0d1ee04a82130e640e48e302a3456817a Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 29 Nov 2011 16:34:45 -0500 Subject: Simplify the pg_dump/pg_restore error reporting macros, and allow pg_dumpall to use the same memory allocation functions as the others. --- src/bin/pg_dump/dumputils.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/bin/pg_dump/dumputils.c') diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 92b9d28e7f1..39601e6a5fc 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -23,6 +23,7 @@ int quote_all_identifiers = 0; +const char *progname; #define supports_grant_options(version) ((version) >= 70400) @@ -1211,3 +1212,33 @@ emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, appendPQExpBuffer(buffer, ";\n"); } } + + +void +write_msg(const char *modulename, const char *fmt,...) +{ + va_list ap; + + va_start(ap, fmt); + if (modulename) + fprintf(stderr, "%s: [%s] ", progname, _(modulename)); + else + fprintf(stderr, "%s: ", progname); + vfprintf(stderr, _(fmt), ap); + va_end(ap); +} + + +void +exit_horribly(const char *modulename, const char *fmt,...) +{ + va_list ap; + + va_start(ap, fmt); + write_msg(modulename, fmt, ap); + va_end(ap); + + exit(1); +} + + -- cgit v1.2.3