7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.12 1996/07/28 06:59:43 scrappy Exp $
10
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.13 1996/07/28 07:08:13 scrappy Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -60,18 +60,18 @@ typedef struct _psqlSettings {
60
60
} PsqlSettings ;
61
61
62
62
/* declarations for functions in this file */
63
- static void usage (char * progname );
63
+ static void usage (char * progname );
64
64
static void slashUsage ();
65
65
static void handleCopyOut (PGresult * res , bool quiet );
66
66
static void handleCopyIn (PGresult * res , bool quiet );
67
67
static int tableList (PsqlSettings * ps , bool deep_tablelist );
68
68
static int tableDesc (PsqlSettings * ps , char * table );
69
69
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 );
73
73
int listAllDbs (PsqlSettings * settings );
74
- int SendQuery (PsqlSettings * settings , char * query );
74
+ int SendQuery (PsqlSettings * settings , char * query );
75
75
int HandleSlashCmds (PsqlSettings * settings ,
76
76
char * line ,
77
77
char * query );
@@ -82,15 +82,15 @@ void PQprint(FILE *fp,
82
82
PQprintOpt * po
83
83
);
84
84
85
- FILE * setFout (PsqlSettings * ps , char * fname );
85
+ FILE * setFout (PsqlSettings * ps , char * fname );
86
86
87
87
/*
88
88
* usage
89
89
* print out usage for command line arguments
90
90
*/
91
91
92
92
static void
93
- usage (char * progname )
93
+ usage (char * progname )
94
94
{
95
95
fprintf (stderr ,"Usage: %s [options] [dbname]\n" ,progname );
96
96
fprintf (stderr ,"\t -a authsvc set authentication service\n" );
187
187
listAllDbs (PsqlSettings * ps )
188
188
{
189
189
PGresult * results ;
190
- char * query = "select * from pg_database;" ;
190
+ char * query = "select * from pg_database;" ;
191
191
192
192
if (!(results = PSQLexec (ps , query )))
193
193
return 1 ;
@@ -213,10 +213,10 @@ tableList (PsqlSettings *ps, bool deep_tablelist)
213
213
char listbuf [256 ];
214
214
int nColumns ;
215
215
int i ;
216
- char * rk ;
217
- char * rr ;
216
+ char * rk ;
217
+ char * rr ;
218
218
219
- PGresult * res ;
219
+ PGresult * res ;
220
220
221
221
listbuf [0 ] = '\0' ;
222
222
strcat (listbuf ,"SELECT usename, relname, relkind, relhasrules" );
@@ -242,7 +242,7 @@ tableList (PsqlSettings *ps, bool deep_tablelist)
242
242
if ( table == NULL )
243
243
perror ("malloc" );
244
244
245
- /* load table table*/
245
+ /* load table table */
246
246
for (i = 0 ; i < nColumns ; i ++ ) {
247
247
table [i ] = (char * ) malloc (PQgetlength (res ,i ,1 ) * sizeof (char ) + 1 );
248
248
if ( table [i ] == NULL )
@@ -304,7 +304,7 @@ tableDesc (PsqlSettings *ps, char *table)
304
304
int i ;
305
305
int rsize ;
306
306
307
- PGresult * res ;
307
+ PGresult * res ;
308
308
309
309
/* Build the query */
310
310
@@ -380,13 +380,13 @@ tableDesc (PsqlSettings *ps, char *table)
380
380
}
381
381
}
382
382
383
- typedef char * (* READ_ROUTINE )(char * prompt , FILE * source );
383
+ typedef char * (* READ_ROUTINE )(char * prompt , FILE * source );
384
384
385
385
/* gets_noreadline prompt source
386
386
gets a line of input without calling readline, the source is ignored
387
387
*/
388
- char *
389
- gets_noreadline (char * prompt , FILE * source )
388
+ char *
389
+ gets_noreadline (char * prompt , FILE * source )
390
390
{
391
391
fputs (prompt , stdout );
392
392
fflush (stdout );
@@ -398,8 +398,8 @@ gets_noreadline(char* prompt, FILE* source)
398
398
* the routine to get input from GNU readline(), the source is ignored
399
399
* the prompt argument is used as the prompting string
400
400
*/
401
- char *
402
- gets_readline (char * prompt , FILE * source )
401
+ char *
402
+ gets_readline (char * prompt , FILE * source )
403
403
{
404
404
return (readline (prompt ));
405
405
}
@@ -408,12 +408,12 @@ gets_readline(char* prompt, FILE* source)
408
408
* gets_fromFile prompt source
409
409
*
410
410
* 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 *
412
412
*/
413
- char *
414
- gets_fromFile (char * prompt , FILE * source )
413
+ char *
414
+ gets_fromFile (char * prompt , FILE * source )
415
415
{
416
- char * line ;
416
+ char * line ;
417
417
int len ;
418
418
419
419
line = malloc (MAX_QUERY_BUFFER + 1 );
@@ -440,8 +440,8 @@ gets_fromFile(char* prompt, FILE* source)
440
440
int
441
441
SendQuery (PsqlSettings * settings , char * query )
442
442
{
443
- PGresult * results ;
444
- PGnotify * notify ;
443
+ PGresult * results ;
444
+ PGnotify * notify ;
445
445
int status = 0 ;
446
446
447
447
if (settings -> singleStep )
@@ -610,7 +610,7 @@ decode(char *s)
610
610
*/
611
611
int
612
612
HandleSlashCmds (PsqlSettings * settings ,
613
- char * line ,
613
+ char * line ,
614
614
char * query )
615
615
{
616
616
int status = 1 ;
@@ -766,7 +766,7 @@ HandleSlashCmds(PsqlSettings *settings,
766
766
break ;
767
767
case 'h' :
768
768
{
769
- char * cmd ;
769
+ char * cmd ;
770
770
int i , numCmds ;
771
771
int all_help = 0 ;
772
772
@@ -814,7 +814,7 @@ HandleSlashCmds(PsqlSettings *settings,
814
814
}
815
815
case 'i' : /* \i is include file */
816
816
{
817
- FILE * fd ;
817
+ FILE * fd ;
818
818
819
819
if (!optarg ) {
820
820
fprintf (stderr ,"\\i must be followed by a file name\n" );
@@ -852,7 +852,7 @@ HandleSlashCmds(PsqlSettings *settings,
852
852
break ;
853
853
case 'r' :
854
854
{
855
- FILE * fd ;
855
+ FILE * fd ;
856
856
static char * lastfile ;
857
857
struct stat st , st2 ;
858
858
if (optarg )
@@ -974,9 +974,9 @@ HandleSlashCmds(PsqlSettings *settings,
974
974
*/
975
975
976
976
int
977
- MainLoop (PsqlSettings * settings , FILE * source )
977
+ MainLoop (PsqlSettings * settings , FILE * source )
978
978
{
979
- char * line ; /* line of input*/
979
+ char * line ; /* line of input */
980
980
int len ; /* length of the line */
981
981
char query [MAX_QUERY_BUFFER ]; /* multi-line query storage */
982
982
int exitStatus = 0 ;
@@ -1028,7 +1028,7 @@ MainLoop(PsqlSettings *settings, FILE* source)
1028
1028
/* filter out comment lines that begin with --,
1029
1029
this could be incorrect if -- is part of a quoted string.
1030
1030
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 */
1032
1032
if (line [0 ] == '-' && line [1 ] == '-' ) {
1033
1033
if (settings -> singleStep ) /* in single step mode, show comments */
1034
1034
fprintf (stdout ,"%s\n" ,line );
@@ -1106,20 +1106,20 @@ MainLoop(PsqlSettings *settings, FILE* source)
1106
1106
}
1107
1107
1108
1108
int
1109
- main (int argc , char * * argv )
1109
+ main (int argc , char * * argv )
1110
1110
{
1111
- extern char * optarg ;
1111
+ extern char * optarg ;
1112
1112
extern int optind ;
1113
1113
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 ;
1118
1118
char errbuf [ERROR_MSG_LENGTH ];
1119
1119
1120
1120
PsqlSettings settings ;
1121
1121
1122
- char * singleQuery = NULL ;
1122
+ char * singleQuery = NULL ;
1123
1123
1124
1124
bool listDatabases = 0 ;
1125
1125
int exitStatus = 0 ;
@@ -1358,10 +1358,10 @@ handleCopyIn(PGresult *res, bool quiet)
1358
1358
PQendcopy (res -> conn );
1359
1359
}
1360
1360
1361
- /* try to open fname and return a FILE*,
1361
+ /* try to open fname and return a FILE *,
1362
1362
if it fails, use stdout, instead */
1363
1363
1364
- FILE *
1364
+ FILE *
1365
1365
setFout (PsqlSettings * ps , char * fname )
1366
1366
{
1367
1367
if (ps -> queryFout && ps -> queryFout != stdout )
0 commit comments