Skip to content

Commit 30a800a

Browse files
committed
Update for new we-always-have-getopt_long approach.
1 parent b4b62cf commit 30a800a

File tree

2 files changed

+12
-42
lines changed

2 files changed

+12
-42
lines changed

contrib/pg_dumplo/main.c

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -------------------------------------------------------------------------
22
* pg_dumplo
33
*
4-
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.13 2002/10/18 18:41:20 momjian Exp $
4+
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.14 2003/01/07 21:42:38 tgl Exp $
55
*
66
* Karel Zak 1999-2000
77
* -------------------------------------------------------------------------
@@ -17,13 +17,14 @@
1717

1818
#include "pg_dumplo.h"
1919

20-
#ifdef HAVE_GETOPT_LONG
21-
#include <getopt.h>
22-
#define no_argument 0
23-
#define required_argument 1
20+
#ifndef HAVE_STRDUP
21+
#include "strdup.h"
2422
#endif
2523

26-
extern int errno;
24+
#ifndef HAVE_GETOPT_LONG
25+
#include "getopt_long.h"
26+
int optreset;
27+
#endif
2728

2829
char *progname = NULL;
2930

@@ -67,8 +68,6 @@ main(int argc, char **argv)
6768
{
6869
int arg;
6970
extern int optind;
70-
71-
#ifdef HAVE_GETOPT_LONG
7271
int l_index = 0;
7372
static struct option l_opt[] = {
7473
{"help", no_argument, 0, 'h'},
@@ -89,10 +88,6 @@ main(int argc, char **argv)
8988

9089
while ((arg = getopt_long(argc, argv, "?aeho:u:p:qd:l:t:irs:w", l_opt, &l_index)) != -1)
9190
{
92-
#else
93-
while ((arg = getopt(argc, argv, "?aeho:u:p:qd:l:t:irs:w")) != -1)
94-
{
95-
#endif
9691
switch (arg)
9792
{
9893
case '?':
@@ -272,11 +267,8 @@ parse_lolist(LODumpMaster * pgLO)
272267
static void
273268
usage()
274269
{
275-
printf("\npg_dumplo %s - PostgreSQL large objects dump\n", VERSION);
270+
printf("\npg_dumplo %s - PostgreSQL large objects dump\n", PG_VERSION);
276271
puts("pg_dumplo [option]\n\n"
277-
278-
#ifdef HAVE_GETOPT_LONG
279-
280272
"-h --help this help\n"
281273
"-u --user=<username> username for connection to server\n"
282274
"-p --password=<password> password for connection to server\n"
@@ -291,34 +283,14 @@ usage()
291283
"-r --remove if is set '-i' try remove old LO\n"
292284
"-q --quiet run quietly\n"
293285
"-w --show not dump, but show all LO in DB\n"
294-
); /* puts() */
295-
296-
#else
297-
"-h this help\n"
298-
"-u <username> username for connection to server\n"
299-
"-p <password> password for connection to server\n"
300-
"-d <database> database name\n"
301-
"-t <hostname> server hostname\n"
302-
"-o <port> database server port (default: 5432)\n"
303-
"-s <dir> directory with dump tree (for export/import)\n"
304-
"-i import large obj dump tree to DB\n"
305-
"-e export (dump) large obj to dump tree\n"
306-
"-l <table.attr ...> dump attribute (columns) with LO to dump tree\n"
307-
"-a dump all LO in DB (default)\n"
308-
"-r if is set '-i' try remove old LO\n"
309-
"-q run quietly\n"
310-
"-w not dump, but show all LO in DB\n"
311-
); /* puts() */
312-
#endif
313-
314-
puts(
286+
"\n"
315287
"Example (dump): pg_dumplo -d my_db -s /my_dump/dir -l t1.a t1.b t2.a\n"
316288
" pg_dumplo -a -d my_db -s /my_dump/dir\n"
317289
"Example (import): pg_dumplo -i -d my_db -s /my_dump/dir\n"
318290
"Example (show): pg_dumplo -w -d my_db\n\n"
319291
"Note: * option '-l' must be last option!\n"
320292
" * option '-i' without option '-r' make new large obj in DB\n"
321293
" not rewrite old, the '-i' UPDATE oid numbers in table.attr only!\n"
322-
" * if is not set option -s, the pg_dumplo use $PWD\n"
294+
" * if option -s is not set, pg_dumplo uses $PWD\n"
323295
); /* puts() */
324296
}

contrib/pg_dumplo/pg_dumplo.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -------------------------------------------------------------------------
2-
* pg_dumplo
2+
* pg_dumplo.h
33
*
4-
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.8 2001/11/12 17:44:14 momjian Exp $
4+
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.9 2003/01/07 21:42:38 tgl Exp $
55
*
66
* Karel Zak 1999-2000
77
* -------------------------------------------------------------------------
@@ -12,8 +12,6 @@
1212

1313
#include "postgres_ext.h"
1414

15-
#define VERSION "7.1.0"
16-
1715
/* ----------
1816
* Define
1917
* ----------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy