summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ebourne <martin@ebourne.me.uk>2005-12-07 16:34:47 +0000
committerMartin Ebourne <martin@ebourne.me.uk>2005-12-07 16:34:47 +0000
commit81d8eda2419e7a23088a98cdfc52a305c9ceac0d (patch)
tree27143d7b539a8bf2e23cc18e2f598804fa8d784d
parent065dc6f8cd168e3ee6e71ddfb06f42a92abfabbd (diff)
Merged martin/autoconf at r35 to trunk
-rwxr-xr-xbin/bbackupd/BackupClientDirectoryRecord.cpp8
-rwxr-xr-xbin/bbackupd/BackupClientInodeToIDMap.cpp8
-rwxr-xr-xbin/bbackupd/BackupClientInodeToIDMap.h2
-rwxr-xr-xbin/bbackupd/BackupDaemon.cpp94
-rwxr-xr-xbin/bbackupquery/BackupQueries.cpp4
-rwxr-xr-xbin/bbackupquery/bbackupquery.cpp26
-rwxr-xr-xbootstrap5
-rwxr-xr-xconfigure15
-rw-r--r--configure.ac198
-rw-r--r--infrastructure/BoxPlatform.pm.in (renamed from infrastructure/BoxPlatform.pm)28
-rw-r--r--infrastructure/m4/ac_cxx_exceptions.m424
-rw-r--r--infrastructure/m4/ac_cxx_namespaces.m425
-rw-r--r--infrastructure/m4/ax_check_bdb_v1.m443
-rw-r--r--infrastructure/m4/ax_check_define_pragma.m425
-rw-r--r--infrastructure/m4/ax_check_dirent_d_type.m441
-rw-r--r--infrastructure/m4/ax_check_llong_minmax.m476
-rw-r--r--infrastructure/m4/ax_check_malloc_workaround.m438
-rw-r--r--infrastructure/m4/ax_check_mount_point.m441
-rw-r--r--infrastructure/m4/ax_check_nonaligned_access.m457
-rw-r--r--infrastructure/m4/ax_check_ssl.m437
-rw-r--r--infrastructure/m4/ax_check_syscall_lseek.m454
-rw-r--r--infrastructure/m4/ax_func_syscall.m439
-rw-r--r--infrastructure/m4/ax_random_device.m431
-rw-r--r--infrastructure/m4/vl_lib_readline.m4106
-rwxr-xr-xinfrastructure/makebuildenv.pl364
-rwxr-xr-xlib/backupclient/BackupClientCryptoKeys.cpp2
-rwxr-xr-xlib/backupclient/BackupClientFileAttributes.cpp20
-rwxr-xr-xlib/backupclient/BackupStoreDirectory.cpp40
-rwxr-xr-xlib/backupclient/BackupStoreFile.cpp36
-rwxr-xr-xlib/backupclient/BackupStoreFile.h2
-rw-r--r--lib/backupclient/BackupStoreFileCmbDiff.cpp16
-rw-r--r--lib/backupclient/BackupStoreFileCmbIdx.cpp10
-rwxr-xr-xlib/backupclient/BackupStoreFileCombine.cpp20
-rwxr-xr-xlib/backupclient/BackupStoreFileCryptVar.cpp2
-rwxr-xr-xlib/backupclient/BackupStoreFileCryptVar.h2
-rwxr-xr-xlib/backupclient/BackupStoreFileDiff.cpp12
-rwxr-xr-xlib/backupclient/BackupStoreFileEncodeStream.cpp22
-rw-r--r--lib/backupclient/BackupStoreFileRevDiff.cpp14
-rwxr-xr-xlib/backupclient/BackupStoreFileWire.h4
-rwxr-xr-xlib/backupclient/BackupStoreFilename.h2
-rw-r--r--lib/backupclient/BackupStoreObjectDump.cpp12
-rw-r--r--lib/backupstore/BackupStoreCheck2.cpp2
-rwxr-xr-xlib/backupstore/BackupStoreInfo.cpp50
-rw-r--r--lib/common/BeginStructPackForWire.h2
-rwxr-xr-xlib/common/Box.h63
-rwxr-xr-xlib/common/BoxPlatform.h286
-rw-r--r--lib/common/EndStructPackForWire.h2
-rw-r--r--lib/common/EventWatchFilesystemObject.cpp6
-rw-r--r--lib/common/EventWatchFilesystemObject.h4
-rwxr-xr-xlib/common/ExcludeList.cpp8
-rwxr-xr-xlib/common/ExcludeList.h4
-rwxr-xr-xlib/common/FileModificationTime.h6
-rwxr-xr-xlib/common/LinuxWorkaround.cpp73
-rwxr-xr-xlib/common/LinuxWorkaround.h20
-rwxr-xr-xlib/common/NamedLock.cpp42
-rwxr-xr-xlib/common/TemporaryDirectory.h4
-rw-r--r--lib/common/WaitForEvent.cpp8
-rw-r--r--lib/common/WaitForEvent.h10
-rw-r--r--lib/crypto/CipherAES.cpp4
-rw-r--r--lib/crypto/CipherAES.h4
-rwxr-xr-xlib/crypto/CipherBlowfish.cpp16
-rwxr-xr-xlib/crypto/CipherBlowfish.h6
-rwxr-xr-xlib/crypto/CipherContext.cpp24
-rwxr-xr-xlib/crypto/CipherContext.h4
-rwxr-xr-xlib/crypto/CipherDescription.h2
-rwxr-xr-xlib/crypto/Random.cpp4
-rwxr-xr-xlib/raidfile/RaidFileRead.cpp26
-rwxr-xr-xlib/raidfile/RaidFileUtil.cpp8
-rwxr-xr-xlib/raidfile/RaidFileWrite.cpp22
-rwxr-xr-xlib/server/Daemon.cpp4
-rwxr-xr-xlib/server/Protocol.cpp12
-rwxr-xr-xlib/server/ProtocolWire.h4
-rwxr-xr-xlib/server/SSLLib.cpp4
-rwxr-xr-xlib/server/Socket.cpp4
-rwxr-xr-xlib/server/SocketListen.h4
-rwxr-xr-xlib/server/SocketStream.cpp8
-rwxr-xr-xmodules.txt10
-rwxr-xr-xtest/backupdiff/testbackupdiff.cpp8
-rw-r--r--test/backupstorefix/testbackupstorefix.cpp10
-rwxr-xr-xtest/common/testcommon.cpp6
-rwxr-xr-xtest/crypto/testcrypto.cpp2
-rwxr-xr-xtest/raidfile/intercept.cpp53
-rwxr-xr-xtest/raidfile/testraidfile.cpp2
83 files changed, 1292 insertions, 1154 deletions
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp
index 89226eef..307c72c4 100755
--- a/bin/bbackupd/BackupClientDirectoryRecord.cpp
+++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp
@@ -26,10 +26,6 @@
#include "BackupDaemon.h"
#include "BackupStoreException.h"
-#ifdef PLATFORM_LINUX
- #include "LinuxWorkaround.h"
-#endif
-
#include "MemLeakFindOn.h"
typedef std::map<std::string, BackupStoreDirectory::Entry *> DecryptedEntriesMap_t;
@@ -151,9 +147,9 @@ void BackupClientDirectoryRecord::SyncDirectory(BackupClientDirectoryRecord::Syn
currentStateChecksum.Add(&st.st_gid, sizeof(st.st_gid));
// Inode to be paranoid about things moving around
currentStateChecksum.Add(&st.st_ino, sizeof(st.st_ino));
-#ifndef PLATFORM_stat_NO_st_flags
+#ifdef HAVE_STRUCT_STAT_ST_FLAGS
currentStateChecksum.Add(&st.st_flags, sizeof(st.st_flags));
-#endif // n PLATFORM_stat_NO_st_flags
+#endif
StreamableMemBlock xattr;
BackupClientFileAttributes::FillExtendedAttr(xattr, rLocalPath.c_str());
diff --git a/bin/bbackupd/BackupClientInodeToIDMap.cpp b/bin/bbackupd/BackupClientInodeToIDMap.cpp
index 23e91eba..7141d5f4 100755
--- a/bin/bbackupd/BackupClientInodeToIDMap.cpp
+++ b/bin/bbackupd/BackupClientInodeToIDMap.cpp
@@ -9,16 +9,12 @@
#include "Box.h"
-#ifndef PLATFORM_BERKELEY_DB_NOT_SUPPORTED
+#ifdef HAVE_DB
// Include db headers and other OS files if they're needed for the disc implementation
#include <sys/types.h>
#include <fcntl.h>
#include <limits.h>
- #ifdef PLATFORM_LINUX
- #include "../../local/_linux_db.h"
- #else
- #include <db.h>
- #endif
+ #include DB_HEADER
#include <sys/stat.h>
#endif
diff --git a/bin/bbackupd/BackupClientInodeToIDMap.h b/bin/bbackupd/BackupClientInodeToIDMap.h
index 1ea7755d..121e88fd 100755
--- a/bin/bbackupd/BackupClientInodeToIDMap.h
+++ b/bin/bbackupd/BackupClientInodeToIDMap.h
@@ -16,7 +16,7 @@
#include <utility>
// Use in memory implementation if there isn't access to the Berkely DB on this platform
-#ifdef PLATFORM_BERKELEY_DB_NOT_SUPPORTED
+#ifndef HAVE_DB
#define BACKIPCLIENTINODETOIDMAP_IN_MEMORY_IMPLEMENTATION
#endif
diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp
index bc07ee21..f22de591 100755
--- a/bin/bbackupd/BackupDaemon.cpp
+++ b/bin/bbackupd/BackupDaemon.cpp
@@ -12,15 +12,16 @@
#include <unistd.h>
#include <syslog.h>
#include <sys/param.h>
-#include <sys/mount.h>
#include <signal.h>
-#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #ifdef PLATFORM_SUNOS
- #include <cstdio>
- #include <sys/mnttab.h>
- #else
- #include <mntent.h>
- #endif
+#ifdef HAVE_SYS_MOUNT_H
+ #include <sys/mount.h>
+#endif
+#ifdef HAVE_MNTENT_H
+ #include <mntent.h>
+#endif
+#ifdef HAVE_SYS_MNTTAB_H
+ #include <cstdio>
+ #include <sys/mnttab.h>
#endif
#include <sys/wait.h>
@@ -894,7 +895,7 @@ void BackupDaemon::SendSyncStartOrFinish(bool SendStart)
-#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
+#ifndef HAVE_STRUCT_STATFS_F_MNTONNAME
// string comparison ordering for when mount points are handled
// by code, rather than the OS.
typedef struct
@@ -957,16 +958,21 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
std::map<std::string, int> mounts;
int numIDMaps = 0;
-#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
+#ifndef HAVE_STRUCT_STATFS_F_MNTONNAME
// Linux and others can't tell you where a directory is mounted. So we
// have to read the mount entries from /etc/mtab! Bizarre that the OS
// itself can't tell you, but there you go.
std::set<std::string, mntLenCompare> mountPoints;
// BLOCK
FILE *mountPointsFile = 0;
-#ifdef PLATFORM_SUNOS
+
+#ifdef HAVE_STRUCT_MNTENT_MNT_DIR
// Open mounts file
- mountPointsFile = ::fopen("/etc/mnttab", "r");
+ mountPointsFile = ::setmntent("/proc/mounts", "r");
+ if(mountPointsFile == 0)
+ {
+ mountPointsFile = ::setmntent("/etc/mtab", "r");
+ }
if(mountPointsFile == 0)
{
THROW_EXCEPTION(CommonException, OSFileError);
@@ -974,51 +980,47 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
try
{
-
// Read all the entries, and put them in the set
- struct mnttab entry;
- while(getmntent(mountPointsFile, &entry) == 0)
+ struct mntent *entry = 0;
+ while((entry = ::getmntent(mountPointsFile)) != 0)
{
- TRACE1("Found mount point at %s\n", entry.mnt_mountp);
- mountPoints.insert(std::string(entry.mnt_mountp));
+ TRACE1("Found mount point at %s\n", entry->mnt_dir);
+ mountPoints.insert(std::string(entry->mnt_dir));
}
// Close mounts file
- ::fclose(mountPointsFile);
+ ::endmntent(mountPointsFile);
}
catch(...)
{
- ::fclose(mountPointsFile);
+ ::endmntent(mountPointsFile);
throw;
}
#else
- // Open mounts file
- mountPointsFile = ::setmntent("/proc/mounts", "r");
+ // Open mounts file
+ mountPointsFile = ::fopen("/etc/mnttab", "r");
if(mountPointsFile == 0)
{
- mountPointsFile = ::setmntent("/etc/mtab", "r");
+ THROW_EXCEPTION(CommonException, OSFileError);
}
- if(mountPointsFile == 0)
- {
- THROW_EXCEPTION(CommonException, OSFileError);
- }
-
+
try
{
+
// Read all the entries, and put them in the set
- struct mntent *entry = 0;
- while((entry = ::getmntent(mountPointsFile)) != 0)
+ struct mnttab entry;
+ while(getmntent(mountPointsFile, &entry) == 0)
{
- TRACE1("Found mount point at %s\n", entry->mnt_dir);
- mountPoints.insert(std::string(entry->mnt_dir));
+ TRACE1("Found mount point at %s\n", entry.mnt_mountp);
+ mountPoints.insert(std::string(entry.mnt_mountp));
}
-
+
// Close mounts file
- ::endmntent(mountPointsFile);
+ ::fclose(mountPointsFile);
}
catch(...)
{
- ::endmntent(mountPointsFile);
+ ::fclose(mountPointsFile);
throw;
}
#endif
@@ -1030,7 +1032,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con
ASSERT(*i == "/");
}
#endif // n NDEBUG
-#endif // PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
+#endif // n HAVE_STRUCT_STATFS_F_MNTONNAME
// Then... go through each of the entries in the configuration,
// making sure there's a directory created for it.
@@ -1052,7 +1054,17 @@ TRACE0("new location\n");
// Do a fsstat on the pathname to find out which mount it's on
{
-#ifdef PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
+#ifdef HAVE_STRUCT_STATFS_F_MNTONNAME
+ // BSD style statfs -- includes mount point, which is nice.
+ struct statfs s;
+ if(::statfs(ploc->mPath.c_str(), &s) != 0)
+ {
+ THROW_EXCEPTION(CommonException, OSFileError)
+ }
+
+ // Where the filesystem is mounted
+ std::string mountName(s.f_mntonname);
+#else
// Warn in logs if the directory isn't absolute
if(ploc->mPath[0] != '/')
{
@@ -1078,16 +1090,6 @@ TRACE0("new location\n");
}
TRACE2("mount point chosen for %s is %s\n", ploc->mPath.c_str(), mountName.c_str());
}
-#else
- // BSD style statfs -- includes mount point, which is nice.
- struct statfs s;
- if(::statfs(ploc->mPath.c_str(), &s) != 0)
- {
- THROW_EXCEPTION(CommonException, OSFileError)
- }
-
- // Where the filesystem is mounted
- std::string mountName(s.f_mntonname);
#endif
// Got it?
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index 0d08f1eb..27b5fa76 100755
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -1163,7 +1163,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
continue;
}
-#ifdef PLATFORM_dirent_BROKEN_d_type
+#ifndef HAVE_VALID_DIRENT_D_TYPE
std::string fn(rLocalDir);
fn += '/';
fn += localDirEn->d_name;
@@ -1196,7 +1196,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s
// Directory
localDirs.insert(std::string(localDirEn->d_name));
}
-#endif // PLATFORM_dirent_BROKEN_d_type
+#endif
}
// Close directory
if(::closedir(dirhandle) != 0)
diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp
index aea0faa8..1eb86db6 100755
--- a/bin/bbackupquery/bbackupquery.cpp
+++ b/bin/bbackupquery/bbackupquery.cpp
@@ -12,12 +12,18 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
-#ifndef PLATFORM_READLINE_NOT_SUPPORTED
- #ifdef PLATFORM_LINUX
- #include "../../local/_linux_readline.h"
- #else
+#ifdef HAVE_LIBREADLINE
+ #ifdef HAVE_READLINE_READLINE_H
#include <readline/readline.h>
+ #elif defined(HAVE_READLINE_H)
+ #include <readline.h>
+ #endif
+#endif
+#ifdef HAVE_READLINE_HISTORY
+ #ifdef HAVE_READLINE_HISTORY_H
#include <readline/history.h>
+ #elif defined(HAVE_HISTORY_H)
+ #include <history.h>
#endif
#endif
@@ -185,8 +191,10 @@ int main(int argc, const char *argv[])
}
// Get commands from input
-#ifndef PLATFORM_READLINE_NOT_SUPPORTED
+#ifdef HAVE_LIBREADLINE
+#ifdef HAVE_READLINE_HISTORY
using_history();
+#endif
char *last_cmd = 0;
while(!context.Stop())
{
@@ -203,10 +211,18 @@ int main(int argc, const char *argv[])
}
else
{
+#ifdef HAVE_READLINE_HISTORY
add_history(command);
+#else
+ free(last_cmd);
+#endif
last_cmd = command;
}
}
+#ifndef HAVE_READLINE_HISTORY
+ free(last_cmd);
+ last_cmd = 0;
+#endif
#else
// Version for platforms which don't have readline by default
FdGetLine getLine(fileno(stdin));
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 00000000..14fc19e3
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+aclocal -I infrastructure/m4
+autoheader
+autoconf
diff --git a/configure b/configure
deleted file mode 100755
index 6de0d998..00000000
--- a/configure
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-perl ./infrastructure/makebuildenv.pl $1 $2 $3 $4 $5 $6 $7 $8 $9
-if [ "$?" -ne "0" ]; then
- exit 1
-fi
-perl ./infrastructure/makeparcels.pl
-
-echo
-echo Type \'make\' to build the installation parcels.
-echo
-echo Then use the install scripts inside 'parcels/<dir>' to install
-echo the components you need.
-echo
-echo
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 00000000..2915a580
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,198 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.59)
+AC_INIT([Box Backup], 0.09, [box@fluffy.co.uk])
+AC_CONFIG_SRCDIR([lib/common/Box.h])
+AC_CONFIG_HEADERS([lib/common/config.h])
+
+
+### Checks for programs.
+
+AC_LANG([C++])
+AC_PROG_CXX
+AC_CXX_EXCEPTIONS
+AC_CXX_NAMESPACES
+if test "x$ac_cv_cxx_exceptions" != "xyes" || \
+ test "x$ac_cv_cxx_namespaces" != "xyes"; then
+ AC_MSG_ERROR([[basic compile checks failed, the C++ compiler is broken]])
+fi
+if test "x$GXX" = "xyes"; then
+ # Use -Wall if we have gcc. This gives better warnings
+ AC_SUBST([CXXFLAGS_STRICT], ['-Wall'])
+ # Use -rdynamic if we have gcc. This is needed for backtrace
+ AC_SUBST([LDADD_RDYNAMIC], ['-rdynamic'])
+fi
+
+
+### Checks for libraries.
+
+AC_SEARCH_LIBS([nanosleep], [rt],,
+ [AC_MSG_ERROR([[Cannot find library with nanosleep]])])
+AC_CHECK_LIB([z], [zlibVersion],, [AC_MSG_ERROR([[Cannot find zlib]])])
+AX_CHECK_BDB_V1
+VL_LIB_READLINE
+have_libreadline=no
+test "x$vl_cv_lib_readline" != "xno" && have_libreadline=yes
+
+
+## Check for Open SSL, use old versions only if explicitly requested
+AX_CHECK_SSL(, [AC_MSG_ERROR([[OpenSSL is not installed but is required]])])
+AC_ARG_ENABLE(
+ [old-ssl],
+ [AC_HELP_STRING([--enable-old-ssl],
+ [Allow use of pre-0.9.7 Open SSL - NOT RECOMMENDED, read the documentation])])
+AC_CHECK_LIB(
+ [crypto],
+ [EVP_CipherInit_ex],, [
+ if test "x$enable_old_ssl" = "xyes"; then
+ AC_DEFINE([HAVE_OLD_SSL], 1, [Define to 1 if SSL is pre-0.9.7])
+ else
+ AC_MSG_ERROR([[found an old (pre 0.9.7) version of SSL.
+Upgrade or read the documentation for alternatives]])
+ fi
+ ])
+
+
+### Checks for header files.
+
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS([execinfo.h netinet/in.h regex.h sys/types.h sys/xattr.h])
+
+
+### Checks for typedefs, structures, and compiler characteristics.
+
+AC_CHECK_TYPES([u_int8_t, u_int16_t, u_int32_t, u_int64_t])
+AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, uint64_t])
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_C_BIGENDIAN
+AX_CHECK_NONALIGNED_ACCESS
+AC_TYPE_UID_T
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_CHECK_MEMBERS([struct stat.st_flags])
+AC_CHECK_MEMBERS([struct stat.st_mtimespec])
+AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,, [[
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ ]])
+AC_CHECK_DECLS([INFTIM],,, [[#include <poll.h>]])
+AC_CHECK_DECLS([SO_PEERCRED],,, [[#include <sys/socket.h>]])
+AC_HEADER_TIME
+AC_STRUCT_TM
+AX_CHECK_DIRENT_D_TYPE
+AC_SYS_LARGEFILE
+AX_CHECK_LLONG_MINMAX
+AX_CHECK_DEFINE_PRAGMA
+AX_RANDOM_DEVICE
+AX_CHECK_MOUNT_POINT(, [AC_MSG_ERROR([[cannot work out how to discover mount points on your platform]])])
+AX_CHECK_MALLOC_WORKAROUND
+
+
+### Checks for library functions.
+
+AC_FUNC_CLOSEDIR_VOID
+AC_FUNC_ERROR_AT_LINE
+AC_TYPE_SIGNAL
+AC_FUNC_STAT
+AC_CHECK_FUNCS([getpeereid kqueue lchown setproctitle])
+AX_FUNC_SYSCALL
+AX_CHECK_SYSCALL_LSEEK
+
+
+### Miscellaneous complicated feature checks
+
+## Check for large file support active. AC_SYS_LARGEFILE has already worked
+## out how to enable it if necessary, we need to know if we've got it so we
+## can disable the raidfile intercepts
+AC_CACHE_CHECK([if we have large file support enabled], [have_large_file_support],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
+ return sizeof(off_t)==4;
+ ]])],
+ [have_large_file_support=yes], [have_large_file_support=no]
+ )])
+if test "x$have_large_file_support" = "xyes"; then
+ AC_DEFINE([HAVE_LARGE_FILE_SUPPORT], 1, [Define to 1 large file support is in use])
+fi
+
+## Find out how to do file locking
+AC_CHECK_FUNCS([flock])
+AC_CHECK_DECLS([O_EXLOCK],,, [[#include <fcntl.h>]])
+AC_CHECK_DECLS([F_SETLK],,, [[#include <fcntl.h>]])
+if test "x$ac_cv_func_flock" != "xyes" && \
+ test "x$ac_cv_have_decl_O_EXLOCK" != "xyes" && \
+ test "x$ac_cv_have_decl_F_SETLK" != "xyes"
+then
+ AC_MSG_ERROR([[cannot work out how to do file locking on your platform]])
+fi
+
+## Get tmpdir
+temp_directory_name="/tmp"
+AC_ARG_WITH(
+ [tmp-dir],
+ [AC_HELP_STRING([--with-tmp-dir=DIR], [Directory for temporary files [/tmp]])],
+ [temp_directory_name="$withval"])
+AC_DEFINE_UNQUOTED([TEMP_DIRECTORY_NAME], ["$temp_directory_name"], [TMP directory name])
+
+## Allow linking binaries with static libraries
+AC_ARG_ENABLE(
+ [static-bin],
+ [AC_HELP_STRING([--enable-static-bin], [Link binaries with static libraries])])
+if test "x$enable_static_bin" = "xyes"; then
+ AC_CHECK_LIB([ssl],[SSL_read])
+ LIBS="-Wl,-Bstatic $LIBS -Wl,-Bdynamic"
+fi
+
+
+### Output files
+AC_CONFIG_FILES([infrastructure/BoxPlatform.pm])
+AC_OUTPUT
+
+# Configure the Box build system
+echo
+perl ./infrastructure/makebuildenv.pl &&
+ perl ./infrastructure/makeparcels.pl
+
+# Write summary of important info
+cat <<EOC
+A summary of the build configuration is below. Box Backup will function
+without these features, but will work better where they are present. Refer
+to the documentation for more information on each feature.
+
+Large files: $have_large_file_support
+Berkeley DB: $ac_have_bdb
+Readline: $have_libreadline
+Extended attributes: $ac_cv_header_sys_xattr_h
+EOC
+
+
+### Warnings at end for visibility
+
+if test "x$gcc_3_plus" != "xyes" && test "x$malloc_workaround" != "xyes"; then
+ echo
+ AC_MSG_WARN([[the implementation of the C++ STL on this platform may
+have a flaw which causes it to apparently leak memory, and this flaw cannot be
+worked around.
+
+When running the daemons, check their memory usage does not constantly
+increase. The STL flaw can cause excessive memory use.]])
+fi
+
+case "$vl_cv_lib_readline" in
+ *readline*)
+ echo
+ AC_MSG_WARN([[do not distribute binaries compiled against GNU readline,
+as this would violate the GNU readline licence, which is GPL. You may use
+libedit or libeditline instead.]])
+ ;;
+esac
+
+if test "x$ac_have_bdb" != "xyes"; then
+ echo
+ AC_MSG_WARN([[db is not installed -- will run in reduced efficiency mode without it]])
+fi
diff --git a/infrastructure/BoxPlatform.pm b/infrastructure/BoxPlatform.pm.in
index 0549b39a..257b298b 100644
--- a/infrastructure/BoxPlatform.pm
+++ b/infrastructure/BoxPlatform.pm.in
@@ -1,7 +1,7 @@
package BoxPlatform;
use Exporter;
@ISA = qw/Exporter/;
-@EXPORT = qw/$build_os $build_cpu $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $gcc_v4 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra/;
+@EXPORT = qw/$build_os $build_cpu $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files/;
BEGIN
{
@@ -18,24 +18,11 @@ BEGIN
$make_command = ($build_os eq 'Darwin') ? 'bsdmake' : ($build_os eq 'SunOS') ? 'gmake' : 'make';
$bsd_make = ($build_os ne 'Linux' && $build_os ne 'CYGWIN' && $build_os ne "SunOS");
- $platform_define = 'PLATFORM_'.uc($build_os);
- $platform_cpu = 'PLATFORM_'.uc($build_cpu);
# blank extra flags by default
- $platform_compile_line_extra = '';
- $platform_link_line_extra = '';
-
- # compiler version?
- $gcc_v3 = 0;
- $gcc_v4 = 0;
- open COMPILER,"gcc -v 2>&1 |" or die "Can't open gcc -v";
- while(<COMPILER>)
- {
- $gcc_v3 = 1 if (m/version gcc 3/ || m/gcc version 3/ || m/gcc \(GCC\) 3/i || m/gcc.Version\s+3/i);
- $gcc_v4 = 1 if (m/version gcc 4/ || m/gcc version 4/ || m/gcc \(GCC\) 4/i || m/gcc.Version\s+4/i);
- }
- close COMPILER;
- $gcc_v3 = 1 if $gcc_v4; # hacks are about the same
+ $platform_compile_line_extra = '@CPPFLAGS@ @CXXFLAGS@ @CXXFLAGS_STRICT@';
+ $platform_link_line_extra = '@LDFLAGS@';
+ $platform_lib_files = '@LIBS@';
# get version
open VERSION,"VERSION.txt";
@@ -46,7 +33,7 @@ BEGIN
close VERSION;
# where to put the files
- $install_into_dir = '/usr/local/bin';
+ $install_into_dir = '@bindir@';
# if it's Darwin,
if($build_os eq 'Darwin')
@@ -67,11 +54,6 @@ BEGIN
$platform_link_line_extra = '-L/sw/lib ';
}
}
-
- if($build_os eq 'SunOS')
- {
- $platform_link_line_extra = '-lrt ';
- }
}
sub make_flag
diff --git a/infrastructure/m4/ac_cxx_exceptions.m4 b/infrastructure/m4/ac_cxx_exceptions.m4
new file mode 100644
index 00000000..4c3013dc
--- /dev/null
+++ b/infrastructure/m4/ac_cxx_exceptions.m4
@@ -0,0 +1,24 @@
+dnl @synopsis AC_CXX_EXCEPTIONS
+dnl
+dnl If the C++ compiler supports exceptions handling (try, throw and
+dnl catch), define HAVE_EXCEPTIONS.
+dnl
+dnl @category Cxx
+dnl @author Todd Veldhuizen
+dnl @author Luc Maisonobe <luc@spaceroots.org>
+dnl @version 2004-02-04
+dnl @license AllPermissive
+
+AC_DEFUN([AC_CXX_EXCEPTIONS],
+[AC_CACHE_CHECK(whether the compiler supports exceptions,
+ac_cv_cxx_exceptions,
+[AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE(,[try { throw 1; } catch (int i) { return i; }],
+ ac_cv_cxx_exceptions=yes, ac_cv_cxx_exceptions=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_exceptions" = yes; then
+ AC_DEFINE(HAVE_EXCEPTIONS,,[define if the compiler supports exceptions])
+fi
+])
diff --git a/infrastructure/m4/ac_cxx_namespaces.m4 b/infrastructure/m4/ac_cxx_namespaces.m4
new file mode 100644
index 00000000..2f18477b
--- /dev/null
+++ b/infrastructure/m4/ac_cxx_namespaces.m4
@@ -0,0 +1,25 @@
+dnl @synopsis AC_CXX_NAMESPACES
+dnl
+dnl If the compiler can prevent names clashes using namespaces, define
+dnl HAVE_NAMESPACES.
+dnl
+dnl @category Cxx
+dnl @author Todd Veldhuizen
+dnl @author Luc Maisonobe <luc@spaceroots.org>
+dnl @version 2004-02-04
+dnl @license AllPermissive
+
+AC_DEFUN([AC_CXX_NAMESPACES],
+[AC_CACHE_CHECK(whether the compiler implements namespaces,
+ac_cv_cxx_namespaces,
+[AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
+ [using namespace Outer::Inner; return i;],
+ ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_cxx_namespaces" = yes; then
+ AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
+fi
+])
diff --git a/infrastructure/m4/ax_check_bdb_v1.m4 b/infrastructure/m4/ax_check_bdb_v1.m4
new file mode 100644
index 00000000..de36ca07
--- /dev/null
+++ b/infrastructure/m4/ax_check_bdb_v1.m4
@@ -0,0 +1,43 @@
+dnl @synopsis AX_CHECK_BDB_V1
+dnl
+dnl This macro find an installation of Berkeley DB version 1, or compatible.
+dnl It will define the following macros on success:
+dnl
+dnl HAVE_DB - If Berkeley DB version 1 or compatible is available
+dnl DB_HEADER - The relative path and filename of the header file
+dnl LIBS - Updated for correct library
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/12
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_BDB_V1], [
+ ac_have_bdb=no
+ AC_CHECK_HEADERS([db_185.h db4/db_185.h db3/db_185.h db1/db.h db.h],
+ [ac_bdb_header=$ac_header; break], [ac_bdb_header=""])
+ if test "x$ac_bdb_header" != x; then
+ AC_SEARCH_LIBS([__db185_open],
+ [db db-4.3 db-4.2 db-4.1 db-4.0 db-3],
+ [ac_have_bdb=yes],
+ [AC_SEARCH_LIBS([dbopen], [db-1 db], [ac_have_bdb=yes])])
+ fi
+ if test "x$ac_have_bdb" = "xyes"; then
+ AC_MSG_CHECKING([whether found db libraries work])
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+ $ac_includes_default
+ #include "$ac_bdb_header"]], [[
+ DB *dbp = dbopen(0, 0, 0, DB_HASH, 0);
+ if(dbp) dbp->close(dbp);
+ return 0;
+ ]])], [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_DB], 1, [Define to 1 if Berkeley DB is available])
+ AC_DEFINE_UNQUOTED([DB_HEADER], ["$ac_bdb_header"],
+ [Define to the location of the Berkeley DB 1.85 header])
+ ], [
+ AC_MSG_RESULT([no])
+ ac_have_bdb=no
+ ])
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_define_pragma.m4 b/infrastructure/m4/ax_check_define_pragma.m4
new file mode 100644
index 00000000..176faf3d
--- /dev/null
+++ b/infrastructure/m4/ax_check_define_pragma.m4
@@ -0,0 +1,25 @@
+dnl @synopsis AX_CHECK_DEFINE_PRAGMA([ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl
+dnl This macro will find out if the compiler will accept #pragma inside a
+dnl #define. HAVE_DEFINE_PRAGMA will be defined if this is the case, and
+dnl ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/03
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_DEFINE_PRAGMA], [
+ AC_CACHE_CHECK([for pre-processor pragma defines], [have_define_pragma],
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #define TEST_DEFINE #pragma pack(1)
+ TEST_DEFINE
+ ]])],
+ [have_define_pragma=yes], [have_define_pragma=no]
+ )])
+ if test "x$have_define_pragma" = "xyes"; then
+ AC_DEFINE([HAVE_DEFINE_PRAGMA], 1, [Define to 1 if #define of pragmas works])
+ m4_ifvaln([$1],[$1],[:])dnl
+ m4_ifvaln([$2],[else $2])dnl
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_dirent_d_type.m4 b/infrastructure/m4/ax_check_dirent_d_type.m4
new file mode 100644
index 00000000..87b93185
--- /dev/null
+++ b/infrastructure/m4/ax_check_dirent_d_type.m4
@@ -0,0 +1,41 @@
+dnl @synopsis AX_CHECK_DIRENT_D_TYPE([ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl
+dnl This macro will find out if struct dirent.d_type is present and supported.
+dnl
+dnl The following defines will be set as appropriate:
+dnl HAVE_STRUCT_DIRENT_D_TYPE
+dnl HAVE_VALID_DIRENT_D_TYPE
+dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/03
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_DIRENT_D_TYPE], [
+ AC_CHECK_MEMBERS([struct dirent.d_type],,, [[#include <dirent.h>]])
+ if test "x$ac_cv_member_struct_dirent_d_type" = "xyes"; then
+ AC_CACHE_CHECK([[whether struct dirent.d_type is valid]], [have_valid_dirent_d_type],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+ $ac_includes_default
+ #include <dirent.h>
+ ]], [[
+ DIR* dir = opendir(".");
+ struct dirent* res = NULL;
+ if(dir) res = readdir(dir);
+ return res ? (res->d_type==DT_UNKNOWN) : 1;
+ ]])],
+ [have_valid_dirent_d_type=yes], [have_valid_dirent_d_type=no]
+ )])
+ if test "x$have_valid_dirent_d_type" = "xyes"; then
+ AC_DEFINE([HAVE_VALID_DIRENT_D_TYPE], 1, [Define to 1 if struct dirent.d_type is valid])
+ fi
+ fi
+ if test "x$ac_cv_member_struct_dirent_d_type" = "xyes" || \
+ test "x$have_valid_dirent_d_type" = "xyes"
+ then
+ m4_ifvaln([$1],[$1],[:])dnl
+ m4_ifvaln([$2],[else $2])dnl
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_llong_minmax.m4 b/infrastructure/m4/ax_check_llong_minmax.m4
new file mode 100644
index 00000000..f3f99c53
--- /dev/null
+++ b/infrastructure/m4/ax_check_llong_minmax.m4
@@ -0,0 +1,76 @@
+dnl @synopsis AX_CHECK_LLONG_MINMAX
+dnl
+dnl This macro will fix up LLONG_MIN and LLONG_MAX as appropriate. I'm finding
+dnl it quite difficult to believe that so many hoops are necessary. The world
+dnl seems to have gone quite mad.
+dnl
+dnl This gem is adapted from the OpenSSH configure script so here's
+dnl the original copyright notice:
+dnl
+dnl Copyright (c) 1999-2004 Damien Miller
+dnl
+dnl Permission to use, copy, modify, and distribute this software for any
+dnl purpose with or without fee is hereby granted, provided that the above
+dnl copyright notice and this permission notice appear in all copies.
+dnl
+dnl @category C
+dnl @author Martin Ebourne and Damien Miller
+dnl @version 2005/07/07
+
+AC_DEFUN([AX_CHECK_LLONG_MINMAX], [
+ AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [[#include <limits.h>]])
+ if test -z "$have_llong_max"; then
+ AC_MSG_CHECKING([[for max value of long long]])
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <stdio.h>
+ /* Why is this so damn hard? */
+ #undef __GNUC__
+ #undef __USE_ISOC99
+ #define __USE_ISOC99
+ #include <limits.h>
+ #define DATA "conftest.llminmax"
+ int main(void) {
+ FILE *f;
+ long long i, llmin, llmax = 0;
+
+ if((f = fopen(DATA,"w")) == NULL)
+ exit(1);
+
+ #if defined(LLONG_MIN) && defined(LLONG_MAX)
+ fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
+ llmin = LLONG_MIN;
+ llmax = LLONG_MAX;
+ #else
+ fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
+ /* This will work on one's complement and two's complement */
+ for (i = 1; i > llmax; i <<= 1, i++)
+ llmax = i;
+ llmin = llmax + 1LL; /* wrap */
+ #endif
+
+ /* Sanity check */
+ if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax || llmax - 1 > llmax) {
+ fprintf(f, "unknown unknown\n");
+ exit(2);
+ }
+
+ if (fprintf(f ,"%lld %lld", llmin, llmax) < 0)
+ exit(3);
+
+ exit(0);
+ }
+ ]])], [
+ read llong_min llong_max < conftest.llminmax
+ AC_MSG_RESULT([$llong_max])
+ AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
+ [max value of long long calculated by configure])
+ AC_MSG_CHECKING([[for min value of long long]])
+ AC_MSG_RESULT([$llong_min])
+ AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
+ [min value of long long calculated by configure])
+ ],
+ [AC_MSG_RESULT(not found)],
+ [AC_MSG_WARN([[cross compiling: not checking]])]
+ )
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_malloc_workaround.m4 b/infrastructure/m4/ax_check_malloc_workaround.m4
new file mode 100644
index 00000000..9b1c9848
--- /dev/null
+++ b/infrastructure/m4/ax_check_malloc_workaround.m4
@@ -0,0 +1,38 @@
+dnl @synopsis AX_CHECK_MALLOC_WORKAROUND
+dnl
+dnl This macro will see if there is a potential STL memory leak, and if we can
+dnl work around it will define __USE_MALLOC as the fix.
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/12
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_MALLOC_WORKAROUND], [
+ if test "x$GXX" = "xyes"; then
+ AC_CACHE_CHECK([for gcc version 3 or later], [gcc_3_plus],
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #if __GNUC__ < 3
+ #error "Old GNU C"
+ #endif
+ ]])],
+ [gcc_3_plus=yes], [gcc_3_plus=no]
+ )])
+ if test "x$gcc_3_plus" = "xno"; then
+ AC_CACHE_CHECK([for malloc workaround], [malloc_workaround],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #define __USE_MALLOC
+ #include <string>
+ ]], [[
+ std::string s;
+ s = "test";
+ ]])],
+ [malloc_workaround=yes], [malloc_workaround=no]
+ )])
+ if test "x$malloc_workaround" = "xyes"; then
+ AC_DEFINE([__USE_MALLOC], 1,
+ [Define to 1 if __USE_MALLOC is required work around STL memory leaks])
+ fi
+ fi
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_mount_point.m4 b/infrastructure/m4/ax_check_mount_point.m4
new file mode 100644
index 00000000..747888cc
--- /dev/null
+++ b/infrastructure/m4/ax_check_mount_point.m4
@@ -0,0 +1,41 @@
+dnl @synopsis AX_CHECK_MOUNT_POINT([ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl
+dnl This macro will find out how to get mount point information if possible.
+dnl
+dnl The following defines will be set as appropriate:
+dnl HAVE_MNTENT_H
+dnl HAVE_SYS_MNTTAB_H
+dnl HAVE_SYS_MOUNT_H
+dnl HAVE_STRUCT_MNTENT_MNT_DIR
+dnl HAVE_STRUCT_MNTTAB_MNT_MOUNTP
+dnl HAVE_STRUCT_STATFS_F_MNTONNAME
+dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/01
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_MOUNT_POINT], [
+ AC_CHECK_FUNCS([getmntent statfs])
+ AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/mount.h],,, [[#include <stdio.h>]])
+ # BSD
+ AC_CHECK_MEMBERS([struct statfs.f_mntonname],,, [[
+ #include <sys/param.h>
+ #include <sys/mount.h>
+ ]])
+ # Linux
+ AC_CHECK_MEMBERS([struct mntent.mnt_dir],,, [[#include <mntent.h>]])
+ # Solaris
+ AC_CHECK_MEMBERS([struct mnttab.mnt_mountp],,, [[
+ #include <stdio.h>
+ #include <sys/mnttab.h>
+ ]])
+ if test "x$ac_cv_member_struct_statfs_f_mntonname" = "xyes" || \
+ test "x$ac_cv_member_struct_mntent_mnt_dir" = "xyes" || \
+ test "x$ac_cv_member_struct_mnttab_mnt_mountp" = "xyes"
+ then
+ m4_ifvaln([$1],[$1],[:])dnl
+ m4_ifvaln([$2],[else $2])dnl
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_nonaligned_access.m4 b/infrastructure/m4/ax_check_nonaligned_access.m4
new file mode 100644
index 00000000..8a6cd0c6
--- /dev/null
+++ b/infrastructure/m4/ax_check_nonaligned_access.m4
@@ -0,0 +1,57 @@
+dnl @synopsis AX_CHECK_NONALIGNED_ACCESS
+dnl
+dnl This macro will see if non-aligned memory accesses will fail. The following
+dnl defines will be made as appropriate:
+dnl HAVE_ALIGNED_ONLY_INT16
+dnl HAVE_ALIGNED_ONLY_INT32
+dnl HAVE_ALIGNED_ONLY_INT64
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/12
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_NONALIGNED_ACCESS], [
+ AC_CACHE_CHECK([if non-aligned 16 bit word accesses fail], [have_aligned_only_int16],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
+ #ifndef HAVE_UINT16_T
+ #define uint16_t u_int16_t;
+ #endif
+ uint16_t scratch[2];
+ memset(scratch, 0, sizeof(scratch));
+ return *(uint16_t*)((char*)scratch+1);
+ ]])],
+ [have_aligned_only_int16=no], [have_aligned_only_int16=yes]
+ )])
+ if test "x$have_aligned_only_int16" = "xyes"; then
+ AC_DEFINE([HAVE_ALIGNED_ONLY_INT16], 1, [Define to 1 if non-aligned int16 access will fail])
+ fi
+ AC_CACHE_CHECK([if non-aligned 32 bit word accesses fail], [have_aligned_only_int32],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
+ #ifndef HAVE_UINT32_T
+ #define uint32_t u_int32_t;
+ #endif
+ uint32_t scratch[2];
+ memset(scratch, 0, sizeof(scratch));
+ return *(uint32_t*)((char*)scratch+1);
+ ]])],
+ [have_aligned_only_int32=no], [have_aligned_only_int32=yes]
+ )])
+ if test "x$have_aligned_only_int32" = "xyes"; then
+ AC_DEFINE([HAVE_ALIGNED_ONLY_INT32], 1, [Define to 1 if non-aligned int32 access will fail])
+ fi
+ AC_CACHE_CHECK([if non-aligned 64 bit word accesses fail], [have_aligned_only_int64],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default]], [[
+ #ifndef HAVE_UINT64_T
+ #define uint64_t u_int64_t;
+ #endif
+ uint64_t scratch[2];
+ memset(scratch, 0, sizeof(scratch));
+ return *(uint64_t*)((char*)scratch+1);
+ ]])],
+ [have_aligned_only_int64=no], [have_aligned_only_int64=yes]
+ )])
+ if test "x$have_aligned_only_int64" = "xyes"; then
+ AC_DEFINE([HAVE_ALIGNED_ONLY_INT64], 1, [Define to 1 if non-aligned int64 access will fail])
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_ssl.m4 b/infrastructure/m4/ax_check_ssl.m4
new file mode 100644
index 00000000..039c8398
--- /dev/null
+++ b/infrastructure/m4/ax_check_ssl.m4
@@ -0,0 +1,37 @@
+dnl @synopsis AX_CHECK_SSL([ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl
+dnl This macro will check for OpenSSL in the standard path, allowing the user
+dnl to specify a directory if it is not found. The user uses
+dnl '--with-ssl-headers=/path/to/headers' or
+dnl '--with-ssl-lib=/path/to/lib' as arguments to configure.
+dnl
+dnl If OpenSSL is found the include directory gets added to CPPFLAGS,
+dnl '-lcrypto', '-lssl', and the libraries directory are added to LDFLAGS.
+dnl Also HAVE_SSL is defined to 1, and ACTION-IF-TRUE and ACTION-IF-FALSE are
+dnl run as appropriate
+dnl
+dnl @category InstalledPackages
+dnl @author Martin Ebourne
+dnl @version 2005/07/01
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_SSL], [
+ AC_ARG_WITH(
+ [ssl-headers],
+ [AC_HELP_STRING([--with-ssl-headers=DIR], [SSL include files location])],
+ [CPPFLAGS="$CPPFLAGS -I$withval"])
+ AC_ARG_WITH(
+ [ssl-lib],
+ [AC_HELP_STRING([--with-ssl-lib=DIR], [SSL library location])],
+ [LDFLAGS="$LDFLAGS -L$withval"])
+
+ ax_check_ssl_found=yes
+ AC_CHECK_HEADERS([openssl/ssl.h],, [ax_check_ssl_found=no])
+ AC_CHECK_LIB([ssl], [SSL_read],, [ax_check_ssl_found=no])
+
+ if test "x$ax_check_ssl_found" = "xyes"; then
+ AC_DEFINE([HAVE_SSL], 1, [Define to 1 if SSL is available])
+ m4_ifvaln([$1],[$1],[:])dnl
+ m4_ifvaln([$2],[else $2])dnl
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_check_syscall_lseek.m4 b/infrastructure/m4/ax_check_syscall_lseek.m4
new file mode 100644
index 00000000..6bf93c23
--- /dev/null
+++ b/infrastructure/m4/ax_check_syscall_lseek.m4
@@ -0,0 +1,54 @@
+dnl @synopsis AX_CHECK_SYSCALL_LSEEK([ACTION-IF-TRUE], [ACTION-IF-FALSE])
+dnl
+dnl This macro will find out if the lseek syscall requires a dummy middle
+dnl parameter
+dnl
+dnl The following defines will be set as appropriate:
+dnl HAVE_LSEEK_DUMMY_PARAM
+dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/03
+dnl @license AllPermissive
+
+AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [
+ AC_REQUIRE([AX_FUNC_SYSCALL])dnl
+ if test "x$ac_cv_header_sys_syscall_h" = "xyes"; then
+ AC_CACHE_CHECK([[whether syscall lseek requires dummy parameter]], [have_lseek_dummy_param],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+ $ac_includes_default
+ #include <fcntl.h>
+ #include <sys/syscall.h>
+ #ifdef HAVE___SYSCALL_NEED_DEFN
+ extern "C" off_t __syscall(quad_t number, ...);
+ #endif
+ #ifndef HAVE_SYSCALL
+ #undef syscall
+ #define syscall __syscall
+ #endif
+ ]], [[
+ int fh = creat("lseektest", 0600);
+ int res = 0;
+ if(fh>=0)
+ {
+ res = syscall(SYS_lseek, fh, 0, SEEK_SET, 99);
+ close(fh);
+ }
+ unlink("lseektest");
+ return res!=-1;
+ ]])],
+ [have_lseek_dummy_param=yes], [have_lseek_dummy_param=no]
+ )])
+ if test "x$have_lseek_dummy_param" = "xyes"; then
+ AC_DEFINE([HAVE_LSEEK_DUMMY_PARAM], 1,
+ [Define to 1 if syscall lseek requires a dummy middle parameter])
+ fi
+ fi
+ if test "x$have_lseek_dummy_param" = "xno"
+ then
+ m4_ifvaln([$1],[$1],[:])dnl
+ m4_ifvaln([$2],[else $2])dnl
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_func_syscall.m4 b/infrastructure/m4/ax_func_syscall.m4
new file mode 100644
index 00000000..40496bf0
--- /dev/null
+++ b/infrastructure/m4/ax_func_syscall.m4
@@ -0,0 +1,39 @@
+dnl @synopsis AX_FUNC_SYSCALL
+dnl
+dnl This macro will find out how to call syscall. One or more of the following
+dnl defines will be made as appropriate:
+dnl HAVE_UNISTD_H - If unistd.h is available
+dnl HAVE_SYS_SYSCALL_H - If sys/syscall.h is available
+dnl HAVE_SYSCALL - If syscall() is available and is defined in unistd.h
+dnl HAVE___SYSCALL - If __syscall() is available and is defined in unistd.h
+dnl HAVE___SYSCALL_NEED_DEFN - If __syscall() is available but is not defined in unistd.h
+dnl
+dnl @category C
+dnl @author Martin Ebourne
+dnl @version 2005/07/01
+dnl @license AllPermissive
+
+AC_DEFUN([AX_FUNC_SYSCALL], [
+ AC_CHECK_HEADERS([sys/syscall.h unistd.h])
+ AC_CHECK_FUNCS([syscall __syscall])
+ if test "x$ac_cv_func_syscall" != "xyes" &&
+ test "x$ac_cv_func___syscall" != "xyes"; then
+ AC_CACHE_CHECK([for __syscall needing definition], [have___syscall_need_defn],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+ $ac_includes_default
+ #ifdef HAVE_SYS_SYSCALL_H
+ #include <sys/syscall.h>
+ #endif
+ extern "C" off_t __syscall(quad_t number, ...);
+ ]], [[
+ __syscall(SYS_exit, 0);
+ return 1;
+ ]])],
+ [have___syscall_need_defn=yes], [have___syscall_need_defn=no]
+ )])
+ if test "x$have___syscall_need_defn" = "xyes"; then
+ AC_DEFINE([HAVE___SYSCALL_NEED_DEFN], 1,
+ [Define to 1 if __syscall is available but needs a definition])
+ fi
+ fi
+ ])dnl
diff --git a/infrastructure/m4/ax_random_device.m4 b/infrastructure/m4/ax_random_device.m4
new file mode 100644
index 00000000..ab9b56fd
--- /dev/null
+++ b/infrastructure/m4/ax_random_device.m4
@@ -0,0 +1,31 @@
+dnl @synopsis AX_RANDOM_DEVICE
+dnl
+dnl This macro will check for a random device, allowing the user to explicitly
+dnl set the path. The user uses '--with-random=FILE' as an argument to
+dnl configure.
+dnl
+dnl If A random device is found then HAVE_RANDOM_DEVICE is set to 1 and
+dnl RANDOM_DEVICE contains the path.
+dnl
+dnl @category Miscellaneous
+dnl @author Martin Ebourne
+dnl @version 2005/07/01
+dnl @license AllPermissive
+
+AC_DEFUN([AX_RANDOM_DEVICE], [
+ AC_ARG_WITH([random],
+ [AC_HELP_STRING([--with-random=FILE], [Use FILE as random number seed [auto-detected]])],
+ [RANDOM_DEVICE="$withval"],
+ [AC_CHECK_FILE("/dev/urandom", [RANDOM_DEVICE="/dev/urandom";],
+ [AC_CHECK_FILE("/dev/arandom", [RANDOM_DEVICE="/dev/arandom";],
+ [AC_CHECK_FILE("/dev/random", [RANDOM_DEVICE="/dev/random";])]
+ )])
+ ])
+ if test "x$RANDOM_DEVICE" != "x" ; then
+ AC_DEFINE([HAVE_RANDOM_DEVICE], 1,
+ [Define to 1 (and set RANDOM_DEVICE) if a random device is available])
+ AC_SUBST([RANDOM_DEVICE])
+ AC_DEFINE_UNQUOTED([RANDOM_DEVICE], ["$RANDOM_DEVICE"],
+ [Define to the filename of the random device (and set HAVE_RANDOM_DEVICE)])
+ fi
+ ])dnl
diff --git a/infrastructure/m4/vl_lib_readline.m4 b/infrastructure/m4/vl_lib_readline.m4
new file mode 100644
index 00000000..7c9217d6
--- /dev/null
+++ b/infrastructure/m4/vl_lib_readline.m4
@@ -0,0 +1,106 @@
+dnl @synopsis VL_LIB_READLINE
+dnl
+dnl Searches for a readline compatible library. If found, defines
+dnl `HAVE_LIBREADLINE'. If the found library has the `add_history'
+dnl function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
+dnl locations of the necessary include files and sets `HAVE_READLINE_H'
+dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
+dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
+dnl
+dnl The libraries that may be readline compatible are `libedit',
+dnl `libeditline' and `libreadline'. Sometimes we need to link a
+dnl termcap library for readline to work, this macro tests these cases
+dnl too by trying to link with `libtermcap', `libcurses' or
+dnl `libncurses' before giving up.
+dnl
+dnl Here is an example of how to use the information provided by this
+dnl macro to perform the necessary includes or declarations in a C
+dnl file:
+dnl
+dnl #ifdef HAVE_LIBREADLINE
+dnl # if defined(HAVE_READLINE_READLINE_H)
+dnl # include <readline/readline.h>
+dnl # elif defined(HAVE_READLINE_H)
+dnl # include <readline.h>
+dnl # else /* !defined(HAVE_READLINE_H) */
+dnl extern char *readline ();
+dnl # endif /* !defined(HAVE_READLINE_H) */
+dnl char *cmdline = NULL;
+dnl #else /* !defined(HAVE_READLINE_READLINE_H) */
+dnl /* no readline */
+dnl #endif /* HAVE_LIBREADLINE */
+dnl
+dnl #ifdef HAVE_READLINE_HISTORY
+dnl # if defined(HAVE_READLINE_HISTORY_H)
+dnl # include <readline/history.h>
+dnl # elif defined(HAVE_HISTORY_H)
+dnl # include <history.h>
+dnl # else /* !defined(HAVE_HISTORY_H) */
+dnl extern void add_history ();
+dnl extern int write_history ();
+dnl extern int read_history ();
+dnl # endif /* defined(HAVE_READLINE_HISTORY_H) */
+dnl /* no history */
+dnl #endif /* HAVE_READLINE_HISTORY */
+dnl
+dnl Modifications to add --enable-gnu-readline to work around licensing
+dnl problems between the traditional BSD licence and the GPL.
+dnl Martin Ebourne, 2005/7/11
+dnl
+dnl @category InstalledPackages
+dnl @author Ville Laurikari <vl@iki.fi>
+dnl @version 2002-04-04
+dnl @license AllPermissive
+
+AC_DEFUN([VL_LIB_READLINE], [
+ AC_ARG_ENABLE(
+ [gnu-readline],
+ AC_HELP_STRING([--enable-gnu-readline],
+ [Allow use of GNU readline (may violate GNU licence)])
+ )
+ vl_gnu_readline_lib=""
+ if test "x$enable_gnu_readline" = "xyes"; then
+ vl_gnu_readline_lib=readline
+ fi
+ AC_CACHE_CHECK([for a readline compatible library],
+ vl_cv_lib_readline, [
+ ORIG_LIBS="$LIBS"
+ for readline_lib in edit editline $vl_gnu_readline_lib; do
+ for termcap_lib in "" termcap curses ncurses; do
+ if test -z "$termcap_lib"; then
+ TRY_LIB="-l$readline_lib"
+ else
+ TRY_LIB="-l$readline_lib -l$termcap_lib"
+ fi
+ LIBS="$ORIG_LIBS $TRY_LIB"
+ AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
+ if test -n "$vl_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -n "$vl_cv_lib_readline"; then
+ break
+ fi
+ done
+ if test -z "$vl_cv_lib_readline"; then
+ vl_cv_lib_readline="no"
+ LIBS="$ORIG_LIBS"
+ fi
+ ])
+
+ if test "x$vl_cv_lib_readline" != "xno"; then
+ AC_DEFINE(HAVE_LIBREADLINE, 1,
+ [Define if you have a readline compatible library])
+ AC_CHECK_HEADERS(readline.h readline/readline.h)
+ AC_CACHE_CHECK([whether readline supports history],
+ vl_cv_lib_readline_history, [
+ vl_cv_lib_readline_history="no"
+ AC_TRY_LINK_FUNC(add_history, vl_cv_lib_readline_history="yes")
+ ])
+ if test "x$vl_cv_lib_readline_history" = "xyes"; then
+ AC_DEFINE(HAVE_READLINE_HISTORY, 1,
+ [Define if your readline library has \`add_history'])
+ AC_CHECK_HEADERS(history.h readline/history.h)
+ fi
+ fi
+])dnl
diff --git a/infrastructure/makebuildenv.pl b/infrastructure/makebuildenv.pl
index ecac6939..0af6d680 100755
--- a/infrastructure/makebuildenv.pl
+++ b/infrastructure/makebuildenv.pl
@@ -12,7 +12,7 @@ $|=1;
# note: Mac OS X resource forks and .DS_Store files are explicity ignored
-print "Box build environment setup.\n\nChecking environment...\n";
+print "Box build environment setup.\n\n";
my $implicit_dep = 'lib/common';
@@ -21,43 +21,12 @@ my $implicit_dep = 'lib/common';
use lib 'infrastructure';
use BoxPlatform;
-# don't allow old versions of openssl by default.
-my $old_version_of_openssl_ok = 0;
-
# keep copy of command line args
my $makebuildenv_args = join(' ',@ARGV);
# do command line arguments
my $compile_line_extra = $platform_compile_line_extra;
my $link_line_extra = $platform_link_line_extra;
-for(@ARGV)
-{
- if($_ eq 'allow-old-openssl')
- {
- $old_version_of_openssl_ok = 1;
- next;
- }
- my ($k,$v) = split /:/,$_,2;
- if($k eq 'compile')
- {
- $compile_line_extra .= $v . ' ';
- }
- elsif($k eq 'link')
- {
- $link_line_extra .= $v . ' ';
- }
- elsif($k eq 'openssl')
- {
- # assume that the bin/lib/include dirs are under the specified path
- chop $v if ($v =~ /\/$/);
- $compile_line_extra = "-I$v/include $compile_line_extra";
- $link_line_extra = "-L$v/lib $link_line_extra";
- }
- else
- {
- die "invalid option $_ specified on command line"
- }
-}
# make sure local files directory exists
unless(-d 'local')
@@ -68,262 +37,9 @@ unless(-d 'local')
# flags about the environment
my %env_flags;
-# messages on test failure
-my $test_failure_text;
-
-# run all tests
-{
- opendir DIR,'infrastructure/tests' or die "Can't read the tests directory";
- my @tests = grep {m/_tests\.pl\Z/} readdir DIR;
- closedir DIR;
- for(@tests)
- {
- require "infrastructure/tests/$_";
- }
-}
-
-
-# ---- LINUX start --------------------------------------------------------------------------
-# do configuration on Linux... find out what's available, and configure appropraitely.
-if($build_os eq 'Linux')
-{
- # setup the basic library translation flags -- these will omit those libraries from the compile line
- $env_flags{'LIBTRANS_-lreadline'} = '';
- $env_flags{'LIBTRANS_-lLINUX_DB'} = '';
-
- my $curses_lib = '-lcurses';
- if((!exists($env_flags{'curses_PRESENT'})) && exists($env_flags{'ncurses_PRESENT'}))
- {
- # got to use ncurses instead...
- $env_flags{'LIBTRANS_-lcurses'} = '-lncurses';
- $curses_lib = '-lncurses';
- }
-
- my ($linux_readline_h, $linux_db_h);
- my $db_ver = -1;
-
- open H_FILES,"find /usr/include |" or die "Can't open find";
- while(<H_FILES>)
- {
- chomp;
-
- if(m~/readline.h\Z~)
- {
- my $rlh = strip_h_name($_);
- if(check_readline_h($rlh,$curses_lib))
- {
- $linux_readline_h = $rlh;
- # allow readline library to be used
- delete $env_flags{'LIBTRANS_-lreadline'};
- }
- }
- if(m~/db(|_1\d+).h\Z~)
- {
- # version?
- my $dv = 0;
- $dv = $1 if m~(\d+)/db~;
- my $fn = $_;
-
- # check this file mentions dbopen
- open DB_H,$_ or die "Can't open $_";
- my $found = 0;
- while(<DB_H>)
- {
- if(m/dbopen/)
- {
- $found = 1;
- last;
- }
- }
- close DB_H;
- next unless $found;
-
- # see if this version works
- print("Checking db version...\n");
- my $db_h = strip_h_name($fn);
- my $db_lib = 'db';
- $db_lib .= $db_ver if $db_ver > 0;
- if(!check_db_lib($db_h, $db_lib))
- {
- # try another
- $db_lib = 'db';
- next unless check_db_lib($db_h, $db_lib)
- }
-
- # good version?
- if($dv > $db_ver)
- {
- $linux_db_h = $db_h;
- $db_ver = $dv;
- $env_flags{'LIBTRANS_-lLINUX_DB'} = '-l'.$db_lib;
- }
- }
- }
- print "Finished checking headers\n";
- close H_FILES;
-
- # write the platform file accordingly and tell the user what's happened.
- open LIN,">local/_linux_platform.h" or die "Can't open file for writing";
- if($linux_readline_h eq '')
- {
- print("---------------------\nWARNING: readline isn't installed\n---------------------\n");
- print LIN "#define PLATFORM_READLINE_NOT_SUPPORTED\n";
-
- }
- else
- {
- open RL_H,">local/_linux_readline.h" or die "Can't open file for writing";
- print RL_H "#include <$linux_readline_h>\n";
- my $hist = $linux_readline_h;
- $hist =~ s/readline\.h/history.h/;
- print RL_H "#include <$hist>\n";
- close RL_H;
- }
- if($linux_db_h eq '')
- {
- print("---------------------\nWARNING: db is not installed -- will run in reduced efficiency mode without it.\n---------------------\n");
- print LIN "#define PLATFORM_BERKELEY_DB_NOT_SUPPORTED\n";
- }
- else
- {
- open DB_H,">local/_linux_db.h" or die "Can't open file for writing";
- print DB_H "#include <$linux_db_h>\n";
- close DB_H;
- }
- close LIN;
-}
-sub strip_h_name
-{
- my $i = $_[0];
- $i =~ s~\A/usr/include/~~;
- return $i;
-}
-sub check_readline_h
-{
- my ($h,$curses_lib) = @_;
- print "Check readline from $h...\n";
- my $hist = $h;
- $hist =~ s/readline\.h/history.h/;
- open READLINEH,">readlineh.cpp" or die "Can't open readline test file for writing";
- print READLINEH <<__E;
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <$h>
-#include <$hist>
-int main(int argc, char *argv[])
-{
- using_history();
- add_history(0);
- readline(0);
- return 0;
-}
-__E
- close READLINEH;
- # attempt to compile
- my $r = system("g++ readlineh.cpp -lreadline $curses_lib -o readlineh $compile_line_extra $link_line_extra 2>/dev/null >/dev/null");
- # delete test files
- unlink 'readlineh';
- unlink 'readlineh.cpp';
- return $r == 0; # compilation succeeded
-}
-sub check_db_lib
-{
- my ($h,$db) = @_;
- open TESTDBLIB,">testdblib.cpp" or die "Can't open db test file for writing";
- print TESTDBLIB <<__E;
-#include <$h>
-int main(int argc, char *argv[])
-{
- DB *dbp = 0;
- dbp = dbopen(0, 0, 0, DB_HASH, 0);
- dbp->close(dbp);
- DBT data;
- dbp->put(dbp, &data, &data, 0);
- dbp->get(dbp, &data, &data, 0);
- return 0;
-}
-__E
- close TESTDBLIB;
- # attempt to compile
- my $r = system("g++ testdblib.cpp -l$db -o testdblib $compile_line_extra $link_line_extra 2>/dev/null >/dev/null");
- # delete test files
- unlink 'testdblib';
- unlink 'testdblib.cpp';
- return $r == 0; # compilation succeeded
-}
-# ---- LINUX end --------------------------------------------------------------------------
# print "Flag: $_\n" for(keys %env_flags);
-# check the version of openssl installed
-if(!exists $env_flags{'OPENSSL_OK'})
-{
- # failed somehow...
-
- # is an old version present?
- my $old_version = (exists $env_flags{'OLD_OPENSSL_OK'});
-
- if(!$old_version && !-e '/usr/include/openssl/evp.h')
- {
- # headers not installed?
- print "\n\nERROR: OpenSSL library and headers need to be installed.\n\nSee documentation on web site if you need to add extra search paths.\n\n";
- exit(1);
- }
- else
- {
- if($old_version)
- {
- if($old_version_of_openssl_ok)
- {
- print "\n\nWARNING: Configuring for old version of OpenSSL.\nPerformance will be lower than with version 0.9.7\n\n";
- $compile_line_extra .= '-DPLATFORM_OLD_OPENSSL ';
- }
- else
- {
- # tell user how they might try anyway with an old version of openssl
- print <<__E;
-
-===============================================================================
-
-You appear to have a version of OpenSSL installed which is less than 0.9.7.
-
-It is possible to configure to use this old version, but performance will be
-lower than if you have 0.9.7 -- the later version is recommended.
-
-If you wish to use this old version, repeat the configuration with the extra
-argument 'allow-old-openssl', like this:
-
- ./configure allow-old-openssl
-
-* Please do not distribute binary packages with this option enabled.
-
-* Please do not distribute ports which set this option by default.
-
-IMPORTANT: Support for older versions of OpenSSL should be considered
-experimental. It is not recommended for production use, but provided to allow
-easier evaluation of this software before installing the latest OpenSSL.
-
-===============================================================================
-
-__E
- exit(1);
- }
- }
- else
- {
- print "\n\nERROR: You need to install OpenSSL, preferably at least version 0.9.7.\n\n";
- print "If you believe you have installed OpenSSL, check that the headers are installed\nas well ('dev' packages?)\n\nSee documentation on web site if you need to add extra search paths.\n\n";
- exit(1);
- }
- }
-}
-
-
-# finished checking the environment
-print "done\n\n";
-
-
# seed autogen code
print "Seeding autogen code...\n";
open FINDAUTOGEN,"find . -follow -name Makefile.extra |" or die "Can't use find for locating files";
@@ -397,14 +113,6 @@ close FL;
# extra platform defines
my $extra_platform_defines = '';
-if($gcc_v3 && !$gcc_v4)
-{
- $extra_platform_defines .= ' -DPLATFORM_GCC3'
-}
-if($gcc_v4)
-{
- $extra_platform_defines .= ' -DPLATFORM_GCC4'
-}
# read in module definitions file, and any files it includes
my @modules_files;
@@ -758,13 +466,13 @@ CXX = g++
AR = ar
RANLIB = ranlib
.ifdef RELEASE
-CXXFLAGS = -DNDEBUG -O2 -Wall $include_paths -D$platform_define -D$platform_cpu$extra_platform_defines -DBOX_VERSION="\\"$product_version\\""
+CXXFLAGS = -DNDEBUG -O2 -Wall $include_paths $extra_platform_defines -DBOX_VERSION="\\"$product_version\\""
OUTBASE = ../../release
OUTDIR = ../../release/$mod
DEPENDMAKEFLAGS = -D RELEASE
VARIENT = RELEASE
.else
-CXXFLAGS = -g -Wall $include_paths -D$platform_define -D$platform_cpu$extra_platform_defines -DBOX_VERSION="\\"$product_version\\""
+CXXFLAGS = -g -Wall $include_paths $extra_platform_defines -DBOX_VERSION="\\"$product_version\\""
OUTBASE = ../../debug
OUTDIR = ../../debug/$mod
DEPENDMAKEFLAGS =
@@ -939,7 +647,7 @@ __E
}
# link line...
- print MAKE "\t\$(CXX) $link_line_extra -o $end_target $o_file_list $lib_files$lo\n";
+ print MAKE "\t\$(CXX) $link_line_extra -o $end_target $o_file_list $lib_files$lo $platform_lib_files\n";
}
# tests need to copy the test file over
if($type eq 'test')
@@ -1006,8 +714,6 @@ __E
print "\nType 'cd <module_dir>; $make_command' to build a module\n\n";
-print $test_failure_text;
-
if($modules_omitted)
{
print "\nNOTE: Some modules have been omitted on this platform\n\n"
@@ -1062,65 +768,3 @@ sub ignore_module
{
exists $env_flags{'IGNORE_'.$_[0]}
}
-
-# how to run a test
-sub do_test
-{
- my %t = @_;
-
- print $t{'Name'},':';
- open TEST_CODE,">envtest.cpp" or die "Can't open envtest.cpp for writing";
- print TEST_CODE $t{'Code'};
- close TEST_CODE;
- my $result = (system("g++ envtest.cpp ".$t{'TestCompileFlags'}." -o envtest $compile_line_extra $link_line_extra 2>/dev/null >/dev/null") == 0);
- if($result && exists $t{'RunCode'})
- {
- $result = 0 unless (system('./envtest') == 0);
- }
- unlink 'envtest.cpp';
- unlink 'envtest';
- print $result?" yes\n":" no\n";
- if($result)
- {
- # success
- if(exists $t{'SuccessFlags'})
- {
- for(@{$t{'SuccessFlags'}})
- {
- my ($k,$v) = split /=>/,$_;
- $v = 1 if $v eq '';
- $env_flags{$k} = $v
- }
- }
- $compile_line_extra .= $t{'SuccessCompileFlags'}.' ' if exists $t{'SuccessCompileFlags'};
- $link_line_extra .= $t{'SuccessLinkFlags'}.' ' if exists $t{'SuccessLinkFlags'};
- }
- else
- {
- # aborting failure?
- if(exists $t{'AbortOnFailure'})
- {
- print $t{'FailureText'};
- print "\nAborting configuration, cannot build in this environment.\n";
- exit(1);
- }
-
- # failure
- if(exists $t{'FailureFlags'})
- {
- for(@{$t{'FailureFlags'}})
- {
- my ($k,$v) = split /=>/,$_;
- $v = 1 if $v eq '';
- $env_flags{$k} = $v
- }
- }
- $compile_line_extra .= $t{'FailureCompileFlags'}.' ' if exists $t{'FailureCompileFlags'};
- $link_line_extra .= $t{'FailureLinkFlags'}.' ' if exists $t{'FailureLinkFlags'};
- $test_failure_text .= $t{'FailureText'} if exists $t{'FailureText'};
- }
- $result
-}
-
-
-
diff --git a/lib/backupclient/BackupClientCryptoKeys.cpp b/lib/backupclient/BackupClientCryptoKeys.cpp
index 015dadd2..46b77f0a 100755
--- a/lib/backupclient/BackupClientCryptoKeys.cpp
+++ b/lib/backupclient/BackupClientCryptoKeys.cpp
@@ -54,7 +54,7 @@ void BackupClientCryptoKeys_Setup(const char *KeyMaterialFilename)
// Tell the files how to encrypt
BackupStoreFile::SetBlowfishKeys(KeyMaterial + BACKUPCRYPTOKEYS_ATTRIBUTES_KEY_START, BACKUPCRYPTOKEYS_ATTRIBUTES_KEY_LENGTH,
KeyMaterial + BACKUPCRYPTOKEYS_FILE_BLOCK_ENTRY_KEY_START, BACKUPCRYPTOKEYS_FILE_BLOCK_ENTRY_KEY_LENGTH);
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
// Use AES where available
BackupStoreFile::SetAESKey(KeyMaterial + BACKUPCRYPTOKEYS_FILE_AES_KEY_START, BACKUPCRYPTOKEYS_FILE_AES_KEY_LENGTH);
#endif
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp
index 24e90697..adc3a91c 100755
--- a/lib/backupclient/BackupClientFileAttributes.cpp
+++ b/lib/backupclient/BackupClientFileAttributes.cpp
@@ -17,7 +17,7 @@
#include <algorithm>
#include <new>
#include <vector>
-#ifdef PLATFORM_HAVE_XATTR
+#ifdef HAVE_SYS_XATTR_H
#include <cerrno>
#include <sys/xattr.h>
#endif
@@ -34,7 +34,7 @@
#include "MemLeakFindOn.h"
// set packing to one byte
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "BeginStructPackForWire.h"
#else
BEGIN_STRUCTURE_PACKING_FOR_WIRE
@@ -73,7 +73,7 @@ typedef struct
} attributeHashData;
// Use default packing
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "EndStructPackForWire.h"
#else
END_STRUCTURE_PACKING_FOR_WIRE
@@ -359,12 +359,12 @@ void BackupClientFileAttributes::FillAttributes(StreamableMemBlock &outputBlock,
}
else
{
- pattr->ModificationTime = hton64(FileModificationTime(st));
- pattr->AttrModificationTime = hton64(FileAttrModificationTime(st));
+ pattr->ModificationTime = box_hton64(FileModificationTime(st));
+ pattr->AttrModificationTime = box_hton64(FileAttrModificationTime(st));
}
pattr->Mode = htons(st.st_mode);
-#ifdef PLATFORM_stat_NO_st_flags
+#ifndef HAVE_STRUCT_STAT_ST_FLAGS
pattr->UserDefinedFlags = 0;
pattr->FileGenerationNumber = 0;
#else
@@ -413,7 +413,7 @@ void BackupClientFileAttributes::FillAttributesLink(StreamableMemBlock &outputBl
// --------------------------------------------------------------------------
void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBlock, const char *Filename)
{
-#ifdef PLATFORM_HAVE_XATTR
+#ifdef HAVE_SYS_XATTR_H
int listBufferSize = 1000;
char* list = new char[listBufferSize];
@@ -587,7 +587,7 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename) const
// If working as root, set user IDs
if(::geteuid() == 0)
{
- #ifdef PLATFORM_LCHOWN_NOT_SUPPORTED
+ #ifndef HAVE_LCHOWN
// only if not a link, can't set their owner on this platform
if((mode & S_IFMT) != S_IFLNK)
{
@@ -617,7 +617,7 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename) const
}
// Set modification time?
- box_time_t modtime = ntoh64(pattr->ModificationTime);
+ box_time_t modtime = box_ntoh64(pattr->ModificationTime);
if(modtime != 0)
{
// Work out times as timevals
@@ -718,7 +718,7 @@ void BackupClientFileAttributes::EnsureClearAvailable() const
// --------------------------------------------------------------------------
void BackupClientFileAttributes::WriteExtendedAttr(const char *Filename, int xattrOffset) const
{
-#ifdef PLATFORM_HAVE_XATTR
+#ifdef HAVE_SYS_XATTR_H
const char* buffer = static_cast<char*>(mpClearAttributes->GetBuffer());
u_int32_t xattrBlockLength = 0;
diff --git a/lib/backupclient/BackupStoreDirectory.cpp b/lib/backupclient/BackupStoreDirectory.cpp
index 31fed78d..6b5a55d1 100755
--- a/lib/backupclient/BackupStoreDirectory.cpp
+++ b/lib/backupclient/BackupStoreDirectory.cpp
@@ -19,7 +19,7 @@
#include "MemLeakFindOn.h"
// set packing to one byte
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "BeginStructPackForWire.h"
#else
BEGIN_STRUCTURE_PACKING_FOR_WIRE
@@ -59,7 +59,7 @@ typedef struct
} en_StreamFormatDepends;
// Use default packing
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "EndStructPackForWire.h"
#else
END_STRUCTURE_PACKING_FOR_WIRE
@@ -135,9 +135,9 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout)
}
// Get data
- mObjectID = ntoh64(hdr.mObjectID);
- mContainerID = ntoh64(hdr.mContainerID);
- mAttributesModTime = ntoh64(hdr.mAttributesModTime);
+ mObjectID = box_ntoh64(hdr.mObjectID);
+ mContainerID = box_ntoh64(hdr.mContainerID);
+ mAttributesModTime = box_ntoh64(hdr.mAttributesModTime);
// Options
int32_t options = ntohl(hdr.mOptionsPresent);
@@ -231,9 +231,9 @@ void BackupStoreDirectory::WriteToStream(IOStream &rStream, int16_t FlagsMustBeS
dir_StreamFormat hdr;
hdr.mMagicValue = htonl(OBJECTMAGIC_DIR_MAGIC_VALUE);
hdr.mNumEntries = htonl(count);
- hdr.mObjectID = hton64(mObjectID);
- hdr.mContainerID = hton64(mContainerID);
- hdr.mAttributesModTime = hton64(mAttributesModTime);
+ hdr.mObjectID = box_hton64(mObjectID);
+ hdr.mContainerID = box_hton64(mContainerID);
+ hdr.mAttributesModTime = box_hton64(mAttributesModTime);
hdr.mOptionsPresent = htonl(options);
// Write header
@@ -480,10 +480,10 @@ void BackupStoreDirectory::Entry::ReadFromStream(IOStream &rStream, int Timeout)
mAttributes.ReadFromStream(rStream, Timeout);
// Store the rest of the bits
- mModificationTime = ntoh64(entry.mModificationTime);
- mObjectID = ntoh64(entry.mObjectID);
- mSizeInBlocks = ntoh64(entry.mSizeInBlocks);
- mAttributesHash = ntoh64(entry.mAttributesHash);
+ mModificationTime = box_ntoh64(entry.mModificationTime);
+ mObjectID = box_ntoh64(entry.mObjectID);
+ mSizeInBlocks = box_ntoh64(entry.mSizeInBlocks);
+ mAttributesHash = box_ntoh64(entry.mAttributesHash);
mFlags = ntohs(entry.mFlags);
mName = name;
}
@@ -501,10 +501,10 @@ void BackupStoreDirectory::Entry::WriteToStream(IOStream &rStream) const
{
// Build a structure
en_StreamFormat entry;
- entry.mModificationTime = hton64(mModificationTime);
- entry.mObjectID = hton64(mObjectID);
- entry.mSizeInBlocks = hton64(mSizeInBlocks);
- entry.mAttributesHash = hton64(mAttributesHash);
+ entry.mModificationTime = box_hton64(mModificationTime);
+ entry.mObjectID = box_hton64(mObjectID);
+ entry.mSizeInBlocks = box_hton64(mSizeInBlocks);
+ entry.mAttributesHash = box_hton64(mAttributesHash);
entry.mFlags = htons(mFlags);
// Write it
@@ -536,8 +536,8 @@ void BackupStoreDirectory::Entry::ReadFromStreamDependencyInfo(IOStream &rStream
}
// Store the data
- mDependsNewer = ntoh64(depends.mDependsNewer);
- mDependsOlder = ntoh64(depends.mDependsOlder);
+ mDependsNewer = box_ntoh64(depends.mDependsNewer);
+ mDependsOlder = box_ntoh64(depends.mDependsOlder);
}
@@ -553,8 +553,8 @@ void BackupStoreDirectory::Entry::WriteToStreamDependencyInfo(IOStream &rStream)
{
// Build structure
en_StreamFormatDepends depends;
- depends.mDependsNewer = hton64(mDependsNewer);
- depends.mDependsOlder = hton64(mDependsOlder);
+ depends.mDependsNewer = box_hton64(mDependsNewer);
+ depends.mDependsOlder = box_hton64(mDependsOlder);
// Write
rStream.Write(&depends, sizeof(depends));
}
diff --git a/lib/backupclient/BackupStoreFile.cpp b/lib/backupclient/BackupStoreFile.cpp
index e1a8fde7..d31b53bb 100755
--- a/lib/backupclient/BackupStoreFile.cpp
+++ b/lib/backupclient/BackupStoreFile.cpp
@@ -154,7 +154,7 @@ bool BackupStoreFile::VerifyEncodedFileFormat(IOStream &rFile, int64_t *pDiffFro
int64_t headerEnd = rFile.GetPosition();
// Get number of blocks
- int64_t numBlocks = ntoh64(hdr.mNumBlocks);
+ int64_t numBlocks = box_ntoh64(hdr.mNumBlocks);
// Calculate where the block index will be, check it's reasonable
int64_t blockIndexLoc = fileSize - ((numBlocks * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader));
@@ -179,7 +179,7 @@ bool BackupStoreFile::VerifyEncodedFileFormat(IOStream &rFile, int64_t *pDiffFro
&& ntohl(blkhdr.mMagicValue) != OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V0
#endif
)
- || (int64_t)ntoh64(blkhdr.mNumBlocks) != numBlocks)
+ || (int64_t)box_ntoh64(blkhdr.mNumBlocks) != numBlocks)
{
// Bad header -- either magic value or number of blocks is wrong
return false;
@@ -201,7 +201,7 @@ bool BackupStoreFile::VerifyEncodedFileFormat(IOStream &rFile, int64_t *pDiffFro
}
// Check size and location
- int64_t blkSize = ntoh64(blk.mEncodedSize);
+ int64_t blkSize = box_ntoh64(blk.mEncodedSize);
if(blkSize <= 0)
{
// Mark that this file references another file
@@ -228,7 +228,7 @@ bool BackupStoreFile::VerifyEncodedFileFormat(IOStream &rFile, int64_t *pDiffFro
}
// Check that if another block is references, then the ID is there, and if one isn't there is no ID.
- int64_t otherID = ntoh64(blkhdr.mOtherFileID);
+ int64_t otherID = box_ntoh64(blkhdr.mOtherFileID);
if((otherID != 0 && blockFromOtherFileReferenced == false)
|| (otherID == 0 && blockFromOtherFileReferenced == true))
{
@@ -245,7 +245,7 @@ bool BackupStoreFile::VerifyEncodedFileFormat(IOStream &rFile, int64_t *pDiffFro
// Does the caller want the container ID?
if(pContainerIDOut)
{
- *pContainerIDOut = ntoh64(hdr.mContainerID);
+ *pContainerIDOut = box_ntoh64(hdr.mContainerID);
}
// Passes all tests
@@ -494,7 +494,7 @@ void BackupStoreFile::DecodedStream::Setup(const BackupClientFileAttributes *pAl
int64_t endOfHeaderPos = mrEncodedFile.GetPosition();
// Work out where the index is
- int64_t numBlocks = ntoh64(hdr.mNumBlocks);
+ int64_t numBlocks = box_ntoh64(hdr.mNumBlocks);
int64_t blockHeaderPos = fileSize - ((numBlocks * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader));
// Seek to that position
@@ -508,7 +508,7 @@ void BackupStoreFile::DecodedStream::Setup(const BackupClientFileAttributes *pAl
}
// Check view of blocks from block header and file header match
- if(mNumBlocks != (int64_t)ntoh64(hdr.mNumBlocks))
+ if(mNumBlocks != (int64_t)box_ntoh64(hdr.mNumBlocks))
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
@@ -523,7 +523,7 @@ void BackupStoreFile::DecodedStream::Setup(const BackupClientFileAttributes *pAl
for(int64_t e = 0; e < mNumBlocks; e++)
{
// Get the clear and encoded size
- int32_t encodedSize = ntoh64(entry[e].mEncodedSize);
+ int32_t encodedSize = box_ntoh64(entry[e].mEncodedSize);
ASSERT(encodedSize > 0);
// Larger?
@@ -587,10 +587,10 @@ void BackupStoreFile::DecodedStream::ReadBlockIndex(bool MagicAlreadyRead)
}
// Get the number of blocks out of the header
- mNumBlocks = ntoh64(blkhdr.mNumBlocks);
+ mNumBlocks = box_ntoh64(blkhdr.mNumBlocks);
// Read the IV base
- mEntryIVBase = ntoh64(blkhdr.mEntryIVBase);
+ mEntryIVBase = box_ntoh64(blkhdr.mEntryIVBase);
// Load the block entries in?
if(mNumBlocks > 0)
@@ -673,7 +673,7 @@ int BackupStoreFile::DecodedStream::Read(void *pBuffer, int NBytes, int Timeout)
// Get the size from the block index
const file_BlockIndexEntry *entry = (file_BlockIndexEntry *)mpBlockIndex;
- int32_t encodedSize = ntoh64(entry[mCurrentBlock].mEncodedSize);
+ int32_t encodedSize = box_ntoh64(entry[mCurrentBlock].mEncodedSize);
if(encodedSize <= 0)
{
// The caller is attempting to decode a file which is the direct result of a diff
@@ -697,7 +697,7 @@ int BackupStoreFile::DecodedStream::Read(void *pBuffer, int NBytes, int Timeout)
iv += mCurrentBlock;
// Convert to network byte order before encrypting with it, so that restores work on
// platforms with different endiannesses.
- iv = hton64(iv);
+ iv = box_hton64(iv);
sBlowfishDecryptBlockEntry.SetIV(&iv);
// Decrypt the encrypted section
@@ -865,7 +865,7 @@ void BackupStoreFile::SetBlowfishKeys(const void *pKey, int KeyLength, const voi
}
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
// --------------------------------------------------------------------------
//
// Function
@@ -1036,7 +1036,7 @@ int BackupStoreFile::DecodeChunk(const void *Encoded, int EncodedSize, void *Out
THROW_EXCEPTION(BackupStoreException, ChunkHasUnknownEncoding)
}
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
// Choose cipher
CipherContext &cipher((encodingType == HEADER_AES_ENCODING)?sAESDecrypt:sBlowfishDecrypt);
#else
@@ -1177,7 +1177,7 @@ std::auto_ptr<IOStream> BackupStoreFile::ReorderFileToStreamOrder(IOStream *pStr
}
// Get number of blocks
- int64_t numBlocks = ntoh64(hdr.mNumBlocks);
+ int64_t numBlocks = box_ntoh64(hdr.mNumBlocks);
// Calculate where the block index will be, check it's reasonable
int64_t blockIndexSize = ((numBlocks * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader));
@@ -1277,8 +1277,8 @@ bool BackupStoreFile::CompareFileContentsAgainstBlockIndex(const char *Filename,
#endif
// Get basic information
- int64_t numBlocks = ntoh64(hdr.mNumBlocks);
- uint64_t entryIVBase = ntoh64(hdr.mEntryIVBase);
+ int64_t numBlocks = box_ntoh64(hdr.mNumBlocks);
+ uint64_t entryIVBase = box_ntoh64(hdr.mEntryIVBase);
//TODO: Verify that these sizes look reasonable
@@ -1303,7 +1303,7 @@ bool BackupStoreFile::CompareFileContentsAgainstBlockIndex(const char *Filename,
// Calculate IV for this entry
uint64_t iv = entryIVBase;
iv += b;
- iv = hton64(iv);
+ iv = box_hton64(iv);
#ifndef BOX_DISABLE_BACKWARDS_COMPATIBILITY_BACKUPSTOREFILE
if(isOldVersion)
{
diff --git a/lib/backupclient/BackupStoreFile.h b/lib/backupclient/BackupStoreFile.h
index de37e8c8..627de4ce 100755
--- a/lib/backupclient/BackupStoreFile.h
+++ b/lib/backupclient/BackupStoreFile.h
@@ -113,7 +113,7 @@ public:
// Crypto setup
static void SetBlowfishKeys(const void *pKey, int KeyLength, const void *pBlockEntryKey, int BlockEntryKeyLength);
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
static void SetAESKey(const void *pKey, int KeyLength);
#endif
diff --git a/lib/backupclient/BackupStoreFileCmbDiff.cpp b/lib/backupclient/BackupStoreFileCmbDiff.cpp
index 039b00eb..1a88fa3f 100644
--- a/lib/backupclient/BackupStoreFileCmbDiff.cpp
+++ b/lib/backupclient/BackupStoreFileCmbDiff.cpp
@@ -63,7 +63,7 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
// Record position
diff1DataStarts = rDiff1.GetPosition();
// Skip to index
- rDiff1.Seek(0 - (((ntoh64(diff1Hdr.mNumBlocks)) * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader)), IOStream::SeekType_End);
+ rDiff1.Seek(0 - (((box_ntoh64(diff1Hdr.mNumBlocks)) * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader)), IOStream::SeekType_End);
}
// Read the index of the first diff
@@ -77,7 +77,7 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
- int64_t diff1NumBlocks = ntoh64(diff1IdxHdr.mNumBlocks);
+ int64_t diff1NumBlocks = box_ntoh64(diff1IdxHdr.mNumBlocks);
// Allocate some memory
int64_t *diff1BlockStartPositions = (int64_t*)::malloc((diff1NumBlocks + 1) * sizeof(int64_t));
if(diff1BlockStartPositions == 0)
@@ -106,7 +106,7 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
}
// Where's the block?
- int64_t blockEn = ntoh64(e.mEncodedSize);
+ int64_t blockEn = box_ntoh64(e.mEncodedSize);
if(blockEn <= 0)
{
// Just store the negated block number
@@ -157,7 +157,7 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
- int64_t diff2NumBlocks = ntoh64(diff2IdxHdr.mNumBlocks);
+ int64_t diff2NumBlocks = box_ntoh64(diff2IdxHdr.mNumBlocks);
int64_t diff2IndexEntriesStart = rDiff2b.GetPosition();
// Then read all the entries
@@ -177,7 +177,7 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
bool fromFileDiff1 = false;
// Where's the block?
- int64_t blockEn = ntoh64(e.mEncodedSize);
+ int64_t blockEn = box_ntoh64(e.mEncodedSize);
if(blockEn > 0)
{
// Block is present in this file -- copy to out
@@ -274,7 +274,7 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
}
// Where's the block?
- int64_t blockEn = ntoh64(e.mEncodedSize);
+ int64_t blockEn = box_ntoh64(e.mEncodedSize);
// If it's not in this file, it needs modification...
if(blockEn <= 0)
@@ -292,12 +292,12 @@ void BackupStoreFile::CombineDiffs(IOStream &rDiff1, IOStream &rDiff2, IOStream
ASSERT(nb <= diff1NumBlocks);
}
int64_t size = diff1BlockStartPositions[nb] - diff1BlockStartPositions[blockIndex];
- e.mEncodedSize = hton64(size);
+ e.mEncodedSize = box_hton64(size);
}
else
{
// Block in the original file, use translated value
- e.mEncodedSize = hton64(diff1BlockStartPositions[blockIndex]);
+ e.mEncodedSize = box_hton64(diff1BlockStartPositions[blockIndex]);
}
}
diff --git a/lib/backupclient/BackupStoreFileCmbIdx.cpp b/lib/backupclient/BackupStoreFileCmbIdx.cpp
index 253001c2..c8bcc3b9 100644
--- a/lib/backupclient/BackupStoreFileCmbIdx.cpp
+++ b/lib/backupclient/BackupStoreFileCmbIdx.cpp
@@ -156,10 +156,10 @@ void BSFCombinedIndexStream::Initialise(IOStream &rFrom)
}
// Read relevant data.
- mNumEntriesToGo = ntoh64(mHeader.mNumBlocks);
+ mNumEntriesToGo = box_ntoh64(mHeader.mNumBlocks);
// Adjust a bit to reflect the fact it's no longer a diff
- mHeader.mOtherFileID = hton64(0);
+ mHeader.mOtherFileID = box_hton64(0);
// Now look at the from file: Read header
file_BlockIndexHeader fromHdr;
@@ -173,7 +173,7 @@ void BSFCombinedIndexStream::Initialise(IOStream &rFrom)
}
// Then... allocate memory for the list of sizes
- mNumEntriesInFromFile = ntoh64(fromHdr.mNumBlocks);
+ mNumEntriesInFromFile = box_ntoh64(fromHdr.mNumBlocks);
mFromBlockSizes = (int64_t*)::malloc(mNumEntriesInFromFile * sizeof(int64_t));
if(mFromBlockSizes == 0)
{
@@ -190,7 +190,7 @@ void BSFCombinedIndexStream::Initialise(IOStream &rFrom)
}
// Check that the from file isn't a delta in itself
- if(ntoh64(e.mEncodedSize) <= 0)
+ if(box_ntoh64(e.mEncodedSize) <= 0)
{
THROW_EXCEPTION(BackupStoreException, OnCombineFromFileIsIncomplete)
}
@@ -256,7 +256,7 @@ int BSFCombinedIndexStream::Read(void *pBuffer, int NBytes, int Timeout)
}
// Does this need adjusting?
- int s = ntoh64(poutput[b].mEncodedSize);
+ int s = box_ntoh64(poutput[b].mEncodedSize);
if(s <= 0)
{
// A reference to a block in the from file
diff --git a/lib/backupclient/BackupStoreFileCombine.cpp b/lib/backupclient/BackupStoreFileCombine.cpp
index 562a32d9..baa331f0 100755
--- a/lib/backupclient/BackupStoreFileCombine.cpp
+++ b/lib/backupclient/BackupStoreFileCombine.cpp
@@ -94,7 +94,7 @@ void BackupStoreFile::CombineFile(IOStream &rDiff, IOStream &rDiff2, IOStream &r
}
// Allocate memory for the block index of the From file
- int64_t fromNumBlocks = ntoh64(fromHdr.mNumBlocks);
+ int64_t fromNumBlocks = box_ntoh64(fromHdr.mNumBlocks);
// NOTE: An extra entry is required so that the length of the last block can be calculated
FromIndexEntry *pFromIndex = (FromIndexEntry*)::malloc((fromNumBlocks+1) * sizeof(FromIndexEntry));
if(pFromIndex == 0)
@@ -110,7 +110,7 @@ void BackupStoreFile::CombineFile(IOStream &rDiff, IOStream &rDiff2, IOStream &r
// Read in the block index of the Diff file in small chunks, and output data
// for each block, either from this file, or the other file.
- int64_t diffNumBlocks = ntoh64(hdr.mNumBlocks);
+ int64_t diffNumBlocks = box_ntoh64(hdr.mNumBlocks);
CopyData(rDiff /* positioned at start of data */, rDiff2, diffNumBlocks, rFrom, pFromIndex, fromNumBlocks, rOut);
// Read in the block index again, and output the new block index, simply
@@ -160,7 +160,7 @@ static void LoadFromIndex(IOStream &rFrom, FromIndexEntry *pIndex, int64_t NumEn
THROW_EXCEPTION(BackupStoreException, FailedToReadBlockOnCombine)
}
if(ntohl(blkhdr.mMagicValue) != OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1
- || (int64_t)ntoh64(blkhdr.mNumBlocks) != NumEntries)
+ || (int64_t)box_ntoh64(blkhdr.mNumBlocks) != NumEntries)
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
@@ -179,7 +179,7 @@ static void LoadFromIndex(IOStream &rFrom, FromIndexEntry *pIndex, int64_t NumEn
pIndex[b].mFilePosition = filePos;
// Encoded size?
- int64_t encodedSize = ntoh64(en.mEncodedSize);
+ int64_t encodedSize = box_ntoh64(en.mEncodedSize);
// Check that the block is actually there
if(encodedSize <= 0)
{
@@ -220,7 +220,7 @@ static void CopyData(IOStream &rDiffData, IOStream &rDiffIndex, int64_t DiffNumB
THROW_EXCEPTION(BackupStoreException, FailedToReadBlockOnCombine)
}
if(ntohl(diffBlkhdr.mMagicValue) != OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1
- || (int64_t)ntoh64(diffBlkhdr.mNumBlocks) != DiffNumBlocks)
+ || (int64_t)box_ntoh64(diffBlkhdr.mNumBlocks) != DiffNumBlocks)
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
@@ -245,7 +245,7 @@ static void CopyData(IOStream &rDiffData, IOStream &rDiffIndex, int64_t DiffNumB
}
// What's the size value stored in the entry
- int64_t encodedSize = ntoh64(en.mEncodedSize);
+ int64_t encodedSize = box_ntoh64(en.mEncodedSize);
// How much data will be read?
int32_t blockSize = 0;
@@ -362,13 +362,13 @@ static void WriteNewIndex(IOStream &rDiff, int64_t DiffNumBlocks, FromIndexEntry
THROW_EXCEPTION(BackupStoreException, FailedToReadBlockOnCombine)
}
if(ntohl(diffBlkhdr.mMagicValue) != OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1
- || (int64_t)ntoh64(diffBlkhdr.mNumBlocks) != DiffNumBlocks)
+ || (int64_t)box_ntoh64(diffBlkhdr.mNumBlocks) != DiffNumBlocks)
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
// Write it out with a blanked out other file ID
- diffBlkhdr.mOtherFileID = hton64(0);
+ diffBlkhdr.mOtherFileID = box_hton64(0);
rOut.Write(&diffBlkhdr, sizeof(diffBlkhdr));
// Rewrite the index
@@ -381,7 +381,7 @@ static void WriteNewIndex(IOStream &rDiff, int64_t DiffNumBlocks, FromIndexEntry
}
// What's the size value stored in the entry
- int64_t encodedSize = ntoh64(en.mEncodedSize);
+ int64_t encodedSize = box_ntoh64(en.mEncodedSize);
// Need to adjust it?
if(encodedSize <= 0)
@@ -396,7 +396,7 @@ static void WriteNewIndex(IOStream &rDiff, int64_t DiffNumBlocks, FromIndexEntry
// Calculate size. This operation is safe because of the extra entry at the end
int32_t blockSize = pFromIndex[blockIdx + 1].mFilePosition - pFromIndex[blockIdx].mFilePosition;
// Then replace entry
- en.mEncodedSize = hton64(((uint64_t)blockSize));
+ en.mEncodedSize = box_hton64(((uint64_t)blockSize));
}
// Write entry
diff --git a/lib/backupclient/BackupStoreFileCryptVar.cpp b/lib/backupclient/BackupStoreFileCryptVar.cpp
index eeed64e4..e826de4e 100755
--- a/lib/backupclient/BackupStoreFileCryptVar.cpp
+++ b/lib/backupclient/BackupStoreFileCryptVar.cpp
@@ -17,7 +17,7 @@
CipherContext BackupStoreFileCryptVar::sBlowfishEncrypt;
CipherContext BackupStoreFileCryptVar::sBlowfishDecrypt;
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
CipherContext BackupStoreFileCryptVar::sAESEncrypt;
CipherContext BackupStoreFileCryptVar::sAESDecrypt;
#endif
diff --git a/lib/backupclient/BackupStoreFileCryptVar.h b/lib/backupclient/BackupStoreFileCryptVar.h
index 00a34f71..566813c8 100755
--- a/lib/backupclient/BackupStoreFileCryptVar.h
+++ b/lib/backupclient/BackupStoreFileCryptVar.h
@@ -22,7 +22,7 @@ namespace BackupStoreFileCryptVar
extern CipherContext sBlowfishEncrypt;
extern CipherContext sBlowfishDecrypt;
// Use AES when available
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
extern CipherContext sAESEncrypt;
extern CipherContext sAESDecrypt;
#endif
diff --git a/lib/backupclient/BackupStoreFileDiff.cpp b/lib/backupclient/BackupStoreFileDiff.cpp
index 22395151..3699eb49 100755
--- a/lib/backupclient/BackupStoreFileDiff.cpp
+++ b/lib/backupclient/BackupStoreFileDiff.cpp
@@ -105,7 +105,7 @@ void BackupStoreFile::MoveStreamPositionToBlockIndex(IOStream &rStream)
}
// Work out where the index is
- int64_t numBlocks = ntoh64(hdr.mNumBlocks);
+ int64_t numBlocks = box_ntoh64(hdr.mNumBlocks);
int64_t blockHeaderPosFromEnd = ((numBlocks * sizeof(file_BlockIndexEntry)) + sizeof(file_BlockIndexHeader));
// Sanity check
@@ -298,7 +298,7 @@ static void LoadIndex(IOStream &rBlockIndex, int64_t ThisID, BlocksAvailableEntr
}
// Check that we're not trying to diff against a file which references blocks from another file
- if(((int64_t)ntoh64(hdr.mOtherFileID)) != 0)
+ if(((int64_t)box_ntoh64(hdr.mOtherFileID)) != 0)
{
THROW_EXCEPTION(BackupStoreException, CannotDiffAnIncompleteStoreFile)
}
@@ -307,8 +307,8 @@ static void LoadIndex(IOStream &rBlockIndex, int64_t ThisID, BlocksAvailableEntr
rCanDiffFromThis = true;
// Get basic information
- int64_t numBlocks = ntoh64(hdr.mNumBlocks);
- uint64_t entryIVBase = ntoh64(hdr.mEntryIVBase);
+ int64_t numBlocks = box_ntoh64(hdr.mNumBlocks);
+ uint64_t entryIVBase = box_ntoh64(hdr.mEntryIVBase);
//TODO: Verify that these sizes look reasonable
@@ -335,7 +335,7 @@ static void LoadIndex(IOStream &rBlockIndex, int64_t ThisID, BlocksAvailableEntr
uint64_t iv = entryIVBase;
iv += b;
// Network byte order
- iv = hton64(iv);
+ iv = box_hton64(iv);
sBlowfishDecryptBlockEntry.SetIV(&iv);
// Decrypt the encrypted section
@@ -348,7 +348,7 @@ static void LoadIndex(IOStream &rBlockIndex, int64_t ThisID, BlocksAvailableEntr
}
// Check that we're not trying to diff against a file which references blocks from another file
- if(((int64_t)ntoh64(entry.mEncodedSize)) <= 0)
+ if(((int64_t)box_ntoh64(entry.mEncodedSize)) <= 0)
{
THROW_EXCEPTION(BackupStoreException, CannotDiffAnIncompleteStoreFile)
}
diff --git a/lib/backupclient/BackupStoreFileEncodeStream.cpp b/lib/backupclient/BackupStoreFileEncodeStream.cpp
index 20e1fd80..c692f18e 100755
--- a/lib/backupclient/BackupStoreFileEncodeStream.cpp
+++ b/lib/backupclient/BackupStoreFileEncodeStream.cpp
@@ -178,9 +178,9 @@ void BackupStoreFileEncodeStream::Setup(const char *Filename, BackupStoreFileEnc
// Header
file_StreamFormat hdr;
hdr.mMagicValue = htonl(OBJECTMAGIC_FILE_MAGIC_VALUE_V1);
- hdr.mNumBlocks = (mSendData)?(hton64(mTotalBlocks)):(0);
- hdr.mContainerID = hton64(ContainerID);
- hdr.mModificationTime = hton64(modTime);
+ hdr.mNumBlocks = (mSendData)?(box_hton64(mTotalBlocks)):(0);
+ hdr.mContainerID = box_hton64(ContainerID);
+ hdr.mModificationTime = box_hton64(modTime);
// add a bit to make it harder to tell what's going on -- try not to give away too much info about file size
hdr.mMaxBlockClearSize = htonl(maxBlockClearSize + 128);
hdr.mOptions = 0; // no options defined yet
@@ -221,9 +221,9 @@ void BackupStoreFileEncodeStream::Setup(const char *Filename, BackupStoreFileEnc
// Write an empty block index for the symlink
file_BlockIndexHeader blkhdr;
blkhdr.mMagicValue = htonl(OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1);
- blkhdr.mOtherFileID = hton64(0); // not other file ID
- blkhdr.mEntryIVBase = hton64(0);
- blkhdr.mNumBlocks = hton64(0);
+ blkhdr.mOtherFileID = box_hton64(0); // not other file ID
+ blkhdr.mEntryIVBase = box_hton64(0);
+ blkhdr.mNumBlocks = box_hton64(0);
mData.Write(&blkhdr, sizeof(blkhdr));
}
@@ -338,12 +338,12 @@ int BackupStoreFileEncodeStream::Read(void *pBuffer, int NBytes, int Timeout)
file_BlockIndexHeader blkhdr;
blkhdr.mMagicValue = htonl(OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1);
ASSERT(mpRecipe != 0);
- blkhdr.mOtherFileID = hton64(mpRecipe->GetOtherFileID());
- blkhdr.mNumBlocks = hton64(mTotalBlocks);
+ blkhdr.mOtherFileID = box_hton64(mpRecipe->GetOtherFileID());
+ blkhdr.mNumBlocks = box_hton64(mTotalBlocks);
// Generate the IV base
Random::Generate(&mEntryIVBase, sizeof(mEntryIVBase));
- blkhdr.mEntryIVBase = hton64(mEntryIVBase);
+ blkhdr.mEntryIVBase = box_hton64(mEntryIVBase);
mData.Write(&blkhdr, sizeof(blkhdr));
}
@@ -568,7 +568,7 @@ void BackupStoreFileEncodeStream::StoreBlockIndexEntry(int64_t EncSizeOrBlkIndex
// Then the clear section
file_BlockIndexEntry entry;
- entry.mEncodedSize = hton64(((uint64_t)EncSizeOrBlkIndex));
+ entry.mEncodedSize = box_hton64(((uint64_t)EncSizeOrBlkIndex));
// Then encrypt the encryted section
// Generate the IV from the block number
@@ -580,7 +580,7 @@ void BackupStoreFileEncodeStream::StoreBlockIndexEntry(int64_t EncSizeOrBlkIndex
iv += mAbsoluteBlockNumber;
// Convert to network byte order before encrypting with it, so that restores work on
// platforms with different endiannesses.
- iv = hton64(iv);
+ iv = box_hton64(iv);
sBlowfishEncryptBlockEntry.SetIV(&iv);
// Encode the data
diff --git a/lib/backupclient/BackupStoreFileRevDiff.cpp b/lib/backupclient/BackupStoreFileRevDiff.cpp
index f1dc52d8..509eef61 100644
--- a/lib/backupclient/BackupStoreFileRevDiff.cpp
+++ b/lib/backupclient/BackupStoreFileRevDiff.cpp
@@ -59,7 +59,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
// Build an index of common blocks.
// For each block in the from file, we want to know it's index in the
// diff file. Allocate memory for this information.
- int64_t fromNumBlocks = ntoh64(hdr.mNumBlocks);
+ int64_t fromNumBlocks = box_ntoh64(hdr.mNumBlocks);
int64_t *pfromIndexInfo = (int64_t*)::malloc(fromNumBlocks * sizeof(int64_t));
if(pfromIndexInfo == 0)
{
@@ -96,7 +96,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
}
// And then read in each entry
- int64_t diffNumBlocks = ntoh64(diffIdxHdr.mNumBlocks);
+ int64_t diffNumBlocks = box_ntoh64(diffIdxHdr.mNumBlocks);
for(int64_t b = 0; b < diffNumBlocks; ++b)
{
file_BlockIndexEntry e;
@@ -106,7 +106,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
}
// Where's the block?
- int64_t blockEn = ntoh64(e.mEncodedSize);
+ int64_t blockEn = box_ntoh64(e.mEncodedSize);
if(blockEn > 0)
{
// Block is in the delta file, is ignored for now -- not relevant to rebuilding the from file
@@ -136,7 +136,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
THROW_EXCEPTION(BackupStoreException, CouldntReadEntireStructureFromStream)
}
if(ntohl(fromIdxHdr.mMagicValue) != OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1
- || ntoh64(fromIdxHdr.mOtherFileID) != 0)
+ || box_ntoh64(fromIdxHdr.mOtherFileID) != 0)
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
}
@@ -153,7 +153,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
}
// Get size
- int64_t blockSize = hton64(e.mEncodedSize);
+ int64_t blockSize = box_hton64(e.mEncodedSize);
if(blockSize < 0)
{
THROW_EXCEPTION(BackupStoreException, BadBackupStoreFile)
@@ -204,7 +204,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
}
// Then write the index, modified header first
- fromIdxHdr.mOtherFileID = isCompletelyDifferent?0:(hton64(ObjectIDOfFrom));
+ fromIdxHdr.mOtherFileID = isCompletelyDifferent?0:(box_hton64(ObjectIDOfFrom));
rOut.Write(&fromIdxHdr, sizeof(fromIdxHdr));
// Move to start of index entries
@@ -225,7 +225,7 @@ void BackupStoreFile::ReverseDiffFile(IOStream &rDiff, IOStream &rFrom, IOStream
// Adjust to reflect real block index (remember 0 has a different meaning here)
if(s < 0) ++s;
// Insert
- e.mEncodedSize = hton64(s);
+ e.mEncodedSize = box_hton64(s);
// Write
rOut.Write(&e, sizeof(e));
}
diff --git a/lib/backupclient/BackupStoreFileWire.h b/lib/backupclient/BackupStoreFileWire.h
index 5b1bc819..49e94aa5 100755
--- a/lib/backupclient/BackupStoreFileWire.h
+++ b/lib/backupclient/BackupStoreFileWire.h
@@ -13,7 +13,7 @@
#include "MD5Digest.h"
// set packing to one byte
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "BeginStructPackForWire.h"
#else
BEGIN_STRUCTURE_PACKING_FOR_WIRE
@@ -57,7 +57,7 @@ typedef struct
} file_BlockIndexEntry;
// Use default packing
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "EndStructPackForWire.h"
#else
END_STRUCTURE_PACKING_FOR_WIRE
diff --git a/lib/backupclient/BackupStoreFilename.h b/lib/backupclient/BackupStoreFilename.h
index 4c951b6f..a7b6c437 100755
--- a/lib/backupclient/BackupStoreFilename.h
+++ b/lib/backupclient/BackupStoreFilename.h
@@ -30,7 +30,7 @@ class IOStream;
// If this is changed, change GetClearFilename() back to returning a reference.
#else
typedef std::string BackupStoreFilename_base;
-#endif // PLATFORM_HAVE_STL_MALLOC_ALLOC
+#endif
// --------------------------------------------------------------------------
//
diff --git a/lib/backupclient/BackupStoreObjectDump.cpp b/lib/backupclient/BackupStoreObjectDump.cpp
index caa0e82f..5f902831 100644
--- a/lib/backupclient/BackupStoreObjectDump.cpp
+++ b/lib/backupclient/BackupStoreObjectDump.cpp
@@ -152,9 +152,9 @@ void BackupStoreFile::DumpFile(void *clibFileHandle, bool ToTrace, IOStream &rFi
}
OutputLine(file, ToTrace, "File object.\nContainer ID: %llx\nModification time: %llx\n"\
- "Max block clear size: %d\nOptions: %08x\nNum blocks: %d\n", ntoh64(hdr.mContainerID),
- ntoh64(hdr.mModificationTime), ntohl(hdr.mMaxBlockClearSize), ntohl(hdr.mOptions),
- ntoh64(hdr.mNumBlocks));
+ "Max block clear size: %d\nOptions: %08x\nNum blocks: %d\n", box_ntoh64(hdr.mContainerID),
+ box_ntoh64(hdr.mModificationTime), ntohl(hdr.mMaxBlockClearSize), ntohl(hdr.mOptions),
+ box_ntoh64(hdr.mNumBlocks));
// Read the next two objects
BackupStoreFilename fn;
@@ -178,9 +178,9 @@ void BackupStoreFile::DumpFile(void *clibFileHandle, bool ToTrace, IOStream &rFi
OutputLine(file, ToTrace, "WARNING: Block header doesn't have the correct magic\n");
}
// number of blocks
- int64_t nblocks = ntoh64(bhdr.mNumBlocks);
+ int64_t nblocks = box_ntoh64(bhdr.mNumBlocks);
OutputLine(file, ToTrace, "Other file ID (for block refs): %llx\nNum blocks (in blk hdr): %lld\n",
- ntoh64(bhdr.mOtherFileID), nblocks);
+ box_ntoh64(bhdr.mOtherFileID), nblocks);
// Dump info about each block
OutputLine(file, ToTrace, "======== ===== ==========\n Index Where EncSz/Idx\n");
@@ -193,7 +193,7 @@ void BackupStoreFile::DumpFile(void *clibFileHandle, bool ToTrace, IOStream &rFi
OutputLine(file, ToTrace, "Didn't manage to read block %lld from file\n", b);
continue;
}
- int64_t s = ntoh64(en.mEncodedSize);
+ int64_t s = box_ntoh64(en.mEncodedSize);
if(s > 0)
{
nnew++;
diff --git a/lib/backupstore/BackupStoreCheck2.cpp b/lib/backupstore/BackupStoreCheck2.cpp
index fe91d00d..63e7c008 100644
--- a/lib/backupstore/BackupStoreCheck2.cpp
+++ b/lib/backupstore/BackupStoreCheck2.cpp
@@ -377,7 +377,7 @@ void BackupStoreCheck::InsertObjectIntoDirectory(int64_t ObjectID, int64_t Direc
THROW_EXCEPTION(BackupStoreException, Internal)
}
// This tells us nice things
- modTime = ntoh64(hdr.mModificationTime);
+ modTime = box_ntoh64(hdr.mModificationTime);
// And the filename comes next
objectStoreFilename.ReadFromStream(*file, IOStream::TimeOutInfinite);
}
diff --git a/lib/backupstore/BackupStoreInfo.cpp b/lib/backupstore/BackupStoreInfo.cpp
index a9effe00..ce785dde 100755
--- a/lib/backupstore/BackupStoreInfo.cpp
+++ b/lib/backupstore/BackupStoreInfo.cpp
@@ -19,7 +19,7 @@
#include "MemLeakFindOn.h"
// set packing to one byte
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "BeginStructPackForWire.h"
#else
BEGIN_STRUCTURE_PACKING_FOR_WIRE
@@ -49,7 +49,7 @@ typedef struct
#define INFO_MAGIC_VALUE 0x34832476
// Use default packing
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "EndStructPackForWire.h"
#else
END_STRUCTURE_PACKING_FOR_WIRE
@@ -111,13 +111,13 @@ void BackupStoreInfo::CreateNew(int32_t AccountID, const std::string &rRootDir,
htonl(INFO_MAGIC_VALUE), // mMagicValue
htonl(AccountID), // mAccountID
0, // mClientStoreMarker
- hton64(1), // mLastObjectIDUsed (which is the root directory)
+ box_hton64(1), // mLastObjectIDUsed (which is the root directory)
0, // mBlocksUsed
0, // mBlocksInOldFiles
0, // mBlocksInDeletedFiles
0, // mBlocksInDirectories
- hton64(BlockSoftLimit), // mBlocksSoftLimit
- hton64(BlockHardLimit), // mBlocksHardLimit
+ box_hton64(BlockSoftLimit), // mBlocksSoftLimit
+ box_hton64(BlockHardLimit), // mBlocksHardLimit
0, // mCurrentMarkNumber
0, // mOptionsPresent
0 // mNumberDeletedDirectories
@@ -179,17 +179,17 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const st
info->mReadOnly = ReadOnly;
// Insert info from file
- info->mClientStoreMarker = ntoh64(hdr.mClientStoreMarker);
- info->mLastObjectIDUsed = ntoh64(hdr.mLastObjectIDUsed);
- info->mBlocksUsed = ntoh64(hdr.mBlocksUsed);
- info->mBlocksInOldFiles = ntoh64(hdr.mBlocksInOldFiles);
- info->mBlocksInDeletedFiles = ntoh64(hdr.mBlocksInDeletedFiles);
- info->mBlocksInDirectories = ntoh64(hdr.mBlocksInDirectories);
- info->mBlocksSoftLimit = ntoh64(hdr.mBlocksSoftLimit);
- info->mBlocksHardLimit = ntoh64(hdr.mBlocksHardLimit);
+ info->mClientStoreMarker = box_ntoh64(hdr.mClientStoreMarker);
+ info->mLastObjectIDUsed = box_ntoh64(hdr.mLastObjectIDUsed);
+ info->mBlocksUsed = box_ntoh64(hdr.mBlocksUsed);
+ info->mBlocksInOldFiles = box_ntoh64(hdr.mBlocksInOldFiles);
+ info->mBlocksInDeletedFiles = box_ntoh64(hdr.mBlocksInDeletedFiles);
+ info->mBlocksInDirectories = box_ntoh64(hdr.mBlocksInDirectories);
+ info->mBlocksSoftLimit = box_ntoh64(hdr.mBlocksSoftLimit);
+ info->mBlocksHardLimit = box_ntoh64(hdr.mBlocksHardLimit);
// Load up array of deleted objects
- int64_t numDelObj = ntoh64(hdr.mNumberDeletedDirectories);
+ int64_t numDelObj = box_ntoh64(hdr.mNumberDeletedDirectories);
// Then load them in
if(numDelObj > 0)
@@ -210,7 +210,7 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const st
// Add them
for(int t = 0; t < b; ++t)
{
- info->mDeletedDirectories.push_back(ntoh64(objs[t]));
+ info->mDeletedDirectories.push_back(box_ntoh64(objs[t]));
}
// Number loaded
@@ -298,17 +298,17 @@ void BackupStoreInfo::Save()
info_StreamFormat hdr;
hdr.mMagicValue = htonl(INFO_MAGIC_VALUE);
hdr.mAccountID = htonl(mAccountID);
- hdr.mClientStoreMarker = hton64(mClientStoreMarker);
- hdr.mLastObjectIDUsed = hton64(mLastObjectIDUsed);
- hdr.mBlocksUsed = hton64(mBlocksUsed);
- hdr.mBlocksInOldFiles = hton64(mBlocksInOldFiles);
- hdr.mBlocksInDeletedFiles = hton64(mBlocksInDeletedFiles);
- hdr.mBlocksInDirectories = hton64(mBlocksInDirectories);
- hdr.mBlocksSoftLimit = hton64(mBlocksSoftLimit);
- hdr.mBlocksHardLimit = hton64(mBlocksHardLimit);
+ hdr.mClientStoreMarker = box_hton64(mClientStoreMarker);
+ hdr.mLastObjectIDUsed = box_hton64(mLastObjectIDUsed);
+ hdr.mBlocksUsed = box_hton64(mBlocksUsed);
+ hdr.mBlocksInOldFiles = box_hton64(mBlocksInOldFiles);
+ hdr.mBlocksInDeletedFiles = box_hton64(mBlocksInDeletedFiles);
+ hdr.mBlocksInDirectories = box_hton64(mBlocksInDirectories);
+ hdr.mBlocksSoftLimit = box_hton64(mBlocksSoftLimit);
+ hdr.mBlocksHardLimit = box_hton64(mBlocksHardLimit);
hdr.mCurrentMarkNumber = 0;
hdr.mOptionsPresent = 0;
- hdr.mNumberDeletedDirectories = hton64(mDeletedDirectories.size());
+ hdr.mNumberDeletedDirectories = box_hton64(mDeletedDirectories.size());
// Write header
rf.Write(&hdr, sizeof(hdr));
@@ -329,7 +329,7 @@ void BackupStoreInfo::Save()
for(int t = 0; t < b; ++t)
{
ASSERT(i != mDeletedDirectories.end());
- objs[t] = hton64((*i));
+ objs[t] = box_hton64((*i));
i++;
}
diff --git a/lib/common/BeginStructPackForWire.h b/lib/common/BeginStructPackForWire.h
index f9f8f616..e73bb886 100644
--- a/lib/common/BeginStructPackForWire.h
+++ b/lib/common/BeginStructPackForWire.h
@@ -9,7 +9,7 @@
// No header guard -- this is intentional
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#pragma pack(1)
diff --git a/lib/common/Box.h b/lib/common/Box.h
index 19e78ada..4a76e74e 100755
--- a/lib/common/Box.h
+++ b/lib/common/Box.h
@@ -21,12 +21,13 @@
//#define MEMLEAKFINDER_FULL_MALLOC_MONITORING
#ifndef NDEBUG
- // not available on OpenBSD... oh well.
- //#define SHOW_BACKTRACE_ON_EXCEPTION
+ #ifdef HAVE_EXECINFO_H
+ #define SHOW_BACKTRACE_ON_EXCEPTION
+ #endif
#endif
#ifdef SHOW_BACKTRACE_ON_EXCEPTION
- // include "Utils.h"
+ #include "Utils.h"
#define OPTIONAL_DO_BACKTRACE DumpStackBacktrace();
#else
#define OPTIONAL_DO_BACKTRACE
@@ -126,55 +127,17 @@ inline uint64_t box_swap64(uint64_t x)
(x & 0xff00000000000000LL) >> 56);
}
-// Does the platform provide a built in SWAP64 we can use?
-#ifdef PLATFORM_NO_BUILT_IN_SWAP64
-
- #define hton64(x) box_swap64(x)
- #define ntoh64(x) box_swap64(x)
-
+#ifdef WORDS_BIGENDIAN
+ #define box_hton64(x) (x)
+ #define box_ntoh64(x) (x)
#else
+ #define box_hton64(x) box_swap64(x)
+ #define box_ntoh64(x) box_swap64(x)
+#endif
- #if BYTE_ORDER == BIG_ENDIAN
-
- // Less hassle than trying to find some working things
- // on Darwin PPC
- #define hton64(x) (x)
- #define ntoh64(x) (x)
-
- #else
-
- #ifdef PLATFORM_LINUX
- // On Linux, use some internal kernal stuff to do this
- #include <asm/byteorder.h>
- #define hton64 __cpu_to_be64
- #define ntoh64 __be64_to_cpu
- #else
- #define hton64 htobe64
- #define ntoh64 betoh64
- #endif
-
- // hack to make some of these work
- // version in /usr/include/sys/endian.h doesn't include the 'LL' at the end of the constants
- // provoking complaints from the compiler
- #ifdef __GNUC__
- #undef __swap64gen
- #define __swap64gen(x) __extension__({ \
- u_int64_t __swap64gen_x = (x); \
- \
- (u_int64_t)((__swap64gen_x & 0xff) << 56 | \
- (__swap64gen_x & 0xff00LL) << 40 | \
- (__swap64gen_x & 0xff0000LL) << 24 | \
- (__swap64gen_x & 0xff000000LL) << 8 | \
- (__swap64gen_x & 0xff00000000LL) >> 8 | \
- (__swap64gen_x & 0xff0000000000LL) >> 24 | \
- (__swap64gen_x & 0xff000000000000LL) >> 40 | \
- (__swap64gen_x & 0xff00000000000000LL) >> 56); \
- })
- #endif // __GNUC__
-
- #endif // n BYTE_ORDER == BIG_ENDIAN
-
-#endif // PLATFORM_NO_BUILT_IN_SWAP64
+#ifdef HAVE_NETINET_IN_H
+ #include <netinet/in.h>
+#endif
#endif // BOX__H
diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h
index 3b75f992..6ddd1643 100755
--- a/lib/common/BoxPlatform.h
+++ b/lib/common/BoxPlatform.h
@@ -16,266 +16,76 @@
#define PLATFORM_DEV_NULL "/dev/null"
+#include "config.h"
-// Other flags which might be useful...
-//
-// #define PLATFORM_BERKELEY_DB_NOT_SUPPORTED
-// -- dbopen etc not on this platform
-//
-// #define PLATFORM_REGEX_NOT_SUPPORTED
-// -- regex support not available on this platform
-
-
-#ifdef PLATFORM_OPENBSD
-
- #include <sys/types.h>
-
- #define PLATFORM_HAVE_setproctitle
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_HAVE_getpeereid
-
- #define PLATFORM_RANDOM_DEVICE "/dev/arandom"
-
-#endif // PLATFORM_OPENBSD
-
-#ifdef PLATFORM_NETBSD
-
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
-
- #define PLATFORM_HAVE_setproctitle
-
- #define PLATFORM_NO_BUILT_IN_SWAP64
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_KQUEUE_NOT_SUPPORTED
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
#endif
-
-#ifdef PLATFORM_FREEBSD
-
- #include <sys/types.h>
- #include <netinet/in.h>
-
- #define PLATFORM_HAVE_setproctitle
-
- #define PLATFORM_NO_BUILT_IN_SWAP64
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_HAVE_getpeereid
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
-#endif // PLATFORM_FREEBSD
-
-#ifdef PLATFORM_DARWIN
-
- #include <sys/types.h>
- #include <netdb.h>
-
- // types 'missing'
- #ifndef _SOCKLEN_T
- typedef int socklen_t;
+#ifdef HAVE_INTTYPES_H
+ #include <inttypes.h>
+#else
+ #ifdef HAVE_STDINT_H
+ #include <stdint.h>
#endif
- typedef u_int8_t uint8_t;
- typedef signed char int8_t;
- typedef u_int64_t uint64_t;
- typedef u_int32_t uint32_t;
- typedef u_int16_t uint16_t;
-
- // poll() emulator on Darwin misses this declaration
- #define INFTIM -1
+#endif
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_LCHOWN_NOT_SUPPORTED
-
- #define PLATFORM_READLINE_NOT_SUPPORTED
+// Find out if credentials on UNIX sockets can be obtained
+#ifndef HAVE_GETPEEREID
+ #if !HAVE_DECL_SO_PEERCRED
+ #define PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET
+ #endif
+#endif
- #define PLATFORM_RANDOM_DEVICE "/dev/random"
-
-#endif // PLATFORM_DARWIN
+// Cannot do the intercepts in test/raidfile if large file support is enabled
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ #define PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
+#endif
-#ifdef PLATFORM_LINUX
-
- #include <sys/types.h>
+#ifdef HAVE_DEFINE_PRAGMA
+ // set packing to one bytes (can't use push/pop on gcc)
+ #define BEGIN_STRUCTURE_PACKING_FOR_WIRE #pragma pack(1)
- // for ntohl etc...
- #include <netinet/in.h>
+ // Use default packing
+ #define END_STRUCTURE_PACKING_FOR_WIRE #pragma pack()
+#else
+ #define STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
+#endif
- // types 'missing'
+// Define missing types
+#ifndef HAVE_UINT8_T
typedef u_int8_t uint8_t;
- typedef signed char int8_t;
- typedef u_int32_t uint32_t;
- typedef u_int16_t uint16_t;
- typedef u_int64_t uint64_t;
-
- // not defined in Linux, a BSD thing
- #define INFTIM -1
-
- #define LLONG_MAX 9223372036854775807LL
- #define LLONG_MIN (-LLONG_MAX - 1LL)
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_HAVE_getsockopt_SO_PEERCRED
-
- // load in installation specific linux configuration
- #include "../../local/_linux_platform.h"
-
- #define PLATFORM_KQUEUE_NOT_SUPPORTED
- #define PLATFORM_dirent_BROKEN_d_type
- #define PLATFORM_stat_SHORT_mtime
- #define PLATFORM_stat_NO_st_flags
- #define PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #define PLATFORM_open_USE_flock
- #define PLATFORM_sockaddr_NO_len
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
- // If large file support is on, can't do the intercepts in the test/raidfile
- #if _FILE_OFFSET_BITS == 64
- #define PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
- #endif
-
-#endif // PLATFORM_LINUX
+#endif
-#ifdef PLATFORM_SUNOS
+#ifndef HAVE_UINT16_T
+ typedef u_int16_t uint16_t;
+#endif
- #include <sys/types.h>
+#ifndef HAVE_UINT32_T
+ typedef u_int32_t uint32_t;
+#endif
- // for ntohl etc...
- #include <netinet/in.h>
+#ifndef HAVE_UINT64_T
+ typedef u_int64_t uint64_t;
+#endif
- // types 'missing'
+#ifndef HAVE_U_INT8_T
typedef uint8_t u_int8_t;
-// typedef signed char int8_t;
- typedef uint32_t u_int32_t;
- typedef uint16_t u_int16_t;
- typedef uint64_t u_int64_t;
-
- // not defined in Solaris, a BSD thing
- #define INFTIM -1
-
- //#define LLONG_MAX 9223372036854775807LL
- //#define LLONG_MIN (-LLONG_MAX - 1LL)
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_BERKELEY_DB_NOT_SUPPORTED
- #define PLATFORM_KQUEUE_NOT_SUPPORTED // This may be in Solaris 10
- #define PLATFORM_dirent_BROKEN_d_type // Well, no d_type at all actually
- #define PLATFORM_stat_SHORT_mtime
- #define PLATFORM_stat_NO_st_flags
- #define PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #define PLATFORM_open_USE_fcntl
- #define PLATFORM_sockaddr_NO_len
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
-#endif // PLATFORM_SUNOS
-
-#ifdef PLATFORM_CYGWIN
-
- #define PLATFORM_BERKELEY_DB_NOT_SUPPORTED
-
- #define PLATFORM_KQUEUE_NOT_SUPPORTED
- #define PLATFORM_dirent_BROKEN_d_type
- #define PLATFORM_stat_SHORT_mtime
- #define PLATFORM_stat_NO_st_flags
- #define PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #define PLATFORM_open_USE_flock
- #define PLATFORM_sockaddr_NO_len
- #define PLATFORM_NO_BUILT_IN_SWAP64
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_READLINE_NOT_SUPPORTED
-
- #define LLONG_MAX 9223372036854775807LL
- #define LLONG_MIN (-LLONG_MAX - 1LL)
-
- #define INFTIM -1
-
- // File listing canonical interesting mount points.
- #define MNTTAB _PATH_MNTTAB
-
- // File listing currently active mount points.
- #define MOUNTED _PATH_MOUNTED
-
- #define __need_FILE
-
- // Extra includes
- #include <stdint.h>
- #include <stdlib.h>
- #include <netinet/in.h>
- #include <sys/socket.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <dirent.h>
- #include <stdio.h>
- #include <paths.h>
-
- // No easy random entropy source
- #define PLATFORM_RANDOM_DEVICE_NONE
-
-#endif // PLATFORM_CYGWIN
-
-
-// Check the processor type
-#ifdef PLATFORM_SPARC
- #define PLATFORM_ALIGN_INT
#endif
-#ifdef PLATFORM_ARM
- #define PLATFORM_ALIGN_INT
+#ifndef HAVE_U_INT16_T
+ typedef uint16_t u_int16_t;
#endif
-
-// Find out if credentials on UNIX sockets can be obtained
-#ifndef PLATFORM_HAVE_getpeereid
- #ifndef PLATFORM_HAVE_getsockopt_SO_PEERCRED
- #define PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET
- #endif
+#ifndef HAVE_U_INT32_T
+ typedef uint32_t u_int32_t;
#endif
-
-// Compiler issues
-#ifdef __GNUC__
-
- #ifdef PLATFORM_GCC3
-
- // GCC v3 doesn't like pragmas in #defines
- #define STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
-
- // But fortunately, the STL allocations are much better behaved.
-
- #else
-
- // Force STL to use malloc() for memory allocation
- // -- slower, but doesn't gradually use more and more memory
- // HOWEVER -- this 'fix' is broken on some platforms. Lots of fun!
- #ifndef PLATFORM_STL_USE_MALLOC_BROKEN
- #define __USE_MALLOC
- #endif
-
- // set packing to one bytes (can't use push/pop on gcc)
- #define BEGIN_STRUCTURE_PACKING_FOR_WIRE #pragma pack(1)
-
- // Use default packing
- #define END_STRUCTURE_PACKING_FOR_WIRE #pragma pack()
-
- #endif
-
-#else
- compiler not supported!
+#ifndef HAVE_U_INT64_T
+ typedef uint64_t u_int64_t;
#endif
+#if !HAVE_DECL_INFTIM
+ #define INFTIM -1
+#endif
#endif // BOXPLATFORM__H
-
diff --git a/lib/common/EndStructPackForWire.h b/lib/common/EndStructPackForWire.h
index c9655cd7..82637f33 100644
--- a/lib/common/EndStructPackForWire.h
+++ b/lib/common/EndStructPackForWire.h
@@ -9,7 +9,7 @@
// No header guard -- this is intentional
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#pragma pack()
diff --git a/lib/common/EventWatchFilesystemObject.cpp b/lib/common/EventWatchFilesystemObject.cpp
index 1611d5bd..c3fe11f8 100644
--- a/lib/common/EventWatchFilesystemObject.cpp
+++ b/lib/common/EventWatchFilesystemObject.cpp
@@ -27,11 +27,11 @@
//
// --------------------------------------------------------------------------
EventWatchFilesystemObject::EventWatchFilesystemObject(const char *Filename)
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
: mDescriptor(::open(Filename, O_RDONLY /*O_EVTONLY*/, 0))
#endif
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
if(mDescriptor == -1)
{
THROW_EXCEPTION(CommonException, OSFileOpenError)
@@ -77,7 +77,7 @@ EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesyste
}
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// --------------------------------------------------------------------------
//
// Function
diff --git a/lib/common/EventWatchFilesystemObject.h b/lib/common/EventWatchFilesystemObject.h
index d8a7245b..f9175a49 100644
--- a/lib/common/EventWatchFilesystemObject.h
+++ b/lib/common/EventWatchFilesystemObject.h
@@ -10,7 +10,7 @@
#ifndef EVENTWATCHFILESYSTEMOBJECT__H
#define EVENTWATCHFILESYSTEMOBJECT__H
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
#include <sys/event.h>
#endif
@@ -34,7 +34,7 @@ private:
EventWatchFilesystemObject &operator=(const EventWatchFilesystemObject &);
public:
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
void FillInKEvent(struct kevent &rEvent, int Flags = 0) const;
#else
void FillInPoll(int &fd, short &events, int Flags = 0) const;
diff --git a/lib/common/ExcludeList.cpp b/lib/common/ExcludeList.cpp
index 6350869d..556a2079 100755
--- a/lib/common/ExcludeList.cpp
+++ b/lib/common/ExcludeList.cpp
@@ -9,7 +9,7 @@
#include "Box.h"
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
#include <regex.h>
#define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED
#endif
@@ -44,7 +44,7 @@ ExcludeList::ExcludeList()
// --------------------------------------------------------------------------
ExcludeList::~ExcludeList()
{
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
// free regex memory
while(mRegex.size() > 0)
{
@@ -106,7 +106,7 @@ void ExcludeList::AddDefiniteEntries(const std::string &rEntries)
// --------------------------------------------------------------------------
void ExcludeList::AddRegexEntries(const std::string &rEntries)
{
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
// Split strings up
std::vector<std::string> ens;
@@ -173,7 +173,7 @@ bool ExcludeList::IsExcluded(const std::string &rTest) const
}
// Check against regular expressions
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
for(std::vector<regex_t *>::const_iterator i(mRegex.begin()); i != mRegex.end(); ++i)
{
// Test against this expression
diff --git a/lib/common/ExcludeList.h b/lib/common/ExcludeList.h
index a1954044..5324d226 100755
--- a/lib/common/ExcludeList.h
+++ b/lib/common/ExcludeList.h
@@ -45,7 +45,7 @@ public:
// Mainly for tests
unsigned int SizeOfDefiniteList() const {return mDefinite.size();}
unsigned int SizeOfRegexList() const
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
{return mRegex.size();}
#else
{return 0;}
@@ -53,7 +53,7 @@ public:
private:
std::set<std::string> mDefinite;
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
std::vector<regex_t *> mRegex;
#endif
diff --git a/lib/common/FileModificationTime.h b/lib/common/FileModificationTime.h
index 78f5c115..a84df579 100755
--- a/lib/common/FileModificationTime.h
+++ b/lib/common/FileModificationTime.h
@@ -16,7 +16,7 @@
inline box_time_t FileModificationTime(struct stat &st)
{
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
box_time_t datamodified = ((int64_t)st.st_mtime) * (MICRO_SEC_IN_SEC_LL);
#else
box_time_t datamodified = (((int64_t)st.st_mtimespec.tv_nsec) / NANO_SEC_IN_USEC_LL)
@@ -28,7 +28,7 @@ inline box_time_t FileModificationTime(struct stat &st)
inline box_time_t FileAttrModificationTime(struct stat &st)
{
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
box_time_t statusmodified = ((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL);
#else
box_time_t statusmodified = (((int64_t)st.st_ctimespec.tv_nsec) / NANO_SEC_IN_USEC_LL)
@@ -40,7 +40,7 @@ inline box_time_t FileAttrModificationTime(struct stat &st)
inline box_time_t FileModificationTimeMaxModAndAttr(struct stat &st)
{
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
box_time_t datamodified = ((int64_t)st.st_mtime) * (MICRO_SEC_IN_SEC_LL);
box_time_t statusmodified = ((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL);
#else
diff --git a/lib/common/LinuxWorkaround.cpp b/lib/common/LinuxWorkaround.cpp
deleted file mode 100755
index 7900fa6e..00000000
--- a/lib/common/LinuxWorkaround.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-// Name: LinuxWorkaround.cpp
-// Purpose: Workarounds for Linux
-// Created: 2003/10/31
-//
-// --------------------------------------------------------------------------
-
-#include "Box.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <string>
-
-#include "LinuxWorkaround.h"
-#include "CommonException.h"
-
-#include "MemLeakFindOn.h"
-
-#ifdef PLATFORM_LINUX
-
-// --------------------------------------------------------------------------
-//
-// Function
-// Name: LinuxWorkaround_FinishDirentStruct(struct dirent *, const char *)
-// Purpose: Finishes off filling in a dirent structure, which Linux leaves incomplete.
-// Created: 2003/10/31
-//
-// --------------------------------------------------------------------------
-void LinuxWorkaround_FinishDirentStruct(struct dirent *entry, const char *DirectoryName)
-{
- // From man readdir under Linux:
- //
- // BUGS
- // Field d_type is not implemented as of libc6 2.1 and will always return
- // DT_UNKNOWN (0).
- //
- // What kind of an OS is this?
-
-
- // Build filename of this entry
- std::string fn(DirectoryName);
- fn += '/';
- fn += entry->d_name;
-
- // Do a stat on it
- struct stat st;
- if(::lstat(fn.c_str(), &st) != 0)
- {
- THROW_EXCEPTION(CommonException, OSFileError)
- }
-
- // Fill in the d_type field.
- if(S_ISREG(st.st_mode))
- {
- entry->d_type = DT_REG;
- }
- else if(S_ISDIR(st.st_mode))
- {
- entry->d_type = DT_DIR;
- }
- else if(S_ISLNK(st.st_mode))
- {
- entry->d_type = DT_LNK;
- }
- // otherwise leave it as we found it
-}
-
-#endif // PLATFORM_LINUX
-
diff --git a/lib/common/LinuxWorkaround.h b/lib/common/LinuxWorkaround.h
deleted file mode 100755
index bcd27495..00000000
--- a/lib/common/LinuxWorkaround.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-// Name: LinuxWorkaround.h
-// Purpose: Workarounds for Linux
-// Created: 2003/10/31
-//
-// --------------------------------------------------------------------------
-
-#ifndef LINUXWORKAROUND__H
-#define LINUXWORKAROUND__H
-
-#ifdef PLATFORM_LINUX
-
-void LinuxWorkaround_FinishDirentStruct(struct dirent *entry, const char *DirectoryName);
-
-#endif // PLATFORM_LINUX
-
-#endif // LINUXWORKAROUND__H
-
diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp
index 8953db89..b9aeb768 100755
--- a/lib/common/NamedLock.cpp
+++ b/lib/common/NamedLock.cpp
@@ -12,9 +12,9 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-#ifdef PLATFORM_open_USE_flock
+#ifdef HAVE_FLOCK
#include <sys/file.h>
-#endif // PLATFORM_open_USE_flock
+#endif
#include "NamedLock.h"
#include "CommonException.h"
@@ -68,14 +68,31 @@ bool NamedLock::TryAndGetLock(const char *Filename, int mode)
}
// See if the lock can be got
-#if defined(PLATFORM_open_USE_flock) || defined(PLATFORM_open_USE_fcntl)
+#if HAVE_DECL_O_EXLOCK
+ int fd = ::open(Filename, O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC | O_EXLOCK, mode);
+ if(fd != -1)
+ {
+ // Got a lock, lovely
+ mFileDescriptor = fd;
+ return true;
+ }
+
+ // Failed. Why?
+ if(errno != EWOULDBLOCK)
+ {
+ // Not the expected error
+ THROW_EXCEPTION(CommonException, OSFileError)
+ }
+
+ return false;
+#else
int fd = ::open(Filename, O_WRONLY | O_CREAT | O_TRUNC, mode);
if(fd == -1)
{
THROW_EXCEPTION(CommonException, OSFileError)
}
-#ifdef PLATFORM_open_USE_flock
+#ifdef HAVE_FLOCK
if(::flock(fd, LOCK_EX | LOCK_NB) != 0)
{
::close(fd);
@@ -112,23 +129,6 @@ bool NamedLock::TryAndGetLock(const char *Filename, int mode)
mFileDescriptor = fd;
return true;
-#else
- int fd = ::open(Filename, O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC | O_EXLOCK, mode);
- if(fd != -1)
- {
- // Got a lock, lovely
- mFileDescriptor = fd;
- return true;
- }
-
- // Failed. Why?
- if(errno != EWOULDBLOCK)
- {
- // Not the expected error
- THROW_EXCEPTION(CommonException, OSFileError)
- }
-
- return false;
#endif
}
diff --git a/lib/common/TemporaryDirectory.h b/lib/common/TemporaryDirectory.h
index 62010f79..e683863b 100755
--- a/lib/common/TemporaryDirectory.h
+++ b/lib/common/TemporaryDirectory.h
@@ -12,11 +12,11 @@
#include <string>
-#ifdef PLATFORM_STATIC_TEMP_DIRECTORY_NAME
+#ifdef TEMP_DIRECTORY_NAME
// Prefix name with Box to avoid clashing with OS API names
inline std::string BoxGetTemporaryDirectoryName()
{
- return std::string(PLATFORM_STATIC_TEMP_DIRECTORY_NAME);
+ return std::string(TEMP_DIRECTORY_NAME);
}
#else
non-static temporary directory names not supported yet
diff --git a/lib/common/WaitForEvent.cpp b/lib/common/WaitForEvent.cpp
index e9ee58d2..c552bb12 100644
--- a/lib/common/WaitForEvent.cpp
+++ b/lib/common/WaitForEvent.cpp
@@ -25,7 +25,7 @@
// Created: 9/3/04
//
// --------------------------------------------------------------------------
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
WaitForEvent::WaitForEvent(int Timeout)
: mKQueue(::kqueue()),
mpTimeout(0)
@@ -56,7 +56,7 @@ WaitForEvent::WaitForEvent(int Timeout)
// --------------------------------------------------------------------------
WaitForEvent::~WaitForEvent()
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
::close(mKQueue);
mKQueue = -1;
#else
@@ -79,7 +79,7 @@ WaitForEvent::~WaitForEvent()
// --------------------------------------------------------------------------
void WaitForEvent::SetTimeout(int Timeout)
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// Generate timeout
if(Timeout != TimeoutInfinite)
{
@@ -106,7 +106,7 @@ void WaitForEvent::SetTimeout(int Timeout)
// --------------------------------------------------------------------------
void *WaitForEvent::Wait()
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// Event return structure
struct kevent e;
::memset(&e, 0, sizeof(e));
diff --git a/lib/common/WaitForEvent.h b/lib/common/WaitForEvent.h
index b8f79da6..46f152c5 100644
--- a/lib/common/WaitForEvent.h
+++ b/lib/common/WaitForEvent.h
@@ -10,7 +10,7 @@
#ifndef WAITFOREVENT__H
#define WAITFOREVENT__H
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
#include <sys/event.h>
#include <sys/time.h>
#else
@@ -42,7 +42,7 @@ public:
void *Wait();
-#ifdef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifndef HAVE_KQUEUE
typedef struct
{
int fd;
@@ -63,7 +63,7 @@ public:
void Add(const T *pItem, int Flags = 0)
{
ASSERT(pItem != 0);
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
struct kevent e;
pItem->FillInKEvent(e, Flags);
// Fill in extra flags to say what to do
@@ -100,7 +100,7 @@ public:
void Remove(const T *pItem, int Flags = 0)
{
ASSERT(pItem != 0);
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
struct kevent e;
pItem->FillInKEvent(e, Flags);
// Fill in extra flags to say what to do
@@ -128,7 +128,7 @@ public:
}
private:
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
int mKQueue;
struct timespec mTimeout;
struct timespec *mpTimeout;
diff --git a/lib/crypto/CipherAES.cpp b/lib/crypto/CipherAES.cpp
index b4de6048..fad8b968 100644
--- a/lib/crypto/CipherAES.cpp
+++ b/lib/crypto/CipherAES.cpp
@@ -10,7 +10,7 @@
#include "Box.h"
// Only available in new versions of openssl
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
#include <openssl/evp.h>
@@ -159,5 +159,5 @@ void CipherAES::SetupParameters(EVP_CIPHER_CTX *pCipherContext) const
-#endif // n PLATFORM_OLD_OPENSSL
+#endif // n HAVE_OLD_SSL
diff --git a/lib/crypto/CipherAES.h b/lib/crypto/CipherAES.h
index 51fb146a..50b96dc3 100644
--- a/lib/crypto/CipherAES.h
+++ b/lib/crypto/CipherAES.h
@@ -11,7 +11,7 @@
#define CIPHERAES__H
// Only available in new versions of openssl
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
#include "CipherDescription.h"
@@ -44,7 +44,7 @@ private:
const void *mpInitialisationVector;
};
-#endif // n PLATFORM_OLD_OPENSSL
+#endif // n HAVE_OLD_SSL
#endif // CIPHERAES__H
diff --git a/lib/crypto/CipherBlowfish.cpp b/lib/crypto/CipherBlowfish.cpp
index e27e3b0a..e16cc6ed 100755
--- a/lib/crypto/CipherBlowfish.cpp
+++ b/lib/crypto/CipherBlowfish.cpp
@@ -11,7 +11,7 @@
#include <openssl/evp.h>
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
#include <string.h>
#include <strings.h>
#endif
@@ -34,7 +34,7 @@
CipherBlowfish::CipherBlowfish(CipherDescription::CipherMode Mode, const void *pKey, unsigned int KeyLength, const void *pInitialisationVector)
: CipherDescription(),
mMode(Mode)
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
, mpKey(pKey),
mKeyLength(KeyLength),
mpInitialisationVector(pInitialisationVector)
@@ -66,7 +66,7 @@ CipherBlowfish::CipherBlowfish(CipherDescription::CipherMode Mode, const void *p
CipherBlowfish::CipherBlowfish(const CipherBlowfish &rToCopy)
: CipherDescription(rToCopy),
mMode(rToCopy.mMode),
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
mpKey(rToCopy.mpKey),
mKeyLength(rToCopy.mKeyLength),
mpInitialisationVector(rToCopy.mpInitialisationVector)
@@ -80,7 +80,7 @@ CipherBlowfish::CipherBlowfish(const CipherBlowfish &rToCopy)
#endif
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
// Hack functions to support old OpenSSL API
CipherDescription *CipherBlowfish::Clone() const
{
@@ -110,7 +110,7 @@ void CipherBlowfish::SetIV(const void *pIV)
// --------------------------------------------------------------------------
CipherBlowfish::~CipherBlowfish()
{
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
// Zero copy of key
for(unsigned int l = 0; l < mKey.size(); ++l)
{
@@ -134,7 +134,7 @@ CipherBlowfish &CipherBlowfish::operator=(const CipherBlowfish &rToCopy)
CipherDescription::operator=(rToCopy);
mMode = rToCopy.mMode;
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
mpKey = rToCopy.mpKey;
mKeyLength = rToCopy.mKeyLength;
mpInitialisationVector = rToCopy.mpInitialisationVector;
@@ -196,7 +196,7 @@ void CipherBlowfish::SetupParameters(EVP_CIPHER_CTX *pCipherContext) const
ASSERT(pCipherContext != 0);
// Set key length
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
if(EVP_CIPHER_CTX_set_key_length(pCipherContext, mKeyLength) != 1)
#else
if(EVP_CIPHER_CTX_set_key_length(pCipherContext, mKey.size()) != 1)
@@ -205,7 +205,7 @@ void CipherBlowfish::SetupParameters(EVP_CIPHER_CTX *pCipherContext) const
THROW_EXCEPTION(CipherException, EVPBadKeyLength)
}
// Set key
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
if(EVP_CipherInit_ex(pCipherContext, NULL, NULL, (unsigned char*)mpKey, (unsigned char*)mpInitialisationVector, -1) != 1)
#else
if(EVP_CipherInit(pCipherContext, NULL, (unsigned char*)mKey.c_str(), (unsigned char*)mInitialisationVector, -1) != 1)
diff --git a/lib/crypto/CipherBlowfish.h b/lib/crypto/CipherBlowfish.h
index 92db1d85..b3bcf028 100755
--- a/lib/crypto/CipherBlowfish.h
+++ b/lib/crypto/CipherBlowfish.h
@@ -10,7 +10,7 @@
#ifndef CIPHERBLOWFISH__H
#define CIPHERBLOWFISH__H
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
#include <string>
#endif
@@ -38,14 +38,14 @@ public:
// Setup any other parameters
virtual void SetupParameters(EVP_CIPHER_CTX *pCipherContext) const;
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
CipherDescription *Clone() const;
void SetIV(const void *pIV);
#endif
private:
CipherDescription::CipherMode mMode;
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
const void *mpKey;
unsigned int mKeyLength;
const void *mpInitialisationVector;
diff --git a/lib/crypto/CipherContext.cpp b/lib/crypto/CipherContext.cpp
index 42707497..8c3b25b2 100755
--- a/lib/crypto/CipherContext.cpp
+++ b/lib/crypto/CipherContext.cpp
@@ -29,7 +29,7 @@ CipherContext::CipherContext()
: mInitialised(false),
mWithinTransform(false),
mPaddingOn(true)
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
, mFunction(Decrypt),
mpDescription(0)
#endif
@@ -52,7 +52,7 @@ CipherContext::~CipherContext()
EVP_CIPHER_CTX_cleanup(&ctx);
mInitialised = false;
}
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
if(mpDescription != 0)
{
delete mpDescription;
@@ -83,7 +83,7 @@ void CipherContext::Init(CipherContext::CipherFunction Function, const CipherDes
}
// Initialise the cipher
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
EVP_CIPHER_CTX_init(&ctx); // no error return code, even though the docs says it does
if(EVP_CipherInit_ex(&ctx, rDescription.GetCipher(), NULL, NULL, NULL, Function) != 1)
@@ -100,7 +100,7 @@ void CipherContext::Init(CipherContext::CipherFunction Function, const CipherDes
try
{
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
// Let the description set up everything else
rDescription.SetupParameters(&ctx);
#else
@@ -137,7 +137,7 @@ void CipherContext::Reset()
EVP_CIPHER_CTX_cleanup(&ctx);
mInitialised = false;
}
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
if(mpDescription != 0)
{
delete mpDescription;
@@ -270,7 +270,7 @@ int CipherContext::Final(void *pOutBuffer, int OutLength)
// Do the transform
int outLength = OutLength;
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
if(EVP_CipherFinal_ex(&ctx, (unsigned char*)pOutBuffer, &outLength) != 1)
{
THROW_EXCEPTION(CipherException, EVPFinalFailure)
@@ -285,7 +285,7 @@ int CipherContext::Final(void *pOutBuffer, int OutLength)
}
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
// --------------------------------------------------------------------------
//
// Function
@@ -458,7 +458,7 @@ int CipherContext::TransformBlock(void *pOutBuffer, int OutLength, const void *p
}
// Finalise
int outLength2 = OutLength - outLength;
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
if(EVP_CipherFinal_ex(&ctx, ((unsigned char*)pOutBuffer) + outLength, &outLength2) != 1)
{
THROW_EXCEPTION(CipherException, EVPFinalFailure)
@@ -472,7 +472,7 @@ int CipherContext::TransformBlock(void *pOutBuffer, int OutLength, const void *p
{
// Finalise the context, so definately ready for the next caller
int outs = OutLength;
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
EVP_CipherFinal_ex(&ctx, (unsigned char*)pOutBuffer, &outs);
#else
OldOpenSSLFinal((unsigned char*)pOutBuffer, outs);
@@ -530,7 +530,7 @@ void CipherContext::SetIV(const void *pIV)
THROW_EXCEPTION(CipherException, EVPInitFailure)
}
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
// Update description
if(mpDescription != 0)
{
@@ -578,7 +578,7 @@ const void *CipherContext::SetRandomIV(int &rLengthOut)
THROW_EXCEPTION(CipherException, EVPInitFailure)
}
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
// Update description
if(mpDescription != 0)
{
@@ -602,7 +602,7 @@ const void *CipherContext::SetRandomIV(int &rLengthOut)
// --------------------------------------------------------------------------
void CipherContext::UsePadding(bool Padding)
{
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
if(EVP_CIPHER_CTX_set_padding(&ctx, Padding) != 1)
{
THROW_EXCEPTION(CipherException, EVPSetPaddingFailure)
diff --git a/lib/crypto/CipherContext.h b/lib/crypto/CipherContext.h
index f9dcd022..64ce52d8 100755
--- a/lib/crypto/CipherContext.h
+++ b/lib/crypto/CipherContext.h
@@ -62,7 +62,7 @@ public:
void UsePadding(bool Padding = true);
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
void OldOpenSSLFinal(unsigned char *Buffer, int &rOutLengthOut);
#endif
@@ -72,7 +72,7 @@ private:
bool mWithinTransform;
bool mPaddingOn;
uint8_t mGeneratedIV[CIPHERCONTEXT_MAX_GENERATED_IV_LENGTH];
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
CipherFunction mFunction;
CipherDescription *mpDescription;
#endif
diff --git a/lib/crypto/CipherDescription.h b/lib/crypto/CipherDescription.h
index 2977f7da..f825eefa 100755
--- a/lib/crypto/CipherDescription.h
+++ b/lib/crypto/CipherDescription.h
@@ -47,7 +47,7 @@ public:
Mode_OFB = 3
} CipherMode;
-#ifdef PLATFORM_OLD_OPENSSL
+#ifdef HAVE_OLD_SSL
// For the old version of OpenSSL, we need to be able to store cipher descriptions.
virtual CipherDescription *Clone() const = 0;
// And to be able to store new IVs
diff --git a/lib/crypto/Random.cpp b/lib/crypto/Random.cpp
index 3df5fc5e..c64e7d50 100755
--- a/lib/crypto/Random.cpp
+++ b/lib/crypto/Random.cpp
@@ -28,8 +28,8 @@
// --------------------------------------------------------------------------
void Random::Initialise()
{
-#ifndef PLATFORM_RANDOM_DEVICE_NONE
- if(::RAND_load_file(PLATFORM_RANDOM_DEVICE, 1024) != 1024)
+#ifdef HAVE_RANDOM_DEVICE
+ if(::RAND_load_file(RANDOM_DEVICE, 1024) != 1024)
{
THROW_EXCEPTION(CipherException, RandomInitFailed)
}
diff --git a/lib/raidfile/RaidFileRead.cpp b/lib/raidfile/RaidFileRead.cpp
index 6314ba90..d60936fc 100755
--- a/lib/raidfile/RaidFileRead.cpp
+++ b/lib/raidfile/RaidFileRead.cpp
@@ -29,10 +29,6 @@
#include "RaidFileController.h"
#include "RaidFileUtil.h"
-#ifdef PLATFORM_LINUX
- #include "LinuxWorkaround.h"
-#endif
-
#include "MemLeakFindOn.h"
#define READ_NUMBER_DISCS_REQUIRED 3
@@ -715,7 +711,7 @@ int RaidFileRead_Raid::ReadRecovered(void *pBuffer, int NBytes)
if(mLastBlockHasSize)
{
int sizeXorOffset = (mBlockSize - sizeof(FileSizeType)) + ((mStripe1Handle != -1)?mBlockSize:0);
- *((FileSizeType*)(mRecoveryBuffer + sizeXorOffset)) ^= ntoh64(mFileSize);
+ *((FileSizeType*)(mRecoveryBuffer + sizeXorOffset)) ^= box_ntoh64(mFileSize);
}
}
else
@@ -1233,7 +1229,7 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
if(parityIntegralPlusOffT)
{
// Wonderful! Have the value
- length = ntoh64(parityLastData);
+ length = box_ntoh64(parityLastData);
}
else
{
@@ -1298,7 +1294,7 @@ std::auto_ptr<RaidFileRead> RaidFileRead::Open(int SetNumber, const std::string
// Lovely!
length = stripe1LastData ^ parityLastData;
// Convert to host byte order
- length = ntoh64(length);
+ length = box_ntoh64(length);
ASSERT(length <= (paritySize + stripe1Size));
// Mark is as having this to aid code later
lastBlockHasSize = true;
@@ -1531,10 +1527,6 @@ bool RaidFileRead::ReadDirectoryContents(int SetNumber, const std::string &rDirN
struct dirent *en = 0;
while((en = ::readdir(dirHandle)) != 0)
{
-#ifdef PLATFORM_LINUX
- LinuxWorkaround_FinishDirentStruct(en, dn.c_str());
-#endif
-
if(en->d_name[0] == '.' &&
(en->d_name[1] == '\0' || (en->d_name[1] == '.' && en->d_name[2] == '\0')))
{
@@ -1547,7 +1539,9 @@ bool RaidFileRead::ReadDirectoryContents(int SetNumber, const std::string &rDirN
unsigned int countToAdd = 1;
// stat the file to find out what type it is
-#ifdef PLATFORM_SUNOS
+#ifdef HAVE_VALID_DIRENT_D_TYPE
+ if(DirReadType == DirReadType_FilesOnly && en->d_type == DT_REG)
+#else
struct stat st;
std::string fullName(dn + DIRECTORY_SEPARATOR + en->d_name);
if(::lstat(fullName.c_str(), &st) != 0)
@@ -1555,8 +1549,6 @@ bool RaidFileRead::ReadDirectoryContents(int SetNumber, const std::string &rDirN
THROW_EXCEPTION(RaidFileException, OSError)
}
if(DirReadType == DirReadType_FilesOnly && (st.st_mode & S_IFDIR) == 0)
-#else
- if(DirReadType == DirReadType_FilesOnly && en->d_type == DT_REG)
#endif
{
// File. Complex, need to check the extension
@@ -1585,10 +1577,10 @@ bool RaidFileRead::ReadDirectoryContents(int SetNumber, const std::string &rDirN
}
}
}
-#ifdef PLATFORM_SUNOS
- if(DirReadType == DirReadType_DirsOnly && (st.st_mode & S_IFDIR))
-#else
+#ifdef HAVE_VALID_DIRENT_D_TYPE
if(DirReadType == DirReadType_DirsOnly && en->d_type == DT_DIR)
+#else
+ if(DirReadType == DirReadType_DirsOnly && (st.st_mode & S_IFDIR))
#endif
{
// Directory, and we want directories
diff --git a/lib/raidfile/RaidFileUtil.cpp b/lib/raidfile/RaidFileUtil.cpp
index c71bb2df..da23cef5 100755
--- a/lib/raidfile/RaidFileUtil.cpp
+++ b/lib/raidfile/RaidFileUtil.cpp
@@ -54,7 +54,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
if(pRevisionID != 0)
{
(*pRevisionID) = FileModificationTime(st);
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
// On linux, the time resolution is very low for modification times.
// So add the size to it to give a bit more chance of it changing.
// TODO: Make this better.
@@ -71,7 +71,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
int64_t revisionID = 0;
int setSize = rDiscSet.size();
int rfCount = 0;
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
// TODO: replace this with better linux revision ID detection
int64_t revisionIDplus = 0;
#endif
@@ -92,7 +92,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
{
int64_t rid = FileModificationTime(st);
if(rid > revisionID) revisionID = rid;
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
revisionIDplus += st.st_size;
#endif
}
@@ -101,7 +101,7 @@ RaidFileUtil::ExistType RaidFileUtil::RaidFileExists(RaidFileDiscSet &rDiscSet,
if(pRevisionID != 0)
{
(*pRevisionID) = revisionID;
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
(*pRevisionID) += revisionIDplus;
#endif
}
diff --git a/lib/raidfile/RaidFileWrite.cpp b/lib/raidfile/RaidFileWrite.cpp
index 987aa22c..8341943d 100755
--- a/lib/raidfile/RaidFileWrite.cpp
+++ b/lib/raidfile/RaidFileWrite.cpp
@@ -112,7 +112,10 @@ void RaidFileWrite::Open(bool AllowOverwrite)
}
// Get a lock on the write file
-#ifdef PLATFORM_open_USE_fcntl
+#ifdef HAVE_FLOCK
+ int errnoBlock = EWOULDBLOCK;
+ if(::flock(mOSFileHandle, LOCK_EX | LOCK_NB) != 0)
+#else
int errnoBlock = EAGAIN;
struct flock desc;
desc.l_type = F_WRLCK;
@@ -120,9 +123,6 @@ void RaidFileWrite::Open(bool AllowOverwrite)
desc.l_start = 0;
desc.l_len = 0;
if(::fcntl(mOSFileHandle, F_SETLK, &desc) != 0)
-#else
- int errnoBlock = EWOULDBLOCK;
- if(::flock(mOSFileHandle, LOCK_EX | LOCK_NB) != 0)
#endif
{
// Lock was not obtained.
@@ -387,14 +387,14 @@ void RaidFileWrite::TransformToRaidStorage()
// Then open them all for writing (in strict order)
try
{
-#if defined(PLATFORM_open_USE_flock) || defined(PLATFORM_open_USE_fcntl)
- FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL)> stripe1(stripe1FilenameW.c_str());
- FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL)> stripe2(stripe2FilenameW.c_str());
- FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL)> parity(parityFilenameW.c_str());
-#else
+#if HAVE_DECL_O_EXLOCK
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK)> stripe1(stripe1FilenameW.c_str());
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK)> stripe2(stripe2FilenameW.c_str());
FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK)> parity(parityFilenameW.c_str());
+#else
+ FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL)> stripe1(stripe1FilenameW.c_str());
+ FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL)> stripe2(stripe2FilenameW.c_str());
+ FileHandleGuard<(O_WRONLY | O_CREAT | O_EXCL)> parity(parityFilenameW.c_str());
#endif
// Then... read in data...
@@ -461,7 +461,7 @@ void RaidFileWrite::TransformToRaidStorage()
ASSERT(sizeof(RaidFileRead::FileSizeType) == (2*sizeof(unsigned int)));
ASSERT(sizeof(RaidFileRead::FileSizeType) >= sizeof(off_t));
int sizePos = (blockSize/sizeof(unsigned int)) - 2;
- RaidFileRead::FileSizeType sw = hton64(writeFileStat.st_size);
+ RaidFileRead::FileSizeType sw = box_hton64(writeFileStat.st_size);
unsigned int *psize = (unsigned int *)(&sw);
pparity[sizePos+0] = pstripe1[sizePos+0] ^ psize[0];
pparity[sizePos+1] = pstripe1[sizePos+1] ^ psize[1];
@@ -517,7 +517,7 @@ void RaidFileWrite::TransformToRaidStorage()
if(sizeRecordRequired)
{
ASSERT(sizeof(writeFileStat.st_size) <= sizeof(RaidFileRead::FileSizeType));
- RaidFileRead::FileSizeType sw = hton64(writeFileStat.st_size);
+ RaidFileRead::FileSizeType sw = box_hton64(writeFileStat.st_size);
ASSERT((::lseek(parity, 0, SEEK_CUR) % blockSize) == 0);
if(::write(parity, &sw, sizeof(sw)) != sizeof(sw))
{
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp
index bb4ecd7c..ca2df62f 100755
--- a/lib/server/Daemon.cpp
+++ b/lib/server/Daemon.cpp
@@ -520,7 +520,7 @@ void Daemon::SetProcessTitle(const char *format, ...)
// -- make sure other platforms include the image name somewhere so ps listings give
// useful information.
-#ifdef PLATFORM_HAVE_setproctitle
+#ifdef HAVE_SETPROCTITLE
// optional arguments
va_list args;
va_start(args, format);
@@ -532,7 +532,7 @@ void Daemon::SetProcessTitle(const char *format, ...)
// Set process title
::setproctitle("%s", title);
-#endif // PLATFORM_HAVE_setproctitle
+#endif // HAVE_SETPROCTITLE
}
diff --git a/lib/server/Protocol.cpp b/lib/server/Protocol.cpp
index 690c2ec0..988d44c8 100755
--- a/lib/server/Protocol.cpp
+++ b/lib/server/Protocol.cpp
@@ -423,13 +423,13 @@ void Protocol::Read(int64_t &rOut)
READ_START_CHECK
READ_CHECK_BYTES_AVAILABLE(sizeof(int64_t))
-#ifdef PLATFORM_ALIGN_INT
+#ifdef HAVE_ALIGNED_ONLY_INT64
int64_t nvalue;
memcpy(&nvalue, mpBuffer + mReadOffset, sizeof(int64_t));
#else
int64_t nvalue = *((int64_t*)(mpBuffer + mReadOffset));
#endif
- rOut = ntoh64(nvalue);
+ rOut = box_ntoh64(nvalue);
mReadOffset += sizeof(int64_t);
}
@@ -447,7 +447,7 @@ void Protocol::Read(int32_t &rOut)
READ_START_CHECK
READ_CHECK_BYTES_AVAILABLE(sizeof(int32_t))
-#ifdef PLATFORM_ALIGN_INT
+#ifdef HAVE_ALIGNED_ONLY_INT32
int32_t nvalue;
memcpy(&nvalue, mpBuffer + mReadOffset, sizeof(int32_t));
#else
@@ -558,8 +558,8 @@ void Protocol::Write(int64_t Value)
WRITE_START_CHECK
WRITE_ENSURE_BYTES_AVAILABLE(sizeof(int64_t))
- int64_t nvalue = hton64(Value);
-#ifdef PLATFORM_ALIGN_INT
+ int64_t nvalue = box_hton64(Value);
+#ifdef HAVE_ALIGNED_ONLY_INT64
memcpy(mpBuffer + mWriteOffset, &nvalue, sizeof(int64_t));
#else
*((int64_t*)(mpBuffer + mWriteOffset)) = nvalue;
@@ -582,7 +582,7 @@ void Protocol::Write(int32_t Value)
WRITE_ENSURE_BYTES_AVAILABLE(sizeof(int32_t))
int32_t nvalue = htonl(Value);
-#ifdef PLATFORM_ALIGN_INT
+#ifdef HAVE_ALIGNED_ONLY_INT32
memcpy(mpBuffer + mWriteOffset, &nvalue, sizeof(int32_t));
#else
*((int32_t*)(mpBuffer + mWriteOffset)) = nvalue;
diff --git a/lib/server/ProtocolWire.h b/lib/server/ProtocolWire.h
index b6d3bd37..ff62b66e 100755
--- a/lib/server/ProtocolWire.h
+++ b/lib/server/ProtocolWire.h
@@ -13,7 +13,7 @@
#include <sys/types.h>
// set packing to one byte
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "BeginStructPackForWire.h"
#else
BEGIN_STRUCTURE_PACKING_FOR_WIRE
@@ -33,7 +33,7 @@ typedef struct
#define SPECIAL_STREAM_OBJECT_TYPE 0xffffffff
// Use default packing
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#include "EndStructPackForWire.h"
#else
END_STRUCTURE_PACKING_FOR_WIRE
diff --git a/lib/server/SSLLib.cpp b/lib/server/SSLLib.cpp
index e9f3a59d..9e98550a 100755
--- a/lib/server/SSLLib.cpp
+++ b/lib/server/SSLLib.cpp
@@ -45,8 +45,8 @@ void SSLLib::Initialise()
::SSL_load_error_strings();
// Extra seeding over and above what's already done by the library
-#ifndef PLATFORM_RANDOM_DEVICE_NONE
- if(::RAND_load_file(PLATFORM_RANDOM_DEVICE, 1024) != 1024)
+#ifdef HAVE_RANDOM_DEVICE
+ if(::RAND_load_file(RANDOM_DEVICE, 1024) != 1024)
{
THROW_EXCEPTION(ServerException, SSLRandomInitFailed)
}
diff --git a/lib/server/Socket.cpp b/lib/server/Socket.cpp
index 52eb79e3..b2d32345 100755
--- a/lib/server/Socket.cpp
+++ b/lib/server/Socket.cpp
@@ -49,7 +49,7 @@ void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, int Type
if(phost->h_addr_list[0] != 0)
{
sockAddrLen = sizeof(addr.sa_inet);
-#ifndef PLATFORM_sockaddr_NO_len
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
addr.sa_inet.sin_len = sizeof(addr.sa_inet);
#endif
addr.sa_inet.sin_family = PF_INET;
@@ -82,7 +82,7 @@ void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, int Type
THROW_EXCEPTION(ServerException, SocketNameUNIXPathTooLong);
}
sockAddrLen = nameLen + (((char*)(&(addr.sa_unix.sun_path[0]))) - ((char*)(&addr.sa_unix)));
-#ifndef PLATFORM_sockaddr_NO_len
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
addr.sa_unix.sun_len = sockAddrLen;
#endif
addr.sa_unix.sun_family = PF_UNIX;
diff --git a/lib/server/SocketListen.h b/lib/server/SocketListen.h
index f1f5e377..7042011c 100755
--- a/lib/server/SocketListen.h
+++ b/lib/server/SocketListen.h
@@ -16,7 +16,7 @@
#include <poll.h>
#include <memory>
#include <string>
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
#include <sys/event.h>
#include <sys/time.h>
#endif
@@ -226,7 +226,7 @@ public:
// Functions to allow adding to WaitForEvent class, for efficient waiting
// on multiple sockets.
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// --------------------------------------------------------------------------
//
// Function
diff --git a/lib/server/SocketStream.cpp b/lib/server/SocketStream.cpp
index 3c8bf453..53865ee3 100755
--- a/lib/server/SocketStream.cpp
+++ b/lib/server/SocketStream.cpp
@@ -372,7 +372,7 @@ int SocketStream::GetSocketHandle()
// --------------------------------------------------------------------------
bool SocketStream::GetPeerCredentials(uid_t &rUidOut, gid_t &rGidOut)
{
-#ifdef PLATFORM_HAVE_getpeereid
+#ifdef HAVE_GETPEEREID
uid_t remoteEUID = 0xffff;
gid_t remoteEGID = 0xffff;
@@ -382,9 +382,9 @@ bool SocketStream::GetPeerCredentials(uid_t &rUidOut, gid_t &rGidOut)
rGidOut = remoteEGID;
return true;
}
-#endif // PLATFORM_HAVE_getpeereid
+#endif
-#ifdef PLATFORM_HAVE_getsockopt_SO_PEERCRED
+#if HAVE_DECL_SO_PEERCRED
struct ucred cred;
socklen_t credLen = sizeof(cred);
@@ -394,7 +394,7 @@ bool SocketStream::GetPeerCredentials(uid_t &rUidOut, gid_t &rGidOut)
rGidOut = cred.gid;
return true;
}
-#endif // PLATFORM_HAVE_getsockopt_SO_PEERCRED
+#endif
// Not available
return false;
diff --git a/modules.txt b/modules.txt
index ab39b428..0f06df31 100755
--- a/modules.txt
+++ b/modules.txt
@@ -12,9 +12,9 @@
OMIT:CYGWIN
lib/raidfile
END-OMIT
-lib/crypto -lcrypto
-lib/server -lssl -lcrypto
-lib/compress -lz
+lib/crypto
+lib/server
+lib/compress
test/common
test/crypto lib/crypto
test/compress lib/compress
@@ -34,8 +34,8 @@ bin/bbstored lib/raidfile lib/server lib/backupstore lib/backupclient
bin/bbstoreaccounts lib/raidfile lib/backupstore
bin/bbackupobjdump lib/backupclient lib/backupstore
END-OMIT
-bin/bbackupd lib/server lib/backupclient -lLINUX_DB!+Linux
-bin/bbackupquery -lreadline!Darwin,NetBSD -ledit!+NetBSD -lcurses lib/server lib/backupclient
+bin/bbackupd lib/server lib/backupclient
+bin/bbackupquery lib/server lib/backupclient
bin/bbackupctl lib/server lib/backupclient
OMIT:CYGWIN
test/backupstore bin/bbstored bin/bbstoreaccounts lib/server lib/backupstore lib/backupclient lib/raidfile
diff --git a/test/backupdiff/testbackupdiff.cpp b/test/backupdiff/testbackupdiff.cpp
index 5fb10038..7845433c 100755
--- a/test/backupdiff/testbackupdiff.cpp
+++ b/test/backupdiff/testbackupdiff.cpp
@@ -103,9 +103,9 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block
file_BlockIndexHeader hdr;
TEST_THAT(enc.ReadFullBuffer(&hdr, sizeof(hdr), 0));
TEST_THAT(hdr.mMagicValue == (int32_t)htonl(OBJECTMAGIC_FILE_BLOCKS_MAGIC_VALUE_V1));
- TEST_THAT((uint64_t)ntoh64(hdr.mOtherFileID) == (uint64_t)OtherFileID);
+ TEST_THAT((uint64_t)box_ntoh64(hdr.mOtherFileID) == (uint64_t)OtherFileID);
// number of blocks
- int64_t nblocks = ntoh64(hdr.mNumBlocks);
+ int64_t nblocks = box_ntoh64(hdr.mNumBlocks);
TRACE2("Reading index from '%s', has %lld blocks\n", filename, nblocks);
TRACE0("======== ===== ========== ======== ========\n Index Where EncSz/Idx Size WChcksm\n");
// Read them all in
@@ -114,7 +114,7 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block
{
file_BlockIndexEntry en;
TEST_THAT(enc.ReadFullBuffer(&en, sizeof(en), 0));
- int64_t s = ntoh64(en.mEncodedSize);
+ int64_t s = box_ntoh64(en.mEncodedSize);
if(s > 0)
{
nnew++;
@@ -126,7 +126,7 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block
TRACE2("%8lld other i=%8lld", b, 0 - s);
}
// Decode the rest
- uint64_t iv = ntoh64(hdr.mEntryIVBase);
+ uint64_t iv = box_ntoh64(hdr.mEntryIVBase);
iv += b;
sBlowfishDecryptBlockEntry.SetIV(&iv);
file_BlockIndexEntryEnc entryEnc;
diff --git a/test/backupstorefix/testbackupstorefix.cpp b/test/backupstorefix/testbackupstorefix.cpp
index a4edfd31..c36bb8b8 100644
--- a/test/backupstorefix/testbackupstorefix.cpp
+++ b/test/backupstorefix/testbackupstorefix.cpp
@@ -411,11 +411,11 @@ int test(int argc, const char *argv[])
} h;
TEST_THAT(file->Read(&h, sizeof(h)) == sizeof(h));
// Modify
- TEST_THAT(ntoh64(h.hdr.mOtherFileID) == 0);
- TEST_THAT(ntoh64(h.hdr.mNumBlocks) >= 2);
- h.hdr.mOtherFileID = hton64(2345); // don't worry about endianness
- h.e[0].mEncodedSize = hton64((ntoh64(h.e[0].mEncodedSize)) + (ntoh64(h.e[1].mEncodedSize)));
- h.e[1].mOtherBlockIndex = hton64(-2);
+ TEST_THAT(box_ntoh64(h.hdr.mOtherFileID) == 0);
+ TEST_THAT(box_ntoh64(h.hdr.mNumBlocks) >= 2);
+ h.hdr.mOtherFileID = box_hton64(2345); // don't worry about endianness
+ h.e[0].mEncodedSize = box_hton64((box_ntoh64(h.e[0].mEncodedSize)) + (box_ntoh64(h.e[1].mEncodedSize)));
+ h.e[1].mOtherBlockIndex = box_hton64(static_cast<uint64_t>(-2));
// Write to modified file
f.Write(&h, sizeof(h));
// Commit new version
diff --git a/test/common/testcommon.cpp b/test/common/testcommon.cpp
index 7febf92f..546228bc 100755
--- a/test/common/testcommon.cpp
+++ b/test/common/testcommon.cpp
@@ -396,7 +396,7 @@ int test(int argc, const char *argv[])
TEST_THAT(lock1.TryAndGetLock("testfiles/lock1") == true);
// Try to lock something using the same lock
TEST_CHECK_THROWS(lock1.TryAndGetLock("testfiles/non-exist/lock2"), CommonException, NamedLockAlreadyLockingSomething);
-#ifndef PLATFORM_open_USE_fcntl
+#if defined(HAVE_FLOCK) || HAVE_DECL_O_EXLOCK
// And again on that name
NamedLock lock2;
TEST_THAT(lock2.TryAndGetLock("testfiles/lock1") == false);
@@ -484,7 +484,7 @@ int test(int argc, const char *argv[])
TEST_THAT(elist.SizeOfDefiniteList() == 4);
// Add regex entries
- #ifndef PLATFORM_REGEX_NOT_SUPPORTED
+ #ifdef HAVE_REGEX_H
elist.AddRegexEntries(std::string("[a-d]+\\.reg$" "\x01" "EXCLUDE" "\x01" "^exclude$"));
elist.AddRegexEntries(std::string(""));
TEST_CHECK_THROWS(elist.AddRegexEntries(std::string("[:not_valid")), CommonException, BadRegularExpression);
@@ -499,7 +499,7 @@ int test(int argc, const char *argv[])
TEST_THAT(elist.IsExcluded(std::string("ThingDefThree")) == true);
TEST_THAT(elist.IsExcluded(std::string("AnotherDef")) == true);
TEST_THAT(elist.IsExcluded(std::string("dir/DefNumberTwo")) == false);
- #ifndef PLATFORM_REGEX_NOT_SUPPORTED
+ #ifdef HAVE_REGEX_H
TEST_THAT(elist.IsExcluded(std::string("b.reg")) == true);
TEST_THAT(elist.IsExcluded(std::string("e.reg")) == false);
TEST_THAT(elist.IsExcluded(std::string("b.Reg")) == false);
diff --git a/test/crypto/testcrypto.cpp b/test/crypto/testcrypto.cpp
index 983ae57e..c312a4a0 100755
--- a/test/crypto/testcrypto.cpp
+++ b/test/crypto/testcrypto.cpp
@@ -256,7 +256,7 @@ int test(int argc, const char *argv[])
// Cipher type
::printf("Blowfish...\n");
test_cipher<CipherBlowfish, 8>();
-#ifndef PLATFORM_OLD_OPENSSL
+#ifndef HAVE_OLD_SSL
::printf("AES...\n");
test_cipher<CipherAES, 16>();
#else
diff --git a/test/raidfile/intercept.cpp b/test/raidfile/intercept.cpp
index 60c0ca1e..11cd06e9 100755
--- a/test/raidfile/intercept.cpp
+++ b/test/raidfile/intercept.cpp
@@ -9,7 +9,9 @@
#include "Box.h"
-#include <sys/syscall.h>
+#ifdef HAVE_SYS_SYSCALL_H
+ #include <sys/syscall.h>
+#endif
#include <sys/types.h>
#include <unistd.h>
#include <sys/uio.h>
@@ -17,8 +19,12 @@
#ifndef PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
-#ifdef PLATFORM_DARWIN
- // For some reason, __syscall just doesn't work on Darwin
+#if !defined(HAVE_SYSCALL) && !defined(HAVE___SYSCALL) && !defined(HAVE___SYSCALL_NEED_DEFN)
+ #define PLATFORM_NO_SYSCALL
+#endif
+
+#ifdef PLATFORM_NO_SYSCALL
+ // For some reason, syscall just doesn't work on Darwin
// so instead, we build functions using assembler in a varient
// of the technique used in the Darwin Libc
extern "C" int
@@ -34,13 +40,14 @@
extern "C" off_t
TEST_lseek(int fildes, off_t offset, int whence);
#else
- #if defined(PLATFORM_LINUX) || defined(PLATFORM_SUNOS)
- #undef __syscall
- #define __syscall syscall
- #else
- // Need this, not declared in syscall.h
+ #ifdef HAVE___SYSCALL_NEED_DEFN
+ // Need this, not declared in syscall.h nor unistd.h
extern "C" off_t __syscall(quad_t number, ...);
#endif
+ #ifndef HAVE_SYSCALL
+ #undef syscall
+ #define syscall __syscall
+ #endif
#endif
#include <string.h>
@@ -137,10 +144,10 @@ open(const char *path, int flags, mode_t mode)
return -1;
}
}
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_open(path, flags, mode);
#else
- int r = __syscall(SYS_open, path, flags, mode);
+ int r = syscall(SYS_open, path, flags, mode);
#endif
if(intercept_enabled && intercept_filedes == -1)
{
@@ -158,10 +165,10 @@ extern "C" int
close(int d)
{
CHECK_FOR_FAKE_ERROR_COND(d, SIZE_ALWAYS_ERROR, SYS_close, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_close(d);
#else
- int r = __syscall(SYS_close, d);
+ int r = syscall(SYS_close, d);
#endif
if(r == 0)
{
@@ -177,10 +184,10 @@ extern "C" ssize_t
write(int d, const void *buf, size_t nbytes)
{
CHECK_FOR_FAKE_ERROR_COND(d, nbytes, SYS_write, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_write(d, buf, nbytes);
#else
- int r = __syscall(SYS_write, d, buf, nbytes);
+ int r = syscall(SYS_write, d, buf, nbytes);
#endif
if(r != -1)
{
@@ -193,10 +200,10 @@ extern "C" ssize_t
read(int d, void *buf, size_t nbytes)
{
CHECK_FOR_FAKE_ERROR_COND(d, nbytes, SYS_read, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_read(d, buf, nbytes);
#else
- int r = __syscall(SYS_read, d, buf, nbytes);
+ int r = syscall(SYS_read, d, buf, nbytes);
#endif
if(r != -1)
{
@@ -216,10 +223,10 @@ readv(int d, const struct iovec *iov, int iovcnt)
}
CHECK_FOR_FAKE_ERROR_COND(d, nbytes, SYS_readv, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_readv(d, iov, iovcnt);
#else
- int r = __syscall(SYS_readv, d, iov, iovcnt);
+ int r = syscall(SYS_readv, d, iov, iovcnt);
#endif
if(r != -1)
{
@@ -233,15 +240,13 @@ lseek(int fildes, off_t offset, int whence)
{
// random magic for lseek syscall, see /usr/src/lib/libc/sys/lseek.c
CHECK_FOR_FAKE_ERROR_COND(fildes, 0, SYS_lseek, -1);
-#ifdef PLATFORM_DARWIN
+#ifdef PLATFORM_NO_SYSCALL
int r = TEST_lseek(fildes, offset, whence);
#else
- #if defined(PLATFORM_LINUX) || defined(PLATFORM_SUNOS)
- off_t r = __syscall(SYS_lseek, fildes, offset, whence);
+ #ifdef HAVE_LSEEK_DUMMY_PARAM
+ off_t r = syscall(SYS_lseek, fildes, 0 /* extra 0 required here! */, offset, whence);
#else
- // Should swap this condition round. No reason to assume that most OS
- // do this syscall wierdness, default should be the sensible way
- off_t r = __syscall(SYS_lseek, fildes, 0 /* extra 0 required here! */, offset, whence);
+ off_t r = syscall(SYS_lseek, fildes, offset, whence);
#endif
#endif
if(r != -1)
diff --git a/test/raidfile/testraidfile.cpp b/test/raidfile/testraidfile.cpp
index 9803d44d..1e510486 100755
--- a/test/raidfile/testraidfile.cpp
+++ b/test/raidfile/testraidfile.cpp
@@ -525,7 +525,7 @@ void test_overwrites()
writeA.Write("TESTTEST", 8);
{
-#ifndef PLATFORM_open_USE_fcntl
+#if defined(HAVE_FLOCK) || HAVE_DECL_O_EXLOCK
RaidFileWrite writeA2(0, "overwrite_A");
TEST_CHECK_THROWS(writeA2.Open(), RaidFileException, FileIsCurrentlyOpenForWriting);
#endif