@@ -59,7 +59,7 @@ static char *xstrdup(const char *s);
59
59
static void * xmalloc0 (int size );
60
60
static void usage (void );
61
61
static void verify_dir_is_empty_or_create (char * dirname );
62
- static void progress_report (int tablespacenum , char * fn );
62
+ static void progress_report (int tablespacenum , const char * filename );
63
63
static PGconn * GetConnection (void );
64
64
65
65
static void ReceiveTarFile (PGconn * conn , PGresult * res , int rownum );
@@ -201,7 +201,7 @@ verify_dir_is_empty_or_create(char *dirname)
201
201
* is enabled, also print the current file name.
202
202
*/
203
203
static void
204
- progress_report (int tablespacenum , char * fn )
204
+ progress_report (int tablespacenum , const char * filename )
205
205
{
206
206
int percent = (int ) ((totaldone / 1024 ) * 100 / totalsize );
207
207
@@ -210,7 +210,7 @@ progress_report(int tablespacenum, char *fn)
210
210
211
211
if (verbose )
212
212
{
213
- if (!fn )
213
+ if (!filename )
214
214
215
215
/*
216
216
* No filename given, so clear the status line (used for last
@@ -225,7 +225,7 @@ progress_report(int tablespacenum, char *fn)
225
225
INT64_FORMAT "/" INT64_FORMAT " kB (%d%%) %d/%d tablespaces (%-30.30s)\r" ,
226
226
totaldone / 1024 , totalsize ,
227
227
percent ,
228
- tablespacenum , tablespacecount , fn );
228
+ tablespacenum , tablespacecount , filename );
229
229
}
230
230
else
231
231
fprintf (stderr , INT64_FORMAT "/" INT64_FORMAT " kB (%d%%) %d/%d tablespaces\r" ,
@@ -248,7 +248,7 @@ progress_report(int tablespacenum, char *fn)
248
248
static void
249
249
ReceiveTarFile (PGconn * conn , PGresult * res , int rownum )
250
250
{
251
- char fn [MAXPGPATH ];
251
+ char filename [MAXPGPATH ];
252
252
char * copybuf = NULL ;
253
253
FILE * tarfile = NULL ;
254
254
@@ -283,8 +283,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
283
283
#ifdef HAVE_LIBZ
284
284
if (compresslevel != 0 )
285
285
{
286
- snprintf (fn , sizeof (fn ), "%s/base.tar.gz" , basedir );
287
- ztarfile = gzopen (fn , "wb" );
286
+ snprintf (filename , sizeof (filename ), "%s/base.tar.gz" , basedir );
287
+ ztarfile = gzopen (filename , "wb" );
288
288
if (gzsetparams (ztarfile , compresslevel , Z_DEFAULT_STRATEGY ) != Z_OK )
289
289
{
290
290
fprintf (stderr , _ ("%s: could not set compression level %d: %s\n" ),
@@ -295,8 +295,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
295
295
else
296
296
#endif
297
297
{
298
- snprintf (fn , sizeof (fn ), "%s/base.tar" , basedir );
299
- tarfile = fopen (fn , "wb" );
298
+ snprintf (filename , sizeof (filename ), "%s/base.tar" , basedir );
299
+ tarfile = fopen (filename , "wb" );
300
300
}
301
301
}
302
302
else
@@ -307,8 +307,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
307
307
#ifdef HAVE_LIBZ
308
308
if (compresslevel != 0 )
309
309
{
310
- snprintf (fn , sizeof (fn ), "%s/%s.tar.gz" , basedir , PQgetvalue (res , rownum , 0 ));
311
- ztarfile = gzopen (fn , "wb" );
310
+ snprintf (filename , sizeof (filename ), "%s/%s.tar.gz" , basedir , PQgetvalue (res , rownum , 0 ));
311
+ ztarfile = gzopen (filename , "wb" );
312
312
if (gzsetparams (ztarfile , compresslevel , Z_DEFAULT_STRATEGY ) != Z_OK )
313
313
{
314
314
fprintf (stderr , _ ("%s: could not set compression level %d: %s\n" ),
@@ -319,8 +319,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
319
319
else
320
320
#endif
321
321
{
322
- snprintf (fn , sizeof (fn ), "%s/%s.tar" , basedir , PQgetvalue (res , rownum , 0 ));
323
- tarfile = fopen (fn , "wb" );
322
+ snprintf (filename , sizeof (filename ), "%s/%s.tar" , basedir , PQgetvalue (res , rownum , 0 ));
323
+ tarfile = fopen (filename , "wb" );
324
324
}
325
325
}
326
326
@@ -331,7 +331,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
331
331
{
332
332
/* Compression is in use */
333
333
fprintf (stderr , _ ("%s: could not create compressed file \"%s\": %s\n" ),
334
- progname , fn , get_gz_error (ztarfile ));
334
+ progname , filename , get_gz_error (ztarfile ));
335
335
disconnect_and_exit (1 );
336
336
}
337
337
}
@@ -342,7 +342,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
342
342
if (!tarfile )
343
343
{
344
344
fprintf (stderr , _ ("%s: could not create file \"%s\": %s\n" ),
345
- progname , fn , strerror (errno ));
345
+ progname , filename , strerror (errno ));
346
346
disconnect_and_exit (1 );
347
347
}
348
348
}
@@ -386,7 +386,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
386
386
if (gzwrite (ztarfile , zerobuf , sizeof (zerobuf )) != sizeof (zerobuf ))
387
387
{
388
388
fprintf (stderr , _ ("%s: could not write to compressed file \"%s\": %s\n" ),
389
- progname , fn , get_gz_error (ztarfile ));
389
+ progname , filename , get_gz_error (ztarfile ));
390
390
}
391
391
}
392
392
else
@@ -395,7 +395,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
395
395
if (fwrite (zerobuf , sizeof (zerobuf ), 1 , tarfile ) != 1 )
396
396
{
397
397
fprintf (stderr , _ ("%s: could not write to file \"%s\": %s\n" ),
398
- progname , fn , strerror (errno ));
398
+ progname , filename , strerror (errno ));
399
399
disconnect_and_exit (1 );
400
400
}
401
401
}
@@ -432,7 +432,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
432
432
if (gzwrite (ztarfile , copybuf , r ) != r )
433
433
{
434
434
fprintf (stderr , _ ("%s: could not write to compressed file \"%s\": %s\n" ),
435
- progname , fn , get_gz_error (ztarfile ));
435
+ progname , filename , get_gz_error (ztarfile ));
436
436
}
437
437
}
438
438
else
@@ -441,13 +441,13 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
441
441
if (fwrite (copybuf , r , 1 , tarfile ) != 1 )
442
442
{
443
443
fprintf (stderr , _ ("%s: could not write to file \"%s\": %s\n" ),
444
- progname , fn , strerror (errno ));
444
+ progname , filename , strerror (errno ));
445
445
disconnect_and_exit (1 );
446
446
}
447
447
}
448
448
totaldone += r ;
449
449
if (showprogress )
450
- progress_report (rownum , fn );
450
+ progress_report (rownum , filename );
451
451
} /* while (1) */
452
452
453
453
if (copybuf != NULL )
@@ -468,7 +468,7 @@ static void
468
468
ReceiveAndUnpackTarFile (PGconn * conn , PGresult * res , int rownum )
469
469
{
470
470
char current_path [MAXPGPATH ];
471
- char fn [MAXPGPATH ];
471
+ char filename [MAXPGPATH ];
472
472
int current_len_left ;
473
473
int current_padding = 0 ;
474
474
char * copybuf = NULL ;
@@ -563,8 +563,8 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
563
563
/*
564
564
* First part of header is zero terminated filename
565
565
*/
566
- snprintf (fn , sizeof (fn ), "%s/%s" , current_path , copybuf );
567
- if (fn [strlen (fn ) - 1 ] == '/' )
566
+ snprintf (filename , sizeof (filename ), "%s/%s" , current_path , copybuf );
567
+ if (filename [strlen (filename ) - 1 ] == '/' )
568
568
{
569
569
/*
570
570
* Ends in a slash means directory or symlink to directory
@@ -574,31 +574,31 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
574
574
/*
575
575
* Directory
576
576
*/
577
- fn [strlen (fn ) - 1 ] = '\0' ; /* Remove trailing slash */
578
- if (mkdir (fn , S_IRWXU ) != 0 )
577
+ filename [strlen (filename ) - 1 ] = '\0' ; /* Remove trailing slash */
578
+ if (mkdir (filename , S_IRWXU ) != 0 )
579
579
{
580
580
fprintf (stderr ,
581
581
_ ("%s: could not create directory \"%s\": %s\n" ),
582
- progname , fn , strerror (errno ));
582
+ progname , filename , strerror (errno ));
583
583
disconnect_and_exit (1 );
584
584
}
585
585
#ifndef WIN32
586
- if (chmod (fn , (mode_t ) filemode ))
586
+ if (chmod (filename , (mode_t ) filemode ))
587
587
fprintf (stderr , _ ("%s: could not set permissions on directory \"%s\": %s\n" ),
588
- progname , fn , strerror (errno ));
588
+ progname , filename , strerror (errno ));
589
589
#endif
590
590
}
591
591
else if (copybuf [156 ] == '2' )
592
592
{
593
593
/*
594
594
* Symbolic link
595
595
*/
596
- fn [strlen (fn ) - 1 ] = '\0' ; /* Remove trailing slash */
597
- if (symlink (& copybuf [157 ], fn ) != 0 )
596
+ filename [strlen (filename ) - 1 ] = '\0' ; /* Remove trailing slash */
597
+ if (symlink (& copybuf [157 ], filename ) != 0 )
598
598
{
599
599
fprintf (stderr ,
600
600
_ ("%s: could not create symbolic link from \"%s\" to \"%s\": %s\n" ),
601
- progname , fn , & copybuf [157 ], strerror (errno ));
601
+ progname , filename , & copybuf [157 ], strerror (errno ));
602
602
disconnect_and_exit (1 );
603
603
}
604
604
}
@@ -614,18 +614,18 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
614
614
/*
615
615
* regular file
616
616
*/
617
- file = fopen (fn , "wb" );
617
+ file = fopen (filename , "wb" );
618
618
if (!file )
619
619
{
620
620
fprintf (stderr , _ ("%s: could not create file \"%s\": %s\n" ),
621
- progname , fn , strerror (errno ));
621
+ progname , filename , strerror (errno ));
622
622
disconnect_and_exit (1 );
623
623
}
624
624
625
625
#ifndef WIN32
626
- if (chmod (fn , (mode_t ) filemode ))
626
+ if (chmod (filename , (mode_t ) filemode ))
627
627
fprintf (stderr , _ ("%s: could not set permissions on file \"%s\": %s\n" ),
628
- progname , fn , strerror (errno ));
628
+ progname , filename , strerror (errno ));
629
629
#endif
630
630
631
631
if (current_len_left == 0 )
@@ -658,12 +658,12 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
658
658
if (fwrite (copybuf , r , 1 , file ) != 1 )
659
659
{
660
660
fprintf (stderr , _ ("%s: could not write to file \"%s\": %s\n" ),
661
- progname , fn , strerror (errno ));
661
+ progname , filename , strerror (errno ));
662
662
disconnect_and_exit (1 );
663
663
}
664
664
totaldone += r ;
665
665
if (showprogress )
666
- progress_report (rownum , fn );
666
+ progress_report (rownum , filename );
667
667
668
668
current_len_left -= r ;
669
669
if (current_len_left == 0 && current_padding == 0 )
0 commit comments