From 657715ed754d69235aac62cd36f514f6dc65aab8 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Sun, 10 May 2020 15:21:30 -0400 Subject: New upstream version 0.13~~git20200326.g8e8b63c --- .cirrus.yml | 114 ++ LICENSE.txt | 158 +-- appveyor.yml | 4 +- contrib/windows/installer/bbackupd.conf.template | 352 +++---- contrib/windows/installer/tools/InstallService.bat | 6 +- .../windows/installer/tools/KillBackupProcess.bat | 6 +- contrib/windows/installer/tools/QueryOutputAll.bat | 10 +- .../windows/installer/tools/QueryOutputCurrent.bat | 10 +- contrib/windows/installer/tools/ReloadConfig.bat | 6 +- contrib/windows/installer/tools/RemoveService.bat | 6 +- contrib/windows/installer/tools/RestartService.bat | 10 +- contrib/windows/installer/tools/ShowUsage.bat | 6 +- contrib/windows/installer/tools/StartService.bat | 6 +- contrib/windows/installer/tools/StopService.bat | 6 +- contrib/windows/installer/tools/Sync.bat | 6 +- docs/xsl-generic/highlighting/common.xsl | 124 +-- docs/xsl-generic/highlighting/xslthl-config.xml | 22 +- docs/xsl-generic/html/highlight.xsl | 108 +- infrastructure/buildenv-testmain-template.cpp | 12 + .../cmake/build/bin_bbackupd.vcxproj.user | 14 +- .../cmake/build/bin_bbstored.vcxproj.user | 14 +- .../cmake/build/test_backupstore.vcxproj.user | 16 +- .../cmake/build/test_backupstorefix.vcxproj.user | 12 +- .../cmake/build/test_bbackupd.vcxproj.user | 14 +- .../cmake/build/test_common.vcxproj.user | 12 +- .../cmake/build/test_httpserver.vcxproj.user | 12 +- .../cmake/build/test_raidfile.vcxproj.user | 12 +- .../cmake/msvc/bin_bbackupd.vcxproj.user | 14 +- .../cmake/msvc/bin_bbstored.vcxproj.user | 14 +- .../cmake/msvc/test_backupstore.vcxproj.user | 16 +- .../cmake/msvc/test_backupstorefix.vcxproj.user | 12 +- .../cmake/msvc/test_bbackupd.vcxproj.user | 14 +- infrastructure/cmake/msvc/test_common.vcxproj.user | 12 +- .../cmake/msvc/test_httpserver.vcxproj.user | 12 +- .../cmake/msvc/test_raidfile.vcxproj.user | 12 +- infrastructure/m4/boxbackup_tests.m4 | 1 + infrastructure/setup-debian-chroot.sh | 18 + lib/backupclient/BackupClientRestore.cpp | 6 +- lib/backupstore/BackupClientFileAttributes.cpp | 2 +- lib/backupstore/BackupStoreFile.cpp | 2 +- lib/backupstore/BackupStoreRefCountDatabase.cpp | 6 +- lib/bbackupd/BackupClientDirectoryRecord.cpp | 330 +++--- lib/bbackupd/BackupClientDirectoryRecord.h | 5 + lib/bbackupd/BackupDaemon.cpp | 222 ++-- lib/bbackupquery/BackupQueries.cpp | 12 +- lib/common/BannerText.cpp | 14 + lib/common/BannerText.h | 43 +- lib/common/Box.h | 16 +- lib/common/BoxPlatform.h | 4 + lib/common/InvisibleTempFileStream.cpp | 2 +- lib/common/MainHelper.h | 10 +- lib/common/NamedLock.cpp | 4 +- lib/common/Test.cpp | 4 +- lib/raidfile/RaidFileWrite.cpp | 30 +- lib/server/Daemon.cpp | 2 +- lib/server/ServerControl.cpp | 4 +- lib/server/ServerStream.h | 2 +- lib/win32/emu.h | 22 +- lib/win32/getopt_long.cpp | 1092 ++++++++++---------- lib/win32/messages.rc | 4 +- qdbm/VCmakefile | 496 ++++----- qdbm/misc/VCmakefile-old | 338 +++--- qdbm/misc/win32check.bat | 222 ++-- qdbm/qdbm.def | 848 +++++++-------- test/backupstore/testbackupstore.cpp | 8 +- test/backupstorefix/testbackupstorefix.cpp | 2 +- test/backupstorepatch/testbackupstorepatch.cpp | 2 +- test/basicserver/testbasicserver.cpp | 2 +- test/bbackupd/testbbackupd.cpp | 56 +- test/httpserver/testhttpserver.cpp | 7 +- test/raidfile/testraidfile.cpp | 10 +- 71 files changed, 2667 insertions(+), 2365 deletions(-) create mode 100644 .cirrus.yml create mode 100755 infrastructure/setup-debian-chroot.sh create mode 100644 lib/common/BannerText.cpp diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..28472f78 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,114 @@ +gcp_credentials: ENCRYPTED[51b00226f2de108c3fa890e94efadc2d4efad2ca8d12d31794b8e8af33d1ece12c13d51dcf3cc0c0222cda3391a469b5] + +standard_build: &standard_build + configure_script: + - ${CHROOT} su build -c ./bootstrap + - ${CHROOT} su build -c ./configure + build_client_script: + - ${CHROOT} su build -c 'make build-backup-client' + build_server_script: + - ${CHROOT} su build -c 'make build-backup-server' + debug_tests_script: + - ${CHROOT} su build -c 'make debug_tests' + release_tests_script: + - ${CHROOT} su build -c 'make release_tests' + +standard_gce_instance: &standard_gce_instance + zone: europe-west2-c + type: n1-standard-1 # 1 vCPU, 3.75GB mem + disk: 10 + use_ssd: true + #preemptible: $CIRRUS_BRANCH != "master" + +task: + name: CentOS 7 amd64 + gce_instance: + <<: *standard_gce_instance + image_project: centos-cloud + image_name: centos-7-v20190619 + setup_script: + - yum install -y git autoconf automake gcc gcc-c++ zlib-devel openssl-devel libdb-devel readline-devel make libxslt perl-libwww-perl boost-devel + - useradd -m build + - chown -R build: . + <<: *standard_build + +task: + matrix: + - name: Debian 9 i386 + gce_instance: + <<: *standard_gce_instance + image_project: debian-cloud + image_name: debian-9-stretch-v20190618 + setup_chroot_script: + - ./infrastructure/setup-debian-chroot.sh + - schroot --begin-session --session-name stretch-build --chroot stretch + env: + CHROOT: schroot --run-session --chroot stretch-build --directory /tmp/cirrus-ci-build -- + - name: Debian 9 amd64 + gce_instance: + <<: *standard_gce_instance + image_project: debian-cloud + image_name: debian-9-stretch-v20190618 + + setup_script: + - ${CHROOT} apt-get update + - ${CHROOT} sh -c "DEBIAN_FRONTEND=noninteractive apt-get install -o Dpkg::Options::='--force-confold' -y git autoconf automake gcc g++ zlib1g-dev libssl-dev libdb-dev libreadline-dev libeditline-dev make xsltproc libwww-perl libboost-dev" + - ${CHROOT} useradd -m build + - ${CHROOT} chown -R build: . + <<: *standard_build + +task: + name: FreeBSD 12.0 amd64 + gce_instance: + <<: *standard_gce_instance + image_project: freebsd-org-cloud-dev + image_name: freebsd-12-0-release-amd64 + disk: 30 # Image is 29GB, VM can't be smaller + platform: FreeBSD + setup_script: + - pkg install -y git autoconf automake libxslt p5-libwww boost-libs + - pw useradd build -m -w none + - chown -R build: . + <<: *standard_build + +task: + name: MacOS Mojave + osx_instance: + image: mojave-xcode-10.2 + env: + CPPFLAGS: -I/usr/local/opt/openssl/include + LDFLAGS: -L/usr/local/opt/openssl/lib + setup_script: + - brew install autoconf automake openssl readline + # Don't use standard_build for now - not sure if the build user is required, or how to add users on macOS + configure_script: + - export CPPFLAGS LDFLAGS + - ./bootstrap + - ./configure + build_client_script: + - make build-backup-client + build_server_script: + - make build-backup-server + debug_tests_script: + - make debug_tests + release_tests_script: + - make release_tests + +task: + matrix: + - name: Ubuntu 16.04 amd64 + gce_instance: + <<: *standard_gce_instance + image_project: ubuntu-os-cloud + image_name: ubuntu-1604-xenial-v20190617 + - name: Ubuntu 18.04 amd64 + gce_instance: + <<: *standard_gce_instance + image_project: ubuntu-os-cloud + image_name: ubuntu-1804-bionic-v20190617 + setup_script: + - apt-get update + - apt-get install -y git autoconf automake gcc g++ zlib1g-dev libssl-dev libdb-dev libreadline-dev libeditline-dev make xsltproc libwww-perl libboost-dev + - useradd -m build + - chown -R build . + <<: *standard_build diff --git a/LICENSE.txt b/LICENSE.txt index 4f57a372..dd4e26e1 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,79 +1,79 @@ -Box Backup, http://www.boxbackup.org/ - -Copyright (c) 2003-2015, Ben Summers and contributors. -All rights reserved. - -The license of the code was changed on 23-Jan-2010 in order to meet the -Fedora Project's definition of Free Software, and therefore allow inclusion -in Fedora, Red Hat Linux and CentOS. This also solves a long-standing -incompatibility with the GNU Readline library that prevented us from -distributing Box Backup binaries compiled against that library. You can -review our discussions of the change in the mailing list archives at: -http://lists.boxbackup.org/pipermail/boxbackup/2010-January/000005.html - -Note that this project uses mixed licensing. Different parts of the project -may be used and distributed under different licenses, as described below. -The two licenses used are "Box Backup GPL" and a BSD-style license. - -For full details of the license, please read the included COPYING.txt file. - -Unless stated otherwise in the file, all files in the following directories -fall under the "Box Backup GPL" license, described below: - -bin/bbackupctl -bin/bbackupd -bin/bbackupobjdump -bin/bbackupquery -bin/bbstoreaccounts -bin/bbstored -bin/s3simulator -lib/backupclient -lib/backupstore -test/backupdiff -test/backupstore -test/backupstorefix -test/backupstorepatch -test/bbackupd -contrib/bbadmin -contrib/bbreporter -contrib/cygwin -contrib/debian -contrib/mac_osx -contrib/redhat -contrib/rpm -contrib/solaris -contrib/suse -contrib/windows -distribution/boxbackup - -The "Box Backup GPL" license text may be found in the file -LICENSE-GPL.txt, or online at: -[https://www.boxbackup.org/svn/box/trunk/LICENSE-GPL.txt] - -Unless stated otherwise in the file, all files in the following directories -are dual licensed under the BSD and GPL licenses. You may use and distribute -them providing that you comply EITHER with the terms of the BSD license, -OR the GPL license. It is not necessary to comply with both licenses, -only one. - -lib/common -lib/compress -lib/crypto -lib/httpserver -lib/intercept -lib/raidfile -lib/server -lib/win32 -test/basicserver -test/common -test/compress -test/crypto -test/httpserver -test/raidfile -test/win32 -infrastructure -distribution - -The dual license text may be found in the file -LICENSE-DUAL.txt, or online at: -[https://www.boxbackup.org/svn/box/trunk/LICENSE-DUAL.txt] +Box Backup, http://www.boxbackup.org/ + +Copyright (c) 2003-2015, Ben Summers and contributors. +All rights reserved. + +The license of the code was changed on 23-Jan-2010 in order to meet the +Fedora Project's definition of Free Software, and therefore allow inclusion +in Fedora, Red Hat Linux and CentOS. This also solves a long-standing +incompatibility with the GNU Readline library that prevented us from +distributing Box Backup binaries compiled against that library. You can +review our discussions of the change in the mailing list archives at: +http://lists.boxbackup.org/pipermail/boxbackup/2010-January/000005.html + +Note that this project uses mixed licensing. Different parts of the project +may be used and distributed under different licenses, as described below. +The two licenses used are "Box Backup GPL" and a BSD-style license. + +For full details of the license, please read the included COPYING.txt file. + +Unless stated otherwise in the file, all files in the following directories +fall under the "Box Backup GPL" license, described below: + +bin/bbackupctl +bin/bbackupd +bin/bbackupobjdump +bin/bbackupquery +bin/bbstoreaccounts +bin/bbstored +bin/s3simulator +lib/backupclient +lib/backupstore +test/backupdiff +test/backupstore +test/backupstorefix +test/backupstorepatch +test/bbackupd +contrib/bbadmin +contrib/bbreporter +contrib/cygwin +contrib/debian +contrib/mac_osx +contrib/redhat +contrib/rpm +contrib/solaris +contrib/suse +contrib/windows +distribution/boxbackup + +The "Box Backup GPL" license text may be found in the file +LICENSE-GPL.txt, or online at: +[https://www.boxbackup.org/svn/box/trunk/LICENSE-GPL.txt] + +Unless stated otherwise in the file, all files in the following directories +are dual licensed under the BSD and GPL licenses. You may use and distribute +them providing that you comply EITHER with the terms of the BSD license, +OR the GPL license. It is not necessary to comply with both licenses, +only one. + +lib/common +lib/compress +lib/crypto +lib/httpserver +lib/intercept +lib/raidfile +lib/server +lib/win32 +test/basicserver +test/common +test/compress +test/crypto +test/httpserver +test/raidfile +test/win32 +infrastructure +distribution + +The dual license text may be found in the file +LICENSE-DUAL.txt, or online at: +[https://www.boxbackup.org/svn/box/trunk/LICENSE-DUAL.txt] diff --git a/appveyor.yml b/appveyor.yml index 44603450..6e33ceb0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,8 +29,10 @@ init: # - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - ps: $env:date_string = Get-Date -Format "yyMMdd" - ps: $env:sane_platform = $($env:PLATFORM.replace("Win32", "x86")) + # Ensafen e.g. "jamesog/cirrus-ci" + - ps: $env:safer_branch = $($env:APPVEYOR_REPO_BRANCH.replace("/", "_")) # http://help.appveyor.com/discussions/problems/2874-how-can-i-add-commit-id-to-build-version - - ps: $env:boxbackup_version_full="$env:BOXBACKUP_VERSION_BASE.$env:APPVEYOR_REPO_BRANCH.$env:date_string.$($env:APPVEYOR_REPO_COMMIT.substring(0,7))" + - ps: $env:boxbackup_version_full="$env:BOXBACKUP_VERSION_BASE.$env:safer_branch.$env:date_string.$($env:APPVEYOR_REPO_COMMIT.substring(0,7))" - ps: Update-AppveyorBuild -Version "$env:boxbackup_version_full" - ps: $env:compiled_version="$($env:boxbackup_version_full)_Win_$($env:sane_platform)_$($env:CONFIGURATION)" # The only way to switch between 32-bit and 64-bit compilers appears to be to append " Win64" diff --git a/contrib/windows/installer/bbackupd.conf.template b/contrib/windows/installer/bbackupd.conf.template index cf61e72e..969ca619 100644 --- a/contrib/windows/installer/bbackupd.conf.template +++ b/contrib/windows/installer/bbackupd.conf.template @@ -1,176 +1,176 @@ -StoreHostname = @@ServerName@@ -AccountNumber = 0x@@AccountNo@@ -KeysFile = @@InstallDir@@/conf/@@AccountNo@@-FileEncKeys.raw - -CertificateFile = @@InstallDir@@/conf/@@AccountNo@@-cert.pem -PrivateKeyFile = @@InstallDir@@/conf/@@AccountNo@@-key.pem -TrustedCAsFile = @@InstallDir@@/conf/serverCA.pem - -DataDirectory = @@InstallDir@@/state - - -# This script is run whenever bbackupd changes state or encounters a -# problem which requires the system administrator to assist: -# -# 1) The store is full, and no more data can be uploaded. -# 2) Some files or directories were not readable. -# 3) A backup run starts or finishes. -# -# The default script emails the system administrator, except for backups -# starting and stopping, where it does nothing. - -NotifyScript = @@InstallDir@@/bin/NotifySysAdmin.vbs - -# The number of seconds between backup runs under normal conditions. To avoid -# cycles of load on the server, this time is randomly adjusted by a small -# percentage as the daemon runs. - -UpdateStoreInterval = 3600 - - -# The minimum age of a file, in seconds, that will be uploaded. Avoids -# repeated uploads of a file which is constantly being modified. - -MinimumFileAge = 21600 - -# If a file is modified repeated, it won't be uploaded immediately in case -# it's modified again, due to the MinimumFileAge specified above. However, it -# should be uploaded eventually even if it is being modified repeatedly. This -# is how long we should wait, in seconds, after first noticing a change. -# (86400 seconds = 1 day) - -MaxUploadWait = 86400 - -# If the connection is idle for some time (e.g. over 10 minutes or 600 -# seconds, not sure exactly how long) then the server will give up and -# disconnect the client, resulting in Connection Protocol_Timeout errors -# on the server and TLSReadFailed or TLSWriteFailed errors on the client. -# Also, some firewalls and NAT gateways will kill idle connections after -# similar lengths of time. -# -# This can happen for example when most files are backed up already and -# don't need to be sent to the store again, while scanning a large -# directory, or while calculating diffs of a large file. To avoid this, -# KeepAliveTime specifies that special keep-alive messages should be sent -# when the connection is otherwise idle for a certain length of time, -# specified here in seconds. -# -# The default is that these messages are never sent, equivalent to setting -# this option to zero, but we recommend that all users enable this. - -KeepAliveTime = 120 - -# Files above this size (in bytes) are tracked, and if they are renamed they will simply be -# renamed on the server, rather than being uploaded again. (64k - 1) - -FileTrackingSizeThreshold = 65535 - -# The daemon does "changes only" uploads for files above this size (in bytes). -# Files less than it are uploaded whole without this extra processing. - -DiffingUploadSizeThreshold = 8192 - -# The limit on how much time is spent diffing files, in seconds. Most files -# shouldn't take very long, but if you have really big files you can use this -# to limit the time spent diffing them. -# -# * Reduce if you are having problems with processor usage. -# -# * Increase if you have large files, and think the upload of changes is too -# large and you want bbackupd to spend more time searching for unchanged -# blocks. - -MaximumDiffingTime = 120 - -# Uncomment this line to see exactly what the daemon is going when it's connected to the server. - -# ExtendedLogging = yes - -# This specifies a program or script script which is run just before each -# sync, and ideally the full path to the interpreter. It will be run as the -# same user bbackupd is running as, usually root. -# -# The script must output (print) either "now" or a number to STDOUT (and a -# terminating newline, no quotes). -# -# If the result was "now", then the sync will happen. If it's a number, then -# no backup will happen for that number of seconds (bbackupd will pause) and -# then the script will be run again. -# -# Use this to temporarily stop bbackupd from syncronising or connecting to the -# store. For example, you could use this on a laptop to only backup when on a -# specific network, or when it has a working Internet connection. - -# SyncAllowScript = /path/to/intepreter/or/exe script-name parameters etc - -# Where the command socket is created in the filesystem. - -CommandSocket = @@CommandSocketNamedPipe@@ - -# Uncomment the StoreObjectInfoFile to enable the experimental archiving -# of the daemon's state (including client store marker and configuration) -# between backup runs. This saves time and increases efficiency when -# bbackupd is frequently stopped and started, since it removes the need -# to rescan all directories on the remote server. However, it is new and -# not yet heavily tested, so use with caution. - -StoreObjectInfoFile = @@InstallDir@@/state/bbackupd.state - -Server -{ - PidFile = @@InstallDir@@/state/bbackupd.pid -} - -# BackupLocations specifies which locations on disc should be backed up. Each -# directory is in the format -# -# name -# { -# Path = /path/of/directory -# (optional exclude directives) -# } -# -# 'name' is derived from the Path by the config script, but should merely be -# unique. -# -# The exclude directives are of the form -# -# [Exclude|AlwaysInclude][File|Dir][|sRegex] = regex or full pathname -# -# (The regex suffix is shown as 'sRegex' to make File or Dir plural) -# -# For example: -# -# ExcludeDir = /home/guest-user -# ExcludeFilesRegex = \.(mp3|MP3)\$ -# AlwaysIncludeFile = /home/username/veryimportant.mp3 -# -# This excludes the directory /home/guest-user from the backup along with all mp3 -# files, except one MP3 file in particular. -# -# In general, Exclude excludes a file or directory, unless the directory is -# explicitly mentioned in a AlwaysInclude directive. However, Box Backup -# does NOT scan inside excluded directories and will never back up an -# AlwaysIncluded file or directory inside an excluded directory or any -# subdirectory thereof. -# -# To back up a directory inside an excluded directory, use a configuration -# like this, to ensure that each directory in the path to the important -# files is included, but none of their contents will be backed up except -# the directories further down that path to the important one. -# -# ExcludeDirsRegex = ^/home/user/bigfiles/ -# ExcludeFilesRegex = ^/home/user/bigfiles/ -# AlwaysIncludeDir = /home/user/bigfiles/path -# AlwaysIncludeDir = /home/user/bigfiles/path/to -# AlwaysIncludeDir = /home/user/bigfiles/path/important -# AlwaysIncludeDir = /home/user/bigfiles/path/important/files -# AlwaysIncludeDirsRegex = ^/home/user/bigfiles/path/important/files/ -# AlwaysIncludeFilesRegex = ^/home/user/bigfiles/path/important/files/ -# -# If a directive ends in Regex, then it is a regular expression rather than a -# explicit full pathname. See -# -# man 7 re_format -# -# for the regex syntax on your platform. +StoreHostname = @@ServerName@@ +AccountNumber = 0x@@AccountNo@@ +KeysFile = @@InstallDir@@/conf/@@AccountNo@@-FileEncKeys.raw + +CertificateFile = @@InstallDir@@/conf/@@AccountNo@@-cert.pem +PrivateKeyFile = @@InstallDir@@/conf/@@AccountNo@@-key.pem +TrustedCAsFile = @@InstallDir@@/conf/serverCA.pem + +DataDirectory = @@InstallDir@@/state + + +# This script is run whenever bbackupd changes state or encounters a +# problem which requires the system administrator to assist: +# +# 1) The store is full, and no more data can be uploaded. +# 2) Some files or directories were not readable. +# 3) A backup run starts or finishes. +# +# The default script emails the system administrator, except for backups +# starting and stopping, where it does nothing. + +NotifyScript = @@InstallDir@@/bin/NotifySysAdmin.vbs + +# The number of seconds between backup runs under normal conditions. To avoid +# cycles of load on the server, this time is randomly adjusted by a small +# percentage as the daemon runs. + +UpdateStoreInterval = 3600 + + +# The minimum age of a file, in seconds, that will be uploaded. Avoids +# repeated uploads of a file which is constantly being modified. + +MinimumFileAge = 21600 + +# If a file is modified repeated, it won't be uploaded immediately in case +# it's modified again, due to the MinimumFileAge specified above. However, it +# should be uploaded eventually even if it is being modified repeatedly. This +# is how long we should wait, in seconds, after first noticing a change. +# (86400 seconds = 1 day) + +MaxUploadWait = 86400 + +# If the connection is idle for some time (e.g. over 10 minutes or 600 +# seconds, not sure exactly how long) then the server will give up and +# disconnect the client, resulting in Connection Protocol_Timeout errors +# on the server and TLSReadFailed or TLSWriteFailed errors on the client. +# Also, some firewalls and NAT gateways will kill idle connections after +# similar lengths of time. +# +# This can happen for example when most files are backed up already and +# don't need to be sent to the store again, while scanning a large +# directory, or while calculating diffs of a large file. To avoid this, +# KeepAliveTime specifies that special keep-alive messages should be sent +# when the connection is otherwise idle for a certain length of time, +# specified here in seconds. +# +# The default is that these messages are never sent, equivalent to setting +# this option to zero, but we recommend that all users enable this. + +KeepAliveTime = 120 + +# Files above this size (in bytes) are tracked, and if they are renamed they will simply be +# renamed on the server, rather than being uploaded again. (64k - 1) + +FileTrackingSizeThreshold = 65535 + +# The daemon does "changes only" uploads for files above this size (in bytes). +# Files less than it are uploaded whole without this extra processing. + +DiffingUploadSizeThreshold = 8192 + +# The limit on how much time is spent diffing files, in seconds. Most files +# shouldn't take very long, but if you have really big files you can use this +# to limit the time spent diffing them. +# +# * Reduce if you are having problems with processor usage. +# +# * Increase if you have large files, and think the upload of changes is too +# large and you want bbackupd to spend more time searching for unchanged +# blocks. + +MaximumDiffingTime = 120 + +# Uncomment this line to see exactly what the daemon is going when it's connected to the server. + +# ExtendedLogging = yes + +# This specifies a program or script script which is run just before each +# sync, and ideally the full path to the interpreter. It will be run as the +# same user bbackupd is running as, usually root. +# +# The script must output (print) either "now" or a number to STDOUT (and a +# terminating newline, no quotes). +# +# If the result was "now", then the sync will happen. If it's a number, then +# no backup will happen for that number of seconds (bbackupd will pause) and +# then the script will be run again. +# +# Use this to temporarily stop bbackupd from syncronising or connecting to the +# store. For example, you could use this on a laptop to only backup when on a +# specific network, or when it has a working Internet connection. + +# SyncAllowScript = /path/to/intepreter/or/exe script-name parameters etc + +# Where the command socket is created in the filesystem. + +CommandSocket = @@CommandSocketNamedPipe@@ + +# Uncomment the StoreObjectInfoFile to enable the experimental archiving +# of the daemon's state (including client store marker and configuration) +# between backup runs. This saves time and increases efficiency when +# bbackupd is frequently stopped and started, since it removes the need +# to rescan all directories on the remote server. However, it is new and +# not yet heavily tested, so use with caution. + +StoreObjectInfoFile = @@InstallDir@@/state/bbackupd.state + +Server +{ + PidFile = @@InstallDir@@/state/bbackupd.pid +} + +# BackupLocations specifies which locations on disc should be backed up. Each +# directory is in the format +# +# name +# { +# Path = /path/of/directory +# (optional exclude directives) +# } +# +# 'name' is derived from the Path by the config script, but should merely be +# unique. +# +# The exclude directives are of the form +# +# [Exclude|AlwaysInclude][File|Dir][|sRegex] = regex or full pathname +# +# (The regex suffix is shown as 'sRegex' to make File or Dir plural) +# +# For example: +# +# ExcludeDir = /home/guest-user +# ExcludeFilesRegex = \.(mp3|MP3)\$ +# AlwaysIncludeFile = /home/username/veryimportant.mp3 +# +# This excludes the directory /home/guest-user from the backup along with all mp3 +# files, except one MP3 file in particular. +# +# In general, Exclude excludes a file or directory, unless the directory is +# explicitly mentioned in a AlwaysInclude directive. However, Box Backup +# does NOT scan inside excluded directories and will never back up an +# AlwaysIncluded file or directory inside an excluded directory or any +# subdirectory thereof. +# +# To back up a directory inside an excluded directory, use a configuration +# like this, to ensure that each directory in the path to the important +# files is included, but none of their contents will be backed up except +# the directories further down that path to the important one. +# +# ExcludeDirsRegex = ^/home/user/bigfiles/ +# ExcludeFilesRegex = ^/home/user/bigfiles/ +# AlwaysIncludeDir = /home/user/bigfiles/path +# AlwaysIncludeDir = /home/user/bigfiles/path/to +# AlwaysIncludeDir = /home/user/bigfiles/path/important +# AlwaysIncludeDir = /home/user/bigfiles/path/important/files +# AlwaysIncludeDirsRegex = ^/home/user/bigfiles/path/important/files/ +# AlwaysIncludeFilesRegex = ^/home/user/bigfiles/path/important/files/ +# +# If a directive ends in Regex, then it is a regular expression rather than a +# explicit full pathname. See +# +# man 7 re_format +# +# for the regex syntax on your platform. diff --git a/contrib/windows/installer/tools/InstallService.bat b/contrib/windows/installer/tools/InstallService.bat index 94696440..80a342eb 100755 --- a/contrib/windows/installer/tools/InstallService.bat +++ b/contrib/windows/installer/tools/InstallService.bat @@ -1,3 +1,3 @@ -service.exe -i -S GigaLock -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +service.exe -i -S GigaLock +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/contrib/windows/installer/tools/KillBackupProcess.bat b/contrib/windows/installer/tools/KillBackupProcess.bat index 87343c57..416d4a79 100755 --- a/contrib/windows/installer/tools/KillBackupProcess.bat +++ b/contrib/windows/installer/tools/KillBackupProcess.bat @@ -1,3 +1,3 @@ -control.exe terminate -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +control.exe terminate +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/contrib/windows/installer/tools/QueryOutputAll.bat b/contrib/windows/installer/tools/QueryOutputAll.bat index c58b4ab6..2ab30a72 100755 --- a/contrib/windows/installer/tools/QueryOutputAll.bat +++ b/contrib/windows/installer/tools/QueryOutputAll.bat @@ -1,5 +1,5 @@ -@ECHO OFF -: o=old, d=deleted, s=size info, t=timestamp, r=recursive -set Queryopts=-odstr -::set Queryopts=-str -query.exe "list %Queryopts%" quit > QueryOutputAllResults.txt +@ECHO OFF +: o=old, d=deleted, s=size info, t=timestamp, r=recursive +set Queryopts=-odstr +::set Queryopts=-str +query.exe "list %Queryopts%" quit > QueryOutputAllResults.txt diff --git a/contrib/windows/installer/tools/QueryOutputCurrent.bat b/contrib/windows/installer/tools/QueryOutputCurrent.bat index 2142b83f..d59ddbf1 100755 --- a/contrib/windows/installer/tools/QueryOutputCurrent.bat +++ b/contrib/windows/installer/tools/QueryOutputCurrent.bat @@ -1,5 +1,5 @@ -@ECHO OFF -: o=old, d=deleted, s=size info, t=timestamp, r=recursive -::set Queryopts=-odstr -set Queryopts=-str -query.exe "list %Queryopts%" quit > QueryOutputCurrentResults.txt +@ECHO OFF +: o=old, d=deleted, s=size info, t=timestamp, r=recursive +::set Queryopts=-odstr +set Queryopts=-str +query.exe "list %Queryopts%" quit > QueryOutputCurrentResults.txt diff --git a/contrib/windows/installer/tools/ReloadConfig.bat b/contrib/windows/installer/tools/ReloadConfig.bat index 911afb0a..5fd44e83 100755 --- a/contrib/windows/installer/tools/ReloadConfig.bat +++ b/contrib/windows/installer/tools/ReloadConfig.bat @@ -1,3 +1,3 @@ -control.exe reload -echo off -ping 192.168.254.254 -n 8 -w 1000 > nul +control.exe reload +echo off +ping 192.168.254.254 -n 8 -w 1000 > nul diff --git a/contrib/windows/installer/tools/RemoveService.bat b/contrib/windows/installer/tools/RemoveService.bat index 193f272f..881ec5b1 100755 --- a/contrib/windows/installer/tools/RemoveService.bat +++ b/contrib/windows/installer/tools/RemoveService.bat @@ -1,3 +1,3 @@ -@@SERVICEEXENAME@ -r -S GigaLock -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +@@SERVICEEXENAME@ -r -S GigaLock +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/contrib/windows/installer/tools/RestartService.bat b/contrib/windows/installer/tools/RestartService.bat index 87a0a4ef..77092a69 100755 --- a/contrib/windows/installer/tools/RestartService.bat +++ b/contrib/windows/installer/tools/RestartService.bat @@ -1,5 +1,5 @@ -net stop GigaLock -ping 192.168.254.254 -n 2 -w 1000 > nul -net start GigaLock -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +net stop GigaLock +ping 192.168.254.254 -n 2 -w 1000 > nul +net start GigaLock +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/contrib/windows/installer/tools/ShowUsage.bat b/contrib/windows/installer/tools/ShowUsage.bat index 2ac0f37d..e6f69e9f 100755 --- a/contrib/windows/installer/tools/ShowUsage.bat +++ b/contrib/windows/installer/tools/ShowUsage.bat @@ -1,3 +1,3 @@ -query.exe usage quit -ping 192.168.254.254 -n 10 -w 1000 > nul - +query.exe usage quit +ping 192.168.254.254 -n 10 -w 1000 > nul + diff --git a/contrib/windows/installer/tools/StartService.bat b/contrib/windows/installer/tools/StartService.bat index dc7dce7e..1771238f 100755 --- a/contrib/windows/installer/tools/StartService.bat +++ b/contrib/windows/installer/tools/StartService.bat @@ -1,3 +1,3 @@ -net start GigaLock -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +net start GigaLock +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/contrib/windows/installer/tools/StopService.bat b/contrib/windows/installer/tools/StopService.bat index 056cc69e..8e70d68d 100755 --- a/contrib/windows/installer/tools/StopService.bat +++ b/contrib/windows/installer/tools/StopService.bat @@ -1,3 +1,3 @@ -net stop GigaLock -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +net stop GigaLock +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/contrib/windows/installer/tools/Sync.bat b/contrib/windows/installer/tools/Sync.bat index 0357070a..30a04bec 100755 --- a/contrib/windows/installer/tools/Sync.bat +++ b/contrib/windows/installer/tools/Sync.bat @@ -1,3 +1,3 @@ -control.exe sync -echo off -ping 192.168.254.254 -n 5 -w 1000 > nul +control.exe sync +echo off +ping 192.168.254.254 -n 5 -w 1000 > nul diff --git a/docs/xsl-generic/highlighting/common.xsl b/docs/xsl-generic/highlighting/common.xsl index 23ac77ea..32f1bbcf 100644 --- a/docs/xsl-generic/highlighting/common.xsl +++ b/docs/xsl-generic/highlighting/common.xsl @@ -1,62 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/xsl-generic/highlighting/xslthl-config.xml b/docs/xsl-generic/highlighting/xslthl-config.xml index dd83aa77..7c77f6fc 100644 --- a/docs/xsl-generic/highlighting/xslthl-config.xml +++ b/docs/xsl-generic/highlighting/xslthl-config.xml @@ -1,11 +1,11 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/docs/xsl-generic/html/highlight.xsl b/docs/xsl-generic/html/highlight.xsl index 05896cd9..30f2153e 100644 --- a/docs/xsl-generic/html/highlight.xsl +++ b/docs/xsl-generic/html/highlight.xsl @@ -1,54 +1,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/infrastructure/buildenv-testmain-template.cpp b/infrastructure/buildenv-testmain-template.cpp index d946c25d..6aba82c5 100644 --- a/infrastructure/buildenv-testmain-template.cpp +++ b/infrastructure/buildenv-testmain-template.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef HAVE_OPENSSL_CLEANUP +# include +#endif + #include "box_getopt.h" #include "depot.h" #include "Logging.h" @@ -392,6 +396,14 @@ int main(int argc, char * const * argv) { Logging::GetSyslog().Shutdown(); + // On Ubuntu 18.04, initialising OpenSSL 1.1.1 leaves open file handles to + // /dev/[u]random which are not easy to close (the docs for OPENSSL_cleanup + // recommend not to call it), but we want to avoid detecting those as + // leaking file descriptors +#ifdef HAVE_OPENSSL_CLEANUP + OPENSSL_cleanup(); +#endif + bool filesleftopen = !checkfilesleftopen(); fflush(stdout); diff --git a/infrastructure/cmake/build/bin_bbackupd.vcxproj.user b/infrastructure/cmake/build/bin_bbackupd.vcxproj.user index fa1f3d34..51928554 100755 --- a/infrastructure/cmake/build/bin_bbackupd.vcxproj.user +++ b/infrastructure/cmake/build/bin_bbackupd.vcxproj.user @@ -1,8 +1,8 @@ - - - - testfiles\bbackupd.conf - $(ProjectDir)\..\..\..\debug\test\bbackupd - WindowsLocalDebugger - + + + + testfiles\bbackupd.conf + $(ProjectDir)\..\..\..\debug\test\bbackupd + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/build/bin_bbstored.vcxproj.user b/infrastructure/cmake/build/bin_bbstored.vcxproj.user index 339cddee..e48b8383 100755 --- a/infrastructure/cmake/build/bin_bbstored.vcxproj.user +++ b/infrastructure/cmake/build/bin_bbstored.vcxproj.user @@ -1,8 +1,8 @@ - - - - testfiles/bbstored.conf - $(ProjectDir)\..\..\..\debug\test\backupstorefix - WindowsLocalDebugger - + + + + testfiles/bbstored.conf + $(ProjectDir)\..\..\..\debug\test\backupstorefix + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/build/test_backupstore.vcxproj.user b/infrastructure/cmake/build/test_backupstore.vcxproj.user index 7d7b3158..79ef7571 100755 --- a/infrastructure/cmake/build/test_backupstore.vcxproj.user +++ b/infrastructure/cmake/build/test_backupstore.vcxproj.user @@ -1,9 +1,9 @@ - - - - $(ProjectDir)\..\..\..\debug\test\backupstore - WindowsLocalDebugger - - - + + + + $(ProjectDir)\..\..\..\debug\test\backupstore + WindowsLocalDebugger + + + \ No newline at end of file diff --git a/infrastructure/cmake/build/test_backupstorefix.vcxproj.user b/infrastructure/cmake/build/test_backupstorefix.vcxproj.user index 170fb496..c0895191 100755 --- a/infrastructure/cmake/build/test_backupstorefix.vcxproj.user +++ b/infrastructure/cmake/build/test_backupstorefix.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\backupstorefix - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\backupstorefix + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/build/test_bbackupd.vcxproj.user b/infrastructure/cmake/build/test_bbackupd.vcxproj.user index ebf8c6a3..9ca2b5e9 100755 --- a/infrastructure/cmake/build/test_bbackupd.vcxproj.user +++ b/infrastructure/cmake/build/test_bbackupd.vcxproj.user @@ -1,8 +1,8 @@ - - - - -e test_basics - $(ProjectDir)\..\..\..\debug\test\bbackupd - WindowsLocalDebugger - + + + + -e test_basics + $(ProjectDir)\..\..\..\debug\test\bbackupd + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/build/test_common.vcxproj.user b/infrastructure/cmake/build/test_common.vcxproj.user index e5854a80..7a375f10 100755 --- a/infrastructure/cmake/build/test_common.vcxproj.user +++ b/infrastructure/cmake/build/test_common.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\common - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\common + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/build/test_httpserver.vcxproj.user b/infrastructure/cmake/build/test_httpserver.vcxproj.user index ac1512a8..b2da015c 100755 --- a/infrastructure/cmake/build/test_httpserver.vcxproj.user +++ b/infrastructure/cmake/build/test_httpserver.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\httpserver - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\httpserver + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/build/test_raidfile.vcxproj.user b/infrastructure/cmake/build/test_raidfile.vcxproj.user index 620aa4bb..d2c2fc34 100755 --- a/infrastructure/cmake/build/test_raidfile.vcxproj.user +++ b/infrastructure/cmake/build/test_raidfile.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\raidfile - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\raidfile + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/bin_bbackupd.vcxproj.user b/infrastructure/cmake/msvc/bin_bbackupd.vcxproj.user index fa1f3d34..51928554 100755 --- a/infrastructure/cmake/msvc/bin_bbackupd.vcxproj.user +++ b/infrastructure/cmake/msvc/bin_bbackupd.vcxproj.user @@ -1,8 +1,8 @@ - - - - testfiles\bbackupd.conf - $(ProjectDir)\..\..\..\debug\test\bbackupd - WindowsLocalDebugger - + + + + testfiles\bbackupd.conf + $(ProjectDir)\..\..\..\debug\test\bbackupd + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/bin_bbstored.vcxproj.user b/infrastructure/cmake/msvc/bin_bbstored.vcxproj.user index 339cddee..e48b8383 100755 --- a/infrastructure/cmake/msvc/bin_bbstored.vcxproj.user +++ b/infrastructure/cmake/msvc/bin_bbstored.vcxproj.user @@ -1,8 +1,8 @@ - - - - testfiles/bbstored.conf - $(ProjectDir)\..\..\..\debug\test\backupstorefix - WindowsLocalDebugger - + + + + testfiles/bbstored.conf + $(ProjectDir)\..\..\..\debug\test\backupstorefix + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/test_backupstore.vcxproj.user b/infrastructure/cmake/msvc/test_backupstore.vcxproj.user index 7d7b3158..79ef7571 100755 --- a/infrastructure/cmake/msvc/test_backupstore.vcxproj.user +++ b/infrastructure/cmake/msvc/test_backupstore.vcxproj.user @@ -1,9 +1,9 @@ - - - - $(ProjectDir)\..\..\..\debug\test\backupstore - WindowsLocalDebugger - - - + + + + $(ProjectDir)\..\..\..\debug\test\backupstore + WindowsLocalDebugger + + + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/test_backupstorefix.vcxproj.user b/infrastructure/cmake/msvc/test_backupstorefix.vcxproj.user index 170fb496..c0895191 100755 --- a/infrastructure/cmake/msvc/test_backupstorefix.vcxproj.user +++ b/infrastructure/cmake/msvc/test_backupstorefix.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\backupstorefix - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\backupstorefix + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/test_bbackupd.vcxproj.user b/infrastructure/cmake/msvc/test_bbackupd.vcxproj.user index ebf8c6a3..9ca2b5e9 100755 --- a/infrastructure/cmake/msvc/test_bbackupd.vcxproj.user +++ b/infrastructure/cmake/msvc/test_bbackupd.vcxproj.user @@ -1,8 +1,8 @@ - - - - -e test_basics - $(ProjectDir)\..\..\..\debug\test\bbackupd - WindowsLocalDebugger - + + + + -e test_basics + $(ProjectDir)\..\..\..\debug\test\bbackupd + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/test_common.vcxproj.user b/infrastructure/cmake/msvc/test_common.vcxproj.user index e5854a80..7a375f10 100755 --- a/infrastructure/cmake/msvc/test_common.vcxproj.user +++ b/infrastructure/cmake/msvc/test_common.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\common - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\common + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/test_httpserver.vcxproj.user b/infrastructure/cmake/msvc/test_httpserver.vcxproj.user index ac1512a8..b2da015c 100755 --- a/infrastructure/cmake/msvc/test_httpserver.vcxproj.user +++ b/infrastructure/cmake/msvc/test_httpserver.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\httpserver - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\httpserver + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/cmake/msvc/test_raidfile.vcxproj.user b/infrastructure/cmake/msvc/test_raidfile.vcxproj.user index 620aa4bb..d2c2fc34 100755 --- a/infrastructure/cmake/msvc/test_raidfile.vcxproj.user +++ b/infrastructure/cmake/msvc/test_raidfile.vcxproj.user @@ -1,7 +1,7 @@ - - - - $(ProjectDir)\..\..\..\debug\test\raidfile - WindowsLocalDebugger - + + + + $(ProjectDir)\..\..\..\debug\test\raidfile + WindowsLocalDebugger + \ No newline at end of file diff --git a/infrastructure/m4/boxbackup_tests.m4 b/infrastructure/m4/boxbackup_tests.m4 index 61cd34c2..15f132cb 100644 --- a/infrastructure/m4/boxbackup_tests.m4 +++ b/infrastructure/m4/boxbackup_tests.m4 @@ -145,6 +145,7 @@ Upgrade or read the documentation for alternatives]]) ]) AC_CHECK_FUNCS([SSL_CTX_set_security_level], [HAVE_SSL_CTX_SET_SECURITY_LEVEL=1]) AC_SUBST([HAVE_SSL_CTX_SET_SECURITY_LEVEL]) +AC_CHECK_FUNCS([OPENSSL_cleanup]) ### Checks for header files. diff --git a/infrastructure/setup-debian-chroot.sh b/infrastructure/setup-debian-chroot.sh new file mode 100755 index 00000000..1e03bd75 --- /dev/null +++ b/infrastructure/setup-debian-chroot.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -ex + +CHROOT_BASE=/var/chroot +LSB_RELEASE=$(lsb_release -s -c) + +apt-get update +apt-get install -y debootstrap schroot + +mkdir -p ${CHROOT_BASE} +debootstrap --arch=i386 --variant=buildd "${LSB_RELEASE}" "${CHROOT_BASE}/${LSB_RELEASE}-i386" http://deb.debian.org/debian +cat > /etc/schroot/chroot.d/ci < { BOX_WARNING(BOX_FILE_MESSAGE(Filename, "Overwriting existing " "temporary reference count database")); - if (unlink(Filename.c_str()) != 0) + if(EMU_UNLINK(Filename.c_str()) != 0) { THROW_SYS_FILE_ERROR("Failed to delete old temporary " "reference count database file", Filename, diff --git a/lib/bbackupd/BackupClientDirectoryRecord.cpp b/lib/bbackupd/BackupClientDirectoryRecord.cpp index 94cb7965..50b5a4bc 100644 --- a/lib/bbackupd/BackupClientDirectoryRecord.cpp +++ b/lib/bbackupd/BackupClientDirectoryRecord.cpp @@ -159,6 +159,9 @@ void BackupClientDirectoryRecord::SyncDirectory( THROW_EXCEPTION(BackupStoreException, SignalReceived) } + std::string local_path_non_vss = ConvertVssPathToRealPath(rLocalPath, + rBackupLocation); + // Start by making some flag changes, marking this sync as not done, // and on the immediate sub directories. mSyncDone = false; @@ -192,8 +195,7 @@ void BackupClientDirectoryRecord::SyncDirectory( // just ignore this error. In a future scan, this // deletion will be noticed, deleted from server, // and this object deleted. - rNotifier.NotifyDirStatFailed(this, - ConvertVssPathToRealPath(rLocalPath, rBackupLocation), + rNotifier.NotifyDirStatFailed(this, local_path_non_vss, strerror(errno)); return; } @@ -208,7 +210,7 @@ void BackupClientDirectoryRecord::SyncDirectory( BackupClientInodeToIDMap &idMap( rParams.mrContext.GetNewIDMap()); idMap.AddToMap(dest_st.st_ino, mObjectID, ContainingDirectoryID, - ConvertVssPathToRealPath(rLocalPath, rBackupLocation)); + local_path_non_vss); } // Add attributes to checksum currentStateChecksum.Add(&dest_st.st_mode, @@ -243,9 +245,7 @@ void BackupClientDirectoryRecord::SyncDirectory( DIR *dirHandle = 0; try { - std::string nonVssDirPath = ConvertVssPathToRealPath(rLocalPath, - rBackupLocation); - rNotifier.NotifyScanDirectory(this, nonVssDirPath); + rNotifier.NotifyScanDirectory(this, local_path_non_vss); dirHandle = ::opendir(rLocalPath.c_str()); if(dirHandle == 0) @@ -253,21 +253,17 @@ void BackupClientDirectoryRecord::SyncDirectory( // Report the error (logs and eventual email to administrator) if (errno == EACCES) { - rNotifier.NotifyDirListFailed(this, - nonVssDirPath, + rNotifier.NotifyDirListFailed(this, local_path_non_vss, "Access denied"); } else { - rNotifier.NotifyDirListFailed(this, - nonVssDirPath, + rNotifier.NotifyDirListFailed(this, local_path_non_vss, strerror(errno)); } - // Report the error (logs and eventual email - // to administrator) - SetErrorWhenReadingFilesystemObject(rParams, - nonVssDirPath); + SetErrorWhenReadingFilesystemObject(rParams, local_path_non_vss); + // Ignore this directory for now. return; } @@ -327,15 +323,49 @@ void BackupClientDirectoryRecord::SyncDirectory( try { // Want to get the directory listing? + bool download_dir = false; + if(ThisDirHasJustBeenCreated) { // Avoid sending another command to the server when we know it's empty apDirOnStore.reset(new BackupStoreDirectory(mObjectID, ContainingDirectoryID)); + BOX_TRACE("No need to download directory " << + BOX_FORMAT_OBJECTID(mObjectID) << " because it has just been " + "created, so we know it's empty"); + ASSERT(!download_dir); } // Consider asking the store for it - else if(!mInitialSyncDone || checksumDifferent || - downloadDirectoryRecordBecauseOfFutureFiles) + else if(!mInitialSyncDone) + { + BOX_TRACE("Downloading directory listing of " << local_path_non_vss << + " (" << BOX_FORMAT_OBJECTID(mObjectID) << " because we haven't " + "done an initial sync yet"); + download_dir = true; + } + else if(checksumDifferent) + { + BOX_TRACE("Downloading directory listing of " << local_path_non_vss << + " (" << BOX_FORMAT_OBJECTID(mObjectID) << " because its contents " + "have changed locally"); + download_dir = true; + } + else if(downloadDirectoryRecordBecauseOfFutureFiles) + { + BOX_TRACE("Downloading directory listing of " << local_path_non_vss << + " (" << BOX_FORMAT_OBJECTID(mObjectID) << " because it contains " + "files with dates in the future"); + download_dir = true; + } + else + { + BOX_TRACE("Not downloading directory listing of " << local_path_non_vss << + " (" << BOX_FORMAT_OBJECTID(mObjectID) << " because our cached " + "copy appears to still be valid"); + ASSERT(!download_dir); + } + + if(download_dir) { apDirOnStore = FetchDirectoryListing(rParams); } @@ -766,17 +796,17 @@ bool BackupClientDirectoryRecord::UpdateItems( // Decrypt all the directory entries. // It would be nice to be able to just compare the encrypted versions, however this doesn't work - // in practise because there can be multiple encodings of the same filename using different + // in practise because there can be multiple encodings of the same filename using different // methods (although each method will result in the same string for the same filename.) This // happens when the server fixes a broken store, and gives plain text generated filenames. // So if we didn't do things like this, then you wouldn't be able to recover from bad things // happening with the server. DecryptedEntriesMap_t decryptedEntries; - if(pDirOnStore != 0) + if(pDirOnStore != NULL) { BackupStoreDirectory::Iterator i(*pDirOnStore); - BackupStoreDirectory::Entry *en = 0; - while((en = i.Next()) != 0) + BackupStoreDirectory::Entry *en = NULL; + while((en = i.Next()) != NULL) { std::string filenameClear; try @@ -837,9 +867,9 @@ bool BackupClientDirectoryRecord::UpdateItems( // See if it's in the listing (if we have one) BackupStoreFilenameClear storeFilename(*f); - BackupStoreDirectory::Entry *en = 0; + BackupStoreDirectory::Entry *en = NULL; int64_t latestObjectID = 0; - if(pDirOnStore != 0) + if(pDirOnStore != NULL) { DecryptedEntriesMap_t::iterator i(decryptedEntries.find(*f)); if(i != decryptedEntries.end()) @@ -850,85 +880,32 @@ bool BackupClientDirectoryRecord::UpdateItems( } // Check that the entry which might have been found is in fact a file - if((en != 0) && !(en->IsFile())) + if((en != NULL) && !(en->IsFile())) { // Directory exists in the place of this file -- sort it out - RemoveDirectoryInPlaceOfFile(rParams, pDirOnStore, - en, *f); - en = 0; + RemoveDirectoryInPlaceOfFile(rParams, pDirOnStore, en, *f); + en = NULL; + latestObjectID = 0; } // Check for renaming? - if(pDirOnStore != 0 && en == 0) + if(pDirOnStore != 0 && en == NULL) { // We now know... // 1) File has just been added // 2) It's not in the store - - // Do we know about the inode number? - const BackupClientInodeToIDMap &idMap(rContext.GetCurrentIDMap()); - int64_t renameObjectID = 0, renameInDirectory = 0; - if(idMap.Lookup(inodeNum, renameObjectID, renameInDirectory)) + ASSERT(latestObjectID == 0); + en = CheckForRename(rContext, pDirOnStore, storeFilename, inodeNum, + nonVssFilePath); + if(en != NULL) { - // Look up on the server to get the name, to build the local filename - std::string localPotentialOldName; - bool isDir = false; - bool isCurrentVersion = false; - box_time_t srvModTime = 0, srvAttributesHash = 0; - BackupStoreFilenameClear oldLeafname; - if(rContext.FindFilename(renameObjectID, renameInDirectory, - localPotentialOldName, isDir, isCurrentVersion, - &srvModTime, &srvAttributesHash, &oldLeafname)) - { - // Only interested if it's a file and the latest version - if(!isDir && isCurrentVersion) - { - // Check that the object we found in the ID map doesn't exist on disc - EMU_STRUCT_STAT st; - if(EMU_STAT(localPotentialOldName.c_str(), &st) != 0 && errno == ENOENT) - { - // Doesn't exist locally, but does exist on the server. - // Therefore we can safely rename it to this new file. - - // Get the connection to the server - BackupProtocolCallable &connection(rContext.GetConnection()); - - // Only do this step if there is room on the server. - // This step will be repeated later when there is space available - if(!rContext.StorageLimitExceeded()) - { - // Rename the existing files (ie include old versions) on the server - connection.QueryMoveObject(renameObjectID, - renameInDirectory, - mObjectID /* move to this directory */, - BackupProtocolMoveObject::Flags_MoveAllWithSameName | - BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, - storeFilename); - - // Stop the attempt to delete the file in the original location - BackupClientDeleteList &rdelList(rContext.GetDeleteList()); - rdelList.StopFileDeletion(renameInDirectory, oldLeafname); - - // Create new entry in the directory for it - // -- will be near enough what's actually on the server for the rest to work. - en = pDirOnStore->AddEntry(storeFilename, - srvModTime, renameObjectID, - 0 /* size in blocks unknown, but not needed */, - BackupStoreDirectory::Entry::Flags_File, - srvAttributesHash); - - // Store the object ID for the inode lookup map later - latestObjectID = renameObjectID; - } - } - } - } + latestObjectID = en->GetObjectID(); } } - + // Is it in the mPendingEntries list? box_time_t pendingFirstSeenTime = 0; // ie not seen - if(mpPendingEntries != 0) + if(mpPendingEntries != NULL) { std::map::const_iterator i(mpPendingEntries->find(*f)); if(i != mpPendingEntries->end()) @@ -939,7 +916,7 @@ bool BackupClientDirectoryRecord::UpdateItems( } // If pDirOnStore == 0, then this must have been after an initial sync: - ASSERT(pDirOnStore != 0 || mInitialSyncDone); + ASSERT(pDirOnStore != NULL || mInitialSyncDone); // So, if pDirOnStore == 0, then we know that everything before syncPeriodStart // is either on the server, or in the toupload list. If the directory had changed, // we'd have got a directory listing. @@ -962,20 +939,20 @@ bool BackupClientDirectoryRecord::UpdateItems( // Only upload a file if the mod time locally is // different to that on the server. - if (en == 0 || en->GetModificationTime() != modTime) + if(en == NULL || en->GetModificationTime() != modTime) { // Check the file modified within the acceptable time period we're checking // If the file isn't on the server, the acceptable time starts at zero. // Check pDirOnStore and en, because if we didn't download a directory listing, // pDirOnStore will be zero, but we know it's on the server. - if (modTime < rParams.mSyncPeriodEnd) + if(modTime < rParams.mSyncPeriodEnd) { - if (pDirOnStore != 0 && en == 0) + if(pDirOnStore != NULL && en == NULL) { doUpload = true; decisionReason = "not on server"; } - else if (modTime >= rParams.mSyncPeriodStart) + else if(modTime >= rParams.mSyncPeriodStart) { doUpload = true; decisionReason = "modified since last sync"; @@ -984,12 +961,19 @@ bool BackupClientDirectoryRecord::UpdateItems( // However, just in case things are continually // modified, we check the first seen time. - // The two compares of syncPeriodEnd and - // pendingFirstSeenTime are because the values - // are unsigned. - if (!doUpload && - pendingFirstSeenTime != 0 && + if(!doUpload && pendingFirstSeenTime != 0) + { + BOX_TRACE("Current period ends at " << + FormatTime(rParams.mSyncPeriodEnd, false, true) << + " and file has been pending since " << + FormatTime(pendingFirstSeenTime, false, true)); + } + + if(!doUpload && pendingFirstSeenTime != 0 && + // The two compares of syncPeriodEnd and + // pendingFirstSeenTime are because the values + // are unsigned. rParams.mSyncPeriodEnd > pendingFirstSeenTime && (rParams.mSyncPeriodEnd - pendingFirstSeenTime) > rParams.mMaxUploadWait) @@ -1005,7 +989,7 @@ bool BackupClientDirectoryRecord::UpdateItems( // will pick up the fact it has been added, so the // store listing will be available when this happens. - if (!doUpload && + if(!doUpload && modTime <= rParams.mSyncPeriodStart && en != 0 && en->GetModificationTime() != modTime) @@ -1014,11 +998,11 @@ bool BackupClientDirectoryRecord::UpdateItems( decisionReason = "mod time changed"; } - // And just to catch really badly off clocks in + // And just to catch really badly off clocks in // the future for file server clients, // just upload the file if it's madly in the future. - if (!doUpload && modTime > + if(!doUpload && modTime > rParams.mUploadAfterThisTimeInTheFuture) { doUpload = true; @@ -1026,14 +1010,14 @@ bool BackupClientDirectoryRecord::UpdateItems( } } - if (en != 0 && en->GetModificationTime() == modTime) + if(en != NULL && en->GetModificationTime() == modTime) { doUpload = false; decisionReason = "not modified since last upload"; } - else if (!doUpload) + else if(!doUpload) { - if (modTime > rParams.mSyncPeriodEnd) + if(modTime > rParams.mSyncPeriodEnd) { box_time_t now = GetCurrentBoxTime(); int age = BoxTimeToSeconds(now - @@ -1060,7 +1044,7 @@ bool BackupClientDirectoryRecord::UpdateItems( bool fileSynced = true; - if (doUpload) + if(doUpload) { // Upload needed, don't mark sync success until // we've actually done it @@ -1094,7 +1078,7 @@ bool BackupClientDirectoryRecord::UpdateItems( attributesHash, noPreviousVersionOnServer); - if (latestObjectID == 0) + if(latestObjectID == 0) { // storage limit exceeded rParams.mrContext.SetStorageLimitExceeded(); @@ -1118,7 +1102,7 @@ bool BackupClientDirectoryRecord::UpdateItems( } catch(BoxException &e) { - if (e.GetType() == BackupStoreException::ExceptionType && + if(e.GetType() == BackupStoreException::ExceptionType && e.GetSubType() == BackupStoreException::SignalReceived) { // abort requested, pass the @@ -1185,7 +1169,7 @@ bool BackupClientDirectoryRecord::UpdateItems( } catch (BoxException &e) { - BOX_ERROR("Failed to read or store file attributes " + BOX_ERROR("Failed to read or store file attributes " "for '" << nonVssFilePath << "', will try again " "later"); } @@ -1199,7 +1183,8 @@ bool BackupClientDirectoryRecord::UpdateItems( { mpPendingEntries = new std::map; } - // Adding to mPendingEntries list + + // Adding to mPendingEntries list if(pendingFirstSeenTime == 0) { // Haven't seen this before -- add to list! @@ -1236,7 +1221,7 @@ bool BackupClientDirectoryRecord::UpdateItems( if(currentIDMap.Lookup(inodeNum, objid, dirid)) { // Found - if (dirid != mObjectID) + if(dirid != mObjectID) { BOX_WARNING("Found conflicting parent ID for " "file ID " << inodeNum << " (" << @@ -1260,11 +1245,10 @@ bool BackupClientDirectoryRecord::UpdateItems( if(latestObjectID != 0) { - BOX_TRACE("Storing uploaded file ID " << - inodeNum << " (" << nonVssFilePath << ") " - "in ID map as object " << - latestObjectID << " with parent " << - mObjectID); + BOX_TRACE("Storing uploaded file ID " << inodeNum << " (" << + nonVssFilePath << ") in ID map as object " << + BOX_FORMAT_OBJECTID(latestObjectID) << " with parent " << + BOX_FORMAT_OBJECTID(mObjectID)); idMap.AddToMap(inodeNum, latestObjectID, mObjectID /* containing directory */, nonVssFilePath); @@ -1272,7 +1256,7 @@ bool BackupClientDirectoryRecord::UpdateItems( } - if (fileSynced) + if(fileSynced) { rNotifier.NotifyFileSynchronised(this, nonVssFilePath, fileSize); @@ -1403,7 +1387,7 @@ bool BackupClientDirectoryRecord::UpdateItems( doCreateDirectoryRecord = (subDirObjectID != 0); } - if (doCreateDirectoryRecord) + if(doCreateDirectoryRecord) { // New an object for this psubDirRecord = new BackupClientDirectoryRecord(subDirObjectID, *d); @@ -1496,7 +1480,7 @@ bool BackupClientDirectoryRecord::UpdateItems( mSubDirectories.erase(e); delete rec; - BOX_TRACE("Deleted directory record for " << + BOX_TRACE("Deleted directory record for " << nonVssLocalName); } } @@ -1507,6 +1491,118 @@ bool BackupClientDirectoryRecord::UpdateItems( return allUpdatedSuccessfully; } +// Returns NULL if not renamed, or the new BackupStoreDirectory::Entry in p_dir (containing the ID +// of the renamed (moved) object) otherwise. +BackupStoreDirectory::Entry* BackupClientDirectoryRecord::CheckForRename( + BackupClientContext& context, BackupStoreDirectory* p_dir, + const BackupStoreFilenameClear& remote_filename, InodeRefType inode_num, + const std::string& local_path_non_vss) +{ + // We now know... + // 1) File has just been added + // 2) It's not in the store + + // Do we know about the inode number? + const BackupClientInodeToIDMap &idMap(context.GetCurrentIDMap()); + int64_t prev_object_id = 0, prev_dir_id = 0; + if(!idMap.Lookup(inode_num, prev_object_id, prev_dir_id)) + { + return NULL; + } + + std::ostringstream msg_prefix_buf; + msg_prefix_buf << local_path_non_vss << ": have seen inode " << inode_num << " before, " + "with ID " << BOX_FORMAT_OBJECTID(prev_object_id) << " in directory " << + BOX_FORMAT_OBJECTID(prev_dir_id); + std::string msg_prefix = msg_prefix_buf.str(); + + std::ostringstream msg_suffix_buf; + msg_suffix_buf << ", so will not move to directory " << BOX_FORMAT_OBJECTID(mObjectID); + std::string msg_suffix = msg_suffix_buf.str(); + + // We've seen this inode number before. Look up on the server to get the filename, to + // reconstruct the local filename that it had when it was backed up before (elsewhere): + std::string possible_prev_local_name; + bool was_a_dir = false; + bool was_current_version = false; + box_time_t remote_mod_time = 0, remote_attr_hash = 0; + BackupStoreFilenameClear prev_remote_name; + if(!context.FindFilename(prev_object_id, prev_dir_id, possible_prev_local_name, was_a_dir, + was_current_version, &remote_mod_time, &remote_attr_hash, &prev_remote_name)) + { + BOX_TRACE(msg_prefix << ", but that no longer exists on the server, so cannot find " + "corresponding local file to check for rename"); + return NULL; + } + + // Only interested if it's a file and the latest version + if(was_a_dir || !was_current_version) + { + BOX_TRACE(msg_prefix << ", but that was " << + (was_a_dir ? "a directory" : "not the latest version") << + msg_suffix); + return NULL; + } + + // Check that the object we found in the ID map doesn't exist on disc + EMU_STRUCT_STAT st; + if(EMU_STAT(possible_prev_local_name.c_str(), &st) == 0) + { + BOX_TRACE(msg_prefix << ", but that was for " << possible_prev_local_name << " " + "which still exists locally (most likely moved and replaced)" << msg_suffix); + return NULL; + } + + if(errno != ENOENT) + { + BOX_TRACE(BOX_SYS_ERROR_MESSAGE(msg_prefix << ", but that was for " << + possible_prev_local_name << " which we cannot access" << msg_suffix)); + return NULL; + } + + // Doesn't exist locally, but does exist on the server. + // Therefore we can safely rename it to this new file. + + // Get the connection to the server + BackupProtocolCallable &connection(context.GetConnection()); + + // Only do this step if there is room on the server. + // This step will be repeated later when there is space available + if(context.StorageLimitExceeded()) + { + BOX_TRACE(possible_prev_local_name << " appears to have been renamed to " << + local_path_non_vss << ", but our account on the server is full, " + "so not moving object " << + BOX_FORMAT_OBJECTID(prev_object_id) << " from directory " << + BOX_FORMAT_OBJECTID(prev_dir_id) << " to " << + BOX_FORMAT_OBJECTID(mObjectID)); + return NULL; + } + + // Rename the existing files (ie include old versions) on the server + connection.QueryMoveObject(prev_object_id, prev_dir_id, + mObjectID /* move to this directory */, + BackupProtocolMoveObject::Flags_MoveAllWithSameName | + BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, + remote_filename); + + // Stop the attempt to delete the file in the original location + BackupClientDeleteList &rdelList(context.GetDeleteList()); + rdelList.StopFileDeletion(prev_dir_id, prev_remote_name); + + BOX_TRACE(possible_prev_local_name << " appears to have been renamed to " << + local_path_non_vss << ", so moving object " << + BOX_FORMAT_OBJECTID(prev_object_id) << " from directory " << + BOX_FORMAT_OBJECTID(prev_dir_id) << " to " << + BOX_FORMAT_OBJECTID(mObjectID)); + + // Create new entry in the directory for it: will be near enough what's actually on the + // server for the rest to work. + return p_dir->AddEntry(remote_filename, remote_mod_time, prev_object_id, + 0 /* size in blocks unknown, but not needed */, + BackupStoreDirectory::Entry::Flags_File, remote_attr_hash); +} + int64_t BackupClientDirectoryRecord::CreateRemoteDir(const std::string& localDirPath, const std::string& nonVssDirPath, const std::string& remoteDirPath, BackupStoreFilenameClear& storeFilename, bool* pHaveJustCreatedDirOnServer, diff --git a/lib/bbackupd/BackupClientDirectoryRecord.h b/lib/bbackupd/BackupClientDirectoryRecord.h index 865fc747..7308d7d1 100644 --- a/lib/bbackupd/BackupClientDirectoryRecord.h +++ b/lib/bbackupd/BackupClientDirectoryRecord.h @@ -163,6 +163,7 @@ private: void UpdateAttributes(SyncParams &rParams, BackupStoreDirectory *pDirOnStore, const std::string &rLocalPath); + protected: // to allow tests to hook in before UpdateItems() runs virtual bool UpdateItems(SyncParams &rParams, const std::string &rLocalPath, @@ -172,7 +173,11 @@ protected: // to allow tests to hook in before UpdateItems() runs std::vector &rEntriesLeftOver, std::vector &rFiles, const std::vector &rDirs); + private: + BackupStoreDirectory::Entry* CheckForRename(BackupClientContext& context, + BackupStoreDirectory* p_dir, const BackupStoreFilenameClear& remote_filename, + InodeRefType inode_num, const std::string& local_path_non_vss); int64_t CreateRemoteDir(const std::string& localDirPath, const std::string& nonVssDirPath, const std::string& remoteDirPath, diff --git a/lib/bbackupd/BackupDaemon.cpp b/lib/bbackupd/BackupDaemon.cpp index d75aa381..f4dcf270 100644 --- a/lib/bbackupd/BackupDaemon.cpp +++ b/lib/bbackupd/BackupDaemon.cpp @@ -531,7 +531,7 @@ void BackupDaemon::Run() mapCommandSocketInfo->mListeningSocket.Listen( socketName); #else - ::unlink(socketName); + EMU_UNLINK(socketName); mapCommandSocketInfo->mListeningSocket.Listen( Socket::TypeUNIX, socketName); #endif @@ -2503,12 +2503,32 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con } } - const Configuration& rConfig( - rLocationsConf.GetSubConfiguration(*pLocName)); + const Configuration& rConfig(rLocationsConf.GetSubConfiguration(*pLocName)); std::auto_ptr apLoc; + BackupStoreFilenameClear dirname(*pLocName); // generate the filename + bool local_dir_exists = true; + int64_t existing_remote_dir_id = 0; + + box_time_t attrModTime = 0; + BackupClientFileAttributes attr; + try { + // Does this exist on the server? Remove from dir object early, so that if + // we fail to stat the local directory, we still don't consider to remote + // one for deletion. + BackupStoreDirectory::Iterator iter(dir); + BackupStoreDirectory::Entry *en = iter.FindMatchingClearName(dirname); + if(en != NULL) + { + existing_remote_dir_id = en->GetObjectID(); + + // Delete the entry from the directory, so we get a list of + // unused root directories at the end of this. + dir.DeleteEntry(existing_remote_dir_id); + } + if(pLoc == NULL) { // Create a record for it @@ -2523,59 +2543,42 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con pLoc->mPath = rConfig.GetKeyValue("Path"); } - // Read the exclude lists from the Configuration - pLoc->mapExcludeFiles.reset(BackupClientMakeExcludeList_Files(rConfig)); - pLoc->mapExcludeDirs.reset(BackupClientMakeExcludeList_Dirs(rConfig)); + // Get the directory's attributes and modification time. We need this to + // check whether the local directory exists, even if we don't have + // stat[v]fs(). Otherwise we must skip it. + attr.ReadAttributes(pLoc->mPath.c_str(), + true /* directories have zero mod times */, + 0 /* not interested in mod time */, + &attrModTime /* get the attribute modification time */); - // Does this exist on the server? - // Remove from dir object early, so that if we fail - // to stat the local directory, we still don't - // consider to remote one for deletion. - BackupStoreDirectory::Iterator iter(dir); - BackupStoreFilenameClear dirname(pLoc->mName); // generate the filename - BackupStoreDirectory::Entry *en = iter.FindMatchingClearName(dirname); - int64_t oid = 0; - if(en != 0) - { - oid = en->GetObjectID(); - - // Delete the entry from the directory, so we get a list of - // unused root directories at the end of this. - dir.DeleteEntry(oid); - } - // Do a fsstat on the pathname to find out which mount it's on { #if defined HAVE_STRUCT_STATFS_F_MNTONNAME || defined HAVE_STRUCT_STATVFS_F_MNTONNAME || defined WIN32 // BSD style statfs -- includes mount point, which is nice. -#ifdef HAVE_STRUCT_STATVFS_F_MNTONNAME +# ifdef HAVE_STRUCT_STATVFS_F_MNTONNAME struct statvfs s; if(::statvfs(pLoc->mPath.c_str(), &s) != 0) -#else // HAVE_STRUCT_STATVFS_F_MNTONNAME +# else // HAVE_STRUCT_STATVFS_F_MNTONNAME struct statfs s; if(::statfs(pLoc->mPath.c_str(), &s) != 0) -#endif // HAVE_STRUCT_STATVFS_F_MNTONNAME +# endif // HAVE_STRUCT_STATVFS_F_MNTONNAME { - THROW_SYS_ERROR("Failed to stat path " - "'" << pLoc->mPath << "' " - "for location " - "'" << pLoc->mName << "'", + THROW_SYS_FILE_ERROR(pLoc->mPath, "Failed to stat local path", CommonException, OSFileError); } // Where the filesystem is mounted std::string mountName(s.f_mntonname); -#else // !HAVE_STRUCT_STATFS_F_MNTONNAME && !WIN32 +#else // !HAVE_STRUCT_STAT*FS_F_MNTONNAME && !WIN32 // Warn in logs if the directory isn't absolute if(pLoc->mPath[0] != '/') { - BOX_WARNING("Location path '" - << pLoc->mPath - << "' is not absolute"); + BOX_WARNING(BOX_FILE_MESSAGE(pLoc->mPath, + "location path is not absolute")); } // Go through the mount points found, and find a suitable one std::string mountName("/"); @@ -2596,12 +2599,10 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con break; } } - BOX_TRACE("mount point chosen for " - << pLoc->mPath << " is " - << mountName); + BOX_TRACE("mount point chosen for " << pLoc->mPath << + " is " << mountName); } - -#endif +#endif // !HAVE_STRUCT_STAT*FS_F_MNTONNAME && !WIN32 // Got it? std::map::iterator f(mounts.find(mountName)); @@ -2623,89 +2624,68 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con ++numIDMaps; } } - - // Does this exist on the server? - if(en == 0) - { - // Doesn't exist, so it has to be created on the server. Let's go! - // First, get the directory's attributes and modification time - box_time_t attrModTime = 0; - BackupClientFileAttributes attr; - try - { - attr.ReadAttributes(pLoc->mPath.c_str(), - true /* directories have zero mod times */, - 0 /* not interested in mod time */, - &attrModTime /* get the attribute modification time */); - } - catch (BoxException &e) - { - BOX_ERROR("Failed to get attributes " - "for path '" << pLoc->mPath - << "', skipping location '" << - pLoc->mName << "'"); - throw; - } - - // Execute create directory command - try - { - std::auto_ptr attrStream( - new MemBlockStream(attr)); - std::auto_ptr - dirCreate(connection.QueryCreateDirectory( - BACKUPSTORE_ROOT_DIRECTORY_ID, // containing directory - attrModTime, dirname, attrStream)); - - // Object ID for later creation - oid = dirCreate->GetObjectID(); - } - catch (BoxException &e) - { - BOX_ERROR("Failed to create remote " - "directory '/" << pLoc->mName << - "', skipping location '" << - pLoc->mName << "'"); - throw; - } + } + catch (std::exception &e) + { + BOX_ERROR("Failed to configure location '" << pLoc->mName << "': " << + e.what()); + local_dir_exists = false; + } + catch(...) + { + BOX_ERROR("Failed to configure location '" << pLoc->mName << "': please " + "check for previous errors"); + local_dir_exists = false; + } - } + // Remove it from the temporary list to avoid deletion, even if it doesn't actually + // exist locally at this time: + tmpLocations.remove(pLoc); - // Create and store the directory object for the root of this location - ASSERT(oid != 0); - if(pLoc->mapDirectoryRecord.get() == NULL) - { - pLoc->mapDirectoryRecord.reset( - new BackupClientDirectoryRecord(oid, *pLocName)); - } - - // Remove it from the temporary list to avoid deletion - tmpLocations.remove(pLoc); + // Does this exist on the server? + if(!local_dir_exists) + { + mReadErrorsOnFilesystemObjects = true; + // Don't try to create it remotely, just skip it. + continue; + } - // Push it back on the vector of locations - mLocations.push_back(pLoc); + if(existing_remote_dir_id == 0) + { + // Doesn't exist, so it has to be created on the server. Let's go! - if(apLoc.get() != NULL) - { - // Don't delete it now! - apLoc.release(); - } + // Create the remote directory for this location. If this fails, then we + // abort the whole backup, otherwise the error isn't reported sufficiently + // severely for test_bbackupd_responds_to_connection_failure_in_process_s3. + std::auto_ptr attrStream(new MemBlockStream(attr)); + std::auto_ptr dirCreate( + connection.QueryCreateDirectory( + BACKUPSTORE_ROOT_DIRECTORY_ID, // containing directory + attrModTime, dirname, attrStream)); + + // Object ID for later creation + existing_remote_dir_id = dirCreate->GetObjectID(); } - catch (std::exception &e) + + // Create and store the directory object for the root of this location + ASSERT(existing_remote_dir_id != 0); + if(pLoc->mapDirectoryRecord.get() == NULL) { - BOX_ERROR("Failed to configure location '" - << pLoc->mName << "' path '" - << pLoc->mPath << "': " << e.what() << - ": please check for previous errors"); - mReadErrorsOnFilesystemObjects = true; + pLoc->mapDirectoryRecord.reset( + new BackupClientDirectoryRecord(existing_remote_dir_id, *pLocName)); } - catch(...) + + // Read the exclude lists from the Configuration + pLoc->mapExcludeFiles.reset(BackupClientMakeExcludeList_Files(rConfig)); + pLoc->mapExcludeDirs.reset(BackupClientMakeExcludeList_Dirs(rConfig)); + + // Push it back on the vector of locations + mLocations.push_back(pLoc); + + if(apLoc.get() != NULL) { - BOX_ERROR("Failed to configure location '" - << pLoc->mName << "' path '" - << pLoc->mPath << "': please check for " - "previous errors"); - mReadErrorsOnFilesystemObjects = true; + // Don't delete it now! + apLoc.release(); } } @@ -2714,8 +2694,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con i = tmpLocations.begin(); i != tmpLocations.end(); i++) { - BOX_INFO("Removing obsolete location from memory: " << - (*i)->mName); + BOX_INFO("Removing obsolete location from memory: " << (*i)->mName); delete *i; } @@ -2745,8 +2724,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con SecondsToBoxTime(mDeleteRedundantLocationsAfter); } - int secs = BoxTimeToSeconds(mDeleteUnusedRootDirEntriesAfter - - now); + int secs = BoxTimeToSeconds(mDeleteUnusedRootDirEntriesAfter - now); BOX_NOTICE(dir.GetNumberOfEntries() << " redundant locations " "in root directory found, will delete from store " @@ -2829,7 +2807,7 @@ void BackupDaemon::FillIDMapVector(std::vector &rVec BOX_NOTICE("Found an incomplete ID map " "database, deleting it to start " "afresh: " << filename); - if(unlink(filename.c_str()) != 0) + if(EMU_UNLINK(filename.c_str()) != 0) { BOX_LOG_NATIVE_ERROR(BOX_FILE_MESSAGE( filename, "Failed to delete " @@ -2878,14 +2856,14 @@ void BackupDaemon::DeleteCorruptBerkelyDbFiles() // Delete the file BOX_TRACE("Deleting " << filename); - ::unlink(filename.c_str()); + EMU_UNLINK(filename.c_str()); // Add a suffix for the new map filename += ".n"; // Delete that too BOX_TRACE("Deleting " << filename); - ::unlink(filename.c_str()); + EMU_UNLINK(filename.c_str()); } } @@ -3636,7 +3614,7 @@ bool BackupDaemon::DeleteStoreObjectInfo() const } // Actually delete it - if(::unlink(storeObjectInfoFile.c_str()) != 0) + if(EMU_UNLINK(storeObjectInfoFile.c_str()) != 0) { BOX_LOG_SYS_ERROR("Failed to delete the old " "StoreObjectInfoFile: " << storeObjectInfoFile); diff --git a/lib/bbackupquery/BackupQueries.cpp b/lib/bbackupquery/BackupQueries.cpp index bcb1827e..f7a511c9 100644 --- a/lib/bbackupquery/BackupQueries.cpp +++ b/lib/bbackupquery/BackupQueries.cpp @@ -1003,17 +1003,17 @@ void BackupQueries::CommandGetObject(const std::vector &args, const { BOX_ERROR("Object ID " << BOX_FORMAT_OBJECTID(id) << " does not exist on store."); - ::unlink(args[1].c_str()); + EMU_UNLINK(args[1].c_str()); } else { BOX_ERROR("Error occured fetching object."); - ::unlink(args[1].c_str()); + EMU_UNLINK(args[1].c_str()); } } catch(...) { - ::unlink(args[1].c_str()); + EMU_UNLINK(args[1].c_str()); BOX_ERROR("Error occured fetching object."); } } @@ -1242,18 +1242,18 @@ void BackupQueries::CommandGet(std::vector args, const bool *opts) { BOX_ERROR("Failed to fetch file: " << e.what()); - ::unlink(localName.c_str()); + EMU_UNLINK(localName.c_str()); } catch(std::exception &e) { BOX_ERROR("Failed to fetch file: " << e.what()); - ::unlink(localName.c_str()); + EMU_UNLINK(localName.c_str()); } catch(...) { BOX_ERROR("Failed to fetch file: unknown error"); - ::unlink(localName.c_str()); + EMU_UNLINK(localName.c_str()); } } diff --git a/lib/common/BannerText.cpp b/lib/common/BannerText.cpp new file mode 100644 index 00000000..9ec2c0d7 --- /dev/null +++ b/lib/common/BannerText.cpp @@ -0,0 +1,14 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: BannerText.cpp +// Purpose: Banner text for daemons and utilities +// Created: 2018-08-16 +// +// -------------------------------------------------------------------------- + +#include "Box.h" + +#include "BannerText.h" + +#pragma message("Build signature: " BOX_BUILD_SIGNATURE) diff --git a/lib/common/BannerText.h b/lib/common/BannerText.h index 9ca0c11c..a2e412a8 100644 --- a/lib/common/BannerText.h +++ b/lib/common/BannerText.h @@ -14,9 +14,48 @@ # include "BoxVersion.h" #endif +// Already included by BoxPlatform.h: +#include + +// Yes, you need two function macros to stringify an expanded macro value. +// https://stackoverflow.com/questions/5459868/concatenate-int-to-string-using-c-preprocessor +#define BOX_STRINGIFY_HELPER(x) #x +#define BOX_STRINGIFY(x) BOX_STRINGIFY_HELPER(x) + +// How to identify a 64-bit build: https://stackoverflow.com/a/687902/648162 +#if UINTPTR_MAX == (4294967295U) +# define BOX_BUILD_BITS 32 +#elif UINTPTR_MAX == (18446744073709551615UL) +# define BOX_BUILD_BITS 64 +#else +# pragma message ("UINTPTR_MAX = " BOX_STRINGIFY(UINTPTR_MAX)) +# error Unknown architecture pointer size +#endif + +#ifdef BOX_RELEASE_BUILD +# define BOX_BUILD_TYPE Release +#else +# define BOX_BUILD_TYPE Debug +#endif + +#define STRINGIFY1(x) #x +#define STRINGIFY2(x) STRINGIFY1(x) +#ifdef _MSC_VER +# define BOX_COMPILER "MSVC " STRINGIFY2(_MSC_VER) +#elif defined __GNUC__ +# define BOX_COMPILER "GCC " __VERSION__ +#elif defined __VERSION__ +// It might be an integer, not a string! +# define BOX_COMPILER "Unknown " BOX_STRINGIFY(__VERSION__) +#else +# define BOX_COMPILER "Unknown" +#endif + +#define BOX_BUILD_SIGNATURE BOX_COMPILER " " BOX_STRINGIFY(BOX_BUILD_BITS) "bit " BOX_STRINGIFY(BOX_BUILD_TYPE) + #define BANNER_TEXT(UtilityName) \ - "Box " UtilityName " v" BOX_VERSION ", (c) Ben Summers and " \ - "contributors 2003-2014" + "Box Backup " UtilityName " v" BOX_VERSION "\n" \ + "(c) Ben Summers and contributors 2003-2020. Build type: " BOX_BUILD_SIGNATURE #endif // BANNERTEXT__H diff --git a/lib/common/Box.h b/lib/common/Box.h index 8ce2a625..5f629790 100644 --- a/lib/common/Box.h +++ b/lib/common/Box.h @@ -39,7 +39,7 @@ #include "CommonException.h" #include "Logging.h" -#ifndef BOX_RELEASE_BUILD +#ifndef BOX_RELEASE_BUILD // this is a debug build: extern bool AssertFailuresToSyslog; #define ASSERT_FAILS_TO_SYSLOG_ON {AssertFailuresToSyslog = true;} void BoxDebugAssertFailed(const char *cond, const char *file, int line); @@ -70,7 +70,7 @@ // Exception names #define EXCEPTION_CODENAMES_EXTENDED -#else +#else // this is a release build: #define ASSERT_FAILS_TO_SYSLOG_ON #define ASSERT(cond) @@ -80,19 +80,19 @@ // Box Backup builds release get extra information for exception logging #define EXCEPTION_CODENAMES_EXTENDED #define EXCEPTION_CODENAMES_EXTENDED_WITH_DESCRIPTION + + #ifdef BOX_MEMORY_LEAK_TESTING + #error BOX_MEMORY_LEAK_TESTING should not already be defined in release builds! + #endif #endif -#if defined DEBUG_LEAKS +#if defined DEBUG_LEAKS // optionally enable memory leak debugging even in release builds #ifdef PLATFORM_DISABLE_MEM_LEAK_TESTING #error Compiling with DEBUG_LEAKS enabled, but not supported on this platform #else #define BOX_MEMORY_LEAK_TESTING #endif -#elif defined BOX_RELEASE_BUILD - #ifndef PLATFORM_DISABLE_MEM_LEAK_TESTING - #define BOX_MEMORY_LEAK_TESTING - #endif -#endif // DEBUG_LEAKS || BOX_RELEASE_BUILD +#endif // DEBUG_LEAKS #ifdef BOX_MEMORY_LEAK_TESTING // Memory leak testing diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h index f7c74bfc..c86573f6 100644 --- a/lib/common/BoxPlatform.h +++ b/lib/common/BoxPlatform.h @@ -48,6 +48,10 @@ #include #endif +// Need to define this before including stdint.h to ensure access to UINTPTR_MAX in C99: +// https://stackoverflow.com/questions/986426/what-do-stdc-limit-macros-and-stdc-constant-macros-mean +#define __STDC_LIMIT_MACROS + #ifdef HAVE_INTTYPES_H #include #else diff --git a/lib/common/InvisibleTempFileStream.cpp b/lib/common/InvisibleTempFileStream.cpp index 1a9d6d5a..d6d04489 100644 --- a/lib/common/InvisibleTempFileStream.cpp +++ b/lib/common/InvisibleTempFileStream.cpp @@ -31,7 +31,7 @@ InvisibleTempFileStream::InvisibleTempFileStream(const std::string& Filename, #endif { #ifndef WIN32 - if(unlink(Filename.c_str()) != 0) + if(EMU_UNLINK(Filename.c_str()) != 0) { MEMLEAKFINDER_NOT_A_LEAK(this); THROW_EXCEPTION(CommonException, OSFileOpenError) diff --git a/lib/common/MainHelper.h b/lib/common/MainHelper.h index 0303090e..f52607bf 100644 --- a/lib/common/MainHelper.h +++ b/lib/common/MainHelper.h @@ -16,13 +16,19 @@ # include "BoxVersion.h" #endif +#include "BannerText.h" #include "BoxException.h" #include "Logging.h" #define MAINHELPER_START \ - if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ - { printf(BOX_VERSION "\n"); return 0; } \ + /* need to init memleakfinder early because we already called MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT */ \ MEMLEAKFINDER_INIT \ + if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ + { \ + printf("Version: " BOX_VERSION "\n"); \ + printf("Build: " BOX_BUILD_SIGNATURE "\n"); \ + return 0; \ + } \ MEMLEAKFINDER_START \ try { diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp index 8e672ff5..08d7c461 100644 --- a/lib/common/NamedLock.cpp +++ b/lib/common/NamedLock.cpp @@ -256,7 +256,7 @@ void NamedLock::ReleaseLock() // Windows, and there we need to close the file before deleting it, // otherwise the system won't let us delete it. - if(::unlink(mFileName.c_str()) != 0) + if(EMU_UNLINK(mFileName.c_str()) != 0) { THROW_EMU_ERROR( BOX_FILE_MESSAGE(mFileName, "Failed to delete lockfile"), @@ -287,7 +287,7 @@ void NamedLock::ReleaseLock() // On Windows we need to close the file before deleting it, otherwise // the system won't let us delete it. - if(::unlink(mFileName.c_str()) != 0) + if(EMU_UNLINK(mFileName.c_str()) != 0) { THROW_EMU_ERROR( BOX_FILE_MESSAGE(mFileName, "Failed to delete lockfile"), diff --git a/lib/common/Test.cpp b/lib/common/Test.cpp index 3d1620a1..c6b28738 100644 --- a/lib/common/Test.cpp +++ b/lib/common/Test.cpp @@ -116,7 +116,7 @@ bool setUp(const char* function_name) int filetype = ObjectExists(filepath); if(filetype == ObjectExists_File) { - if(::unlink(filepath.c_str()) != 0) + if(EMU_UNLINK(filepath.c_str()) != 0) { TEST_FAIL_WITH_MESSAGE(BOX_SYS_ERROR_MESSAGE("Failed to delete " "test fixture file: unlink(\"" << filepath << "\")")); @@ -428,7 +428,7 @@ void TestRemoteProcessMemLeaksFunc(const char *filename, } // Delete it - ::unlink(filename); + EMU_UNLINK(filename); } #endif } diff --git a/lib/raidfile/RaidFileWrite.cpp b/lib/raidfile/RaidFileWrite.cpp index 8f95ba65..3d661956 100644 --- a/lib/raidfile/RaidFileWrite.cpp +++ b/lib/raidfile/RaidFileWrite.cpp @@ -358,7 +358,7 @@ void RaidFileWrite::Commit(bool ConvertToRaidNow) #ifdef WIN32 // need to delete the target first - if(::unlink(renameTo.c_str()) != 0) + if(EMU_UNLINK(renameTo.c_str()) != 0) { DWORD errorNumber = GetLastError(); if (errorNumber != ERROR_FILE_NOT_FOUND) @@ -421,9 +421,9 @@ void RaidFileWrite::Discard() #ifdef WIN32 // On Win32 we must close it first if (::close(mOSFileHandle) != 0 || - ::unlink(writeFilename.c_str()) != 0) + EMU_UNLINK(writeFilename.c_str()) != 0) #else // !WIN32 - if (::unlink(writeFilename.c_str()) != 0 || + if (EMU_UNLINK(writeFilename.c_str()) != 0 || ::close(mOSFileHandle) != 0) #endif // !WIN32 { @@ -670,7 +670,7 @@ void RaidFileWrite::TransformToRaidStorage() // Must delete before renaming #define CHECK_UNLINK(file) \ { \ - if (::unlink(file) != 0 && errno != ENOENT) \ + if (EMU_UNLINK(file) != 0 && errno != ENOENT) \ { \ THROW_EMU_ERROR("Failed to unlink raidfile " \ "stripe: " << file, RaidFileException, \ @@ -695,7 +695,7 @@ void RaidFileWrite::TransformToRaidStorage() writeFile.Close(); // Finally delete the write file - if(::unlink(writeFilename.c_str()) != 0) + if(EMU_UNLINK(writeFilename.c_str()) != 0) { BOX_LOG_SYS_ERROR("Failed to delete file: " << writeFilename); @@ -705,12 +705,12 @@ void RaidFileWrite::TransformToRaidStorage() catch(...) { // Unlink all the dodgy files - ::unlink(stripe1Filename.c_str()); - ::unlink(stripe2Filename.c_str()); - ::unlink(parityFilename.c_str()); - ::unlink(stripe1FilenameW.c_str()); - ::unlink(stripe2FilenameW.c_str()); - ::unlink(parityFilenameW.c_str()); + EMU_UNLINK(stripe1Filename.c_str()); + EMU_UNLINK(stripe2Filename.c_str()); + EMU_UNLINK(parityFilename.c_str()); + EMU_UNLINK(stripe1FilenameW.c_str()); + EMU_UNLINK(stripe2FilenameW.c_str()); + EMU_UNLINK(parityFilenameW.c_str()); // and send the error on its way throw; @@ -754,7 +754,7 @@ void RaidFileWrite::Delete() // Attempt to delete it bool deletedSomething = false; - if(::unlink(writeFilename.c_str()) == 0) + if(EMU_UNLINK(writeFilename.c_str()) == 0) { deletedSomething = true; } @@ -769,15 +769,15 @@ void RaidFileWrite::Delete() std::string stripe1Filename(RaidFileUtil::MakeRaidComponentName(rdiscSet, mFilename, 0 % TRANSFORM_NUMBER_DISCS_REQUIRED)); std::string stripe2Filename(RaidFileUtil::MakeRaidComponentName(rdiscSet, mFilename, 1 % TRANSFORM_NUMBER_DISCS_REQUIRED)); std::string parityFilename(RaidFileUtil::MakeRaidComponentName(rdiscSet, mFilename, 2 % TRANSFORM_NUMBER_DISCS_REQUIRED)); - if(::unlink(stripe1Filename.c_str()) == 0) + if(EMU_UNLINK(stripe1Filename.c_str()) == 0) { deletedSomething = true; } - if(::unlink(stripe2Filename.c_str()) == 0) + if(EMU_UNLINK(stripe2Filename.c_str()) == 0) { deletedSomething = true; } - if(::unlink(parityFilename.c_str()) == 0) + if(EMU_UNLINK(parityFilename.c_str()) == 0) { deletedSomething = true; } diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index 76141b6f..748e6e47 100644 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -702,7 +702,7 @@ int Daemon::Main(const std::string &rConfigFileName) } // Delete the PID file - ::unlink(pidFileName.c_str()); + EMU_UNLINK(pidFileName.c_str()); // Log BOX_NOTICE("Terminating daemon"); diff --git a/lib/server/ServerControl.cpp b/lib/server/ServerControl.cpp index b6cadab3..958302b8 100644 --- a/lib/server/ServerControl.cpp +++ b/lib/server/ServerControl.cpp @@ -241,7 +241,7 @@ bool KillServer(const std::string& pid_file, bool WaitForProcess) #ifdef WIN32 if(WaitForProcess) { - int unlink_result = unlink(pid_file.c_str()); + int unlink_result = EMU_UNLINK(pid_file.c_str()); TEST_EQUAL_LINE(0, unlink_result, std::string("unlink ") + pid_file); if(unlink_result != 0) { @@ -439,7 +439,7 @@ bool StopDaemon(int current_pid, const std::string& pid_file, TEST_THAT_OR(!ServerIsAlive(current_pid), return false); #ifdef WIN32 - int unlink_result = unlink(pid_file.c_str()); + int unlink_result = EMU_UNLINK(pid_file.c_str()); TEST_EQUAL_LINE(0, unlink_result, std::string("unlink ") + pid_file); if(unlink_result != 0) { diff --git a/lib/server/ServerStream.h b/lib/server/ServerStream.h index db8beaf2..bf508311 100644 --- a/lib/server/ServerStream.h +++ b/lib/server/ServerStream.h @@ -208,7 +208,7 @@ public: } // unlink anything there - ::unlink(c[1].c_str()); + EMU_UNLINK(c[1].c_str()); psocket->Listen(Socket::TypeUNIX, c[1].c_str()); #endif // WIN32 diff --git a/lib/win32/emu.h b/lib/win32/emu.h index 91793004..9b6ec117 100644 --- a/lib/win32/emu.h +++ b/lib/win32/emu.h @@ -4,14 +4,18 @@ #ifdef WIN32 #define EMU_STRUCT_STAT struct emu_stat - #define EMU_STAT emu_stat - #define EMU_FSTAT emu_fstat - #define EMU_LSTAT emu_stat + #define EMU_STAT emu_stat + #define EMU_FSTAT emu_fstat + #define EMU_LSTAT emu_stat + #define EMU_LINK emu_link + #define EMU_UNLINK emu_unlink #else #define EMU_STRUCT_STAT struct stat - #define EMU_STAT ::stat - #define EMU_FSTAT ::fstat - #define EMU_LSTAT ::lstat + #define EMU_STAT ::stat + #define EMU_FSTAT ::fstat + #define EMU_LSTAT ::lstat + #define EMU_LINK ::link + #define EMU_UNLINK ::unlink #endif #if ! defined EMU_INCLUDE && defined WIN32 @@ -352,13 +356,15 @@ int emu_rename (const char* pOldName, const char* pNewName); #define chdir(directory) emu_chdir (directory) #define mkdir(path, mode) emu_mkdir (path) -#define link(oldpath, newpath) emu_link (oldpath, newpath) -#define unlink(file) emu_unlink (file) #define utimes(buffer, times) emu_utimes (buffer, times) #define chmod(file, mode) emu_chmod (file, mode) #define getcwd(buffer, size) emu_getcwd (buffer, size) #define rename(oldname, newname) emu_rename (oldname, newname) +// link() and unlink() conflict with Boost if implemented using macros like +// the others above, so I've removed the macros and you need to use EMU_LINK +// and EMU_UNLINK everywhere. + // Not safe to replace stat/fstat/lstat on mingw at least, as struct stat // has a 16-bit st_ino and we need a 64-bit one. // diff --git a/lib/win32/getopt_long.cpp b/lib/win32/getopt_long.cpp index 825de2a0..af2833a1 100755 --- a/lib/win32/getopt_long.cpp +++ b/lib/win32/getopt_long.cpp @@ -1,546 +1,546 @@ -/* $OpenBSD: getopt_long.c,v 1.20 2005/10/25 15:49:37 jmc Exp $ */ -/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ -// Adapted for Box Backup by Chris Wilson - -/* - * Copyright (c) 2002 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dieter Baron and Thomas Klausner. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -// #include "Box.h" -#include "emu.h" - -#include -#include -#include -#include -#include - -#include "box_getopt.h" - -#ifdef REPLACE_GETOPT // until end of file - -int opterr = 1; /* if error message should be printed */ -int optind = 1; /* index into parent argv vector */ -int optopt = '?'; /* character checked for validity */ -int optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ - -#define PRINT_ERROR ((opterr) && (*options != ':')) - -#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ -#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ -#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ - -/* return values */ -#define BADCH (int)'?' -#define BADARG ((*options == ':') ? (int)':' : (int)'?') -#define INORDER (int)1 - -#define EMSG "" - -static void warnx(const char* fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static int getopt_internal(int, char * const *, const char *, - const struct option *, int *, int); -static int parse_long_options(char * const *, const char *, - const struct option *, int *, int); -static int gcd(int, int); -static void permute_args(int, int, int, char * const *); - -static char *place = EMSG; /* option letter processing */ - -/* XXX: set optreset to 1 rather than these two */ -static int nonopt_start = -1; /* first non option argument (for permute) */ -static int nonopt_end = -1; /* first option after non options (for permute) */ - -/* Error messages */ -static const char recargchar[] = "option requires an argument -- %c"; -static const char recargstring[] = "option requires an argument -- %s"; -static const char ambig[] = "ambiguous option -- %.*s"; -static const char noarg[] = "option doesn't take an argument -- %.*s"; -static const char illoptchar[] = "unknown option -- %c"; -static const char illoptstring[] = "unknown option -- %s"; - -/* - * Compute the greatest common divisor of a and b. - */ -static int -gcd(int a, int b) -{ - int c; - - c = a % b; - while (c != 0) { - a = b; - b = c; - c = a % b; - } - - return (b); -} - -/* - * Exchange the block from nonopt_start to nonopt_end with the block - * from nonopt_end to opt_end (keeping the same order of arguments - * in each block). - */ -static void -permute_args(int panonopt_start, int panonopt_end, int opt_end, - char * const *nargv) -{ - int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; - char *swap; - - /* - * compute lengths of blocks and number and size of cycles - */ - nnonopts = panonopt_end - panonopt_start; - nopts = opt_end - panonopt_end; - ncycle = gcd(nnonopts, nopts); - cyclelen = (opt_end - panonopt_start) / ncycle; - - for (i = 0; i < ncycle; i++) { - cstart = panonopt_end+i; - pos = cstart; - for (j = 0; j < cyclelen; j++) { - if (pos >= panonopt_end) - pos -= nnonopts; - else - pos += nopts; - swap = nargv[pos]; - /* LINTED const cast */ - ((char **) nargv)[pos] = nargv[cstart]; - /* LINTED const cast */ - ((char **)nargv)[cstart] = swap; - } - } -} - -/* - * parse_long_options -- - * Parse long options in argc/argv argument vector. - * Returns -1 if short_too is set and the option does not match long_options. - */ -static int -parse_long_options(char * const *nargv, const char *options, - const struct option *long_options, int *idx, int short_too) -{ - char *current_argv, *has_equal; - size_t current_argv_len; - int i, match; - - current_argv = place; - match = -1; - - optind++; - - if ((has_equal = strchr(current_argv, '=')) != NULL) { - /* argument found (--option=arg) */ - current_argv_len = has_equal - current_argv; - has_equal++; - } else - current_argv_len = strlen(current_argv); - - for (i = 0; long_options[i].name; i++) { - /* find matching long option */ - if (strncmp(current_argv, long_options[i].name, - current_argv_len)) - continue; - - if (strlen(long_options[i].name) == current_argv_len) { - /* exact match */ - match = i; - break; - } - /* - * If this is a known short option, don't allow - * a partial match of a single character. - */ - if (short_too && current_argv_len == 1) - continue; - - if (match == -1) /* partial match */ - match = i; - else { - /* ambiguous abbreviation */ - if (PRINT_ERROR) - warnx(ambig, (int)current_argv_len, - current_argv); - optopt = 0; - return (BADCH); - } - } - if (match != -1) { /* option found */ - if (long_options[match].has_arg == no_argument - && has_equal) { - if (PRINT_ERROR) - warnx(noarg, (int)current_argv_len, - current_argv); - /* - * XXX: GNU sets optopt to val regardless of flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - return (BADARG); - } - if (long_options[match].has_arg == required_argument || - long_options[match].has_arg == optional_argument) { - if (has_equal) - optarg = has_equal; - else if (long_options[match].has_arg == - required_argument) { - /* - * optional argument doesn't use next nargv - */ - optarg = nargv[optind++]; - } - } - if ((long_options[match].has_arg == required_argument) - && (optarg == NULL)) { - /* - * Missing argument; leading ':' indicates no error - * should be generated. - */ - if (PRINT_ERROR) - warnx(recargstring, - current_argv); - /* - * XXX: GNU sets optopt to val regardless of flag - */ - if (long_options[match].flag == NULL) - optopt = long_options[match].val; - else - optopt = 0; - --optind; - return (BADARG); - } - } else { /* unknown option */ - if (short_too) { - --optind; - return (-1); - } - if (PRINT_ERROR) - warnx(illoptstring, current_argv); - optopt = 0; - return (BADCH); - } - if (idx) - *idx = match; - if (long_options[match].flag) { - *long_options[match].flag = long_options[match].val; - return (0); - } else - return (long_options[match].val); -} - -/* - * getopt_internal -- - * Parse argc/argv argument vector. Called by user level routines. - */ -static int -getopt_internal(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx, int flags) -{ - const char * oli; /* option letter list index */ - int optchar, short_too; - static int posixly_correct = -1; - - if (options == NULL) - return (-1); - - /* - * Disable GNU extensions if POSIXLY_CORRECT is set or options - * string begins with a '+'. - */ - if (posixly_correct == -1) - posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); - if (posixly_correct || *options == '+') - flags &= ~FLAG_PERMUTE; - else if (*options == '-') - flags |= FLAG_ALLARGS; - if (*options == '+' || *options == '-') - options++; - - /* - * XXX Some GNU programs (like cvs) set optind to 0 instead of - * XXX using optreset. Work around this braindamage. - */ - if (optind == 0) - optind = optreset = 1; - - optarg = NULL; - if (optreset) - nonopt_start = nonopt_end = -1; -start: - if (optreset || !*place) { /* update scanning pointer */ - optreset = 0; - if (optind >= nargc) { /* end of argument vector */ - place = EMSG; - if (nonopt_end != -1) { - /* do permutation, if we have to */ - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - else if (nonopt_start != -1) { - /* - * If we skipped non-options, set optind - * to the first of them. - */ - optind = nonopt_start; - } - nonopt_start = nonopt_end = -1; - return (-1); - } - if (*(place = nargv[optind]) != '-' || - (place[1] == '\0' && strchr(options, '-') == NULL)) { - place = EMSG; /* found non-option */ - if (flags & FLAG_ALLARGS) { - /* - * GNU extension: - * return non-option as argument to option 1 - */ - optarg = nargv[optind++]; - return (INORDER); - } - if (!(flags & FLAG_PERMUTE)) { - /* - * If no permutation wanted, stop parsing - * at first non-option. - */ - return (-1); - } - /* do permutation */ - if (nonopt_start == -1) - nonopt_start = optind; - else if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - nonopt_start = optind - - (nonopt_end - nonopt_start); - nonopt_end = -1; - } - optind++; - /* process next argument */ - goto start; - } - if (nonopt_start != -1 && nonopt_end == -1) - nonopt_end = optind; - - /* - * If we have "-" do nothing, if "--" we are done. - */ - if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { - optind++; - place = EMSG; - /* - * We found an option (--), so if we skipped - * non-options, we have to permute. - */ - if (nonopt_end != -1) { - permute_args(nonopt_start, nonopt_end, - optind, nargv); - optind -= nonopt_end - nonopt_start; - } - nonopt_start = nonopt_end = -1; - return (-1); - } - } - - /* - * Check long options if: - * 1) we were passed some - * 2) the arg is not just "-" - * 3) either the arg starts with -- we are getopt_long_only() - */ - if (long_options != NULL && place != nargv[optind] && - (*place == '-' || (flags & FLAG_LONGONLY))) { - short_too = 0; - if (*place == '-') - place++; /* --foo long option */ - else if (*place != ':' && strchr(options, *place) != NULL) - short_too = 1; /* could be short option too */ - - optchar = parse_long_options(nargv, options, long_options, - idx, short_too); - if (optchar != -1) { - place = EMSG; - return (optchar); - } - } - - if ((optchar = (int)*place++) == (int)':' || - optchar == (int)'-' && *place != '\0' || - (oli = strchr(options, optchar)) == NULL) { - /* - * If the user specified "-" and '-' isn't listed in - * options, return -1 (non-option) as per POSIX. - * Otherwise, it is an unknown option character (or ':'). - */ - if (optchar == (int)'-' && *place == '\0') - return (-1); - if (!*place) - ++optind; - if (PRINT_ERROR) - warnx(illoptchar, optchar); - optopt = optchar; - return (BADCH); - } - if (long_options != NULL && optchar == 'W' && oli[1] == ';') { - /* -W long-option */ - if (*place) /* no space */ - /* NOTHING */; - else if (++optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - warnx(recargchar, optchar); - optopt = optchar; - return (BADARG); - } else /* white space */ - place = nargv[optind]; - optchar = parse_long_options(nargv, options, long_options, - idx, 0); - place = EMSG; - return (optchar); - } - if (*++oli != ':') { /* doesn't take argument */ - if (!*place) - ++optind; - } else { /* takes (optional) argument */ - optarg = NULL; - if (*place) /* no white space */ - optarg = place; - /* XXX: disable test for :: if PC? (GNU doesn't) */ - else if (oli[1] != ':') { /* arg not optional */ - if (++optind >= nargc) { /* no arg */ - place = EMSG; - if (PRINT_ERROR) - warnx(recargchar, optchar); - optopt = optchar; - return (BADARG); - } else - optarg = nargv[optind]; - } else if (!(flags & FLAG_PERMUTE)) { - /* - * If permutation is disabled, we can accept an - * optional arg separated by whitespace so long - * as it does not start with a dash (-). - */ - if (optind + 1 < nargc && *nargv[optind + 1] != '-') - optarg = nargv[++optind]; - } - place = EMSG; - ++optind; - } - /* dump back option letter */ - return (optchar); -} - -/* - * getopt -- - * Parse argc/argv argument vector. - * - * [eventually this will replace the BSD getopt] - */ -int -getopt(int nargc, char * const *nargv, const char *options) -{ - - /* - * We don't pass FLAG_PERMUTE to getopt_internal() since - * the BSD getopt(3) (unlike GNU) has never done this. - * - * Furthermore, since many privileged programs call getopt() - * before dropping privileges it makes sense to keep things - * as simple (and bug-free) as possible. - */ - return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); -} - -/* - * getopt_long -- - * Parse argc/argv argument vector. - */ -int -getopt_long(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) -{ - - return (getopt_internal(nargc, nargv, options, long_options, idx, - FLAG_PERMUTE)); -} - -/* - * getopt_long_only -- - * Parse argc/argv argument vector. - */ -int -getopt_long_only(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) -{ - - return (getopt_internal(nargc, nargv, options, long_options, idx, - FLAG_PERMUTE|FLAG_LONGONLY)); -} - -#endif // REPLACE_GETOPT +/* $OpenBSD: getopt_long.c,v 1.20 2005/10/25 15:49:37 jmc Exp $ */ +/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ +// Adapted for Box Backup by Chris Wilson + +/* + * Copyright (c) 2002 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. + */ +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// #include "Box.h" +#include "emu.h" + +#include +#include +#include +#include +#include + +#include "box_getopt.h" + +#ifdef REPLACE_GETOPT // until end of file + +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = '?'; /* character checked for validity */ +int optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define PRINT_ERROR ((opterr) && (*options != ':')) + +#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */ +#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */ +#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */ + +/* return values */ +#define BADCH (int)'?' +#define BADARG ((*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +#define EMSG "" + +static void warnx(const char* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static int getopt_internal(int, char * const *, const char *, + const struct option *, int *, int); +static int parse_long_options(char * const *, const char *, + const struct option *, int *, int); +static int gcd(int, int); +static void permute_args(int, int, int, char * const *); + +static char *place = EMSG; /* option letter processing */ + +/* XXX: set optreset to 1 rather than these two */ +static int nonopt_start = -1; /* first non option argument (for permute) */ +static int nonopt_end = -1; /* first option after non options (for permute) */ + +/* Error messages */ +static const char recargchar[] = "option requires an argument -- %c"; +static const char recargstring[] = "option requires an argument -- %s"; +static const char ambig[] = "ambiguous option -- %.*s"; +static const char noarg[] = "option doesn't take an argument -- %.*s"; +static const char illoptchar[] = "unknown option -- %c"; +static const char illoptstring[] = "unknown option -- %s"; + +/* + * Compute the greatest common divisor of a and b. + */ +static int +gcd(int a, int b) +{ + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return (b); +} + +/* + * Exchange the block from nonopt_start to nonopt_end with the block + * from nonopt_end to opt_end (keeping the same order of arguments + * in each block). + */ +static void +permute_args(int panonopt_start, int panonopt_end, int opt_end, + char * const *nargv) +{ + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; + char *swap; + + /* + * compute lengths of blocks and number and size of cycles + */ + nnonopts = panonopt_end - panonopt_start; + nopts = opt_end - panonopt_end; + ncycle = gcd(nnonopts, nopts); + cyclelen = (opt_end - panonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = panonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= panonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + /* LINTED const cast */ + ((char **) nargv)[pos] = nargv[cstart]; + /* LINTED const cast */ + ((char **)nargv)[cstart] = swap; + } + } +} + +/* + * parse_long_options -- + * Parse long options in argc/argv argument vector. + * Returns -1 if short_too is set and the option does not match long_options. + */ +static int +parse_long_options(char * const *nargv, const char *options, + const struct option *long_options, int *idx, int short_too) +{ + char *current_argv, *has_equal; + size_t current_argv_len; + int i, match; + + current_argv = place; + match = -1; + + optind++; + + if ((has_equal = strchr(current_argv, '=')) != NULL) { + /* argument found (--option=arg) */ + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + /* find matching long option */ + if (strncmp(current_argv, long_options[i].name, + current_argv_len)) + continue; + + if (strlen(long_options[i].name) == current_argv_len) { + /* exact match */ + match = i; + break; + } + /* + * If this is a known short option, don't allow + * a partial match of a single character. + */ + if (short_too && current_argv_len == 1) + continue; + + if (match == -1) /* partial match */ + match = i; + else { + /* ambiguous abbreviation */ + if (PRINT_ERROR) + warnx(ambig, (int)current_argv_len, + current_argv); + optopt = 0; + return (BADCH); + } + } + if (match != -1) { /* option found */ + if (long_options[match].has_arg == no_argument + && has_equal) { + if (PRINT_ERROR) + warnx(noarg, (int)current_argv_len, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + return (BADARG); + } + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].has_arg == + required_argument) { + /* + * optional argument doesn't use next nargv + */ + optarg = nargv[optind++]; + } + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument; leading ':' indicates no error + * should be generated. + */ + if (PRINT_ERROR) + warnx(recargstring, + current_argv); + /* + * XXX: GNU sets optopt to val regardless of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return (BADARG); + } + } else { /* unknown option */ + if (short_too) { + --optind; + return (-1); + } + if (PRINT_ERROR) + warnx(illoptstring, current_argv); + optopt = 0; + return (BADCH); + } + if (idx) + *idx = match; + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + return (0); + } else + return (long_options[match].val); +} + +/* + * getopt_internal -- + * Parse argc/argv argument vector. Called by user level routines. + */ +static int +getopt_internal(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx, int flags) +{ + const char * oli; /* option letter list index */ + int optchar, short_too; + static int posixly_correct = -1; + + if (options == NULL) + return (-1); + + /* + * Disable GNU extensions if POSIXLY_CORRECT is set or options + * string begins with a '+'. + */ + if (posixly_correct == -1) + posixly_correct = (getenv("POSIXLY_CORRECT") != NULL); + if (posixly_correct || *options == '+') + flags &= ~FLAG_PERMUTE; + else if (*options == '-') + flags |= FLAG_ALLARGS; + if (*options == '+' || *options == '-') + options++; + + /* + * XXX Some GNU programs (like cvs) set optind to 0 instead of + * XXX using optreset. Work around this braindamage. + */ + if (optind == 0) + optind = optreset = 1; + + optarg = NULL; + if (optreset) + nonopt_start = nonopt_end = -1; +start: + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc) { /* end of argument vector */ + place = EMSG; + if (nonopt_end != -1) { + /* do permutation, if we have to */ + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + /* + * If we skipped non-options, set optind + * to the first of them. + */ + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + if (*(place = nargv[optind]) != '-' || + (place[1] == '\0' && strchr(options, '-') == NULL)) { + place = EMSG; /* found non-option */ + if (flags & FLAG_ALLARGS) { + /* + * GNU extension: + * return non-option as argument to option 1 + */ + optarg = nargv[optind++]; + return (INORDER); + } + if (!(flags & FLAG_PERMUTE)) { + /* + * If no permutation wanted, stop parsing + * at first non-option. + */ + return (-1); + } + /* do permutation */ + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + /* process next argument */ + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + + /* + * If we have "-" do nothing, if "--" we are done. + */ + if (place[1] != '\0' && *++place == '-' && place[1] == '\0') { + optind++; + place = EMSG; + /* + * We found an option (--), so if we skipped + * non-options, we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return (-1); + } + } + + /* + * Check long options if: + * 1) we were passed some + * 2) the arg is not just "-" + * 3) either the arg starts with -- we are getopt_long_only() + */ + if (long_options != NULL && place != nargv[optind] && + (*place == '-' || (flags & FLAG_LONGONLY))) { + short_too = 0; + if (*place == '-') + place++; /* --foo long option */ + else if (*place != ':' && strchr(options, *place) != NULL) + short_too = 1; /* could be short option too */ + + optchar = parse_long_options(nargv, options, long_options, + idx, short_too); + if (optchar != -1) { + place = EMSG; + return (optchar); + } + } + + if ((optchar = (int)*place++) == (int)':' || + optchar == (int)'-' && *place != '\0' || + (oli = strchr(options, optchar)) == NULL) { + /* + * If the user specified "-" and '-' isn't listed in + * options, return -1 (non-option) as per POSIX. + * Otherwise, it is an unknown option character (or ':'). + */ + if (optchar == (int)'-' && *place == '\0') + return (-1); + if (!*place) + ++optind; + if (PRINT_ERROR) + warnx(illoptchar, optchar); + optopt = optchar; + return (BADCH); + } + if (long_options != NULL && optchar == 'W' && oli[1] == ';') { + /* -W long-option */ + if (*place) /* no space */ + /* NOTHING */; + else if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } else /* white space */ + place = nargv[optind]; + optchar = parse_long_options(nargv, options, long_options, + idx, 0); + place = EMSG; + return (optchar); + } + if (*++oli != ':') { /* doesn't take argument */ + if (!*place) + ++optind; + } else { /* takes (optional) argument */ + optarg = NULL; + if (*place) /* no white space */ + optarg = place; + /* XXX: disable test for :: if PC? (GNU doesn't) */ + else if (oli[1] != ':') { /* arg not optional */ + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar, optchar); + optopt = optchar; + return (BADARG); + } else + optarg = nargv[optind]; + } else if (!(flags & FLAG_PERMUTE)) { + /* + * If permutation is disabled, we can accept an + * optional arg separated by whitespace so long + * as it does not start with a dash (-). + */ + if (optind + 1 < nargc && *nargv[optind + 1] != '-') + optarg = nargv[++optind]; + } + place = EMSG; + ++optind; + } + /* dump back option letter */ + return (optchar); +} + +/* + * getopt -- + * Parse argc/argv argument vector. + * + * [eventually this will replace the BSD getopt] + */ +int +getopt(int nargc, char * const *nargv, const char *options) +{ + + /* + * We don't pass FLAG_PERMUTE to getopt_internal() since + * the BSD getopt(3) (unlike GNU) has never done this. + * + * Furthermore, since many privileged programs call getopt() + * before dropping privileges it makes sense to keep things + * as simple (and bug-free) as possible. + */ + return (getopt_internal(nargc, nargv, options, NULL, NULL, 0)); +} + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE)); +} + +/* + * getopt_long_only -- + * Parse argc/argv argument vector. + */ +int +getopt_long_only(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + + return (getopt_internal(nargc, nargv, options, long_options, idx, + FLAG_PERMUTE|FLAG_LONGONLY)); +} + +#endif // REPLACE_GETOPT diff --git a/lib/win32/messages.rc b/lib/win32/messages.rc index 0885a897..116522b7 100755 --- a/lib/win32/messages.rc +++ b/lib/win32/messages.rc @@ -1,2 +1,2 @@ -LANGUAGE 0x9,0x1 -1 11 MSG00001.bin +LANGUAGE 0x9,0x1 +1 11 MSG00001.bin diff --git a/qdbm/VCmakefile b/qdbm/VCmakefile index e37275c9..210a98ff 100644 --- a/qdbm/VCmakefile +++ b/qdbm/VCmakefile @@ -1,248 +1,248 @@ -# Makefile to build QDBM using Microsoft Visual C++ - - - -#================================================================ -# Setting variables -#================================================================ - - -# VC++ directory -VCPATH = C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 - -# User options -YOUR_CLFLAGS = -YOUR_LIBFLAGS = -YOUR_LINKFLAGS= - -# Configurations -!IF "$(CFG)" == "ld" -!MESSAGE Build using static debug configuration -BASE_FLAGS = /MLd /W3 /ZI /Od /FD /GZ /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" -BASE_DEFS = /D_DEBUG /D__DEBUG__ -OUTDIR = .\tmp_ld -LIB_APPEND = _ld -EXE_APPEND = _ld -!ELSEIF "$(CFG)" == "l" -!MESSAGE Build using static release configuration -BASE_DEFS = /DNDEBUG -BASE_FLAGS = /ML /W3 /O2 /FD /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" -OUTDIR = .\tmp_l -LIB_APPEND = _l -EXE_APPEND = _l -!ELSEIF "$(CFG)" == "td" -!MESSAGE Build using static threaded debug configuration -BASE_FLAGS = /MTd /W3 /ZI /Od /FD /GZ /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" -BASE_DEFS = /D_DEBUG /D__DEBUG__ -OUTDIR = .\tmp_td -LIB_APPEND = _td -EXE_APPEND = _td -!ELSEIF "$(CFG)" == "t" -!MESSAGE Build using static threaded release configuration -BASE_DEFS = /DNDEBUG -BASE_FLAGS = /MT /W3 /O2 /FD /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" -OUTDIR = .\tmp_t -LIB_APPEND = _t -EXE_APPEND = _t -!ELSEIF "$(CFG)" == "dd" -!MESSAGE Build using dynamic threaded debug configuration -BASE_FLAGS = /MDd /W3 /ZI /Od /FD /GZ /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" -BASE_DEFS = /D_DEBUG /D__DEBUG__ -OUTDIR = .\tmp_dd -LIB_APPEND = _dd -EXE_APPEND = _dd -!ELSE -!MESSAGE Build using dynamic threaded release configuration -BASE_DEFS = /DNDEBUG -BASE_FLAGS = /MD /W3 /O2 /FD /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" -OUTDIR = .\tmp -LIB_APPEND = -EXE_APPEND = -!ENDIF - -# Building binaries -CLFLAGS = /I "$(VCPATH)\Include" /I "$(VCPATH)\PlatformSDK\Include" /I "." \ - /nologo $(YOUR_CLFLAGS) $(BASE_FLAGS) $(BASE_DEFS) /D_CRT_SECURE_NO_DEPRECATE=1 -LIBFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." \ - /nologo $(YOUR_LIBFLAGS) -LINKFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." \ - /nologo $(YOUR_LINKFLAGS) - -# Targets -MYLIBS = qdbm$(LIB_APPEND).dll qdbm$(LIB_APPEND).lib qdbm$(LIB_APPEND)_static.lib -LIBOBJS = $(OUTDIR)\depot.obj $(OUTDIR)\curia.obj $(OUTDIR)\relic.obj \ - $(OUTDIR)\hovel.obj $(OUTDIR)\cabin.obj $(OUTDIR)\villa.obj \ - $(OUTDIR)\vista.obj $(OUTDIR)\odeum.obj $(OUTDIR)\myconf.obj -MYBINS = dpmgr$(EXE_APPEND).exe dptest$(EXE_APPEND).exe dptsv$(EXE_APPEND).exe \ - crmgr$(EXE_APPEND).exe crtest$(EXE_APPEND).exe crtsv$(EXE_APPEND).exe \ - rlmgr$(EXE_APPEND).exe rltest$(EXE_APPEND).exe hvmgr$(EXE_APPEND).exe \ - hvtest$(EXE_APPEND).exe cbtest$(EXE_APPEND).exe cbcodec$(EXE_APPEND).exe \ - vlmgr$(EXE_APPEND).exe vltest$(EXE_APPEND).exe vltsv$(EXE_APPEND).exe \ - odmgr$(EXE_APPEND).exe odtest$(EXE_APPEND).exe odidx$(EXE_APPEND).exe - - - -#================================================================ -# Suffix rules -#================================================================ - - -.SUFFIXES : -.SUFFIXES : .c .obj - -.c{$(OUTDIR)}.obj : - cl /c $(CLFLAGS) $< - -.c.obj: - cl /c $(CLFLAGS) $< - - - -#================================================================ -# Actions -#================================================================ - - -all : $(OUTDIR) $(MYLIBS) $(MYBINS) - - -allcfg: - nmake /NOLOGO /f VCmakefile CFG=ld - nmake /NOLOGO /f VCmakefile CFG=l - nmake /NOLOGO /f VCmakefile CFG=td - nmake /NOLOGO /f VCmakefile CFG=t - nmake /NOLOGO /f VCmakefile CFG=dd - nmake /NOLOGO /f VCmakefile - - -clean : - -rd tmp_ld /S /Q > NUL: 2>&1 - -rd tmp_l /S /Q > NUL: 2>&1 - -rd tmp_td /S /Q > NUL: 2>&1 - -rd tmp_t /S /Q > NUL: 2>&1 - -rd tmp_dd /S /Q > NUL: 2>&1 - -rd tmp /S /Q > NUL: 2>&1 - -del *.obj *.lib *.dll *.exp *.exe casket /F /Q > NUL: 2>&1 - - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/" mkdir "$(OUTDIR)" - - - -#================================================================ -# Building binaries -#================================================================ - - -qdbm$(LIB_APPEND).dll : $(LIBOBJS) qdbm.def - link /DLL /DEF:qdbm.def $(LINKFLAGS) /OUT:$@ /IMPLIB:qdbm$(LIB_APPEND).lib $(LIBOBJS) - - -qdbm$(LIB_APPEND).lib : qdbm$(LIB_APPEND).dll - - -qdbm$(LIB_APPEND)_static.lib : $(LIBOBJS) - lib $(LIBFLAGS) /OUT:$@ $(LIBOBJS) - - -dpmgr$(EXE_APPEND).exe : $(OUTDIR)\dpmgr.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\dpmgr.obj qdbm$(LIB_APPEND).lib - - -dptest$(EXE_APPEND).exe : $(OUTDIR)\dptest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\dptest.obj qdbm$(LIB_APPEND).lib - - -dptsv$(EXE_APPEND).exe : $(OUTDIR)\dptsv.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\dptsv.obj qdbm$(LIB_APPEND).lib - - -crmgr$(EXE_APPEND).exe : $(OUTDIR)\crmgr.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\crmgr.obj qdbm$(LIB_APPEND).lib - - -crtest$(EXE_APPEND).exe : $(OUTDIR)\crtest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\crtest.obj qdbm$(LIB_APPEND).lib - - -crtsv$(EXE_APPEND).exe : $(OUTDIR)\crtsv.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\crtsv.obj qdbm$(LIB_APPEND).lib - - -rlmgr$(EXE_APPEND).exe : $(OUTDIR)\rlmgr.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\rlmgr.obj qdbm$(LIB_APPEND).lib - - -rltest$(EXE_APPEND).exe : $(OUTDIR)\rltest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\rltest.obj qdbm$(LIB_APPEND).lib - - -hvmgr$(EXE_APPEND).exe : $(OUTDIR)\hvmgr.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\hvmgr.obj qdbm$(LIB_APPEND).lib - - -hvtest$(EXE_APPEND).exe : $(OUTDIR)\hvtest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\hvtest.obj qdbm$(LIB_APPEND).lib - - -cbtest$(EXE_APPEND).exe : $(OUTDIR)\cbtest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\cbtest.obj qdbm$(LIB_APPEND).lib - - -cbcodec$(EXE_APPEND).exe : $(OUTDIR)\cbcodec.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\cbcodec.obj qdbm$(LIB_APPEND).lib - - -vlmgr$(EXE_APPEND).exe : $(OUTDIR)\vlmgr.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\vlmgr.obj qdbm$(LIB_APPEND).lib - - -vltest$(EXE_APPEND).exe : $(OUTDIR)\vltest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\vltest.obj qdbm$(LIB_APPEND).lib - - -vltsv$(EXE_APPEND).exe : $(OUTDIR)\vltsv.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\vltsv.obj qdbm$(LIB_APPEND).lib - - -odmgr$(EXE_APPEND).exe : $(OUTDIR)\odmgr.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\odmgr.obj qdbm$(LIB_APPEND).lib - - -odtest$(EXE_APPEND).exe : $(OUTDIR)\odtest.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\odtest.obj qdbm$(LIB_APPEND).lib - - -odidx$(EXE_APPEND).exe : $(OUTDIR)\odidx.obj qdbm$(LIB_APPEND).lib - link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\odidx.obj qdbm$(LIB_APPEND).lib - - -$(OUTDIR)\depot.obj $(OUTDIR)\dpmgr.obj $(OUTDIR)\dptest.obj $(OUTDIR)\dptsv.obj : \ - depot.h myconf.h - -$(OUTDIR)\curia.obj $(OUTDIR)\crmgr.obj $(OUTDIR)\crtest.obj $(OUTDIR)\crtsv.obj : \ - curia.h depot.h myconf.h - -$(OUTDIR)\relic.obj $(OUTDIR)\rlmgr.obj $(OUTDIR)\rltest.obj : \ - relic.h depot.h myconf.h - -$(OUTDIR)\hovel.obj $(OUTDIR)\hvmgr.obj $(OUTDIR)\hvtest.obj : \ - hovel.h depot.h curia.h myconf.h - -$(OUTDIR)\cabin.obj $(OUTDIR)\cbtest.obj $(OUTDIR)\cbcodec.obj : \ - cabin.h myconf.h - -$(OUTDIR)\villa.obj $(OUTDIR)\vlmgr.obj $(OUTDIR)\vltest.obj $(OUTDIR)\vltsv.obj : \ - villa.h depot.h cabin.h myconf.h - -$(OUTDIR)\vista.obj : vista.h villa.h depot.h curia.h cabin.h myconf.h - -$(OUTDIR)\odeum.obj $(OUTDIR)\odmgr.obj $(OUTDIR)\odtest.obj $(OUTDIR)\odidx.obj : \ - odeum.h depot.h curia.h cabin.h villa.h myconf.h - -$(OUTDIR)\myconf.obj : myconf.h - - - -# END OF FILE +# Makefile to build QDBM using Microsoft Visual C++ + + + +#================================================================ +# Setting variables +#================================================================ + + +# VC++ directory +VCPATH = C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 + +# User options +YOUR_CLFLAGS = +YOUR_LIBFLAGS = +YOUR_LINKFLAGS= + +# Configurations +!IF "$(CFG)" == "ld" +!MESSAGE Build using static debug configuration +BASE_FLAGS = /MLd /W3 /ZI /Od /FD /GZ /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" +BASE_DEFS = /D_DEBUG /D__DEBUG__ +OUTDIR = .\tmp_ld +LIB_APPEND = _ld +EXE_APPEND = _ld +!ELSEIF "$(CFG)" == "l" +!MESSAGE Build using static release configuration +BASE_DEFS = /DNDEBUG +BASE_FLAGS = /ML /W3 /O2 /FD /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" +OUTDIR = .\tmp_l +LIB_APPEND = _l +EXE_APPEND = _l +!ELSEIF "$(CFG)" == "td" +!MESSAGE Build using static threaded debug configuration +BASE_FLAGS = /MTd /W3 /ZI /Od /FD /GZ /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" +BASE_DEFS = /D_DEBUG /D__DEBUG__ +OUTDIR = .\tmp_td +LIB_APPEND = _td +EXE_APPEND = _td +!ELSEIF "$(CFG)" == "t" +!MESSAGE Build using static threaded release configuration +BASE_DEFS = /DNDEBUG +BASE_FLAGS = /MT /W3 /O2 /FD /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" +OUTDIR = .\tmp_t +LIB_APPEND = _t +EXE_APPEND = _t +!ELSEIF "$(CFG)" == "dd" +!MESSAGE Build using dynamic threaded debug configuration +BASE_FLAGS = /MDd /W3 /ZI /Od /FD /GZ /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" +BASE_DEFS = /D_DEBUG /D__DEBUG__ +OUTDIR = .\tmp_dd +LIB_APPEND = _dd +EXE_APPEND = _dd +!ELSE +!MESSAGE Build using dynamic threaded release configuration +BASE_DEFS = /DNDEBUG +BASE_FLAGS = /MD /W3 /O2 /FD /Fo"$(OUTDIR)\\" /Fd"$(OUTDIR)\\" +OUTDIR = .\tmp +LIB_APPEND = +EXE_APPEND = +!ENDIF + +# Building binaries +CLFLAGS = /I "$(VCPATH)\Include" /I "$(VCPATH)\PlatformSDK\Include" /I "." \ + /nologo $(YOUR_CLFLAGS) $(BASE_FLAGS) $(BASE_DEFS) /D_CRT_SECURE_NO_DEPRECATE=1 +LIBFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." \ + /nologo $(YOUR_LIBFLAGS) +LINKFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." \ + /nologo $(YOUR_LINKFLAGS) + +# Targets +MYLIBS = qdbm$(LIB_APPEND).dll qdbm$(LIB_APPEND).lib qdbm$(LIB_APPEND)_static.lib +LIBOBJS = $(OUTDIR)\depot.obj $(OUTDIR)\curia.obj $(OUTDIR)\relic.obj \ + $(OUTDIR)\hovel.obj $(OUTDIR)\cabin.obj $(OUTDIR)\villa.obj \ + $(OUTDIR)\vista.obj $(OUTDIR)\odeum.obj $(OUTDIR)\myconf.obj +MYBINS = dpmgr$(EXE_APPEND).exe dptest$(EXE_APPEND).exe dptsv$(EXE_APPEND).exe \ + crmgr$(EXE_APPEND).exe crtest$(EXE_APPEND).exe crtsv$(EXE_APPEND).exe \ + rlmgr$(EXE_APPEND).exe rltest$(EXE_APPEND).exe hvmgr$(EXE_APPEND).exe \ + hvtest$(EXE_APPEND).exe cbtest$(EXE_APPEND).exe cbcodec$(EXE_APPEND).exe \ + vlmgr$(EXE_APPEND).exe vltest$(EXE_APPEND).exe vltsv$(EXE_APPEND).exe \ + odmgr$(EXE_APPEND).exe odtest$(EXE_APPEND).exe odidx$(EXE_APPEND).exe + + + +#================================================================ +# Suffix rules +#================================================================ + + +.SUFFIXES : +.SUFFIXES : .c .obj + +.c{$(OUTDIR)}.obj : + cl /c $(CLFLAGS) $< + +.c.obj: + cl /c $(CLFLAGS) $< + + + +#================================================================ +# Actions +#================================================================ + + +all : $(OUTDIR) $(MYLIBS) $(MYBINS) + + +allcfg: + nmake /NOLOGO /f VCmakefile CFG=ld + nmake /NOLOGO /f VCmakefile CFG=l + nmake /NOLOGO /f VCmakefile CFG=td + nmake /NOLOGO /f VCmakefile CFG=t + nmake /NOLOGO /f VCmakefile CFG=dd + nmake /NOLOGO /f VCmakefile + + +clean : + -rd tmp_ld /S /Q > NUL: 2>&1 + -rd tmp_l /S /Q > NUL: 2>&1 + -rd tmp_td /S /Q > NUL: 2>&1 + -rd tmp_t /S /Q > NUL: 2>&1 + -rd tmp_dd /S /Q > NUL: 2>&1 + -rd tmp /S /Q > NUL: 2>&1 + -del *.obj *.lib *.dll *.exp *.exe casket /F /Q > NUL: 2>&1 + + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/" mkdir "$(OUTDIR)" + + + +#================================================================ +# Building binaries +#================================================================ + + +qdbm$(LIB_APPEND).dll : $(LIBOBJS) qdbm.def + link /DLL /DEF:qdbm.def $(LINKFLAGS) /OUT:$@ /IMPLIB:qdbm$(LIB_APPEND).lib $(LIBOBJS) + + +qdbm$(LIB_APPEND).lib : qdbm$(LIB_APPEND).dll + + +qdbm$(LIB_APPEND)_static.lib : $(LIBOBJS) + lib $(LIBFLAGS) /OUT:$@ $(LIBOBJS) + + +dpmgr$(EXE_APPEND).exe : $(OUTDIR)\dpmgr.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\dpmgr.obj qdbm$(LIB_APPEND).lib + + +dptest$(EXE_APPEND).exe : $(OUTDIR)\dptest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\dptest.obj qdbm$(LIB_APPEND).lib + + +dptsv$(EXE_APPEND).exe : $(OUTDIR)\dptsv.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\dptsv.obj qdbm$(LIB_APPEND).lib + + +crmgr$(EXE_APPEND).exe : $(OUTDIR)\crmgr.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\crmgr.obj qdbm$(LIB_APPEND).lib + + +crtest$(EXE_APPEND).exe : $(OUTDIR)\crtest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\crtest.obj qdbm$(LIB_APPEND).lib + + +crtsv$(EXE_APPEND).exe : $(OUTDIR)\crtsv.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\crtsv.obj qdbm$(LIB_APPEND).lib + + +rlmgr$(EXE_APPEND).exe : $(OUTDIR)\rlmgr.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\rlmgr.obj qdbm$(LIB_APPEND).lib + + +rltest$(EXE_APPEND).exe : $(OUTDIR)\rltest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\rltest.obj qdbm$(LIB_APPEND).lib + + +hvmgr$(EXE_APPEND).exe : $(OUTDIR)\hvmgr.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\hvmgr.obj qdbm$(LIB_APPEND).lib + + +hvtest$(EXE_APPEND).exe : $(OUTDIR)\hvtest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\hvtest.obj qdbm$(LIB_APPEND).lib + + +cbtest$(EXE_APPEND).exe : $(OUTDIR)\cbtest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\cbtest.obj qdbm$(LIB_APPEND).lib + + +cbcodec$(EXE_APPEND).exe : $(OUTDIR)\cbcodec.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\cbcodec.obj qdbm$(LIB_APPEND).lib + + +vlmgr$(EXE_APPEND).exe : $(OUTDIR)\vlmgr.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\vlmgr.obj qdbm$(LIB_APPEND).lib + + +vltest$(EXE_APPEND).exe : $(OUTDIR)\vltest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\vltest.obj qdbm$(LIB_APPEND).lib + + +vltsv$(EXE_APPEND).exe : $(OUTDIR)\vltsv.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\vltsv.obj qdbm$(LIB_APPEND).lib + + +odmgr$(EXE_APPEND).exe : $(OUTDIR)\odmgr.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\odmgr.obj qdbm$(LIB_APPEND).lib + + +odtest$(EXE_APPEND).exe : $(OUTDIR)\odtest.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\odtest.obj qdbm$(LIB_APPEND).lib + + +odidx$(EXE_APPEND).exe : $(OUTDIR)\odidx.obj qdbm$(LIB_APPEND).lib + link $(LINKFLAGS) /OUT:$@ $(OUTDIR)\odidx.obj qdbm$(LIB_APPEND).lib + + +$(OUTDIR)\depot.obj $(OUTDIR)\dpmgr.obj $(OUTDIR)\dptest.obj $(OUTDIR)\dptsv.obj : \ + depot.h myconf.h + +$(OUTDIR)\curia.obj $(OUTDIR)\crmgr.obj $(OUTDIR)\crtest.obj $(OUTDIR)\crtsv.obj : \ + curia.h depot.h myconf.h + +$(OUTDIR)\relic.obj $(OUTDIR)\rlmgr.obj $(OUTDIR)\rltest.obj : \ + relic.h depot.h myconf.h + +$(OUTDIR)\hovel.obj $(OUTDIR)\hvmgr.obj $(OUTDIR)\hvtest.obj : \ + hovel.h depot.h curia.h myconf.h + +$(OUTDIR)\cabin.obj $(OUTDIR)\cbtest.obj $(OUTDIR)\cbcodec.obj : \ + cabin.h myconf.h + +$(OUTDIR)\villa.obj $(OUTDIR)\vlmgr.obj $(OUTDIR)\vltest.obj $(OUTDIR)\vltsv.obj : \ + villa.h depot.h cabin.h myconf.h + +$(OUTDIR)\vista.obj : vista.h villa.h depot.h curia.h cabin.h myconf.h + +$(OUTDIR)\odeum.obj $(OUTDIR)\odmgr.obj $(OUTDIR)\odtest.obj $(OUTDIR)\odidx.obj : \ + odeum.h depot.h curia.h cabin.h villa.h myconf.h + +$(OUTDIR)\myconf.obj : myconf.h + + + +# END OF FILE diff --git a/qdbm/misc/VCmakefile-old b/qdbm/misc/VCmakefile-old index 94ececb9..8cd55467 100644 --- a/qdbm/misc/VCmakefile-old +++ b/qdbm/misc/VCmakefile-old @@ -1,169 +1,169 @@ -# Makefile to build QDBM using Microsoft Visual C++ - - - -#================================================================ -# Setting Variables -#================================================================ - - -# Targets -MYLIBS = qdbm.lib -LIBOBJS = depot.obj curia.obj relic.obj hovel.obj \ - cabin.obj villa.obj vista.obj odeum.obj myconf.obj -MYBINS = dpmgr.exe dptest.exe dptsv.exe crmgr.exe crtest.exe crtsv.exe \ - rlmgr.exe rltest.exe hvmgr.exe hvtest.exe cbtest.exe cbcodec.exe \ - vlmgr.exe vltest.exe vltsv.exe odmgr.exe odtest.exe odidx.exe - -# VC++ directory -VCPATH = C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 - -# Building binaries -CLFLAGS = /I "$(VCPATH)\Include" /I "$(VCPATH)\PlatformSDK\Include" /I "." /O2 /nologo -LIBFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." /nologo -LINKFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." /nologo - - - -#================================================================ -# Suffix rules -#================================================================ - - -.SUFFIXES : -.SUFFIXES : .c .obj - -.c.obj : - cl /c $(CLFLAGS) $< - - - -#================================================================ -# Actions -#================================================================ - - -all : $(MYLIBS) $(MYBINS) - - -clean : - del *.obj *.lib *.dll *.exp *.exe - - - -#================================================================ -# Building binaries -#================================================================ - - -qdbm.lib : $(LIBOBJS) - lib $(LIBFLAGS) /OUT:$@ $(LIBOBJS) - - -dpmgr.exe : dpmgr.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ dpmgr.obj qdbm.lib - - -dptest.exe : dptest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ dptest.obj qdbm.lib - - -dptsv.exe : dptsv.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ dptsv.obj qdbm.lib - - -crmgr.exe : crmgr.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ crmgr.obj qdbm.lib - - -crtest.exe : crtest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ crtest.obj qdbm.lib - - -crtsv.exe : crtsv.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ crtsv.obj qdbm.lib - - -rlmgr.exe : rlmgr.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ rlmgr.obj qdbm.lib - - -rltest.exe : rltest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ rltest.obj qdbm.lib - - -hvmgr.exe : hvmgr.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ hvmgr.obj qdbm.lib - - -hvtest.exe : hvtest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ hvtest.obj qdbm.lib - - -cbtest.exe : cbtest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ cbtest.obj qdbm.lib - - -cbcodec.exe : cbcodec.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ cbcodec.obj qdbm.lib - - -vlmgr.exe : vlmgr.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ vlmgr.obj qdbm.lib - - -vltest.exe : vltest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ vltest.obj qdbm.lib - - -vltsv.exe : vltsv.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ vltsv.obj qdbm.lib - - -odmgr.exe : odmgr.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ odmgr.obj qdbm.lib - - -odtest.exe : odtest.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ odtest.obj qdbm.lib - - -odidx.exe : odidx.obj qdbm.lib - link $(LINKFLAGS) /OUT:$@ odidx.obj qdbm.lib - - -depot.obj : depot.h myconf.h - -curia.obj : depot.h curia.h myconf.h - -relic.obj : depot.h relic.h myconf.h - -hovel.obj : depot.h curia.h hovel.h myconf.h - -cabin.obj : cabin.h myconf.h - -villa.obj : depot.h cabin.h villa.h myconf.h - -vista.obj : depot.h curia.h cabin.h villa.h vista.h myconf.h - -odeum.obj : depot.h curia.h cabin.h villa.h myconf.h - -myconf.obj : myconf.h - -dpmgr.obj dptest.obj dptsv.obj : depot.h cabin.h - -crmgr.obj crtest.obj crtsv.obj : depot.h curia.h cabin.h - -rlmgr.obj rltest.obj : depot.h relic.h cabin.h - -hvmgr.obj hvtest.obj : depot.h curia.h hovel.h cabin.h - -cbtest.obj cbcodec.obj : cabin.h - -vlmgr.obj vltest.obj vltsv.obj : depot.h cabin.h villa.h - -odmgr.obj odtest.obj odidx.obj : depot.h curia.h cabin.h villa.h odeum.h - - - -# END OF FILE +# Makefile to build QDBM using Microsoft Visual C++ + + + +#================================================================ +# Setting Variables +#================================================================ + + +# Targets +MYLIBS = qdbm.lib +LIBOBJS = depot.obj curia.obj relic.obj hovel.obj \ + cabin.obj villa.obj vista.obj odeum.obj myconf.obj +MYBINS = dpmgr.exe dptest.exe dptsv.exe crmgr.exe crtest.exe crtsv.exe \ + rlmgr.exe rltest.exe hvmgr.exe hvtest.exe cbtest.exe cbcodec.exe \ + vlmgr.exe vltest.exe vltsv.exe odmgr.exe odtest.exe odidx.exe + +# VC++ directory +VCPATH = C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 + +# Building binaries +CLFLAGS = /I "$(VCPATH)\Include" /I "$(VCPATH)\PlatformSDK\Include" /I "." /O2 /nologo +LIBFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." /nologo +LINKFLAGS = /libpath:"$(VCPATH)\lib" /libpath:"$(VCPATH)\PlatformSDK\Lib" /libpath:"." /nologo + + + +#================================================================ +# Suffix rules +#================================================================ + + +.SUFFIXES : +.SUFFIXES : .c .obj + +.c.obj : + cl /c $(CLFLAGS) $< + + + +#================================================================ +# Actions +#================================================================ + + +all : $(MYLIBS) $(MYBINS) + + +clean : + del *.obj *.lib *.dll *.exp *.exe + + + +#================================================================ +# Building binaries +#================================================================ + + +qdbm.lib : $(LIBOBJS) + lib $(LIBFLAGS) /OUT:$@ $(LIBOBJS) + + +dpmgr.exe : dpmgr.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ dpmgr.obj qdbm.lib + + +dptest.exe : dptest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ dptest.obj qdbm.lib + + +dptsv.exe : dptsv.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ dptsv.obj qdbm.lib + + +crmgr.exe : crmgr.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ crmgr.obj qdbm.lib + + +crtest.exe : crtest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ crtest.obj qdbm.lib + + +crtsv.exe : crtsv.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ crtsv.obj qdbm.lib + + +rlmgr.exe : rlmgr.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ rlmgr.obj qdbm.lib + + +rltest.exe : rltest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ rltest.obj qdbm.lib + + +hvmgr.exe : hvmgr.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ hvmgr.obj qdbm.lib + + +hvtest.exe : hvtest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ hvtest.obj qdbm.lib + + +cbtest.exe : cbtest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ cbtest.obj qdbm.lib + + +cbcodec.exe : cbcodec.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ cbcodec.obj qdbm.lib + + +vlmgr.exe : vlmgr.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ vlmgr.obj qdbm.lib + + +vltest.exe : vltest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ vltest.obj qdbm.lib + + +vltsv.exe : vltsv.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ vltsv.obj qdbm.lib + + +odmgr.exe : odmgr.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ odmgr.obj qdbm.lib + + +odtest.exe : odtest.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ odtest.obj qdbm.lib + + +odidx.exe : odidx.obj qdbm.lib + link $(LINKFLAGS) /OUT:$@ odidx.obj qdbm.lib + + +depot.obj : depot.h myconf.h + +curia.obj : depot.h curia.h myconf.h + +relic.obj : depot.h relic.h myconf.h + +hovel.obj : depot.h curia.h hovel.h myconf.h + +cabin.obj : cabin.h myconf.h + +villa.obj : depot.h cabin.h villa.h myconf.h + +vista.obj : depot.h curia.h cabin.h villa.h vista.h myconf.h + +odeum.obj : depot.h curia.h cabin.h villa.h myconf.h + +myconf.obj : myconf.h + +dpmgr.obj dptest.obj dptsv.obj : depot.h cabin.h + +crmgr.obj crtest.obj crtsv.obj : depot.h curia.h cabin.h + +rlmgr.obj rltest.obj : depot.h relic.h cabin.h + +hvmgr.obj hvtest.obj : depot.h curia.h hovel.h cabin.h + +cbtest.obj cbcodec.obj : cabin.h + +vlmgr.obj vltest.obj vltsv.obj : depot.h cabin.h villa.h + +odmgr.obj odtest.obj odidx.obj : depot.h curia.h cabin.h villa.h odeum.h + + + +# END OF FILE diff --git a/qdbm/misc/win32check.bat b/qdbm/misc/win32check.bat index 4d6aebf4..63dae180 100644 --- a/qdbm/misc/win32check.bat +++ b/qdbm/misc/win32check.bat @@ -1,111 +1,111 @@ -dptest write casket 50000 5000 -if errorlevel 1 goto error -dptest read casket -if errorlevel 1 goto error -dptest read -wb casket -if errorlevel 1 goto error -dptest rcat casket 50000 50 500 32 32 -if errorlevel 1 goto error -dptest combo casket -if errorlevel 1 goto error -dptest wicked casket 5000 -if errorlevel 1 goto error -del /Q casket - -crtest write casket 50000 500 10 -if errorlevel 1 goto error -crtest read casket -if errorlevel 1 goto error -crtest read -wb casket -if errorlevel 1 goto error -crtest rcat casket 50000 5 10 500 32 32 -if errorlevel 1 goto error -crtest combo casket -if errorlevel 1 goto error -crtest wicked casket 5000 -if errorlevel 1 goto error -rd /S /Q casket - -crtest write -lob casket 1000 50 10 -if errorlevel 1 goto error -crtest read -lob casket -if errorlevel 1 goto error -rd /S /Q casket - -rltest write casket 50000 -if errorlevel 1 goto error -rltest read casket 50000 -if errorlevel 1 goto error -del /Q casket* - -hvtest write casket 50000 -if errorlevel 1 goto error -hvtest read casket 50000 -if errorlevel 1 goto error -del /Q casket - -hvtest write -qdbm casket 50000 -if errorlevel 1 goto error -hvtest read -qdbm casket 50000 -if errorlevel 1 goto error -rd /S /Q casket - -cbtest sort 5000 -if errorlevel 1 goto error -cbtest strstr 500 -if errorlevel 1 goto error -cbtest list 50000 -if errorlevel 1 goto error -cbtest map 50000 -if errorlevel 1 goto error -cbtest wicked 5000 -if errorlevel 1 goto error -cbtest misc -if errorlevel 1 goto error - -vltest write -tune 25 64 32 32 casket 50000 -if errorlevel 1 goto error -vltest read casket -if errorlevel 1 goto error -vltest rdup -tune 25 64 256 256 casket 50000 50000 -if errorlevel 1 goto error -vltest combo casket -if errorlevel 1 goto error -vltest wicked casket 5000 -if errorlevel 1 goto error -del /Q casket - -vltest write -int -cz -tune 25 64 32 32 casket 50000 -if errorlevel 1 goto error -vltest read -int casket -if errorlevel 1 goto error -vltest rdup -int -cz -tune 25 64 256 256 casket 50000 50000 -if errorlevel 1 goto error -vltest combo -cz casket -if errorlevel 1 goto error -vltest wicked -cz casket 5000 -if errorlevel 1 goto error -del /Q casket - -odtest write casket 500 50 5000 -if errorlevel 1 goto error -odtest read casket -if errorlevel 1 goto error -odtest combo casket -if errorlevel 1 goto error -odtest wicked casket 500 -if errorlevel 1 goto error -rd /S /Q casket - -@echo off -echo #================================ -echo # SUCCESS -echo #================================ -goto :EOF - -:error -@echo off -echo #================================ -echo # ERROR -echo #================================ -goto :EOF +dptest write casket 50000 5000 +if errorlevel 1 goto error +dptest read casket +if errorlevel 1 goto error +dptest read -wb casket +if errorlevel 1 goto error +dptest rcat casket 50000 50 500 32 32 +if errorlevel 1 goto error +dptest combo casket +if errorlevel 1 goto error +dptest wicked casket 5000 +if errorlevel 1 goto error +del /Q casket + +crtest write casket 50000 500 10 +if errorlevel 1 goto error +crtest read casket +if errorlevel 1 goto error +crtest read -wb casket +if errorlevel 1 goto error +crtest rcat casket 50000 5 10 500 32 32 +if errorlevel 1 goto error +crtest combo casket +if errorlevel 1 goto error +crtest wicked casket 5000 +if errorlevel 1 goto error +rd /S /Q casket + +crtest write -lob casket 1000 50 10 +if errorlevel 1 goto error +crtest read -lob casket +if errorlevel 1 goto error +rd /S /Q casket + +rltest write casket 50000 +if errorlevel 1 goto error +rltest read casket 50000 +if errorlevel 1 goto error +del /Q casket* + +hvtest write casket 50000 +if errorlevel 1 goto error +hvtest read casket 50000 +if errorlevel 1 goto error +del /Q casket + +hvtest write -qdbm casket 50000 +if errorlevel 1 goto error +hvtest read -qdbm casket 50000 +if errorlevel 1 goto error +rd /S /Q casket + +cbtest sort 5000 +if errorlevel 1 goto error +cbtest strstr 500 +if errorlevel 1 goto error +cbtest list 50000 +if errorlevel 1 goto error +cbtest map 50000 +if errorlevel 1 goto error +cbtest wicked 5000 +if errorlevel 1 goto error +cbtest misc +if errorlevel 1 goto error + +vltest write -tune 25 64 32 32 casket 50000 +if errorlevel 1 goto error +vltest read casket +if errorlevel 1 goto error +vltest rdup -tune 25 64 256 256 casket 50000 50000 +if errorlevel 1 goto error +vltest combo casket +if errorlevel 1 goto error +vltest wicked casket 5000 +if errorlevel 1 goto error +del /Q casket + +vltest write -int -cz -tune 25 64 32 32 casket 50000 +if errorlevel 1 goto error +vltest read -int casket +if errorlevel 1 goto error +vltest rdup -int -cz -tune 25 64 256 256 casket 50000 50000 +if errorlevel 1 goto error +vltest combo -cz casket +if errorlevel 1 goto error +vltest wicked -cz casket 5000 +if errorlevel 1 goto error +del /Q casket + +odtest write casket 500 50 5000 +if errorlevel 1 goto error +odtest read casket +if errorlevel 1 goto error +odtest combo casket +if errorlevel 1 goto error +odtest wicked casket 500 +if errorlevel 1 goto error +rd /S /Q casket + +@echo off +echo #================================ +echo # SUCCESS +echo #================================ +goto :EOF + +:error +@echo off +echo #================================ +echo # ERROR +echo #================================ +goto :EOF diff --git a/qdbm/qdbm.def b/qdbm/qdbm.def index 6445b384..4c10e49e 100644 --- a/qdbm/qdbm.def +++ b/qdbm/qdbm.def @@ -1,424 +1,424 @@ -EXPORTS - VL_CMPDEC = VL_CMPDEC DATA - VL_CMPINT = VL_CMPINT DATA - VL_CMPLEX = VL_CMPLEX DATA - VL_CMPNUM = VL_CMPNUM DATA - VST_CMPDEC = VST_CMPDEC DATA - VST_CMPINT = VST_CMPINT DATA - VST_CMPLEX = VST_CMPLEX DATA - VST_CMPNUM = VST_CMPNUM DATA - cbfatalfunc = cbfatalfunc DATA - dpdbgfd = dpdbgfd DATA - dpisreentrant = dpisreentrant DATA - dpsysname = dpsysname DATA - dpversion = dpversion DATA - gdbm_version = gdbm_version DATA - odcachebnum = odcachebnum DATA - odcachesiz = odcachesiz DATA - odindexbnum = odindexbnum DATA - odindexdnum = odindexdnum DATA - odotcb = odotcb DATA - cbbasedecode = cbbasedecode - cbbaseencode = cbbaseencode - cbbzdecode = cbbzdecode - cbbzencode = cbbzencode - cbcalendar = cbcalendar - cbcsvcells = cbcsvcells - cbcsvescape = cbcsvescape - cbcsvrows = cbcsvrows - cbcsvunescape = cbcsvunescape - cbdatestrhttp = cbdatestrhttp - cbdatestrwww = cbdatestrwww - cbdatumcat = cbdatumcat - cbdatumclose = cbdatumclose - cbdatumdup = cbdatumdup - cbdatumopen = cbdatumopen - cbdatumopenbuf = cbdatumopenbuf - cbdatumprintf = cbdatumprintf - cbdatumptr = cbdatumptr - cbdatumsetbuf = cbdatumsetbuf - cbdatumsetsize = cbdatumsetsize - cbdatumsize = cbdatumsize - cbdatumtomalloc = cbdatumtomalloc - cbdayofweek = cbdayofweek - cbdeflate = cbdeflate - cbdirlist = cbdirlist - cbencname = cbencname - cbfilestat = cbfilestat - cbfree = cbfree - cbgetcrc = cbgetcrc - cbggcsweep = cbggcsweep - cbglobalgc = cbglobalgc - cbgzdecode = cbgzdecode - cbgzencode = cbgzencode - cbheapclose = cbheapclose - cbheapdup = cbheapdup - cbheapinsert = cbheapinsert - cbheapnum = cbheapnum - cbheapopen = cbheapopen - cbheaptomalloc = cbheaptomalloc - cbheapval = cbheapval - cbhsort = cbhsort - cbiconv = cbiconv - cbinflate = cbinflate - cbisort = cbisort - cbjetlag = cbjetlag - cblistbsearch = cblistbsearch - cblistclose = cblistclose - cblistdump = cblistdump - cblistdup = cblistdup - cblistinsert = cblistinsert - cblistload = cblistload - cblistlsearch = cblistlsearch - cblistnum = cblistnum - cblistopen = cblistopen - cblistover = cblistover - cblistpop = cblistpop - cblistpush = cblistpush - cblistpushbuf = cblistpushbuf - cblistremove = cblistremove - cblistshift = cblistshift - cblistsort = cblistsort - cblistunshift = cblistunshift - cblistval = cblistval - cblzodecode = cblzodecode - cblzoencode = cblzoencode - cbmalloc = cbmalloc - cbmapclose = cbmapclose - cbmapdump = cbmapdump - cbmapdup = cbmapdup - cbmapget = cbmapget - cbmapiterinit = cbmapiterinit - cbmapiternext = cbmapiternext - cbmapiterval = cbmapiterval - cbmapkeys = cbmapkeys - cbmapload = cbmapload - cbmaploadone = cbmaploadone - cbmapmove = cbmapmove - cbmapopen = cbmapopen - cbmapopenex = cbmapopenex - cbmapout = cbmapout - cbmapput = cbmapput - cbmapputcat = cbmapputcat - cbmaprnum = cbmaprnum - cbmapvals = cbmapvals - cbmemdup = cbmemdup - cbmimebreak = cbmimebreak - cbmimedecode = cbmimedecode - cbmimeencode = cbmimeencode - cbmimeparts = cbmimeparts - cbmyfatal = cbmyfatal - cbproctime = cbproctime - cbqsort = cbqsort - cbquotedecode = cbquotedecode - cbquoteencode = cbquoteencode - cbreadfile = cbreadfile - cbreadlines = cbreadlines - cbrealloc = cbrealloc - cbremove = cbremove - cbreplace = cbreplace - cbsplit = cbsplit - cbsprintf = cbsprintf - cbssort = cbssort - cbstdiobin = cbstdiobin - cbstrbwimatch = cbstrbwimatch - cbstrbwmatch = cbstrbwmatch - cbstrcountutf = cbstrcountutf - cbstrcututf = cbstrcututf - cbstrfwimatch = cbstrfwimatch - cbstrfwmatch = cbstrfwmatch - cbstricmp = cbstricmp - cbstrmktime = cbstrmktime - cbstrsqzspc = cbstrsqzspc - cbstrstrbm = cbstrstrbm - cbstrstrkmp = cbstrstrkmp - cbstrtolower = cbstrtolower - cbstrtoupper = cbstrtoupper - cbstrtrim = cbstrtrim - cburlbreak = cburlbreak - cburldecode = cburldecode - cburlencode = cburlencode - cburlresolve = cburlresolve - cbvmemavail = cbvmemavail - cbwritefile = cbwritefile - cbxmlattrs = cbxmlattrs - cbxmlbreak = cbxmlbreak - cbxmlescape = cbxmlescape - cbxmlunescape = cbxmlunescape - crbnum = crbnum - crbusenum = crbusenum - crclose = crclose - crexportdb = crexportdb - crfatalerror = crfatalerror - crfsiz = crfsiz - crfsizd = crfsizd - crget = crget - crgetflags = crgetflags - crgetlob = crgetlob - crgetlobfd = crgetlobfd - crgetwb = crgetwb - crimportdb = crimportdb - crinode = crinode - criterinit = criterinit - criternext = criternext - crmemflush = crmemflush - crmemsync = crmemsync - crmtime = crmtime - crname = crname - cropen = cropen - croptimize = croptimize - crout = crout - croutlob = croutlob - crput = crput - crputlob = crputlob - crremove = crremove - crrepair = crrepair - crrnum = crrnum - crrnumlob = crrnumlob - crsetalign = crsetalign - crsetfbpsiz = crsetfbpsiz - crsetflags = crsetflags - crsnaffle = crsnaffle - crsync = crsync - crvsiz = crvsiz - crvsizlob = crvsizlob - crwritable = crwritable - dbm_clearerr = dbm_clearerr - dbm_close = dbm_close - dbm_delete = dbm_delete - dbm_dirfno = dbm_dirfno - dbm_error = dbm_error - dbm_fetch = dbm_fetch - dbm_firstkey = dbm_firstkey - dbm_nextkey = dbm_nextkey - dbm_open = dbm_open - dbm_pagfno = dbm_pagfno - dbm_rdonly = dbm_rdonly - dbm_store = dbm_store - dpbnum = dpbnum - dpbusenum = dpbusenum - dpclose = dpclose - dpecodeptr = dpecodeptr - dpecodeset = dpecodeset - dperrmsg = dperrmsg - dpexportdb = dpexportdb - dpfatalerror = dpfatalerror - dpfdesc = dpfdesc - dpfsiz = dpfsiz - dpget = dpget - dpgetflags = dpgetflags - dpgetwb = dpgetwb - dpimportdb = dpimportdb - dpinnerhash = dpinnerhash - dpinode = dpinode - dpiterinit = dpiterinit - dpiternext = dpiternext - dpmemflush = dpmemflush - dpmemsync = dpmemsync - dpmtime = dpmtime - dpname = dpname - dpopen = dpopen - dpoptimize = dpoptimize - dpout = dpout - dpouterhash = dpouterhash - dpprimenum = dpprimenum - dpput = dpput - dpremove = dpremove - dprepair = dprepair - dprnum = dprnum - dpsetalign = dpsetalign - dpsetfbpsiz = dpsetfbpsiz - dpsetflags = dpsetflags - dpsnaffle = dpsnaffle - dpsync = dpsync - dpvsiz = dpvsiz - dpwritable = dpwritable - gdbm_close = gdbm_close - gdbm_delete = gdbm_delete - gdbm_errnoptr = gdbm_errnoptr - gdbm_exists = gdbm_exists - gdbm_fdesc = gdbm_fdesc - gdbm_fetch = gdbm_fetch - gdbm_firstkey = gdbm_firstkey - gdbm_nextkey = gdbm_nextkey - gdbm_open = gdbm_open - gdbm_open2 = gdbm_open2 - gdbm_reorganize = gdbm_reorganize - gdbm_setopt = gdbm_setopt - gdbm_store = gdbm_store - gdbm_strerror = gdbm_strerror - gdbm_sync = gdbm_sync - odanalyzetext = odanalyzetext - odbnum = odbnum - odbreaktext = odbreaktext - odbusenum = odbusenum - odcheck = odcheck - odclose = odclose - oddnum = oddnum - oddocaddattr = oddocaddattr - oddocaddword = oddocaddword - oddocawords = oddocawords - oddocclose = oddocclose - oddocgetattr = oddocgetattr - oddocid = oddocid - oddocnwords = oddocnwords - oddocopen = oddocopen - oddocscores = oddocscores - oddocuri = oddocuri - odfatalerror = odfatalerror - odfsiz = odfsiz - odget = odget - odgetbyid = odgetbyid - odgetidbyuri = odgetidbyuri - odidbdocs = odidbdocs - odidbindex = odidbindex - odidbrdocs = odidbrdocs - odinode = odinode - oditerinit = oditerinit - oditernext = oditernext - odlogarithm = odlogarithm - odmerge = odmerge - odmtime = odmtime - odname = odname - odnormalizeword = odnormalizeword - odopen = odopen - odoptimize = odoptimize - odout = odout - odoutbyid = odoutbyid - odpairsand = odpairsand - odpairsnotand = odpairsnotand - odpairsor = odpairsor - odpairssort = odpairssort - odput = odput - odquery = odquery - odremove = odremove - odsearch = odsearch - odsearchdnum = odsearchdnum - odsetcharclass = odsetcharclass - odsetotcb = odsetotcb - odsettuning = odsettuning - odsquareroot = odsquareroot - odsync = odsync - odvecabsolute = odvecabsolute - odvecinnerproduct = odvecinnerproduct - odvectorcosine = odvectorcosine - odwnum = odwnum - odwritable = odwritable - vlclose = vlclose - vlcrdnumptr = vlcrdnumptr - vlcurfirst = vlcurfirst - vlcurjump = vlcurjump - vlcurkey = vlcurkey - vlcurkeycache = vlcurkeycache - vlcurlast = vlcurlast - vlcurnext = vlcurnext - vlcurout = vlcurout - vlcurprev = vlcurprev - vlcurput = vlcurput - vlcurval = vlcurval - vlcurvalcache = vlcurvalcache - vlexportdb = vlexportdb - vlfatalerror = vlfatalerror - vlfsiz = vlfsiz - vlget = vlget - vlgetcache = vlgetcache - vlgetcat = vlgetcat - vlgetflags = vlgetflags - vlgetlist = vlgetlist - vlimportdb = vlimportdb - vlinode = vlinode - vllnum = vllnum - vlmemflush = vlmemflush - vlmemsync = vlmemsync - vlmtime = vlmtime - vlmulcurclose = vlmulcurclose - vlmulcurfirst = vlmulcurfirst - vlmulcurjump = vlmulcurjump - vlmulcurkey = vlmulcurkey - vlmulcurkeycache = vlmulcurkeycache - vlmulcurlast = vlmulcurlast - vlmulcurnext = vlmulcurnext - vlmulcuropen = vlmulcuropen - vlmulcurprev = vlmulcurprev - vlmulcurval = vlmulcurval - vlmulcurvalcache = vlmulcurvalcache - vlname = vlname - vlnnum = vlnnum - vlopen = vlopen - vloptimize = vloptimize - vlout = vlout - vloutlist = vloutlist - vlput = vlput - vlputlist = vlputlist - vlremove = vlremove - vlrepair = vlrepair - vlrnum = vlrnum - vlsetfbpsiz = vlsetfbpsiz - vlsetflags = vlsetflags - vlsettuning = vlsettuning - vlsync = vlsync - vltranabort = vltranabort - vltranbegin = vltranbegin - vltrancommit = vltrancommit - vlvnum = vlvnum - vlvsiz = vlvsiz - vlwritable = vlwritable - vstclose = vstclose - vstcrdnumptr = vstcrdnumptr - vstcurfirst = vstcurfirst - vstcurjump = vstcurjump - vstcurkey = vstcurkey - vstcurkeycache = vstcurkeycache - vstcurlast = vstcurlast - vstcurnext = vstcurnext - vstcurout = vstcurout - vstcurprev = vstcurprev - vstcurput = vstcurput - vstcurval = vstcurval - vstcurvalcache = vstcurvalcache - vstexportdb = vstexportdb - vstfatalerror = vstfatalerror - vstfsiz = vstfsiz - vstget = vstget - vstgetcache = vstgetcache - vstgetcat = vstgetcat - vstgetflags = vstgetflags - vstgetlist = vstgetlist - vstimportdb = vstimportdb - vstinode = vstinode - vstlnum = vstlnum - vstmemflush = vstmemflush - vstmemsync = vstmemsync - vstmtime = vstmtime - vstmulcurclose = vstmulcurclose - vstmulcurfirst = vstmulcurfirst - vstmulcurjump = vstmulcurjump - vstmulcurkey = vstmulcurkey - vstmulcurkeycache = vstmulcurkeycache - vstmulcurlast = vstmulcurlast - vstmulcurnext = vstmulcurnext - vstmulcuropen = vstmulcuropen - vstmulcurprev = vstmulcurprev - vstmulcurval = vstmulcurval - vstmulcurvalcache = vstmulcurvalcache - vstname = vstname - vstnnum = vstnnum - vstopen = vstopen - vstoptimize = vstoptimize - vstout = vstout - vstoutlist = vstoutlist - vstput = vstput - vstputlist = vstputlist - vstremove = vstremove - vstrepair = vstrepair - vstrnum = vstrnum - vstsetfbpsiz = vstsetfbpsiz - vstsetflags = vstsetflags - vstsettuning = vstsettuning - vstsync = vstsync - vsttranabort = vsttranabort - vsttranbegin = vsttranbegin - vsttrancommit = vsttrancommit - vstvnum = vstvnum - vstvsiz = vstvsiz - vstwritable = vstwritable +EXPORTS + VL_CMPDEC = VL_CMPDEC DATA + VL_CMPINT = VL_CMPINT DATA + VL_CMPLEX = VL_CMPLEX DATA + VL_CMPNUM = VL_CMPNUM DATA + VST_CMPDEC = VST_CMPDEC DATA + VST_CMPINT = VST_CMPINT DATA + VST_CMPLEX = VST_CMPLEX DATA + VST_CMPNUM = VST_CMPNUM DATA + cbfatalfunc = cbfatalfunc DATA + dpdbgfd = dpdbgfd DATA + dpisreentrant = dpisreentrant DATA + dpsysname = dpsysname DATA + dpversion = dpversion DATA + gdbm_version = gdbm_version DATA + odcachebnum = odcachebnum DATA + odcachesiz = odcachesiz DATA + odindexbnum = odindexbnum DATA + odindexdnum = odindexdnum DATA + odotcb = odotcb DATA + cbbasedecode = cbbasedecode + cbbaseencode = cbbaseencode + cbbzdecode = cbbzdecode + cbbzencode = cbbzencode + cbcalendar = cbcalendar + cbcsvcells = cbcsvcells + cbcsvescape = cbcsvescape + cbcsvrows = cbcsvrows + cbcsvunescape = cbcsvunescape + cbdatestrhttp = cbdatestrhttp + cbdatestrwww = cbdatestrwww + cbdatumcat = cbdatumcat + cbdatumclose = cbdatumclose + cbdatumdup = cbdatumdup + cbdatumopen = cbdatumopen + cbdatumopenbuf = cbdatumopenbuf + cbdatumprintf = cbdatumprintf + cbdatumptr = cbdatumptr + cbdatumsetbuf = cbdatumsetbuf + cbdatumsetsize = cbdatumsetsize + cbdatumsize = cbdatumsize + cbdatumtomalloc = cbdatumtomalloc + cbdayofweek = cbdayofweek + cbdeflate = cbdeflate + cbdirlist = cbdirlist + cbencname = cbencname + cbfilestat = cbfilestat + cbfree = cbfree + cbgetcrc = cbgetcrc + cbggcsweep = cbggcsweep + cbglobalgc = cbglobalgc + cbgzdecode = cbgzdecode + cbgzencode = cbgzencode + cbheapclose = cbheapclose + cbheapdup = cbheapdup + cbheapinsert = cbheapinsert + cbheapnum = cbheapnum + cbheapopen = cbheapopen + cbheaptomalloc = cbheaptomalloc + cbheapval = cbheapval + cbhsort = cbhsort + cbiconv = cbiconv + cbinflate = cbinflate + cbisort = cbisort + cbjetlag = cbjetlag + cblistbsearch = cblistbsearch + cblistclose = cblistclose + cblistdump = cblistdump + cblistdup = cblistdup + cblistinsert = cblistinsert + cblistload = cblistload + cblistlsearch = cblistlsearch + cblistnum = cblistnum + cblistopen = cblistopen + cblistover = cblistover + cblistpop = cblistpop + cblistpush = cblistpush + cblistpushbuf = cblistpushbuf + cblistremove = cblistremove + cblistshift = cblistshift + cblistsort = cblistsort + cblistunshift = cblistunshift + cblistval = cblistval + cblzodecode = cblzodecode + cblzoencode = cblzoencode + cbmalloc = cbmalloc + cbmapclose = cbmapclose + cbmapdump = cbmapdump + cbmapdup = cbmapdup + cbmapget = cbmapget + cbmapiterinit = cbmapiterinit + cbmapiternext = cbmapiternext + cbmapiterval = cbmapiterval + cbmapkeys = cbmapkeys + cbmapload = cbmapload + cbmaploadone = cbmaploadone + cbmapmove = cbmapmove + cbmapopen = cbmapopen + cbmapopenex = cbmapopenex + cbmapout = cbmapout + cbmapput = cbmapput + cbmapputcat = cbmapputcat + cbmaprnum = cbmaprnum + cbmapvals = cbmapvals + cbmemdup = cbmemdup + cbmimebreak = cbmimebreak + cbmimedecode = cbmimedecode + cbmimeencode = cbmimeencode + cbmimeparts = cbmimeparts + cbmyfatal = cbmyfatal + cbproctime = cbproctime + cbqsort = cbqsort + cbquotedecode = cbquotedecode + cbquoteencode = cbquoteencode + cbreadfile = cbreadfile + cbreadlines = cbreadlines + cbrealloc = cbrealloc + cbremove = cbremove + cbreplace = cbreplace + cbsplit = cbsplit + cbsprintf = cbsprintf + cbssort = cbssort + cbstdiobin = cbstdiobin + cbstrbwimatch = cbstrbwimatch + cbstrbwmatch = cbstrbwmatch + cbstrcountutf = cbstrcountutf + cbstrcututf = cbstrcututf + cbstrfwimatch = cbstrfwimatch + cbstrfwmatch = cbstrfwmatch + cbstricmp = cbstricmp + cbstrmktime = cbstrmktime + cbstrsqzspc = cbstrsqzspc + cbstrstrbm = cbstrstrbm + cbstrstrkmp = cbstrstrkmp + cbstrtolower = cbstrtolower + cbstrtoupper = cbstrtoupper + cbstrtrim = cbstrtrim + cburlbreak = cburlbreak + cburldecode = cburldecode + cburlencode = cburlencode + cburlresolve = cburlresolve + cbvmemavail = cbvmemavail + cbwritefile = cbwritefile + cbxmlattrs = cbxmlattrs + cbxmlbreak = cbxmlbreak + cbxmlescape = cbxmlescape + cbxmlunescape = cbxmlunescape + crbnum = crbnum + crbusenum = crbusenum + crclose = crclose + crexportdb = crexportdb + crfatalerror = crfatalerror + crfsiz = crfsiz + crfsizd = crfsizd + crget = crget + crgetflags = crgetflags + crgetlob = crgetlob + crgetlobfd = crgetlobfd + crgetwb = crgetwb + crimportdb = crimportdb + crinode = crinode + criterinit = criterinit + criternext = criternext + crmemflush = crmemflush + crmemsync = crmemsync + crmtime = crmtime + crname = crname + cropen = cropen + croptimize = croptimize + crout = crout + croutlob = croutlob + crput = crput + crputlob = crputlob + crremove = crremove + crrepair = crrepair + crrnum = crrnum + crrnumlob = crrnumlob + crsetalign = crsetalign + crsetfbpsiz = crsetfbpsiz + crsetflags = crsetflags + crsnaffle = crsnaffle + crsync = crsync + crvsiz = crvsiz + crvsizlob = crvsizlob + crwritable = crwritable + dbm_clearerr = dbm_clearerr + dbm_close = dbm_close + dbm_delete = dbm_delete + dbm_dirfno = dbm_dirfno + dbm_error = dbm_error + dbm_fetch = dbm_fetch + dbm_firstkey = dbm_firstkey + dbm_nextkey = dbm_nextkey + dbm_open = dbm_open + dbm_pagfno = dbm_pagfno + dbm_rdonly = dbm_rdonly + dbm_store = dbm_store + dpbnum = dpbnum + dpbusenum = dpbusenum + dpclose = dpclose + dpecodeptr = dpecodeptr + dpecodeset = dpecodeset + dperrmsg = dperrmsg + dpexportdb = dpexportdb + dpfatalerror = dpfatalerror + dpfdesc = dpfdesc + dpfsiz = dpfsiz + dpget = dpget + dpgetflags = dpgetflags + dpgetwb = dpgetwb + dpimportdb = dpimportdb + dpinnerhash = dpinnerhash + dpinode = dpinode + dpiterinit = dpiterinit + dpiternext = dpiternext + dpmemflush = dpmemflush + dpmemsync = dpmemsync + dpmtime = dpmtime + dpname = dpname + dpopen = dpopen + dpoptimize = dpoptimize + dpout = dpout + dpouterhash = dpouterhash + dpprimenum = dpprimenum + dpput = dpput + dpremove = dpremove + dprepair = dprepair + dprnum = dprnum + dpsetalign = dpsetalign + dpsetfbpsiz = dpsetfbpsiz + dpsetflags = dpsetflags + dpsnaffle = dpsnaffle + dpsync = dpsync + dpvsiz = dpvsiz + dpwritable = dpwritable + gdbm_close = gdbm_close + gdbm_delete = gdbm_delete + gdbm_errnoptr = gdbm_errnoptr + gdbm_exists = gdbm_exists + gdbm_fdesc = gdbm_fdesc + gdbm_fetch = gdbm_fetch + gdbm_firstkey = gdbm_firstkey + gdbm_nextkey = gdbm_nextkey + gdbm_open = gdbm_open + gdbm_open2 = gdbm_open2 + gdbm_reorganize = gdbm_reorganize + gdbm_setopt = gdbm_setopt + gdbm_store = gdbm_store + gdbm_strerror = gdbm_strerror + gdbm_sync = gdbm_sync + odanalyzetext = odanalyzetext + odbnum = odbnum + odbreaktext = odbreaktext + odbusenum = odbusenum + odcheck = odcheck + odclose = odclose + oddnum = oddnum + oddocaddattr = oddocaddattr + oddocaddword = oddocaddword + oddocawords = oddocawords + oddocclose = oddocclose + oddocgetattr = oddocgetattr + oddocid = oddocid + oddocnwords = oddocnwords + oddocopen = oddocopen + oddocscores = oddocscores + oddocuri = oddocuri + odfatalerror = odfatalerror + odfsiz = odfsiz + odget = odget + odgetbyid = odgetbyid + odgetidbyuri = odgetidbyuri + odidbdocs = odidbdocs + odidbindex = odidbindex + odidbrdocs = odidbrdocs + odinode = odinode + oditerinit = oditerinit + oditernext = oditernext + odlogarithm = odlogarithm + odmerge = odmerge + odmtime = odmtime + odname = odname + odnormalizeword = odnormalizeword + odopen = odopen + odoptimize = odoptimize + odout = odout + odoutbyid = odoutbyid + odpairsand = odpairsand + odpairsnotand = odpairsnotand + odpairsor = odpairsor + odpairssort = odpairssort + odput = odput + odquery = odquery + odremove = odremove + odsearch = odsearch + odsearchdnum = odsearchdnum + odsetcharclass = odsetcharclass + odsetotcb = odsetotcb + odsettuning = odsettuning + odsquareroot = odsquareroot + odsync = odsync + odvecabsolute = odvecabsolute + odvecinnerproduct = odvecinnerproduct + odvectorcosine = odvectorcosine + odwnum = odwnum + odwritable = odwritable + vlclose = vlclose + vlcrdnumptr = vlcrdnumptr + vlcurfirst = vlcurfirst + vlcurjump = vlcurjump + vlcurkey = vlcurkey + vlcurkeycache = vlcurkeycache + vlcurlast = vlcurlast + vlcurnext = vlcurnext + vlcurout = vlcurout + vlcurprev = vlcurprev + vlcurput = vlcurput + vlcurval = vlcurval + vlcurvalcache = vlcurvalcache + vlexportdb = vlexportdb + vlfatalerror = vlfatalerror + vlfsiz = vlfsiz + vlget = vlget + vlgetcache = vlgetcache + vlgetcat = vlgetcat + vlgetflags = vlgetflags + vlgetlist = vlgetlist + vlimportdb = vlimportdb + vlinode = vlinode + vllnum = vllnum + vlmemflush = vlmemflush + vlmemsync = vlmemsync + vlmtime = vlmtime + vlmulcurclose = vlmulcurclose + vlmulcurfirst = vlmulcurfirst + vlmulcurjump = vlmulcurjump + vlmulcurkey = vlmulcurkey + vlmulcurkeycache = vlmulcurkeycache + vlmulcurlast = vlmulcurlast + vlmulcurnext = vlmulcurnext + vlmulcuropen = vlmulcuropen + vlmulcurprev = vlmulcurprev + vlmulcurval = vlmulcurval + vlmulcurvalcache = vlmulcurvalcache + vlname = vlname + vlnnum = vlnnum + vlopen = vlopen + vloptimize = vloptimize + vlout = vlout + vloutlist = vloutlist + vlput = vlput + vlputlist = vlputlist + vlremove = vlremove + vlrepair = vlrepair + vlrnum = vlrnum + vlsetfbpsiz = vlsetfbpsiz + vlsetflags = vlsetflags + vlsettuning = vlsettuning + vlsync = vlsync + vltranabort = vltranabort + vltranbegin = vltranbegin + vltrancommit = vltrancommit + vlvnum = vlvnum + vlvsiz = vlvsiz + vlwritable = vlwritable + vstclose = vstclose + vstcrdnumptr = vstcrdnumptr + vstcurfirst = vstcurfirst + vstcurjump = vstcurjump + vstcurkey = vstcurkey + vstcurkeycache = vstcurkeycache + vstcurlast = vstcurlast + vstcurnext = vstcurnext + vstcurout = vstcurout + vstcurprev = vstcurprev + vstcurput = vstcurput + vstcurval = vstcurval + vstcurvalcache = vstcurvalcache + vstexportdb = vstexportdb + vstfatalerror = vstfatalerror + vstfsiz = vstfsiz + vstget = vstget + vstgetcache = vstgetcache + vstgetcat = vstgetcat + vstgetflags = vstgetflags + vstgetlist = vstgetlist + vstimportdb = vstimportdb + vstinode = vstinode + vstlnum = vstlnum + vstmemflush = vstmemflush + vstmemsync = vstmemsync + vstmtime = vstmtime + vstmulcurclose = vstmulcurclose + vstmulcurfirst = vstmulcurfirst + vstmulcurjump = vstmulcurjump + vstmulcurkey = vstmulcurkey + vstmulcurkeycache = vstmulcurkeycache + vstmulcurlast = vstmulcurlast + vstmulcurnext = vstmulcurnext + vstmulcuropen = vstmulcuropen + vstmulcurprev = vstmulcurprev + vstmulcurval = vstmulcurval + vstmulcurvalcache = vstmulcurvalcache + vstname = vstname + vstnnum = vstnnum + vstopen = vstopen + vstoptimize = vstoptimize + vstout = vstout + vstoutlist = vstoutlist + vstput = vstput + vstputlist = vstputlist + vstremove = vstremove + vstrepair = vstrepair + vstrnum = vstrnum + vstsetfbpsiz = vstsetfbpsiz + vstsetflags = vstsetflags + vstsettuning = vstsettuning + vstsync = vstsync + vsttranabort = vsttranabort + vsttranbegin = vsttranbegin + vsttrancommit = vsttrancommit + vstvnum = vstvnum + vstvsiz = vstvsiz + vstwritable = vstwritable diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 891d1461..3330bf67 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -139,7 +139,7 @@ static const char *uploads_filenames[] = {"49587fds", "cvhjhj324", "sdfcscs324", #define UPLOAD_FILE_TO_MOVE 8 #define UNLINK_IF_EXISTS(filename) \ - if (FileExists(filename)) { TEST_THAT(unlink(filename) == 0); } + if (FileExists(filename)) { TEST_THAT(EMU_UNLINK(filename) == 0); } //! Simplifies calling setUp() with the current function name in each test. #define SETUP_TEST_BACKUPSTORE() \ @@ -496,7 +496,7 @@ void test_test_file(int t, IOStream &rStream) free(data); in.Close(); - TEST_THAT(unlink("testfiles/test_download") == 0); + TEST_THAT(EMU_UNLINK("testfiles/test_download") == 0); } void assert_everything_deleted(BackupProtocolCallable &protocol, int64_t DirID) @@ -2665,7 +2665,7 @@ bool test_login_with_no_refcount_db() // Delete the refcount database and try to log in again. Check that // we're locked out of the account until housekeeping has recreated // the refcount db. - TEST_EQUAL(0, ::unlink("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); + TEST_EQUAL(0, EMU_UNLINK("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); TEST_CHECK_THROWS(BackupProtocolLocal2 protocolLocal(0x01234567, "test", "backup/01234567/", 0, false), // Not read-only BackupStoreException, CorruptReferenceCountDatabase); @@ -2690,7 +2690,7 @@ bool test_login_with_no_refcount_db() // because housekeeping may fix the refcount database while we're // stepping through. TEST_THAT_THROWONFAIL(StartServer()); - TEST_EQUAL(0, ::unlink("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); + TEST_EQUAL(0, EMU_UNLINK("testfiles/0_0/backup/01234567/refcount.rdb.rfw")); TEST_CHECK_THROWS(connect_and_login(context), ConnectionException, Protocol_UnexpectedReply); diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp index ac1d0c14..79fd68e1 100644 --- a/test/backupstorefix/testbackupstorefix.cpp +++ b/test/backupstorefix/testbackupstorefix.cpp @@ -1013,7 +1013,7 @@ int test(int argc, const char *argv[]) TEST_THAT(KillServer(bbstored_pid)); #ifdef WIN32 - TEST_THAT(unlink("testfiles/bbstored.pid") == 0); + TEST_THAT(EMU_UNLINK("testfiles/bbstored.pid") == 0); #else TestRemoteProcessMemLeaks("bbstored.memleaks"); #endif diff --git a/test/backupstorepatch/testbackupstorepatch.cpp b/test/backupstorepatch/testbackupstorepatch.cpp index 46f278ad..c26788dc 100644 --- a/test/backupstorepatch/testbackupstorepatch.cpp +++ b/test/backupstorepatch/testbackupstorepatch.cpp @@ -559,7 +559,7 @@ int test(int argc, const char *argv[]) char filename[64], filename_fetched[64]; ::sprintf(filename, "testfiles/%d.test", f); ::sprintf(filename_fetched, "testfiles/%d.test.fetched", f); - ::unlink(filename_fetched); + EMU_UNLINK(filename_fetched); // Fetch the file { diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp index 9285dfc9..b940b30f 100644 --- a/test/basicserver/testbasicserver.cpp +++ b/test/basicserver/testbasicserver.cpp @@ -663,7 +663,7 @@ int test(int argc, const char *argv[]) // Move the config file over #ifdef WIN32 - TEST_THAT(::unlink("testfiles" + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "srv1.conf") != -1); #endif diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index deff53e2..b2264b14 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -1272,6 +1272,13 @@ bool test_getobject_on_nonexistent_file() TEARDOWN_TEST_BBACKUPD(); } +void run_bbackupd_sync_with_logging(BackupDaemon& bbackupd) +{ + Logging::Tagger bbackupd_tagger("bbackupd", true); // replace + Logging::ShowTagOnConsole temp_enable_tags; + bbackupd.RunSyncNow(); +} + // ASSERT((mpBlockIndex == 0) || (NumBlocksInIndex != 0)) in // BackupStoreFileEncodeStream::Recipe::Recipe once failed, apparently because // a zero byte file had a block index but no entries in it. But this test @@ -1556,30 +1563,31 @@ bool test_backup_hardlinked_files() { SETUP_WITH_BBSTORED(); + run_bbackupd_sync_with_logging(bbackupd); bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); // Create some hard links. First in the same directory: - TEST_THAT(link("testfiles/TestDir1/x1/dsfdsfs98.fd", + TEST_THAT(EMU_LINK("testfiles/TestDir1/x1/dsfdsfs98.fd", "testfiles/TestDir1/x1/hardlink1") == 0); - bbackupd.RunSyncNow(); + run_bbackupd_sync_with_logging(bbackupd); TEST_COMPARE(Compare_Same); - // Now in a different directory + BOX_NOTICE("Creating a hard-linked file in a different directory (x2/hardlink2)"); TEST_THAT(mkdir("testfiles/TestDir1/x2", 0755) == 0); - TEST_THAT(link("testfiles/TestDir1/x1/dsfdsfs98.fd", + TEST_THAT(EMU_LINK("testfiles/TestDir1/x1/dsfdsfs98.fd", "testfiles/TestDir1/x2/hardlink2") == 0); - bbackupd.RunSyncNow(); + run_bbackupd_sync_with_logging(bbackupd); TEST_COMPARE(Compare_Same); // Now delete one of them - TEST_THAT(unlink("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); // And another. - TEST_THAT(unlink("testfiles/TestDir1/x1/hardlink1") == 0); - bbackupd.RunSyncNow(); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/hardlink1") == 0); + run_bbackupd_sync_with_logging(bbackupd); TEST_COMPARE(Compare_Same); TEARDOWN_TEST_BBACKUPD(); @@ -1618,7 +1626,7 @@ bool test_backup_pauses_when_store_is_full() unpack_files("spacetest2", "testfiles/TestDir1"); // Delete a file and a directory - TEST_THAT(::unlink("testfiles/TestDir1/spacetest/f1") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/spacetest/f1") == 0); #ifdef WIN32 TEST_THAT(::system("rd /s/q testfiles\\TestDir1\\spacetest\\d7") == 0); #else @@ -1733,7 +1741,7 @@ bool test_bbackupd_exclusions() TEST_THAT(unpack_files("spacetest1", "testfiles/TestDir1")); // Delete a file and a directory - TEST_THAT(::unlink("testfiles/TestDir1/spacetest/f1") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/spacetest/f1") == 0); #ifdef WIN32 TEST_THAT(::system("rd /s/q testfiles\\TestDir1\\spacetest\\d7") == 0); @@ -2520,7 +2528,7 @@ bool test_unicode_filenames_can_be_backed_up() std::string fileToUnlink = "testfiles/restore-" + dirname + "/" + filename; - TEST_THAT(::unlink(fileToUnlink.c_str()) == 0); + TEST_THAT(EMU_UNLINK(fileToUnlink.c_str()) == 0); // Check that bbackupquery can get the file when given // on the command line in system encoding. @@ -2536,7 +2544,7 @@ bool test_unicode_filenames_can_be_backed_up() // cannot overwrite a file that exists, so delete it std::string tmp = "testfiles/" + filename; - TEST_THAT(::unlink(tmp.c_str()) == 0); + TEST_THAT(EMU_UNLINK(tmp.c_str()) == 0); // And after changing directory to an absolute path TEST_THAT(bbackupquery( @@ -2632,7 +2640,7 @@ bool test_sync_allow_script_can_pause_backup() // check that no backup has run (compare fails) TEST_COMPARE(Compare_Different); - TEST_THAT(unlink(sync_control_file) == 0); + TEST_THAT(EMU_UNLINK(sync_control_file) == 0); wait_for_sync_start(); long end_time = time(NULL); long wait_time = end_time - start_time + 2; @@ -2670,7 +2678,7 @@ bool test_delete_update_and_symlink_files() // TODO FIXME dedent { // Delete a file - TEST_THAT(::unlink("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); #ifndef WIN32 // New symlink @@ -2825,7 +2833,7 @@ bool test_store_error_reporting() // Check that it did get uploaded, and we have no more errors TEST_COMPARE(Compare_Same); - TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); + TEST_THAT(EMU_UNLINK("testfiles/notifyscript.tag") == 0); // Stop the snapshot bbackupd TEST_THAT(StopClient()); @@ -2900,7 +2908,7 @@ bool test_store_error_reporting() // Check that it did get uploaded, and we have no more errors TEST_COMPARE(Compare_Same); - TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); + TEST_THAT(EMU_UNLINK("testfiles/notifyscript.tag") == 0); } TEARDOWN_TEST_BBACKUPD(); @@ -2924,7 +2932,7 @@ bool test_change_file_to_symlink_and_back() // Replace symlink with directory, add new directory. #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/symlink-to-dir") + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/symlink-to-dir") == 0); #endif @@ -2949,7 +2957,7 @@ bool test_change_file_to_symlink_and_back() // And the inverse, replace a directory with a file/symlink #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/x1/dir-to-file" + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dir-to-file" "/contents") == 0); #endif @@ -2968,7 +2976,7 @@ bool test_change_file_to_symlink_and_back() BOX_INFO("Replace symlink with directory (which was a symlink)"); #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/x1" + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1" "/dir-to-file") == 0); #endif @@ -2991,7 +2999,7 @@ bool test_change_file_to_symlink_and_back() // directories over other old directories. #ifndef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/x1/dir-to-file" + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dir-to-file" "/contents2") == 0); #endif @@ -3039,7 +3047,7 @@ bool test_file_rename_tracking() TEST_COMPARE(Compare_Same); #ifdef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/untracked-2") + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/untracked-2") == 0); #endif @@ -3077,7 +3085,7 @@ bool test_file_rename_tracking() TEST_COMPARE(Compare_Same); #ifdef WIN32 - TEST_THAT(::unlink("testfiles/TestDir1/tracked-2") + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/tracked-2") == 0); #endif @@ -3092,7 +3100,7 @@ bool test_file_rename_tracking() // case which went wrong: rename a tracked file // over a deleted file BOX_INFO("Rename an existing file over a deleted file"); - TEST_THAT(::unlink("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); TEST_THAT(::rename("testfiles/TestDir1/df9834.dsf", "testfiles/TestDir1/x1/dsfdsfs98.fd") == 0); @@ -3872,7 +3880,7 @@ bool test_restore_deleted_files() bbackupd.RunSyncNow(); TEST_COMPARE(Compare_Same); - TEST_THAT(::unlink("testfiles/TestDir1/f1.dat") == 0); + TEST_THAT(EMU_UNLINK("testfiles/TestDir1/f1.dat") == 0); #ifdef WIN32 TEST_THAT(::system("rd /s/q testfiles\\TestDir1\\x1") == 0); #else diff --git a/test/httpserver/testhttpserver.cpp b/test/httpserver/testhttpserver.cpp index 469fa383..a28d387d 100644 --- a/test/httpserver/testhttpserver.cpp +++ b/test/httpserver/testhttpserver.cpp @@ -377,7 +377,7 @@ int test(int argc, const char *argv[]) FileStream f1("testfiles/testrequests.pl"); FileStream f2("testfiles/newfile"); TEST_THAT(f1.CompareWith(f2)); - TEST_EQUAL(0, ::unlink("testfiles/newfile")); + TEST_EQUAL(0, EMU_UNLINK("testfiles/newfile")); } // Start the S3Simulator server @@ -458,8 +458,7 @@ int test(int argc, const char *argv[]) SocketStream sock; sock.Open(Socket::TypeINET, "localhost", 1080); - HTTPRequest request(HTTPRequest::Method_PUT, - "/newfile"); + HTTPRequest request(HTTPRequest::Method_PUT, "/newfile"); request.SetHostName("quotes.s3.amazonaws.com"); request.AddHeader("Date", "Wed, 01 Mar 2006 12:00:00 GMT"); request.AddHeader("Authorization", "AWS 0PN5J17HBGZHT7JJ3X82:kfY1m6V3zTufRy2kj92FpQGKz4M="); @@ -481,9 +480,9 @@ int test(int argc, const char *argv[]) FileStream f1("testfiles/testrequests.pl"); FileStream f2("testfiles/newfile"); TEST_THAT(f1.CompareWith(f2)); + TEST_THAT(EMU_UNLINK("testfiles/newfile") == 0); } - // Kill it TEST_THAT(StopDaemon(pid, "testfiles/s3simulator.pid", "s3simulator.memleaks", true)); diff --git a/test/raidfile/testraidfile.cpp b/test/raidfile/testraidfile.cpp index 2314d376..06580204 100644 --- a/test/raidfile/testraidfile.cpp +++ b/test/raidfile/testraidfile.cpp @@ -822,7 +822,7 @@ int test(int argc, const char *argv[]) TEST_THAT(::rename("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf-NT", "testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf") == 0); // Delete one of the files - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "damage.rf") == 0); // stripe 1 + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "damage.rf") == 0); // stripe 1 #ifdef TRF_CAN_INTERCEPT // Open it and read... @@ -839,7 +839,7 @@ int test(int argc, const char *argv[]) #endif //TRF_CAN_INTERCEPT // Delete another - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf") == 0); // parity + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "damage.rf") == 0); // parity TEST_CHECK_THROWS( std::auto_ptr pread2 = RaidFileRead::Open(0, "damage"), @@ -881,15 +881,15 @@ int test(int argc, const char *argv[]) TEST_THAT(true == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_DirsOnly, names)); TEST_THAT(list_matches(names, dir_list1)); // Delete things - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_0" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); TEST_THAT(true == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_FilesOnly, names)); TEST_THAT(list_matches(names, file_list1)); // Delete something else so that it's not recoverable - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_1" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); TEST_THAT(false == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_FilesOnly, names)); TEST_THAT(list_matches(names, file_list1)); // And finally... - TEST_THAT(::unlink("testfiles" DIRECTORY_SEPARATOR "0_2" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); + TEST_THAT(EMU_UNLINK("testfiles" DIRECTORY_SEPARATOR "0_2" DIRECTORY_SEPARATOR "dirread" DIRECTORY_SEPARATOR "sdf9873241.rf") == 0); TEST_THAT(true == RaidFileRead::ReadDirectoryContents(0, std::string("dirread"), RaidFileRead::DirReadType_FilesOnly, names)); TEST_THAT(list_matches(names, file_list2)); } -- cgit v1.2.3