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 * -------------------------------------------------------------------------
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
2829char * progname = NULL ;
2930
@@ -67,8 +68,6 @@ main(int argc, char **argv)
6768{
6869int arg ;
6970extern int optind ;
70-
71- #ifdef HAVE_GETOPT_LONG
7271int l_index = 0 ;
7372static struct option l_opt []= {
7473{"help" ,no_argument ,0 ,'h' },
@@ -89,10 +88,6 @@ main(int argc, char **argv)
8988
9089while ((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
9691switch (arg )
9792{
9893case '?' :
@@ -272,11 +267,8 @@ parse_lolist(LODumpMaster * pgLO)
272267static void
273268usage ()
274269{
275- printf ("\npg_dumplo %s - PostgreSQL large objects dump\n" ,VERSION );
270+ printf ("\npg_dumplo %s - PostgreSQL large objects dump\n" ,PG_VERSION );
276271puts ("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_dumplouse $PWD\n"
294+ " * ifoption -s is not set, pg_dumplouses $PWD\n"
323295);/* puts() */
324296}