diff options
Diffstat (limited to 'src/bin/pg_dump/dumputils.c')
-rw-r--r-- | src/bin/pg_dump/dumputils.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 39601e6a5fc..5dab9675fc0 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -16,14 +16,14 @@ #include <ctype.h> -#include "dumpmem.h" #include "dumputils.h" #include "parser/keywords.h" +/* Globals exported by this file */ int quote_all_identifiers = 0; -const char *progname; +const char *progname = NULL; #define supports_grant_options(version) ((version) >= 70400) @@ -1214,31 +1214,51 @@ emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, } +/* + * Write a printf-style message to stderr. + * + * The program name is prepended, if "progname" has been set. + * Also, if modulename isn't NULL, that's included too. + * Note that we'll try to translate the modulename and the fmt string. + */ 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); + vwrite_msg(modulename, fmt, ap); va_end(ap); } +/* + * As write_msg, but pass a va_list not variable arguments. + */ +void +vwrite_msg(const char *modulename, const char *fmt, va_list ap) +{ + if (progname) + { + if (modulename) + fprintf(stderr, "%s: [%s] ", progname, _(modulename)); + else + fprintf(stderr, "%s: ", progname); + } + vfprintf(stderr, _(fmt), ap); +} + +/* + * Fail and die, with a message to stderr. Parameters as for write_msg. + */ void exit_horribly(const char *modulename, const char *fmt,...) { va_list ap; va_start(ap, fmt); - write_msg(modulename, fmt, ap); + vwrite_msg(modulename, fmt, ap); va_end(ap); exit(1); } - - |