77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.12 1996/07/2806:59:43 scrappy Exp $
10+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.13 1996/07/2807:08:13 scrappy Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -60,18 +60,18 @@ typedef struct _psqlSettings {
6060}PsqlSettings ;
6161
6262/* declarations for functions in this file */
63- static void usage (char * progname );
63+ static void usage (char * progname );
6464static void slashUsage ();
6565static void handleCopyOut (PGresult * res ,bool quiet );
6666static void handleCopyIn (PGresult * res ,bool quiet );
6767static int tableList (PsqlSettings * ps ,bool deep_tablelist );
6868static int tableDesc (PsqlSettings * ps ,char * table );
6969
70- char * gets_noreadline (char * prompt ,FILE * source );
71- char * gets_readline (char * prompt ,FILE * source );
72- char * gets_fromFile (char * prompt ,FILE * source );
70+ char * gets_noreadline (char * prompt ,FILE * source );
71+ char * gets_readline (char * prompt ,FILE * source );
72+ char * gets_fromFile (char * prompt ,FILE * source );
7373int listAllDbs (PsqlSettings * settings );
74- int SendQuery (PsqlSettings * settings ,char * query );
74+ int SendQuery (PsqlSettings * settings ,char * query );
7575int HandleSlashCmds (PsqlSettings * settings ,
7676char * line ,
7777char * query );
@@ -82,15 +82,15 @@ void PQprint(FILE *fp,
8282PQprintOpt * po
8383 );
8484
85- FILE * setFout (PsqlSettings * ps ,char * fname );
85+ FILE * setFout (PsqlSettings * ps ,char * fname );
8686
8787/*
8888 * usage
8989 * print out usage for command line arguments
9090 */
9191
9292static void
93- usage (char * progname )
93+ usage (char * progname )
9494{
9595fprintf (stderr ,"Usage: %s [options] [dbname]\n" ,progname );
9696fprintf (stderr ,"\t -a authsvc set authentication service\n" );
187187listAllDbs (PsqlSettings * ps )
188188{
189189PGresult * results ;
190- char * query = "select * from pg_database;" ;
190+ char * query = "select * from pg_database;" ;
191191
192192if (!(results = PSQLexec (ps ,query )))
193193return 1 ;
@@ -213,10 +213,10 @@ tableList (PsqlSettings *ps, bool deep_tablelist)
213213char listbuf [256 ];
214214int nColumns ;
215215int i ;
216- char * rk ;
217- char * rr ;
216+ char * rk ;
217+ char * rr ;
218218
219- PGresult * res ;
219+ PGresult * res ;
220220
221221listbuf [0 ]= '\0' ;
222222strcat (listbuf ,"SELECT usename, relname, relkind, relhasrules" );
@@ -242,7 +242,7 @@ tableList (PsqlSettings *ps, bool deep_tablelist)
242242if (table == NULL )
243243perror ("malloc" );
244244
245- /* load table table*/
245+ /* load table table */
246246for (i = 0 ;i < nColumns ;i ++ ) {
247247table [i ]= (char * )malloc (PQgetlength (res ,i ,1 )* sizeof (char )+ 1 );
248248if (table [i ]== NULL )
@@ -304,7 +304,7 @@ tableDesc (PsqlSettings *ps, char *table)
304304int i ;
305305int rsize ;
306306
307- PGresult * res ;
307+ PGresult * res ;
308308
309309/* Build the query */
310310
@@ -380,13 +380,13 @@ tableDesc (PsqlSettings *ps, char *table)
380380 }
381381}
382382
383- typedef char * (* READ_ROUTINE )(char * prompt ,FILE * source );
383+ typedef char * (* READ_ROUTINE )(char * prompt ,FILE * source );
384384
385385/* gets_noreadline prompt source
386386 gets a line of input without calling readline, the source is ignored
387387*/
388- char *
389- gets_noreadline (char * prompt ,FILE * source )
388+ char *
389+ gets_noreadline (char * prompt ,FILE * source )
390390{
391391fputs (prompt ,stdout );
392392fflush (stdout );
@@ -398,8 +398,8 @@ gets_noreadline(char* prompt, FILE* source)
398398 * the routine to get input from GNU readline(), the source is ignored
399399 * the prompt argument is used as the prompting string
400400 */
401- char *
402- gets_readline (char * prompt ,FILE * source )
401+ char *
402+ gets_readline (char * prompt ,FILE * source )
403403{
404404return (readline (prompt ));
405405}
@@ -408,12 +408,12 @@ gets_readline(char* prompt, FILE* source)
408408 * gets_fromFile prompt source
409409 *
410410 * the routine to read from a file, the prompt argument is ignored
411- * the source argument is a FILE*
411+ * the source argument is a FILE *
412412 */
413- char *
414- gets_fromFile (char * prompt ,FILE * source )
413+ char *
414+ gets_fromFile (char * prompt ,FILE * source )
415415{
416- char * line ;
416+ char * line ;
417417int len ;
418418
419419line = malloc (MAX_QUERY_BUFFER + 1 );
@@ -440,8 +440,8 @@ gets_fromFile(char* prompt, FILE* source)
440440int
441441SendQuery (PsqlSettings * settings ,char * query )
442442{
443- PGresult * results ;
444- PGnotify * notify ;
443+ PGresult * results ;
444+ PGnotify * notify ;
445445int status = 0 ;
446446
447447if (settings -> singleStep )
@@ -610,7 +610,7 @@ decode(char *s)
610610*/
611611int
612612HandleSlashCmds (PsqlSettings * settings ,
613- char * line ,
613+ char * line ,
614614char * query )
615615{
616616int status = 1 ;
@@ -766,7 +766,7 @@ HandleSlashCmds(PsqlSettings *settings,
766766break ;
767767case 'h' :
768768 {
769- char * cmd ;
769+ char * cmd ;
770770int i ,numCmds ;
771771int all_help = 0 ;
772772
@@ -814,7 +814,7 @@ HandleSlashCmds(PsqlSettings *settings,
814814 }
815815case 'i' :/* \i is include file */
816816 {
817- FILE * fd ;
817+ FILE * fd ;
818818
819819if (!optarg ) {
820820fprintf (stderr ,"\\i must be followed by a file name\n" );
@@ -852,7 +852,7 @@ HandleSlashCmds(PsqlSettings *settings,
852852break ;
853853case 'r' :
854854 {
855- FILE * fd ;
855+ FILE * fd ;
856856static char * lastfile ;
857857struct stat st ,st2 ;
858858if (optarg )
@@ -974,9 +974,9 @@ HandleSlashCmds(PsqlSettings *settings,
974974*/
975975
976976int
977- MainLoop (PsqlSettings * settings ,FILE * source )
977+ MainLoop (PsqlSettings * settings ,FILE * source )
978978{
979- char * line ;/* line of input*/
979+ char * line ;/* line of input */
980980int len ;/* length of the line */
981981char query [MAX_QUERY_BUFFER ];/* multi-line query storage */
982982int exitStatus = 0 ;
@@ -1028,7 +1028,7 @@ MainLoop(PsqlSettings *settings, FILE* source)
10281028/* filter out comment lines that begin with --,
10291029 this could be incorrect if -- is part of a quoted string.
10301030 But we won't go through the trouble of detecting that. If you have
1031- -- in your quoted string, be careful and don't start a line with it*/
1031+ -- in your quoted string, be careful and don't start a line with it */
10321032if (line [0 ]== '-' && line [1 ]== '-' ) {
10331033if (settings -> singleStep )/* in single step mode, show comments */
10341034fprintf (stdout ,"%s\n" ,line );
@@ -1106,20 +1106,20 @@ MainLoop(PsqlSettings *settings, FILE* source)
11061106}
11071107
11081108int
1109- main (int argc ,char * * argv )
1109+ main (int argc ,char * * argv )
11101110{
1111- extern char * optarg ;
1111+ extern char * optarg ;
11121112extern int optind ;
11131113
1114- char * dbname = NULL ;
1115- char * host = NULL ;
1116- char * port = NULL ;
1117- char * qfilename = NULL ;
1114+ char * dbname = NULL ;
1115+ char * host = NULL ;
1116+ char * port = NULL ;
1117+ char * qfilename = NULL ;
11181118char errbuf [ERROR_MSG_LENGTH ];
11191119
11201120PsqlSettings settings ;
11211121
1122- char * singleQuery = NULL ;
1122+ char * singleQuery = NULL ;
11231123
11241124bool listDatabases = 0 ;
11251125int exitStatus = 0 ;
@@ -1358,10 +1358,10 @@ handleCopyIn(PGresult *res, bool quiet)
13581358PQendcopy (res -> conn );
13591359}
13601360
1361- /* try to open fname and return a FILE*,
1361+ /* try to open fname and return a FILE *,
13621362 if it fails, use stdout, instead */
13631363
1364- FILE *
1364+ FILE *
13651365setFout (PsqlSettings * ps ,char * fname )
13661366{
13671367if (ps -> queryFout && ps -> queryFout != stdout )