@@ -21,6 +21,8 @@ struct options
2121int gettable ;
2222int getoid ;
2323
24+ int quiet ;
25+
2426int systables ;
2527
2628int remotehost ;
@@ -59,6 +61,8 @@ get_opts(int argc, char **argv, struct options * my_opts)
5961my_opts -> gettable = 0 ;
6062my_opts -> getoid = 0 ;
6163
64+ my_opts -> quiet = 0 ;
65+
6266my_opts -> systables = 0 ;
6367
6468my_opts -> remotehost = 0 ;
@@ -67,7 +71,7 @@ get_opts(int argc, char **argv, struct options * my_opts)
6771my_opts -> remotepass = 0 ;
6872
6973/* get opts */
70- while ((c = getopt (argc ,argv ,"H:p:U:P:d:t:o:xh ?" ))!= -1 )
74+ while ((c = getopt (argc ,argv ,"H:p:U:P:d:t:o:qxh ?" ))!= -1 )
7175{
7276switch (c )
7377{
@@ -82,13 +86,13 @@ get_opts(int argc, char **argv, struct options * my_opts)
8286/* make sure we set the database first */
8387if (!my_opts -> getdatabase )
8488{
85- fprintf (stderr ,"Sorry, but you must specify a database to dump from.\n" );
89+ fprintf (stderr ,"You must specify a database to dump from.\n" );
8690exit (1 );
8791}
8892/* make sure we don't try to do a -o also */
8993if (my_opts -> getoid )
9094{
91- fprintf (stderr ,"Sorry, you can only specify either oid or table\n" );
95+ fprintf (stderr ,"You can only specify either oid or table\n" );
9296exit (1 );
9397}
9498
@@ -102,13 +106,13 @@ get_opts(int argc, char **argv, struct options * my_opts)
102106/* make sure we set the database first */
103107if (!my_opts -> getdatabase )
104108{
105- fprintf (stderr ,"Sorry, but you must specify a database to dump from.\n" );
109+ fprintf (stderr ,"You must specify a database to dump from.\n" );
106110exit (1 );
107111}
108112/* make sure we don't try to do a -t also */
109113if (my_opts -> gettable )
110114{
111- fprintf (stderr ,"Sorry, you can only specify either oid or table\n" );
115+ fprintf (stderr ,"You can only specify either oid or table\n" );
112116exit (1 );
113117}
114118
@@ -117,6 +121,10 @@ get_opts(int argc, char **argv, struct options * my_opts)
117121
118122break ;
119123
124+ case 'q' :
125+ my_opts -> quiet = 1 ;
126+ break ;
127+
120128/* host to connect to */
121129case 'H' :
122130my_opts -> remotehost = 1 ;
@@ -149,17 +157,18 @@ get_opts(int argc, char **argv, struct options * my_opts)
149157/* help! (ugly in code for easier editing) */
150158case '?' :
151159case 'h' :
152- fprintf (stderr ,"\n\
153- Usage: pg_oid2name [-d database [-x] ] [-t table | -o oid] \n\
160+ fprintf (stderr ,"\
161+ Usage: pg_oid2name [-d database [-x] ] [-t table | -o oid]\n\
154162 default action display all databases\n\
155163 -d database database to oid2name\n\
156164 -x display system tables\n\
157165 -t table | -o oid search for table name (-t) or\n\
158166 oid (-o) in -d database\n\
167+ -q quiet\n\
159168 -H host connect to remote host\n\
160169 -p port host port to connect to\n\
161170 -U username username to connect with\n\
162- -P password password for username\n\n\
171+ -P password password for username\n\
163172" );
164173exit (1 );
165174break ;
@@ -402,9 +411,11 @@ main(int argc, char **argv)
402411/* display all the tables in the database */
403412if (my_opts -> getdatabase & my_opts -> gettable )
404413{
405- printf ("Oid of table %s from database \"%s\":\n" ,my_opts -> _tbname ,my_opts -> _dbname );
406- printf ("_______________________________\n" );
407-
414+ if (!my_opts -> quiet )
415+ {
416+ printf ("Oid of table %s from database \"%s\":\n" ,my_opts -> _tbname ,my_opts -> _dbname );
417+ printf ("---------------------------------\n" );
418+ }
408419pgconn = sql_conn (my_opts -> _dbname ,my_opts );
409420sql_exec_searchtable (pgconn ,my_opts -> _tbname );
410421PQfinish (pgconn );
@@ -415,9 +426,11 @@ main(int argc, char **argv)
415426/* search for the tablename of the given OID */
416427if (my_opts -> getdatabase & my_opts -> getoid )
417428{
418- printf ("Tablename of oid %i from database \"%s\":\n" ,my_opts -> _oid ,my_opts -> _dbname );
419- printf ("---------------------------------\n" );
420-
429+ if (!my_opts -> quiet )
430+ {
431+ printf ("Tablename of oid %i from database \"%s\":\n" ,my_opts -> _oid ,my_opts -> _dbname );
432+ printf ("---------------------------------\n" );
433+ }
421434pgconn = sql_conn (my_opts -> _dbname ,my_opts );
422435sql_exec_searchoid (pgconn ,my_opts -> _oid );
423436PQfinish (pgconn );
@@ -428,9 +441,11 @@ main(int argc, char **argv)
428441/* search for the oid for the given tablename */
429442if (my_opts -> getdatabase )
430443{
431- printf ("All tables from database \"%s\":\n" ,my_opts -> _dbname );
432- printf ("---------------------------------\n" );
433-
444+ if (!my_opts -> quiet )
445+ {
446+ printf ("All tables from database \"%s\":\n" ,my_opts -> _dbname );
447+ printf ("---------------------------------\n" );
448+ }
434449pgconn = sql_conn (my_opts -> _dbname ,my_opts );
435450sql_exec_dumptable (pgconn ,my_opts -> systables );
436451PQfinish (pgconn );
@@ -439,9 +454,11 @@ main(int argc, char **argv)
439454}
440455
441456/* display all the databases for the server we are connected to.. */
442- printf ("All databases:\n" );
443- printf ("---------------------------------\n" );
444-
457+ if (!my_opts -> quiet )
458+ {
459+ printf ("All databases:\n" );
460+ printf ("---------------------------------\n" );
461+ }
445462pgconn = sql_conn ("template1" ,my_opts );
446463sql_exec_dumpdb (pgconn );
447464PQfinish (pgconn );