# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2001 Craig Barratt
+# Copyright (C) 2001-2003 Craig Barratt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
#========================================================================
#
-# Version 1.6.0_CVS, released 10 Dec 2002.
+# Version 2.1.0_CVS, released 3 Jul 2003.
#
# See http://backuppc.sourceforge.net.
#
#========================================================================
use strict;
+no utf8;
use lib "/usr/local/BackupPC/lib";
use File::Path;
use Getopt::Std;
my %Conf = $bpc->Conf();
my %opts;
-getopts("th:n:p:r:s:", \%opts);
-if ( @ARGV < 1 ) {
+if ( !getopts("th:n:p:r:s:", \%opts) || @ARGV < 1 ) {
print(STDERR "usage: $0 [-t] [-h host] [-n dumpNum] [-s shareName]"
. " [-r pathRemove] [-p pathAdd]"
. " files/directories...\n");
exit(1);
}
-if ( $opts{h} !~ /^([\w\.-]+)$/ ) {
+if ( $opts{h} !~ /^([\w\.\s-]+)$/ ) {
print(STDERR "$0: bad host name '$opts{h}'\n");
exit(1);
}
#
# Write out all the requested files/directories
#
+binmode(STDOUT);
my $fh = *STDOUT;
foreach my $dir ( @ARGV ) {
archiveWrite($fh, $dir);
my $done = $WriteBufSz - length($WriteBuf);
if ( syswrite($fh, $WriteBuf . substr($$dataRef, 0, $done))
!= $WriteBufSz ) {
- print(STDERR "Unable to write to output file\n");
+ print(STDERR "Unable to write to output file ($!)\n");
exit(1);
}
while ( $done + $WriteBufSz <= length($$dataRef) ) {
if ( syswrite($fh, substr($$dataRef, $done, $WriteBufSz))
!= $WriteBufSz ) {
- print(STDERR "Unable to write to output file\n");
+ print(STDERR "Unable to write to output file ($!)\n");
exit(1);
}
$done += $WriteBufSz;