summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
committerChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
commitc7662795f519d2b6797e4b1ac7fa4a22afa26310 (patch)
treeb1737dfa78d8e7bfb2d5a7e9831bab91869ade97 /lib/common
parenta85b710c46ec79e968da349304f30945cb9b7bc1 (diff)
* merge
- This is my current patch queue. I think that all of these are safe to apply. This is just under half of the pending changes in chris/general (the easy half).
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/BoxPlatform.h9
-rw-r--r--lib/common/FdGetLine.h4
-rw-r--r--lib/common/Guards.h2
-rw-r--r--lib/common/UnixUser.cpp4
-rwxr-xr-xlib/common/makeexception.pl.in11
5 files changed, 24 insertions, 6 deletions
diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h
index b766706a..cb83f7a9 100644
--- a/lib/common/BoxPlatform.h
+++ b/lib/common/BoxPlatform.h
@@ -40,8 +40,8 @@
#endif
#endif
-// Slight hack; disable interception on Darwin within raidfile test
-#ifdef __APPLE__
+// Slight hack; disable interception in raidfile test on Darwin and Windows
+#if defined __APPLE__ || defined WIN32
// TODO: Replace with autoconf test
#define PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
#endif
@@ -138,6 +138,11 @@
#define INFTIM -1
#endif
+// for Unix compatibility with Windows :-)
+#if !HAVE_DECL_O_BINARY
+ #define O_BINARY 0
+#endif
+
#ifdef WIN32
typedef u_int64_t InodeRefType;
#else
diff --git a/lib/common/FdGetLine.h b/lib/common/FdGetLine.h
index fecb0371..a18007a3 100644
--- a/lib/common/FdGetLine.h
+++ b/lib/common/FdGetLine.h
@@ -14,6 +14,10 @@
#ifdef NDEBUG
#define FDGETLINE_BUFFER_SIZE 1024
+#elif defined WIN32
+ // need enough space for at least one unicode character
+ // in UTF-8 when calling console_read() from bbackupquery
+ #define FDGETLINE_BUFFER_SIZE 5
#else
#define FDGETLINE_BUFFER_SIZE 4
#endif
diff --git a/lib/common/Guards.h b/lib/common/Guards.h
index 17d73b3f..b1bca0fa 100644
--- a/lib/common/Guards.h
+++ b/lib/common/Guards.h
@@ -24,7 +24,7 @@
#include "MemLeakFindOn.h"
-template <int flags = O_RDONLY, int mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)>
+template <int flags = O_RDONLY | O_BINARY, int mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)>
class FileHandleGuard
{
public:
diff --git a/lib/common/UnixUser.cpp b/lib/common/UnixUser.cpp
index df2d0ddd..d0fd337b 100644
--- a/lib/common/UnixUser.cpp
+++ b/lib/common/UnixUser.cpp
@@ -75,6 +75,7 @@ UnixUser::UnixUser(uid_t UID, gid_t GID)
// --------------------------------------------------------------------------
UnixUser::~UnixUser()
{
+#ifndef WIN32
if(mRevertOnDestruction)
{
// Revert to "real" user and group id of the process
@@ -84,6 +85,7 @@ UnixUser::~UnixUser()
THROW_EXCEPTION(CommonException, CouldNotRestoreProcessUser)
}
}
+#endif
}
@@ -98,6 +100,7 @@ UnixUser::~UnixUser()
// --------------------------------------------------------------------------
void UnixUser::ChangeProcessUser(bool Temporary)
{
+#ifndef WIN32
if(Temporary)
{
// Change temporarily (change effective only)
@@ -119,6 +122,7 @@ void UnixUser::ChangeProcessUser(bool Temporary)
THROW_EXCEPTION(CommonException, CouldNotChangeProcessUser)
}
}
+#endif
}
diff --git a/lib/common/makeexception.pl.in b/lib/common/makeexception.pl.in
index 1564b75b..c03b8277 100755
--- a/lib/common/makeexception.pl.in
+++ b/lib/common/makeexception.pl.in
@@ -1,9 +1,11 @@
#!@PERL@
+use lib "../../infrastructure";
+use BoxPlatform;
+
# global exception list file
my $global_list = '../../ExceptionCodes.txt';
-
my @exception;
my @exception_desc;
my $class;
@@ -46,8 +48,8 @@ close EXCEPTION_DESC;
# write the code
print "Generating $class exception...\n";
-open CPP,">autogen_${class}Exception.cpp" or die "Can't open cpp file for writing";
-open H,">autogen_${class}Exception.h" or die "Can't open h file for writing";
+open CPP,">autogen_${class}Exception.cpp.new" or die "Can't open cpp file for writing";
+open H,">autogen_${class}Exception.h.new" or die "Can't open h file for writing";
# write header file
my $guardname = uc 'AUTOGEN_'.$class.'EXCEPTION_H';
@@ -200,6 +202,9 @@ __E
close H;
close CPP;
+update_if_changed("autogen_${class}Exception.cpp");
+update_if_changed("autogen_${class}Exception.h");
+
# update the global exception list
my $list_before;
my $list_after;