diff options
76 files changed, 7973 insertions, 148 deletions
diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 00000000..b268b0c9 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1,2 @@ +0.09_autoconf_win32 +boxbackup diff --git a/bbackupctl.vcproj b/bbackupctl.vcproj new file mode 100644 index 00000000..f5cf53d8 --- /dev/null +++ b/bbackupctl.vcproj @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="bbackupctl"
+ ProjectGUID="{9FD51412-E945-4457-A17A-CA3C505CF431}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(ProjectDir)..\db-4.2.52.NC\build_win32";"$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Debug\common.lib $(ProjectDir)..\db-4.2.52.NC\build_win32\Debug\libdb42d.lib"
+ OutputFile="$(OutDir)/bbackupctl.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/bbackupctl.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableFiberSafeOptimizations="TRUE"
+ OptimizeForProcessor="1"
+ AdditionalIncludeDirectories=""$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Release\common.lib"
+ OutputFile="$(OutDir)/bbackupctl.exe"
+ LinkIncremental="1"
+ IgnoreDefaultLibraryNames=""
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <Filter
+ Name="bin"
+ Filter="">
+ <Filter
+ Name="bbackupctl"
+ Filter="">
+ <File
+ RelativePath=".\bin\bbackupctl\bbackupctl.cpp">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/bbackupd.vcproj b/bbackupd.vcproj new file mode 100644 index 00000000..1b2267f1 --- /dev/null +++ b/bbackupd.vcproj @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="bbackupd"
+ ProjectGUID="{22D325FB-9131-4BD6-B390-968F0491D687}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)..\db-4.2.52.NC\build_win32";"$(SolutionDir)..\boost_1_31_0";"$(SolutionDir)..\openssl\include";"$(SolutionDir)..\zlib\include";"$(SolutionDir)lib\backupclient";"$(SolutionDir)lib\server";"$(SolutionDir)lib\crypto";"$(SolutionDir)lib\compress";"$(SolutionDir)lib\win32";"$(SolutionDir)lib\common\""
+ PreprocessorDefinitions="BOOST_REGEX_NO_LIB;WIN32;_DEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Debug\common.lib $(ProjectDir)lib\win32\Debug\boost_regex.lib $(ProjectDir)..\db-4.2.52.NC\build_win32\Debug\libdb42d.lib"
+ OutputFile="$(OutDir)/bbackupd.exe"
+ LinkIncremental="2"
+ IgnoreAllDefaultLibraries="FALSE"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/bbackupd.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableFiberSafeOptimizations="TRUE"
+ OptimizeForProcessor="1"
+ AdditionalIncludeDirectories=""$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\";"$(SolutionDir)..\boost_1_31_0""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING;BOOST_REGEX_NO_LIB"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Release\common.lib $(ProjectDir)lib\win32\Release\boost_regex.lib"
+ OutputFile="$(OutDir)/bbackupd.exe"
+ LinkIncremental="1"
+ IgnoreDefaultLibraryNames=""
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <Filter
+ Name="bin"
+ Filter="">
+ <Filter
+ Name="bbackupd"
+ Filter="">
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientContext.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientDeleteList.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientDirectoryRecord.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientInodeToIDMap.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupDaemon.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\bbackupd.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\bbwinservice.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\ServiceBackupDaemon.cpp">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <Filter
+ Name="bin"
+ Filter="">
+ <Filter
+ Name="bbackupd"
+ Filter="">
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientContext.h">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientDeleteList.h">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientDirectoryRecord.h">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupClientInodeToIDMap.h">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\BackupDaemon.h">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\bbwinservice.h">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupd\ServiceBackupDaemon.h">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/bin/bbackupctl/bbackupctl.cpp b/bin/bbackupctl/bbackupctl.cpp index 0dc4f98d..d39092e8 100755 --- a/bin/bbackupctl/bbackupctl.cpp +++ b/bin/bbackupctl/bbackupctl.cpp @@ -19,6 +19,10 @@ #include "SocketStream.h" #include "IOStreamGetLine.h" +#ifdef WIN32 + #include "WinNamedPipeStream.h" +#endif + #include "MemLeakFindOn.h" void PrintUsageAndExit() @@ -26,7 +30,8 @@ void PrintUsageAndExit() printf("Usage: bbackupctl [-q] [-c config_file] <command>\n" "Commands are:\n" " sync -- start a syncronisation run now\n" - " force-sync -- force the start of a syncronisation run, even if SyncAllowScript says no\n" + " force-sync -- force the start of a syncronisation run, " + "even if SyncAllowScript says no\n" " reload -- reload daemon configuration\n" " terminate -- terminate daemon now\n" " wait-for-sync -- wait until the next sync starts, then exit\n" @@ -38,7 +43,12 @@ int main(int argc, const char *argv[]) { int returnCode = 0; - MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupctl.memleaks", "bbackupctl") +#if defined WIN32 && ! defined NDEBUG + ::openlog("Box Backup (bbackupctl)", 0, 0); +#endif + + MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupctl.memleaks", + "bbackupctl") MAINHELPER_START @@ -99,20 +109,35 @@ int main(int argc, const char *argv[]) } // Connect to socket + +#ifndef WIN32 SocketStream connection; +#else /* WIN32 */ + WinNamedPipeStream connection; +#endif /* ! WIN32 */ + try { +#ifdef WIN32 + connection.Connect(BOX_NAMED_PIPE_NAME); +#else connection.Open(Socket::TypeUNIX, conf.GetKeyValue("CommandSocket").c_str()); +#endif } catch(...) { - printf("Failed to connect to daemon control socket.\n" \ - "Possible causes:\n" \ - " * Daemon not running\n" \ - " * Daemon busy syncing with store server\n" \ - " * Another bbackupctl process is communicating with the daemon\n" \ + printf("Failed to connect to daemon control socket.\n" + "Possible causes:\n" + " * Daemon not running\n" + " * Daemon busy syncing with store server\n" + " * Another bbackupctl process is communicating with the daemon\n" " * Daemon is waiting to recover from an error\n" ); + +#if defined WIN32 && ! defined NDEBUG + syslog(LOG_ERR,"Failed to connect to the command socket"); +#endif + return 1; } @@ -123,14 +148,29 @@ int main(int argc, const char *argv[]) std::string configSummary; if(!getLine.GetLine(configSummary)) { +#if defined WIN32 && ! defined NDEBUG + syslog(LOG_ERR, "Failed to receive configuration summary " + "from daemon"); +#else printf("Failed to receive configuration summary from daemon\n"); +#endif + return 1; } // Was the connection rejected by the server? if(getLine.IsEOF()) { - printf("Server rejected the connection. Are you running bbackupctl as the same user as the daemon?\n"); +#if defined WIN32 && ! defined NDEBUG + syslog(LOG_ERR, "Server rejected the connection. " + "Are you running bbackupctl as the same user " + "as the daemon?"); +#else + printf("Server rejected the connection. " + "Are you running bbackupctl as the same user " + "as the daemon?\n"); +#endif + return 1; } @@ -212,6 +252,10 @@ int main(int argc, const char *argv[]) } MAINHELPER_END + +#if defined WIN32 && ! defined NDEBUG + closelog(); +#endif return returnCode; } diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp index 08a203c1..50f2cd08 100755 --- a/bin/bbackupd/BackupClientContext.cpp +++ b/bin/bbackupd/BackupClientContext.cpp @@ -9,7 +9,9 @@ #include "Box.h" +#ifndef WIN32 #include <syslog.h> +#endif #include "BoxPortsAndFiles.h" #include "BoxTime.h" diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp index 307c72c4..1a124333 100755 --- a/bin/bbackupd/BackupClientDirectoryRecord.cpp +++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp @@ -133,7 +133,8 @@ void BackupClientDirectoryRecord::SyncDirectory(BackupClientDirectoryRecord::Syn { // The directory has probably been deleted, so just ignore this error. // In a future scan, this deletion will be noticed, deleted from server, and this object deleted. - TRACE1("Stat failed for '%s' (directory)\n", rLocalPath.c_str()); + TRACE1("Stat failed for '%s' (directory)\n", + rLocalPath.c_str()); return; } // Store inode number in map so directories are tracked in case they're renamed @@ -202,11 +203,18 @@ void BackupClientDirectoryRecord::SyncDirectory(BackupClientDirectoryRecord::Syn } // Stat file to get info - filename = rLocalPath + DIRECTORY_SEPARATOR + en->d_name; + filename = rLocalPath + DIRECTORY_SEPARATOR + + en->d_name; + if(::lstat(filename.c_str(), &st) != 0) { - TRACE1("Stat failed for '%s' (contents)\n", filename.c_str()); - THROW_EXCEPTION(CommonException, OSFileError) + // Report the error (logs and + // eventual email to administrator) + SetErrorWhenReadingFilesystemObject( + rParams, filename.c_str()); + + // Ignore this entry for now. + continue; } int type = st.st_mode & S_IFMT; @@ -506,7 +514,7 @@ bool BackupClientDirectoryRecord::UpdateItems(BackupClientDirectoryRecord::SyncP box_time_t modTime = 0; uint64_t attributesHash = 0; int64_t fileSize = 0; - ino_t inodeNum = 0; + InodeRefType inodeNum = 0; bool hasMultipleHardLinks = true; // BLOCK { @@ -865,7 +873,7 @@ bool BackupClientDirectoryRecord::UpdateItems(BackupClientDirectoryRecord::SyncP // Get attributes box_time_t attrModTime = 0; - ino_t inodeNum = 0; + InodeRefType inodeNum = 0; BackupClientFileAttributes attr; attr.ReadAttributes(dirname.c_str(), true /* directories have zero mod times */, 0 /* not interested in mod time */, &attrModTime, 0 /* not file size */, @@ -1109,8 +1117,12 @@ int64_t BackupClientDirectoryRecord::UploadFile(BackupClientDirectoryRecord::Syn std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(rFilename.c_str(), mObjectID, rStoreFilename)); // Send to store - std::auto_ptr<BackupProtocolClientSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime, - AttributesHash, 0 /* no diff from file ID */, rStoreFilename, *upload)); + std::auto_ptr<BackupProtocolClientSuccess> stored( + connection.QueryStoreFile( + mObjectID, ModificationTime, + AttributesHash, + 0 /* no diff from file ID */, + rStoreFilename, *upload)); // Get object ID from the result objID = stored->GetObjectID(); @@ -1130,7 +1142,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(BackupClientDirectoryRecord::Syn rParams.mrDaemon.NotifySysadmin(BackupDaemon::NotifyEvent_StoreFull); } } - + // Send the error on it's way throw; } diff --git a/bin/bbackupd/BackupClientInodeToIDMap.cpp b/bin/bbackupd/BackupClientInodeToIDMap.cpp index 7141d5f4..c3f20df0 100755 --- a/bin/bbackupd/BackupClientInodeToIDMap.cpp +++ b/bin/bbackupd/BackupClientInodeToIDMap.cpp @@ -65,7 +65,11 @@ BackupClientInodeToIDMap::~BackupClientInodeToIDMap() #ifndef BACKIPCLIENTINODETOIDMAP_IN_MEMORY_IMPLEMENTATION if(dbp != 0) { +#ifdef BERKELY_V4 + dbp->close(0); +#else dbp->close(dbp); +#endif } #endif } @@ -90,7 +94,14 @@ void BackupClientInodeToIDMap::Open(const char *Filename, bool ReadOnly, bool Cr ASSERT(!mEmpty); // Open the database file +#ifdef BERKELY_V4 + dbp = new Db(0,0); + dbp->set_pagesize(1024); /* Page size: 1K. */ + dbp->set_cachesize(0, 32 * 1024, 0); + dbp->open(NULL, Filename, NULL, DB_HASH, DB_CREATE, 0664); +#else dbp = dbopen(Filename, (CreateNew?O_CREAT:0) | (ReadOnly?O_RDONLY:O_RDWR), S_IRUSR | S_IWUSR | S_IRGRP, TABLE_DATABASE_TYPE, NULL); +#endif if(dbp == NULL) { THROW_EXCEPTION(BackupStoreException, BerkelyDBFailure); @@ -135,7 +146,11 @@ void BackupClientInodeToIDMap::Close() #ifndef BACKIPCLIENTINODETOIDMAP_IN_MEMORY_IMPLEMENTATION if(dbp != 0) { +#ifdef BERKELY_V4 + if(dbp->close(0) != 0) +#else if(dbp->close(dbp) != 0) +#endif { THROW_EXCEPTION(BackupStoreException, BerkelyDBFailure); } @@ -172,6 +187,15 @@ void BackupClientInodeToIDMap::AddToMap(InodeRefType InodeRef, int64_t ObjectID, IDBRecord rec; rec.mObjectID = ObjectID; rec.mInDirectory = InDirectory; + +#ifdef BERKELY_V4 + Dbt key(&InodeRef, sizeof(InodeRef)); + Dbt data(&rec, sizeof(rec)); + + if (dbp->put(0, &key, &data, 0) != 0) { + THROW_EXCEPTION(BackupStoreException, BerkelyDBFailure); + } +#else DBT key; key.data = &InodeRef; @@ -187,6 +211,7 @@ void BackupClientInodeToIDMap::AddToMap(InodeRefType InodeRef, int64_t ObjectID, THROW_EXCEPTION(BackupStoreException, BerkelyDBFailure); } #endif +#endif } // -------------------------------------------------------------------------- @@ -225,6 +250,11 @@ bool BackupClientInodeToIDMap::Lookup(InodeRefType InodeRef, int64_t &rObjectIDO THROW_EXCEPTION(BackupStoreException, InodeMapNotOpen); } +#ifdef BERKELY_V4 + Dbt key(&InodeRef, sizeof(InodeRef)); + Dbt data(0, 0); + switch(dbp->get(NULL, &key, &data, 0)) +#else DBT key; key.data = &InodeRef; key.size = sizeof(InodeRef); @@ -234,6 +264,8 @@ bool BackupClientInodeToIDMap::Lookup(InodeRefType InodeRef, int64_t &rObjectIDO data.size = 0; switch(dbp->get(dbp, &key, &data, 0)) +#endif + { case 1: // key not in file return false; @@ -248,6 +280,21 @@ bool BackupClientInodeToIDMap::Lookup(InodeRefType InodeRef, int64_t &rObjectIDO } // Check for sensible return +#ifdef BERKELY_V4 + if(key.get_data() == 0 || data.get_size() != sizeof(IDBRecord)) + { + // Assert in debug version + ASSERT(key.get_data() == 0 || data.get_size() != sizeof(IDBRecord)); + + // Invalid entries mean it wasn't found + return false; + } + + // Data alignment isn't guaranteed to be on a suitable boundary + IDBRecord rec; + + ::memcpy(&rec, data.get_data(), sizeof(rec)); +#else if(key.data == 0 || data.size != sizeof(IDBRecord)) { // Assert in debug version @@ -257,9 +304,11 @@ bool BackupClientInodeToIDMap::Lookup(InodeRefType InodeRef, int64_t &rObjectIDO return false; } - // Data alignment isn't guarentted to be on a suitable bounday + // Data alignment isn't guaranteed to be on a suitable boundary IDBRecord rec; + ::memcpy(&rec, data.data, sizeof(rec)); +#endif // Return data rObjectIDOut = rec.mObjectID; diff --git a/bin/bbackupd/BackupClientInodeToIDMap.h b/bin/bbackupd/BackupClientInodeToIDMap.h index 121e88fd..1dfef702 100755 --- a/bin/bbackupd/BackupClientInodeToIDMap.h +++ b/bin/bbackupd/BackupClientInodeToIDMap.h @@ -20,12 +20,14 @@ #define BACKIPCLIENTINODETOIDMAP_IN_MEMORY_IMPLEMENTATION #endif -typedef ino_t InodeRefType; - // avoid having to include the DB files when not necessary #ifndef BACKIPCLIENTINODETOIDMAP_IMPLEMENTATION +#ifdef BERKELY_V4 + class Db; +#else class DB; #endif +#endif // -------------------------------------------------------------------------- // @@ -58,8 +60,12 @@ private: #else bool mReadOnly; bool mEmpty; +#ifdef BERKELY_V4 + Db *dbp; // c++ style implimentation +#else DB *dbp; // C style interface, use notation from documentation -#endif +#endif // BERKELY_V4 +#endif // BACKIPCLIENTINODETOIDMAP_IN_MEMORY_IMPLEMENTATION }; #endif // BACKUPCLIENTINODETOIDMAP__H diff --git a/bin/bbackupd/BackupDaemon.cpp b/bin/bbackupd/BackupDaemon.cpp index f22de591..c56aaa59 100755 --- a/bin/bbackupd/BackupDaemon.cpp +++ b/bin/bbackupd/BackupDaemon.cpp @@ -9,26 +9,31 @@ #include "Box.h" +#include <stdio.h> #include <unistd.h> -#include <syslog.h> -#include <sys/param.h> -#include <signal.h> + +#ifndef WIN32 + #include <signal.h> + #include <syslog.h> + #include <sys/param.h> + #include <sys/wait.h> +#endif #ifdef HAVE_SYS_MOUNT_H - #include <sys/mount.h> + #include <sys/mount.h> #endif #ifdef HAVE_MNTENT_H - #include <mntent.h> -#endif + #include <mntent.h> +#endif #ifdef HAVE_SYS_MNTTAB_H #include <cstdio> #include <sys/mnttab.h> #endif -#include <sys/wait.h> #include "Configuration.h" #include "IOStream.h" #include "MemBlockStream.h" #include "CommonException.h" +#include "BoxPortsAndFiles.h" #include "SSLLib.h" #include "TLSContext.h" @@ -160,8 +165,9 @@ const ConfigurationVerify *BackupDaemon::GetConfigVerify() const // // Function // Name: BackupDaemon::SetupInInitialProcess() -// Purpose: Platforms with non-checkable credientals on local sockets only. -// Prints a warning if the command socket is used. +// Purpose: Platforms with non-checkable credentials on +// local sockets only. +// Prints a warning if the command socket is used. // Created: 25/2/04 // // -------------------------------------------------------------------------- @@ -206,6 +212,133 @@ void BackupDaemon::DeleteAllLocations() mIDMapMounts.clear(); } +#ifdef WIN32 +// -------------------------------------------------------------------------- +// +// Function +// Name: HelperThread() +// Purpose: Background thread function, called by Windows, +// calls the BackupDaemon's RunHelperThread method +// to listen for and act on control communications +// Created: 18/2/04 +// +// -------------------------------------------------------------------------- +unsigned int WINAPI HelperThread( LPVOID lpParam ) +{ + printf( "Parameter = %lu.\n", *(DWORD*)lpParam ); + ((BackupDaemon *)lpParam)->RunHelperThread(); + + return 0; +} + +void BackupDaemon::RunHelperThread(void) +{ + mpCommandSocketInfo = new CommandSocketInfo; + this->mReceivedCommandConn = false; + + while ( !IsTerminateWanted() ) + { + try + { + mpCommandSocketInfo->mListeningSocket.Accept( + BOX_NAMED_PIPE_NAME); + + // This next section comes from Ben's original function + // Log + ::syslog(LOG_INFO, "Connection from command socket"); + + // Send a header line summarising the configuration + // and current state + const Configuration &conf(GetConfiguration()); + char summary[256]; + size_t summarySize = sprintf(summary, + "bbackupd: %d %d %d %d\nstate %d\n", + conf.GetKeyValueBool("AutomaticBackup"), + conf.GetKeyValueInt("UpdateStoreInterval"), + conf.GetKeyValueInt("MinimumFileAge"), + conf.GetKeyValueInt("MaxUploadWait"), + mState); + + mpCommandSocketInfo->mListeningSocket.Write(summary, summarySize); + mpCommandSocketInfo->mListeningSocket.Write("ping\n", 5); + + IOStreamGetLine readLine(mpCommandSocketInfo->mListeningSocket); + std::string command; + + while (mpCommandSocketInfo->mListeningSocket.IsConnected() && + readLine.GetLine(command) ) + { + TRACE1("Receiving command '%s' over " + "command socket\n", command.c_str()); + + bool sendOK = false; + bool sendResponse = true; + bool disconnect = false; + + // Command to process! + if(command == "quit" || command == "") + { + // Close the socket. + disconnect = true; + sendResponse = false; + } + else if(command == "sync") + { + // Sync now! + this->mDoSyncFlagOut = true; + this->mSyncIsForcedOut = false; + sendOK = true; + } + else if(command == "force-sync") + { + // Sync now (forced -- overrides any SyncAllowScript) + this->mDoSyncFlagOut = true; + this->mSyncIsForcedOut = true; + sendOK = true; + } + else if(command == "reload") + { + // Reload the configuration + SetReloadConfigWanted(); + sendOK = true; + } + else if(command == "terminate") + { + // Terminate the daemon cleanly + SetTerminateWanted(); + sendOK = true; + } + + // Send a response back? + if (sendResponse) + { + const char* response = sendOK ? "ok\n" : "error\n"; + mpCommandSocketInfo->mListeningSocket.Write( + response, strlen(response)); + } + + if (disconnect) + { + break; + } + + this->mReceivedCommandConn = true; + } + + mpCommandSocketInfo->mListeningSocket.Close(); + } + catch (BoxException &e) + { + ::syslog(LOG_ERR, "Communication error with " + "control client: %s", e.what()); + } + catch (...) + { + ::syslog(LOG_ERR, "Communication error with control client"); + } + } +} +#endif // -------------------------------------------------------------------------- // @@ -217,6 +350,25 @@ void BackupDaemon::DeleteAllLocations() // -------------------------------------------------------------------------- void BackupDaemon::Run() { +#ifdef WIN32 + + // Create a thread to handle the named pipe + HANDLE hThread; + unsigned int dwThreadId; + + hThread = (HANDLE) _beginthreadex( + NULL, // default security attributes + 0, // use default stack size + HelperThread, // thread function + this, // argument to thread function + 0, // use default creation flags + &dwThreadId); // returns the thread identifier + + // init our own timer for file diff timeouts + InitTimer(); + +#else // ! WIN32 + // Ignore SIGPIPE (so that if a command connection is broken, the daemon doesn't terminate) ::signal(SIGPIPE, SIG_IGN); @@ -230,6 +382,8 @@ void BackupDaemon::Run() ::unlink(socketName); mpCommandSocketInfo->mListeningSocket.Listen(Socket::TypeUNIX, socketName); } + +#endif // WIN32 // Handle things nicely on exceptions try @@ -253,6 +407,11 @@ void BackupDaemon::Run() delete mpCommandSocketInfo; mpCommandSocketInfo = 0; } + +#ifdef WIN32 + // clean up windows specific stuff. + FiniTimer(); +#endif } // -------------------------------------------------------------------------- @@ -303,9 +462,9 @@ void BackupDaemon::Run2() // When the last sync started (only updated if the store was not full when the sync ended) box_time_t lastSyncTime = 0; - - // -------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------- + // And what's the current client store marker? int64_t clientStoreMarker = BackupClientContext::ClientStoreMarker_NotKnown; // haven't contacted the store yet @@ -409,6 +568,8 @@ void BackupDaemon::Run2() // Do sync bool errorOccurred = false; int errorCode = 0, errorSubCode = 0; + const char* errorString = "unknown"; + try { // Set state and log start @@ -512,6 +673,7 @@ void BackupDaemon::Run2() catch(BoxException &e) { errorOccurred = true; + errorString = e.what(); errorCode = e.GetType(); errorSubCode = e.GetSubType(); } @@ -555,8 +717,13 @@ void BackupDaemon::Run2() { // Not restart/terminate, pause and retry SetState(State_Error); - ::syslog(LOG_ERR, "Exception caught (%d/%d), reset state and waiting to retry...", errorCode, errorSubCode); - ::sleep(100); + ::syslog(LOG_ERR, + "Exception caught (%s %d/%d), " + "reset state and waiting " + "to retry...", + errorString, errorCode, + errorSubCode); + ::sleep(10); } } @@ -665,6 +832,29 @@ int BackupDaemon::UseScriptToSeeIfSyncAllowed() // -------------------------------------------------------------------------- void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFlagOut, bool &SyncIsForcedOut) { +#ifdef WIN32 + // Really could use some interprocess protection, mutex etc + // any side effect should be too bad???? :) + DWORD timeout = BoxTimeToMilliSeconds(RequiredDelay); + + while ( this->mReceivedCommandConn == false ) + { + Sleep(1); + + if ( timeout == 0 ) + { + DoSyncFlagOut = false; + SyncIsForcedOut = false; + return; + } + timeout--; + } + this->mReceivedCommandConn = false; + DoSyncFlagOut = this->mDoSyncFlagOut; + SyncIsForcedOut = this->mSyncIsForcedOut; + + return; +#else // ! WIN32 ASSERT(mpCommandSocketInfo != 0); if(mpCommandSocketInfo == 0) {::sleep(1); return;} // failure case isn't too bad @@ -713,9 +903,9 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla } } } -#endif +#endif // PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET - // Is this an acceptible connection? + // Is this an acceptable connection? if(!uidOK) { // Dump the connection @@ -833,6 +1023,7 @@ void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFla CloseCommandConnection(); } } +#endif // WIN32 } @@ -849,13 +1040,17 @@ void BackupDaemon::CloseCommandConnection() try { TRACE0("Closing command connection\n"); - + +#ifdef WIN32 + mpCommandSocketInfo->mListeningSocket.Close(); +#else if(mpCommandSocketInfo->mpGetLine) { delete mpCommandSocketInfo->mpGetLine; mpCommandSocketInfo->mpGetLine = 0; } mpCommandSocketInfo->mpConnectedSocket.reset(); +#endif } catch(...) { @@ -875,15 +1070,27 @@ void BackupDaemon::CloseCommandConnection() // -------------------------------------------------------------------------- void BackupDaemon::SendSyncStartOrFinish(bool SendStart) { - // The bbackupctl program can't rely on a state change, because it may never // change if the server doesn't need to be contacted. - if(mpCommandSocketInfo != 0 && mpCommandSocketInfo->mpConnectedSocket.get() != 0) + if (mpCommandSocketInfo != NULL && +#ifdef WIN32 + mpCommandSocketInfo->mListeningSocket.IsConnected() +#else + mpCommandSocketInfo->mpConnectedSocket.get() != 0 +#endif + ) { + const char* message = SendStart ? "start-sync\n" : "finish-sync\n"; try { - mpCommandSocketInfo->mpConnectedSocket->Write(SendStart?"start-sync\n":"finish-sync\n", SendStart?11:12); +#ifdef WIN32 + mpCommandSocketInfo->mListeningSocket.Write(message, + strlen(message)); +#else + mpCommandSocketInfo->mpConnectedSocket->Write(message, + strlen(message)); +#endif } catch(...) { @@ -958,6 +1165,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con std::map<std::string, int> mounts; int numIDMaps = 0; +#ifdef HAVE_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 @@ -996,7 +1204,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con ::endmntent(mountPointsFile); throw; } -#else +#else // ! HAVE_STRUCT_MNTENT_MNT_DIR // Open mounts file mountPointsFile = ::fopen("/etc/mnttab", "r"); if(mountPointsFile == 0) @@ -1023,7 +1231,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con ::fclose(mountPointsFile); throw; } -#endif +#endif // HAVE_STRUCT_MNTENT_MNT_DIR // Check sorting and that things are as we expect ASSERT(mountPoints.size() > 0); #ifndef NDEBUG @@ -1033,6 +1241,7 @@ void BackupDaemon::SetupLocations(BackupClientContext &rClientContext, const Con } #endif // n NDEBUG #endif // n HAVE_STRUCT_STATFS_F_MNTONNAME +#endif // HAVE_MOUNTS // Then... go through each of the entries in the configuration, // making sure there's a directory created for it. @@ -1054,7 +1263,9 @@ TRACE0("new location\n"); // Do a fsstat on the pathname to find out which mount it's on { -#ifdef HAVE_STRUCT_STATFS_F_MNTONNAME + +#if defined HAVE_STRUCT_STATFS_F_MNTONNAME || defined WIN32 + // BSD style statfs -- includes mount point, which is nice. struct statfs s; if(::statfs(ploc->mPath.c_str(), &s) != 0) @@ -1064,7 +1275,9 @@ TRACE0("new location\n"); // Where the filesystem is mounted std::string mountName(s.f_mntonname); -#else + +#else // !HAVE_STRUCT_STATFS_F_MNTONNAME && !WIN32 + // Warn in logs if the directory isn't absolute if(ploc->mPath[0] != '/') { @@ -1090,6 +1303,7 @@ TRACE0("new location\n"); } TRACE2("mount point chosen for %s is %s\n", ploc->mPath.c_str(), mountName.c_str()); } + #endif // Got it? @@ -1376,6 +1590,10 @@ void BackupDaemon::CommitIDMapsAfterSync() std::string newmap(target + ".n"); // Try to rename +#ifdef WIN32 + // win32 rename doesn't overwrite existing files + ::remove(target.c_str()); +#endif if(::rename(newmap.c_str(), target.c_str()) != 0) { THROW_EXCEPTION(CommonException, OSFileError) @@ -1457,14 +1675,33 @@ void BackupDaemon::SetState(int State) // Set process title const static char *stateText[] = {"idle", "connected", "error -- waiting for retry", "over limit on server -- not backing up"}; SetProcessTitle(stateText[State]); - + // If there's a command socket connected, then inform it -- disconnecting from the // command socket if there's an error + + char newState[64]; + char newStateSize = sprintf(newState, "state %d\n", State); + +#ifdef WIN32 + #warning FIX ME: race condition + // what happens if the socket is closed by the other thread before + // we can write to it? Null pointer deref at best. + if (mpCommandSocketInfo && + mpCommandSocketInfo->mListeningSocket.IsConnected()) + { + try + { + mpCommandSocketInfo->mListeningSocket.Write(newState, newStateSize); + } + catch(...) + { + CloseCommandConnection(); + } + } +#else if(mpCommandSocketInfo != 0 && mpCommandSocketInfo->mpConnectedSocket.get() != 0) { // Something connected to the command socket, tell it about the new state - char newState[64]; - char newStateSize = sprintf(newState, "state %d\n", State); try { mpCommandSocketInfo->mpConnectedSocket->Write(newState, newStateSize); @@ -1474,6 +1711,7 @@ void BackupDaemon::SetState(int State) CloseCommandConnection(); } } +#endif } @@ -1658,4 +1896,3 @@ BackupDaemon::CommandSocketInfo::~CommandSocketInfo() mpGetLine = 0; } } - diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h index ffaf5783..e6798798 100755 --- a/bin/bbackupd/BackupDaemon.h +++ b/bin/bbackupd/BackupDaemon.h @@ -19,6 +19,7 @@ #include "Socket.h" #include "SocketListen.h" #include "SocketStream.h" +#include "WinNamedPipeStream.h" class BackupClientDirectoryRecord; class BackupClientContext; @@ -146,8 +147,12 @@ private: CommandSocketInfo(const CommandSocketInfo &); // no copying CommandSocketInfo &operator=(const CommandSocketInfo &); public: +#ifdef WIN32 + WinNamedPipeStream mListeningSocket; +#else SocketListen<SocketStream, 1 /* listen backlog */> mListeningSocket; std::auto_ptr<SocketStream> mpConnectedSocket; +#endif IOStreamGetLine *mpGetLine; }; @@ -160,7 +165,14 @@ private: // Unused entries in the root directory wait a while before being deleted box_time_t mDeleteUnusedRootDirEntriesAfter; // time to delete them std::vector<std::pair<int64_t,std::string> > mUnusedRootDirEntries; + +#ifdef WIN32 + public: + void RunHelperThread(void); + + private: + bool mDoSyncFlagOut, mSyncIsForcedOut, mReceivedCommandConn; +#endif }; #endif // BACKUPDAEMON__H - diff --git a/bin/bbackupd/Win32BackupService.cpp b/bin/bbackupd/Win32BackupService.cpp new file mode 100644 index 00000000..aa3bf55c --- /dev/null +++ b/bin/bbackupd/Win32BackupService.cpp @@ -0,0 +1,51 @@ +// Win32 service functions for Box Backup, by Nick Knight + +#ifdef WIN32 + +#include "Box.h" +#include "BackupDaemon.h" +#include "MainHelper.h" +#include "BoxPortsAndFiles.h" +#include "BackupStoreException.h" + +#include "MemLeakFindOn.h" + +#include "Win32BackupService.h" + +Win32BackupService gDaemonService; +extern HANDLE gStopServiceEvent; + +unsigned int WINAPI RunService(LPVOID lpParameter) +{ + DWORD retVal = gDaemonService.WinService(); + SetEvent( gStopServiceEvent ); + return retVal; +} + +void TerminateService(void) +{ + gDaemonService.SetTerminateWanted(); +} + +DWORD Win32BackupService::WinService(void) +{ + int argc = 2; + //first off get the path name for the default + char buf[MAX_PATH]; + + GetModuleFileName(NULL, buf, sizeof(buf)); + std::string buffer(buf); + std::string conf( "-c"); + std::string cfile(buffer.substr(0,(buffer.find("bbackupd.exe"))) + + "bbackupd.conf"); + + const char *argv[] = {conf.c_str(), cfile.c_str()}; + + MAINHELPER_START + + return this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); + + MAINHELPER_END +} + +#endif // WIN32 diff --git a/bin/bbackupd/Win32BackupService.h b/bin/bbackupd/Win32BackupService.h new file mode 100644 index 00000000..38cebacc --- /dev/null +++ b/bin/bbackupd/Win32BackupService.h @@ -0,0 +1,21 @@ +// Box Backup service daemon implementation by Nick Knight + +#ifndef WIN32BACKUPSERVICE_H +#define WIN32BACKUPSERVICE_H + +#ifdef WIN32 + +class Configuration; +class ConfigurationVerify; +class BackupDaemon; + +class Win32BackupService : public BackupDaemon +{ +public: + DWORD WinService(void); +}; + +#endif // WIN32 + +#endif // WIN32BACKUPSERVICE_H + diff --git a/bin/bbackupd/Win32ServiceFunctions.cpp b/bin/bbackupd/Win32ServiceFunctions.cpp new file mode 100644 index 00000000..89f02f62 --- /dev/null +++ b/bin/bbackupd/Win32ServiceFunctions.cpp @@ -0,0 +1,236 @@ +//*************************************************************** +// From the book "Win32 System Services: The Heart of Windows 98 +// and Windows 2000" +// by Marshall Brain +// Published by Prentice Hall +// Copyright 1995 Prentice Hall. +// +// This code implements the Windows API Service interface +// for the Box Backup for Windows native port. +// Adapted for Box Backup by Nick Knight. +//*************************************************************** + +#ifdef WIN32 + +#include "Box.h" + +//#include <stdio.h> +//#include <stdlib.h> +#include <unistd.h> +//#include <windows.h> + +extern void TerminateService(void); +extern unsigned int WINAPI RunService(LPVOID lpParameter); + +// Global variables + +TCHAR* gServiceName = TEXT("Box Backup Service"); +SERVICE_STATUS gServiceStatus; +SERVICE_STATUS_HANDLE gServiceStatusHandle = 0; +HANDLE gStopServiceEvent = 0; + +#define SERVICE_NAME "boxbackup" + +void ErrorHandler(char *s, DWORD err) +{ + char buf[256]; + memset(buf, 0, sizeof(buf)); + snprintf(buf, sizeof(buf)-1, "%s (%d)", s, err); + ::syslog(LOG_ERR, "%s", buf); + MessageBox(0, buf, "Error", + MB_OK | MB_SETFOREGROUND | MB_DEFAULT_DESKTOP_ONLY); + ExitProcess(err); +} + + +void WINAPI ServiceControlHandler( DWORD controlCode ) +{ + switch ( controlCode ) + { + case SERVICE_CONTROL_INTERROGATE: + break; + + case SERVICE_CONTROL_SHUTDOWN: + case SERVICE_CONTROL_STOP: + Beep(1000,100); + TerminateService(); + gServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + SetServiceStatus(gServiceStatusHandle, &gServiceStatus); + + SetEvent(gStopServiceEvent); + return; + + case SERVICE_CONTROL_PAUSE: + break; + + case SERVICE_CONTROL_CONTINUE: + break; + + default: + if ( controlCode >= 128 && controlCode <= 255 ) + // user defined control code + break; + else + // unrecognised control code + break; + } + + SetServiceStatus( gServiceStatusHandle, &gServiceStatus ); +} + +// ServiceMain is called when the SCM wants to +// start the service. When it returns, the service +// has stopped. It therefore waits on an event +// just before the end of the function, and +// that event gets set when it is time to stop. +// It also returns on any error because the +// service cannot start if there is an eror. + +VOID ServiceMain(DWORD argc, LPTSTR *argv) +{ + // initialise service status + gServiceStatus.dwServiceType = SERVICE_WIN32; + gServiceStatus.dwCurrentState = SERVICE_STOPPED; + gServiceStatus.dwControlsAccepted = 0; + gServiceStatus.dwWin32ExitCode = NO_ERROR; + gServiceStatus.dwServiceSpecificExitCode = NO_ERROR; + gServiceStatus.dwCheckPoint = 0; + gServiceStatus.dwWaitHint = 0; + + gServiceStatusHandle = RegisterServiceCtrlHandler(gServiceName, + ServiceControlHandler); + + if (gServiceStatusHandle) + { + // service is starting + gServiceStatus.dwCurrentState = SERVICE_START_PENDING; + SetServiceStatus(gServiceStatusHandle, &gServiceStatus); + + // do initialisation here + gStopServiceEvent = CreateEvent( 0, TRUE, FALSE, 0 ); + if (!gStopServiceEvent) + { + gServiceStatus.dwControlsAccepted &= + ~(SERVICE_ACCEPT_STOP | + SERVICE_ACCEPT_SHUTDOWN); + gServiceStatus.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(gServiceStatusHandle, &gServiceStatus); + return; + } + + HANDLE ourThread = (HANDLE)_beginthreadex( + NULL, + 0, + RunService, + 0, + CREATE_SUSPENDED, + NULL); + + SetThreadPriority(ourThread, THREAD_PRIORITY_LOWEST); + ResumeThread(ourThread); + + // we are now running so tell the SCM + gServiceStatus.dwControlsAccepted |= + (SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); + gServiceStatus.dwCurrentState = SERVICE_RUNNING; + SetServiceStatus(gServiceStatusHandle, &gServiceStatus); + + // do cleanup here + WaitForSingleObject(gStopServiceEvent, INFINITE); + CloseHandle(gStopServiceEvent); + gStopServiceEvent = 0; + + // service was stopped + gServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + SetServiceStatus(gServiceStatusHandle, &gServiceStatus); + + // service is now stopped + gServiceStatus.dwControlsAccepted &= + ~(SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN); + gServiceStatus.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(gServiceStatusHandle, &gServiceStatus); + } +} + +void OurService(void) +{ + SERVICE_TABLE_ENTRY serviceTable[] = + { + { SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION) ServiceMain }, + { NULL, NULL } + }; + BOOL success; + + // Register with the SCM + success = StartServiceCtrlDispatcher(serviceTable); + + if (!success) + { + ErrorHandler("Failed to start service. Did you start " + "Box Backup from the Service Control Manager? " + "(StartServiceCtrlDispatcher)", GetLastError()); + } +} + +void InstallService(void) +{ + SC_HANDLE newService, scm; + + scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); + + if (!scm) return; + + char cmd[MAX_PATH]; + GetModuleFileName(NULL, cmd, sizeof(cmd)-1); + cmd[sizeof(cmd)-1] = 0; + + char cmd_args[MAX_PATH]; + snprintf(cmd_args, sizeof(cmd_args)-1, "%s --service", cmd); + cmd_args[sizeof(cmd_args)-1] = 0; + + newService = CreateService( + scm, + SERVICE_NAME, + "Box Backup", + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + cmd_args, + 0,0,0,0,0); + + if (newService) CloseServiceHandle(newService); + CloseServiceHandle(scm); +} + +void RemoveService(void) +{ + SC_HANDLE service, scm; + SERVICE_STATUS status; + + scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); + + if (!scm) return; + + service = OpenService(scm, SERVICE_NAME, SERVICE_ALL_ACCESS|DELETE); + ControlService(service, SERVICE_CONTROL_STOP, &status); + + if (!service) + { + printf("Failed to open service manager"); + return; + } + if (DeleteService(service)) + { + printf("Service removed"); + } + else + { + printf("Failed to remove service"); + } + + CloseServiceHandle(service); + CloseServiceHandle(scm); +} + +#endif // WIN32 diff --git a/bin/bbackupd/Win32ServiceFunctions.h b/bin/bbackupd/Win32ServiceFunctions.h new file mode 100644 index 00000000..72f65479 --- /dev/null +++ b/bin/bbackupd/Win32ServiceFunctions.h @@ -0,0 +1,19 @@ +//*************************************************************** +// From the book "Win32 System Services: The Heart of Windows 98 +// and Windows 2000" +// by Marshall Brain +// Published by Prentice Hall +// Copyright 1995 Prentice Hall. +// +// This code implements the Windows API Service interface +// for the Box Backup for Windows native port. +//*************************************************************** + +#ifndef WIN32SERVICEFUNCTIONS_H +#define WIN32SERVICEFUNCTIONS_H + +void RemoveService(void); +void InstallService(void); +void OurService(void); + +#endif diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp index ca843105..1c870317 100755 --- a/bin/bbackupd/bbackupd.cpp +++ b/bin/bbackupd/bbackupd.cpp @@ -11,16 +11,84 @@ #include "BackupDaemon.h" #include "MainHelper.h" #include "BoxPortsAndFiles.h" +#include "BackupStoreException.h" #include "MemLeakFindOn.h" +#ifdef WIN32 + #include "Win32ServiceFunctions.h" + #include "Win32BackupService.h" + + extern Win32BackupService gDaemonService; +#endif + int main(int argc, const char *argv[]) { MAINHELPER_START +#ifdef WIN32 + + ::openlog("Box Backup (bbackupd)", 0, 0); + + if(argc == 2 && + (::strcmp(argv[1], "--help") == 0 || + ::strcmp(argv[1], "-h") == 0)) + { + printf("-h help, -i install service, -r remove service,\n" + "-c <config file> start daemon now"); + return 2; + } + if(argc == 2 && ::strcmp(argv[1], "-r") == 0) + { + RemoveService(); + return 0; + } + if(argc == 2 && ::strcmp(argv[1], "-i") == 0) + { + InstallService(); + return 0; + } + + // Under win32 we must initialise the Winsock library + // before using sockets + + WSADATA info; + + if (WSAStartup(MAKELONG(1, 1), &info) == SOCKET_ERROR) + { + // box backup will not run without sockets + ::syslog(LOG_ERR, "Failed to initialise Windows Sockets"); + THROW_EXCEPTION(BackupStoreException, Internal) + } + + EnableBackupRights(); + + int ExitCode = 0; + + if (argc == 2 && ::strcmp(argv[1], "--service") == 0) + { + syslog(LOG_INFO,"Starting Box Backup Service"); + OurService(); + } + else + { + ExitCode = gDaemonService.Main( + BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); + } + + // Clean up our sockets + WSACleanup(); + + ::closelog(); + + return ExitCode; + +#else // !WIN32 + BackupDaemon daemon; return daemon.Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); - + +#endif // WIN32 + MAINHELPER_END } - diff --git a/bin/bbackupd/win32/ReadMe.txt b/bin/bbackupd/win32/ReadMe.txt new file mode 100644 index 00000000..3d260750 --- /dev/null +++ b/bin/bbackupd/win32/ReadMe.txt @@ -0,0 +1,24 @@ +Upgrade instructions + +Version 0.09g to 0.09h + +This version included patches to the server as well. The server for this +upgrade can be found at http://home.earthlink.net/~gniemcew/ but hopefully +will be merged into the core in the next release. + +New values in the bbackupd.conf can now be added: + +StoreObjectInfoFile = C:\Program Files\Box Backup\bbackupd\bbackupd.dat + +This stores the state when a backup daemon is shutdown. + +KeepAliveTime = 250 + +This is imperative if MaximumDiffingTime is larger than 300, this stops the ssl +layer timing out when a diff is performed. It is wise to set MaximumDiffingTime +long enough for the largest file you may have. If you do not wish to upgrade your +server then make KeepAliveTime greater than MaximumDiffingTime. + +Have fun + +Nick diff --git a/bin/bbackupd/win32/bbackupd.conf b/bin/bbackupd/win32/bbackupd.conf new file mode 100644 index 00000000..85915520 --- /dev/null +++ b/bin/bbackupd/win32/bbackupd.conf @@ -0,0 +1,143 @@ + +StoreHostname = yourhost +AccountNumber = 0x1 +KeysFile = C:\Program Files\Box Backup\1-FileEncKeys.raw + +CertificateFile = C:\Program Files\Box Backup\1-cert.pem +PrivateKeyFile = C:\Program Files\Box Backup\1-key.pem +TrustedCAsFile = C:\Program Files\Box Backup\serverCA.pem + +DataDirectory = C:\Program Files\Box Backup\bbackupd + +# If you do not install it in the default location - also do not forget to +# change the pid file location (below) + + +# This script is run whenever bbackupd encounters a problem which requires +# the system administrator to assist: +# 1) The store is full, and no more data can be uploaded. +# 2) Some files or directories were not readable. +# The default script emails the system administrator. + +# NotifyScript = NotifySysadmin.sh + + +# A scan of the local discs will be made once an hour (approximately). +# To avoid cycles of load on the server, this time is randomly adjusted by a small +# percentage as the daemon runs. + +UpdateStoreInterval = 3600 + + +# A file must have been modified at least 6 hours ago before it will be uploaded. + +MinimumFileAge = 21600 + + +# If a file is modified repeated, it won't be uploaded immediately in case it's modified again. +# However, it should be uploaded eventually. This is how long we should wait after first noticing +# a change. (1 day) + +MaxUploadWait = 86400 + + +# Files above this size (in bytes) are tracked, and if they are renamed they will simply be +# renamed on the server, rather than being uploaded again. (64k - 1) + +FileTrackingSizeThreshold = 65535 + + +# The daemon does "changes only" uploads for files above this size (in bytes). +# Files less than it are uploaded whole without this extra processing. + +DiffingUploadSizeThreshold = 8192 + + +# The limit on how much time is spent diffing files. Most files shouldn't take very long, +# but if you have really big files you can use this to limit the time spent diffing them. +# * Reduce if you are having problems with processor usage. +# * Increase if you have large files, and think the upload of changes is too large and want +# to spend more time searching for unchanged blocks. + +MaximumDiffingTime = 20 + +# KeepAliveTime requires Gary's SSL KeepAlive patches +# KeepAliveTime = 250 + +# Uncomment this line to see exactly what the daemon is going when it's connected to the server. + +# ExtendedLogging = yes + + +# Use this to temporarily stop bbackupd from syncronising or connecting to the store. +# This specifies a program or script script which is run just before each sync, and ideally +# the full path to the interpreter. It will be run as the same user bbackupd is running as, +# usually root. +# The script prints either "now" or a number to STDOUT (and a terminating newline, no quotes). +# If the result was "now", then the sync will happen. If it's a number, then the script will +# be asked again in that number of seconds. +# For example, you could use this on a laptop to only backup when on a specific network. + +# SyncAllowScript = /path/to/intepreter/or/exe script-name parameters etc + + +# Where the command socket is created in the filesystem. + +CommandSocket = pipe + + +Server +{ + PidFile = C:\Program Files\Box Backup\bbackupd\bbackupd.pid +} + +# StoreObjectInfoFile requires Gary's client marker serialisation patch +# StoreObjectInfoFile = C:\Program Files\Box Backup\bbackupd\bbackupd.dat + +# +# BackupLocations specifies which locations on disc should be backed up. Each +# directory is in the format +# +# name +# { +# Path = /path/of/directory +# (optional exclude directives) +# } +# +# 'name' is derived from the Path by the config script, but should merely be +# unique. +# +# The exclude directives are of the form +# +# [Exclude|AlwaysInclude][File|Dir][|sRegex] = regex or full pathname +# +# (The regex suffix is shown as 'sRegex' to make File or Dir plural) +# +# For example: +# +# ExcludeDir = /home/guest-user +# ExcludeFilesRegex = *.(mp3|MP3)$ +# AlwaysIncludeFile = /home/username/veryimportant.mp3 +# +# This excludes the directory /home/guest-user from the backup along with all mp3 +# files, except one MP3 file in particular. +# +# In general, Exclude excludes a file or directory, unless the directory is +# explicitly mentioned in a AlwaysInclude directive. +# +# If a directive ends in Regex, then it is a regular expression rather than a +# explicit full pathname. See +# +# man 7 re_format +# +# for the regex syntax on your platform. +# + +BackupLocations +{ + MyDocuments + { + Path = C:\Documents and Settings\ + } +} + diff --git a/bin/bbackupd/win32/installer.iss b/bin/bbackupd/win32/installer.iss new file mode 100644 index 00000000..20e3addb --- /dev/null +++ b/bin/bbackupd/win32/installer.iss @@ -0,0 +1,51 @@ +; Script to generate output file for Box Backup client for the Windows Platform
+;
+; Very important - this is the release process
+;
+; 1/ Upgrade BOX_VERSION in the file emu.h to the current version for example 0.09eWin32 - then perform a full rebuild
+;
+; 2/ Upgrade the AppVerName below to reflect the version
+;
+; 3/ Generate the output file, then rename it to the relevent filename to reflect the version
+
+[Setup]
+AppName=Box Backup
+AppVerName=BoxWin32 0.09h
+AppPublisher=Fluffy & Omniis
+AppPublisherURL=http://www.omniis.com
+AppSupportURL=http://www.omniis.com
+AppUpdatesURL=http://www.omniis.com
+DefaultDirName={pf}\Box Backup
+DefaultGroupName=Box Backup
+Compression=lzma
+SolidCompression=yes
+PrivilegesRequired=admin
+
+[Files]
+Source: "..\..\Release\bbackupd.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "..\..\Release\bbackupctl.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "..\..\Release\bbackupquery.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "..\..\ExceptionCodes.txt"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "icon.ico"; DestDir: "{app}\"; Flags: ignoreversion restartreplace
+Source: "msvcr71.dll"; DestDir: "{app}\"; Flags: restartreplace
+Source: "bbackupd.conf"; DestDir: "{app}"; Flags: confirmoverwrite
+Source: "..\..\..\zlib\zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "..\..\..\openssl\bin\libeay32.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "..\..\..\openssl\bin\ssleay32.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+Source: "ReadMe.txt"; DestDir: "{app}"; Flags: ignoreversion restartreplace
+
+; NOTE: Don't use "Flags: ignoreversion" on any shared system files
+
+[Icons]
+Name: "{group}\Box Backup Query"; Filename: "{app}\bbackupquery.exe"; IconFilename: "{app}\icon.ico" ;Parameters: "-c bbackupd.conf"; WorkingDir: "{app}"
+Name: "{group}\Service\Install Service"; Filename: "{app}\bbackupd.exe"; IconFilename: "{app}\icon.ico" ;Parameters: "-i"; WorkingDir: "{app}"
+Name: "{group}\Service\Remove Service"; Filename: "{app}\bbackupd.exe"; IconFilename: "{app}\icon.ico" ;Parameters: "-r"; WorkingDir: "{app}"
+Name: "{group}\Initiate Backup Now"; Filename: "{app}\bbackupctl.exe"; IconFilename: "{app}\icon.ico" ;Parameters: "-c bbackupd.conf sync"; WorkingDir: "{app}"
+
+[Dirs]
+Name: "{app}\bbackupd"
+
+[Run]
+Filename: "{app}\bbackupd.exe"; Description: "Install Boxbackup as service"; Parameters: "-i"; Flags: postinstall
+Filename: "{app}\Readme.txt"; Description: "View upgrade notes"; Flags: postinstall shellexec skipifsilent
+
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 27b5fa76..b37abc9d 100755 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -380,7 +380,11 @@ void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool { // add object ID to line char oid[32]; +#ifdef WIN32 + sprintf(oid, "%08I64x ", en->GetObjectID()); +#else sprintf(oid, "%08llx ", en->GetObjectID()); +#endif line += oid; } @@ -404,6 +408,7 @@ void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool } // attributes flags *(f++) = (en->HasAttributes())?'a':'-'; + // terminate *(f++) = ' '; *(f++) = '\0'; @@ -424,14 +429,22 @@ void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool if(opts[LIST_OPTION_DISPLAY_HASH]) { char hash[64]; +#ifdef WIN32 + ::sprintf(hash, "%016I64x ", en->GetAttributesHash()); +#else ::sprintf(hash, "%016llx ", en->GetAttributesHash()); +#endif line += hash; } if(opts[LIST_OPTION_SIZEINBLOCKS]) { char num[32]; +#ifdef WIN32 + sprintf(num, "%05I64d ", en->GetSizeInBlocks()); +#else sprintf(num, "%05lld ", en->GetSizeInBlocks()); +#endif line += num; } @@ -1034,7 +1047,8 @@ void BackupQueries::CompareLocation(const std::string &rLocation, BackupQueries: } // Then get it compared - Compare(std::string("/") + rLocation, loc.GetKeyValue("Path"), rParams); + Compare(std::string(DIRECTORY_SEPARATOR) + rLocation, + loc.GetKeyValue("Path"), rParams); } catch(...) { @@ -1165,7 +1179,7 @@ void BackupQueries::Compare(int64_t DirID, const std::string &rStoreDir, const s #ifndef HAVE_VALID_DIRENT_D_TYPE std::string fn(rLocalDir); - fn += '/'; + fn += DIRECTORY_SEPARATOR_ASCHAR; fn += localDirEn->d_name; struct stat st; if(::lstat(fn.c_str(), &st) != 0) diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp index 1eb86db6..d76664fb 100755 --- a/bin/bbackupquery/bbackupquery.cpp +++ b/bin/bbackupquery/bbackupquery.cpp @@ -56,6 +56,19 @@ int main(int argc, const char *argv[]) { MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupquery.memleaks", "bbackupquery") +#ifdef WIN32 + WSADATA info; + + // Under Win32 we must initialise the Winsock library + // before using it. + + if (WSAStartup(MAKELONG(1, 1), &info) == SOCKET_ERROR) + { + // throw error? perhaps give it its own id in the furture + THROW_EXCEPTION(BackupStoreException, Internal) + } +#endif + // Really don't want trace statements happening, even in debug mode #ifndef NDEBUG BoxDebugTraceOn = false; @@ -253,7 +266,11 @@ int main(int argc, const char *argv[]) MAINHELPER_END - exit(returnCode); +#ifdef WIN32 + // Clean up our sockets + WSACleanup(); +#endif + return returnCode; } diff --git a/bin/bbstoreaccounts/bbstoreaccounts.cpp b/bin/bbstoreaccounts/bbstoreaccounts.cpp index 89edd0b2..dd42458b 100755 --- a/bin/bbstoreaccounts/bbstoreaccounts.cpp +++ b/bin/bbstoreaccounts/bbstoreaccounts.cpp @@ -70,7 +70,11 @@ const char *BlockSizeToString(int64_t Blocks, int DiscSet) double mb = (Blocks * BlockSizeOfDiscSet(DiscSet)) / (1024.0*1024.0); // Format string +#ifdef WIN32 + sprintf(string, "%I64d (%.2fMb)", Blocks, mb); +#else sprintf(string, "%lld (%.2fMb)", Blocks, mb); +#endif return string; } diff --git a/boxbackup.sln b/boxbackup.sln new file mode 100644 index 00000000..ede6faa1 --- /dev/null +++ b/boxbackup.sln @@ -0,0 +1,67 @@ +Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boxquery", "boxquery.vcproj", "{FE9EC666-4B3A-4370-B3D4-DEBD4A21F36E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {98598F62-FEA7-4134-AA29-0AD2315A214F} = {98598F62-FEA7-4134-AA29-0AD2315A214F}
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6} = {A089CEE6-EBF0-4232-A0C0-74850A8127A6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcproj", "{A089CEE6-EBF0-4232-A0C0-74850A8127A6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bbackupd", "bbackupd.vcproj", "{22D325FB-9131-4BD6-B390-968F0491D687}"
+ ProjectSection(ProjectDependencies) = postProject
+ {98598F62-FEA7-4134-AA29-0AD2315A214F} = {98598F62-FEA7-4134-AA29-0AD2315A214F}
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6} = {A089CEE6-EBF0-4232-A0C0-74850A8127A6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32test", "win32test.vcproj", "{28C29E72-76A2-4D0C-B35B-12D446733D2E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6} = {A089CEE6-EBF0-4232-A0C0-74850A8127A6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bbackupctl", "bbackupctl.vcproj", "{9FD51412-E945-4457-A17A-CA3C505CF431}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6} = {A089CEE6-EBF0-4232-A0C0-74850A8127A6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_regex", "lib\win32\boost_regex.vcproj", "{98598F62-FEA7-4134-AA29-0AD2315A214F}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {FE9EC666-4B3A-4370-B3D4-DEBD4A21F36E}.Debug.ActiveCfg = Debug|Win32
+ {FE9EC666-4B3A-4370-B3D4-DEBD4A21F36E}.Debug.Build.0 = Debug|Win32
+ {FE9EC666-4B3A-4370-B3D4-DEBD4A21F36E}.Release.ActiveCfg = Release|Win32
+ {FE9EC666-4B3A-4370-B3D4-DEBD4A21F36E}.Release.Build.0 = Release|Win32
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6}.Debug.ActiveCfg = Debug|Win32
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6}.Debug.Build.0 = Debug|Win32
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6}.Release.ActiveCfg = Release|Win32
+ {A089CEE6-EBF0-4232-A0C0-74850A8127A6}.Release.Build.0 = Release|Win32
+ {22D325FB-9131-4BD6-B390-968F0491D687}.Debug.ActiveCfg = Debug|Win32
+ {22D325FB-9131-4BD6-B390-968F0491D687}.Debug.Build.0 = Debug|Win32
+ {22D325FB-9131-4BD6-B390-968F0491D687}.Release.ActiveCfg = Release|Win32
+ {22D325FB-9131-4BD6-B390-968F0491D687}.Release.Build.0 = Release|Win32
+ {28C29E72-76A2-4D0C-B35B-12D446733D2E}.Debug.ActiveCfg = Debug|Win32
+ {28C29E72-76A2-4D0C-B35B-12D446733D2E}.Debug.Build.0 = Debug|Win32
+ {28C29E72-76A2-4D0C-B35B-12D446733D2E}.Release.ActiveCfg = Release|Win32
+ {28C29E72-76A2-4D0C-B35B-12D446733D2E}.Release.Build.0 = Release|Win32
+ {9FD51412-E945-4457-A17A-CA3C505CF431}.Debug.ActiveCfg = Debug|Win32
+ {9FD51412-E945-4457-A17A-CA3C505CF431}.Debug.Build.0 = Debug|Win32
+ {9FD51412-E945-4457-A17A-CA3C505CF431}.Release.ActiveCfg = Release|Win32
+ {9FD51412-E945-4457-A17A-CA3C505CF431}.Release.Build.0 = Release|Win32
+ {98598F62-FEA7-4134-AA29-0AD2315A214F}.Debug.ActiveCfg = Debug|Win32
+ {98598F62-FEA7-4134-AA29-0AD2315A214F}.Debug.Build.0 = Debug|Win32
+ {98598F62-FEA7-4134-AA29-0AD2315A214F}.Release.ActiveCfg = Release|Win32
+ {98598F62-FEA7-4134-AA29-0AD2315A214F}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/boxbackup.suo b/boxbackup.suo Binary files differnew file mode 100644 index 00000000..bd804d83 --- /dev/null +++ b/boxbackup.suo diff --git a/boxquery.vcproj b/boxquery.vcproj new file mode 100644 index 00000000..ed080a9a --- /dev/null +++ b/boxquery.vcproj @@ -0,0 +1,171 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="boxquery"
+ ProjectGUID="{FE9EC666-4B3A-4370-B3D4-DEBD4A21F36E}"
+ RootNamespace="boxquery"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\";"$(SolutionDir)..\boost_1_31_0""
+ PreprocessorDefinitions="BOOST_REGEX_NO_LIB;WIN32;_DEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Debug\common.lib $(ProjectDir)lib\win32\Debug\boost_regex.lib"
+ OutputFile="$(OutDir)/bbackupquery.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/boxquery.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableFiberSafeOptimizations="TRUE"
+ OptimizeForProcessor="1"
+ AdditionalIncludeDirectories=""$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\";"$(SolutionDir)..\boost_1_31_0""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING;BOOST_REGEX_NO_LIB"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)Release\common.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)lib\win32\Release\boost_regex.lib"
+ OutputFile="$(OutDir)/bbackupquery.exe"
+ LinkIncremental="1"
+ IgnoreDefaultLibraryNames=""
+ GenerateDebugInformation="FALSE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <Filter
+ Name="bin"
+ Filter="">
+ <Filter
+ Name="backupquery"
+ Filter="">
+ <File
+ RelativePath=".\bin\bbackupquery\autogen_Documentation.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupquery\BackupQueries.cpp">
+ </File>
+ <File
+ RelativePath=".\bin\bbackupquery\bbackupquery.cpp">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <Filter
+ Name="bin"
+ Filter="">
+ <Filter
+ Name="backupquery"
+ Filter="">
+ <File
+ RelativePath=".\bin\bbackupquery\BackupQueries.h">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/common.vcproj b/common.vcproj new file mode 100644 index 00000000..50e0e5a3 --- /dev/null +++ b/common.vcproj @@ -0,0 +1,638 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="common"
+ ProjectGUID="{A089CEE6-EBF0-4232-A0C0-74850A8127A6}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="4"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\";"$(SolutionDir)..\boost_1_31_0\""
+ PreprocessorDefinitions="BOOST_REGEX_NO_LIB;WIN32;_DEBUG;_LIB;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="$(OutDir)/common.lib"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="4"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableFiberSafeOptimizations="TRUE"
+ OptimizeForProcessor="1"
+ AdditionalIncludeDirectories=""$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\";"$(SolutionDir)..\boost_1_31_0\""
+ PreprocessorDefinitions="BOOST_REGEX_NO_LIB;WIN32;NDEBUG;_LIB;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile="$(OutDir)/common.lib"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <Filter
+ Name="lib"
+ Filter="">
+ <Filter
+ Name="compress"
+ Filter="">
+ <File
+ RelativePath=".\lib\compress\autogen_CompressException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\compress\CompressStream.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="common"
+ Filter="">
+ <File
+ RelativePath=".\lib\common\autogen_CommonException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\autogen_ConversionException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxTime.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxTimeToText.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\CollectInBufferStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\Configuration.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\ConversionString.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\DebugAssertFailed.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\DebugMemLeakFinder.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\DebugPrintf.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\EventWatchFilesystemObject.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\ExcludeList.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\FdGetLine.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\FileStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\IOStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\IOStreamGetLine.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\LinuxWorkaround.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\MemBlockStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\PartialReadStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\ReadGatherStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\StreamableMemBlock.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\UnixUser.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\Utils.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\common\WaitForEvent.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="backupclient"
+ Filter="">
+ <File
+ RelativePath=".\lib\backupclient\autogen_BackupProtocolClient.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\autogen_BackupStoreException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientCryptoKeys.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientFileAttributes.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientMakeExcludeList.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientRestore.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupDaemonConfigVerify.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreDirectory.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFile.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileCmbDiff.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileCmbIdx.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileCombine.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileCryptVar.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileDiff.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileEncodeStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFilename.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFilenameClear.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileRevDiff.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreObjectDump.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="crypto"
+ Filter="">
+ <File
+ RelativePath=".\lib\crypto\autogen_CipherException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherAES.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherBlowfish.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherContext.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherDescription.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\MD5Digest.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\Random.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\RollingChecksum.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="win32"
+ Filter="">
+ <File
+ RelativePath=".\lib\win32\emu.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="server"
+ Filter="">
+ <File
+ RelativePath=".\lib\server\autogen_ConnectionException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\autogen_ServerException.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\Daemon.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\LocalProcessStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\Protocol.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\ProtocolObject.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\ProtocolUncertainStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\Socket.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\SocketStream.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\SocketStreamTLS.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\SSLLib.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\server\TLSContext.cpp">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <Filter
+ Name="lib"
+ Filter="">
+ <Filter
+ Name="compress"
+ Filter="">
+ <File
+ RelativePath=".\lib\compress\autogen_CompressException.h">
+ </File>
+ <File
+ RelativePath=".\lib\compress\Compress.h">
+ </File>
+ <File
+ RelativePath=".\lib\compress\CompressException.h">
+ </File>
+ <File
+ RelativePath=".\lib\compress\CompressStream.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="common"
+ Filter="">
+ <File
+ RelativePath=".\lib\common\autogen_CommonException.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\autogen_ConversionException.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BannerText.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BeginStructPackForWire.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\Box.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxException.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxPlatform.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxPortsAndFiles.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxTime.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxTimeToText.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\BoxTimeToUnix.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\CollectInBufferStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\CommonException.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\Configuration.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\Conversion.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\EndStructPackForWire.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\EventWatchFilesystemObject.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\ExcludeList.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\FdGetLine.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\FileModificationTime.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\FileStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\Guards.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\IOStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\IOStreamGetLine.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\LinuxWorkaround.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\LocalProcessStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\MainHelper.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\MemBlockStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\MemLeakFinder.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\MemLeakFindOff.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\MemLeakFindOn.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\NamedLock.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\PartialReadStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\ReadGatherStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\StreamableMemBlock.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\TemporaryDirectory.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\Test.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\UnixUser.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\Utils.h">
+ </File>
+ <File
+ RelativePath=".\lib\common\WaitForEvent.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="backupclient"
+ Filter="">
+ <File
+ RelativePath=".\lib\backupclient\autogen_BackupProtocolClient.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\autogen_BackupStoreException.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientCryptoKeys.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientFileAttributes.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientMakeExcludeList.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupClientRestore.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupDaemonConfigVerify.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreConstants.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreDirectory.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreException.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFile.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileCryptVar.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileEncodeStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFilename.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFilenameClear.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreFileWire.h">
+ </File>
+ <File
+ RelativePath=".\lib\backupclient\BackupStoreObjectMagic.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="crypto"
+ Filter="">
+ <File
+ RelativePath=".\lib\crypto\autogen_CipherException.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherAES.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherBlowfish.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherContext.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherDescription.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\CipherException.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\MD5Digest.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\Random.h">
+ </File>
+ <File
+ RelativePath=".\lib\crypto\RollingChecksum.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="win32"
+ Filter="">
+ <File
+ RelativePath=".\lib\win32\emu.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="server"
+ Filter="">
+ <File
+ RelativePath=".\lib\server\autogen_ConnectionException.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\autogen_ServerException.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\Daemon.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\Protocol.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\ProtocolObject.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\ProtocolUncertainStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\ProtocolWire.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\ServerException.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\ServerStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\ServerTLS.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\Socket.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\SocketListen.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\SocketStream.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\SocketStreamTLS.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\SSLLib.h">
+ </File>
+ <File
+ RelativePath=".\lib\server\TLSContext.h">
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/config.guess b/config.guess new file mode 100755 index 00000000..0773d0f6 --- /dev/null +++ b/config.guess @@ -0,0 +1,1456 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2004-03-03' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Per Bothner <per@bothner.com>. +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amd64:OpenBSD:*:*) + echo x86_64-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + cats:OpenBSD:*:*) + echo arm-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pegasos:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit 0 ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <features.h> + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + # GNU/KFreeBSD systems have a "k" prefix to indicate we are using + # FreeBSD's kernel, but not the complete OS. + case ${LIBC} in gnu) kernel_only='k' ;; esac + echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <features.h> + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit 0 ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c <<EOF +#ifdef _SEQUENT_ +# include <sys/types.h> +# include <sys/utsname.h> +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + ftp://ftp.gnu.org/pub/gnu/config/ + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.sub b/config.sub new file mode 100644 index 00000000..264f820a --- /dev/null +++ b/config.sub @@ -0,0 +1,1549 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2004-02-23' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure.ac b/configure.ac index 2915a580..ef903ad8 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,10 @@ AC_INIT([Box Backup], 0.09, [box@fluffy.co.uk]) AC_CONFIG_SRCDIR([lib/common/Box.h]) AC_CONFIG_HEADERS([lib/common/config.h]) +touch install-sh +AC_CANONICAL_SYSTEM +# echo "Build target OS: '$target_os'" +test -s install-sh || rm install-sh ### Checks for programs. @@ -26,9 +30,11 @@ fi ### Checks for libraries. +if test "$target_os" != "mingw32" -a "$target_os" != "winnt"; then +AC_SEARCH_LIBS([nanosleep], [rt], [ac_have_nanosleep=yes], + [AC_MSG_ERROR([[Cannot find a short sleep function (nanosleep)]])]) +fi -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 @@ -89,8 +95,12 @@ AX_CHECK_DIRENT_D_TYPE AC_SYS_LARGEFILE AX_CHECK_LLONG_MINMAX AX_CHECK_DEFINE_PRAGMA + +if test "$target_os" != "mingw32"; then AX_RANDOM_DEVICE -AX_CHECK_MOUNT_POINT(, [AC_MSG_ERROR([[cannot work out how to discover mount points on your platform]])]) +fi + +AX_CHECK_MOUNT_POINT([],[]) AX_CHECK_MALLOC_WORKAROUND @@ -124,12 +134,6 @@ fi 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" @@ -144,7 +148,7 @@ 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]) + AC_CHECK_LIB([ssl],[SSL_read],[],[],[crypto]) LIBS="-Wl,-Bstatic $LIBS -Wl,-Bdynamic" fi diff --git a/docs/backup/Win32_Clients.txt b/docs/backup/Win32_Clients.txt new file mode 100644 index 00000000..fad6c4af --- /dev/null +++ b/docs/backup/Win32_Clients.txt @@ -0,0 +1,13 @@ +The basic client tools now run on Win32 natively. +The port was done by nick@omniis.com. + +* bbackupd +* bbackupquery +* bbackupctl + +Have been ported. bbackupd runs as a NT style service. + +Known limitations: + +* File attributes and permissions are not backed up. + diff --git a/docs/backup/win32_build_on_cygwin_using_mingw.txt b/docs/backup/win32_build_on_cygwin_using_mingw.txt new file mode 100755 index 00000000..c0e68447 --- /dev/null +++ b/docs/backup/win32_build_on_cygwin_using_mingw.txt @@ -0,0 +1,37 @@ +How to build Box Backup on Win32 using Cygwin and MinGW
+By Chris Wilson, 2005-12-07
+
+Install Cygwin on your Windows box [http://www.cygwin.org]
+Make sure to include the following packages:
+* Devel/gcc-mingw
+* Devel/gcc-mingw-core
+* Devel/gcc-mingw-g++
+* Mingw/mingw-zlib
+
+Download OpenSSL from
+[http://www.openssl.org/source/openssl-0.9.7i.tar.gz]
+
+Open a Cygwin shell, and unpack OpenSSL:
+
+ tar xzvf openssl-0.9.7i.tar.gz
+
+Configure OpenSSL for MinGW compilation, and build and install it:
+
+ cd openssl-0.9.7i
+ ./Configure --prefix=/usr/i686-pc-mingw32/ mingw
+ make
+ make install
+
+Now unpack the Box Backup sources, enter the source directory,
+and configure like this:
+
+ export CXX="g++ -mno-cygwin"
+ export LD="g++ -mno-cygwin"
+ export CFLAGS="-mno-cygwin -mthreads"
+ export CXXFLAGS="-mno-cygwin -mthreads"
+ export LDFLAGS="-mno-cygwin -mthreads"
+ export LIBS="-lcrypto -lws2_32 -lgdi32"
+ (if you don't have a "configure" file, run "./bootstrap")
+ ./configure --target=i686-pc-mingw32
+ make
+
diff --git a/docs/backup/win32_build_on_linux_using_mingw.txt b/docs/backup/win32_build_on_linux_using_mingw.txt new file mode 100644 index 00000000..a3243a50 --- /dev/null +++ b/docs/backup/win32_build_on_linux_using_mingw.txt @@ -0,0 +1,31 @@ +How to build Box Backup for Windows (Native) on Linux using MinGW +By Chris Wilson, 2005-12-07 + +Install the MinGW cross-compiler for Windows: + +- Debian users can "apt-get install mingw32" +- Fedora and SuSE users can download RPM packages from + [http://mirzam.it.vu.nl/mingw/] + +Download Zlib from [http://www.zlib.net/], unpack and enter source directory: + + export CC=i386-mingw32-gcc + export AR="i386-mingw32-ar rc" + export RANLIB="i386-mingw32-ranlib" + ./configure + make + make install prefix=/usr/local/i386-mingw32 + +Download OpenSSL 0.9.7 from + +Configure Box with: + + export CXX="i386-mingw32-g++" + export AR=i386-mingw32-ar + export RANLIB=i386-mingw32-ranlib + export CFLAGS="-mthreads" + export CXXFLAGS="-mthreads" + export LDFLAGS="-mthreads" + export LIBS="-lcrypto -lws2_32 -lgdi32" + ./configure --target=i386-mingw32 + make CXX="$CXX" AR="$AR" RANLIB="$RANLIB" diff --git a/infrastructure/BoxPlatform.pm.in b/infrastructure/BoxPlatform.pm.in index 257b298b..e3a1a26a 100644 --- a/infrastructure/BoxPlatform.pm.in +++ 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 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files/; +@EXPORT = qw/$build_os $build_cpu $target_os $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 $platform_exe_ext/; BEGIN { @@ -23,9 +23,11 @@ BEGIN $platform_compile_line_extra = '@CPPFLAGS@ @CXXFLAGS@ @CXXFLAGS_STRICT@'; $platform_link_line_extra = '@LDFLAGS@'; $platform_lib_files = '@LIBS@'; + $target_os = '@target_os@'; + $platform_exe_ext = '@EXEEXT@'; # get version - open VERSION,"VERSION.txt"; + open VERSION,"VERSION.txt" or die "VERSION.txt: $!"; $product_version = <VERSION>; chomp $product_version; $product_name = <VERSION>; diff --git a/infrastructure/m4/ax_check_mount_point.m4 b/infrastructure/m4/ax_check_mount_point.m4 index 747888cc..3ed3f85d 100644 --- a/infrastructure/m4/ax_check_mount_point.m4 +++ b/infrastructure/m4/ax_check_mount_point.m4 @@ -3,6 +3,7 @@ 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_MOUNTS dnl HAVE_MNTENT_H dnl HAVE_SYS_MNTTAB_H dnl HAVE_SYS_MOUNT_H @@ -35,6 +36,7 @@ AC_DEFUN([AX_CHECK_MOUNT_POINT], [ test "x$ac_cv_member_struct_mntent_mnt_dir" = "xyes" || \ test "x$ac_cv_member_struct_mnttab_mnt_mountp" = "xyes" then + AC_DEFINE([HAVE_MOUNTS], [1], [Define to 1 if this platform supports mounts]) m4_ifvaln([$1],[$1],[:])dnl m4_ifvaln([$2],[else $2])dnl fi diff --git a/infrastructure/m4/ax_check_ssl.m4 b/infrastructure/m4/ax_check_ssl.m4 index 039c8398..03362bb6 100644 --- a/infrastructure/m4/ax_check_ssl.m4 +++ b/infrastructure/m4/ax_check_ssl.m4 @@ -27,7 +27,7 @@ AC_DEFUN([AX_CHECK_SSL], [ 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]) + AC_CHECK_LIB([ssl], [SSL_read],, [ax_check_ssl_found=no], [-lcrypto]) if test "x$ax_check_ssl_found" = "xyes"; then AC_DEFINE([HAVE_SSL], 1, [Define to 1 if SSL is available]) diff --git a/infrastructure/makebuildenv.pl b/infrastructure/makebuildenv.pl index 0af6d680..64c73eb0 100755 --- a/infrastructure/makebuildenv.pl +++ b/infrastructure/makebuildenv.pl @@ -182,6 +182,7 @@ sub make_obj_symlink print "Scanning code...\n"; my $modules_omitted = 0; +my $modules_omitting = 0; # process lines in flattened modules files for(@modules_files) @@ -191,16 +192,20 @@ for(@modules_files) next unless m/\S/; # omit bits on some platforms? - next if m/\AEND-OMIT/; + if(m/\AEND-OMIT/) + { + $modules_omitting = 0; + next; + } + + next if $modules_omitting; + if(m/\AOMIT:(.+)/) { - if($1 eq $build_os) + if($1 eq $build_os or $1 eq $target_os) { $modules_omitted = 1; - while(<MODULES>) - { - last if m/\AEND-OMIT/; - } + $modules_omitting = 1; } next; } @@ -402,8 +407,10 @@ __E close TESTFILE; } - writetestfile("$mod/_t", './test $1 $2 $3 $4 $5', $mod); - writetestfile("$mod/_t-gdb", 'gdb ./test', $mod); + writetestfile("$mod/_t", + './test${platform_exe_ext} $1 $2 $3 $4 $5', $mod); + writetestfile("$mod/_t-gdb", + 'gdb ./test${platform_exe_ext}', $mod); } @@ -440,15 +447,26 @@ __E # make include path - my $include_paths = join(' ',map {'-I../../'.$_} @all_deps_for_module); + my $include_paths = "-I../../lib/win32 " . + join(' ',map {'-I../../'.$_} @all_deps_for_module); # is target a library? my $target_is_library = ($type ne 'bin' && $type ne 'test'); # make target name my $end_target = $name; - $end_target .= '.a' if $target_is_library; - $end_target = 'test' if $type eq 'test'; + + if ($target_is_library) + { + $end_target .= '.a'; + } + else + { + $end_target .= $platform_exe_ext; + } + + $end_target = 'test'.$platform_exe_ext if $type eq 'test'; + # adjust for outdir $end_target = '$(OUTDIR)/' . $end_target; @@ -456,6 +474,13 @@ __E my $mk_name_extra = ($bsd_make)?'':'X'; open MAKE,">$mod/Makefile".$mk_name_extra or die "Can't open Makefile for $mod\n"; my $debug_link_extra = ($target_is_library)?'':'../../debug/lib/debug/debug.a'; + + my $release_flags = "-O2"; + if ($target_os eq "mingw32") + { + $release_flags = "-O0 -g"; + } + print MAKE <<__E; # # AUTOMATICALLY GENERATED FILE @@ -466,7 +491,7 @@ CXX = g++ AR = ar RANLIB = ranlib .ifdef RELEASE -CXXFLAGS = -DNDEBUG -O2 -Wall $include_paths $extra_platform_defines -DBOX_VERSION="\\"$product_version\\"" +CXXFLAGS = -DNDEBUG $release_flags -Wall $include_paths $extra_platform_defines -DBOX_VERSION="\\"$product_version\\"" OUTBASE = ../../release OUTDIR = ../../release/$mod DEPENDMAKEFLAGS = -D RELEASE @@ -567,6 +592,7 @@ __E my $has_deps = ($#{$module_dependency{$mod}} >= 0); # ----- # always has dependencies with debug library $has_deps = 1; + $has_deps = 0 if $target_is_library; # Depenency stuff my $deps_makeinfo; @@ -613,7 +639,7 @@ __E my $o_file_list = join(' ',map {'$(OUTDIR)/'.$_.'.o'} @objs); print MAKE $end_target,': ',$o_file_list; - print MAKE ' dep_modules' if !$bsd_make; + print MAKE ' dep_modules' if $has_deps and not $bsd_make; print MAKE " ",$lib_files unless $target_is_library; print MAKE "\n"; @@ -658,7 +684,7 @@ __E # dependency line? print MAKE "\n"; - # module dependcies for GNU make? + # module dependencies for GNU make? print MAKE $deps_makeinfo if !$bsd_make; # print the rest of the file diff --git a/infrastructure/makeparcels.pl b/infrastructure/makeparcels.pl index 1c0b0ead..55e64976 100755 --- a/infrastructure/makeparcels.pl +++ b/infrastructure/makeparcels.pl @@ -26,7 +26,7 @@ open PARCELS,"parcels.txt" or die "Can't open parcels file"; next if m/\AEND-OMIT/; if(m/\AOMIT:(.+)/) { - if($1 eq $build_os) + if($1 eq $build_os or $1 eq $target_os) { while(<PARCELS>) { @@ -35,6 +35,21 @@ open PARCELS,"parcels.txt" or die "Can't open parcels file"; } next; } + + if (m'\AONLY:(.+)') + { + my @only_targets = split m'\,', $1; + + if (not grep {$_ eq $build_os or $_ eq $target_os} + @only_targets) + { + while (<PARCELS>) + { + last if m'\AEND-ONLY'; + } + next; + } + } # new parcel, or a new parcel definition? if(m/\A\s+(.+)\Z/) @@ -100,7 +115,7 @@ for my $parcel (@parcels) if($type eq 'bin') { - my $exeext = ($build_os eq 'CYGWIN')?'.exe':''; + my $exeext = $platform_exe_ext; print MAKE "\t(cd bin/$name; \$(MAKE) $release_flag)\n"; print MAKE "\tcp release/bin/$name/$name$exeext $dir\n"; } diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp index adc3a91c..7b7cd216 100755 --- a/lib/backupclient/BackupClientFileAttributes.cpp +++ b/lib/backupclient/BackupClientFileAttributes.cpp @@ -287,7 +287,7 @@ bool BackupClientFileAttributes::Compare(const BackupClientFileAttributes &rAttr // // -------------------------------------------------------------------------- void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroModificationTimes, box_time_t *pModTime, - box_time_t *pAttrModTime, int64_t *pFileSize, ino_t *pInodeNumber, bool *pHasMultipleLinks) + box_time_t *pAttrModTime, int64_t *pFileSize, InodeRefType *pInodeNumber, bool *pHasMultipleLinks) { StreamableMemBlock *pnewAttr = 0; try @@ -309,14 +309,46 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM FillAttributes(*pnewAttr, Filename, st, ZeroModificationTimes); +#ifndef WIN32 // Is it a link? if((st.st_mode & S_IFMT) == S_IFLNK) { FillAttributesLink(*pnewAttr, Filename, st); } +#endif FillExtendedAttr(*pnewAttr, Filename); +#ifdef WIN32 + //this is to catch those problems with invalid time stamps stored... + //need to find out the reason why - but also a catch as well. + + attr_StreamFormat *pattr = + (attr_StreamFormat*)pnewAttr->GetBuffer(); + ASSERT(pattr != 0); + + // __time64_t winTime = BoxTimeToSeconds( + // pnewAttr->ModificationTime); + + box_time_t bob = BoxTimeToSeconds(pattr->ModificationTime); + __time64_t winTime = bob; + if (_gmtime64(&winTime) == 0 ) + { + ::syslog(LOG_ERR, "Corrupt value in store " + "Modification Time in file %s", Filename); + pattr->ModificationTime = 0; + } + + bob = BoxTimeToSeconds(pattr->AttrModificationTime); + winTime = bob; + if (_gmtime64(&winTime) == 0 ) + { + ::syslog(LOG_ERR, "Corrupt value in store " + "Attr Modification Time in file %s", Filename); + pattr->AttrModificationTime = 0; + } +#endif + // Attributes ready. Encrypt into this block EncryptAttr(*pnewAttr); @@ -372,7 +404,7 @@ void BackupClientFileAttributes::FillAttributes(StreamableMemBlock &outputBlock, pattr->FileGenerationNumber = htonl(st.st_gen); #endif } - +#ifndef WIN32 // -------------------------------------------------------------------------- // // Function @@ -402,6 +434,7 @@ void BackupClientFileAttributes::FillAttributesLink(StreamableMemBlock &outputBl std::memcpy(buffer+oldSize, linkedTo, linkedToSize); buffer[oldSize+linkedToSize] = '\0'; } +#endif // -------------------------------------------------------------------------- // @@ -574,12 +607,18 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename) const THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); } +#ifdef WIN32 + ::syslog(LOG_WARNING, + "Cannot create symbolic links on Windows: %s", + Filename); +#else // Make a symlink, first deleting anything in the way ::unlink(Filename); if(::symlink((char*)(pattr + 1), Filename) != 0) { THROW_EXCEPTION(CommonException, OSFileError) } +#endif xattrOffset += std::strlen(reinterpret_cast<char*>(pattr+1))+1; } @@ -943,6 +982,3 @@ uint64_t BackupClientFileAttributes::GenerateAttributeHash(struct stat &st, cons uint64_t result = *((uint64_t *)(digest.DigestAsData())); return result; } - - - diff --git a/lib/backupclient/BackupClientFileAttributes.h b/lib/backupclient/BackupClientFileAttributes.h index 17124039..62ba2184 100755 --- a/lib/backupclient/BackupClientFileAttributes.h +++ b/lib/backupclient/BackupClientFileAttributes.h @@ -44,7 +44,7 @@ public: void ReadAttributes(const char *Filename, bool ZeroModificationTimes = false, box_time_t *pModTime = 0, box_time_t *pAttrModTime = 0, int64_t *pFileSize = 0, - ino_t *pInodeNumber = 0, bool *pHasMultipleLinks = 0); + InodeRefType *pInodeNumber = 0, bool *pHasMultipleLinks = 0); void WriteAttributes(const char *Filename) const; bool IsSymLink() const; diff --git a/lib/backupclient/BackupStoreFile.cpp b/lib/backupclient/BackupStoreFile.cpp index d31b53bb..28d88d27 100755 --- a/lib/backupclient/BackupStoreFile.cpp +++ b/lib/backupclient/BackupStoreFile.cpp @@ -15,7 +15,9 @@ #include <new> #include <string.h> #ifndef BOX_DISABLE_BACKWARDS_COMPATIBILITY_BACKUPSTOREFILE - #include <syslog.h> + #ifndef WIN32 + #include <syslog.h> + #endif #include <stdio.h> #endif diff --git a/lib/backupclient/BackupStoreFileDiff.cpp b/lib/backupclient/BackupStoreFileDiff.cpp index 3699eb49..c1d0492d 100755 --- a/lib/backupclient/BackupStoreFileDiff.cpp +++ b/lib/backupclient/BackupStoreFileDiff.cpp @@ -12,7 +12,11 @@ #include <new> #include <map> #include <signal.h> +#ifdef WIN32 +#include <time.h> +#else #include <sys/time.h> +#endif #include "BackupStoreFile.h" #include "BackupStoreFileWire.h" @@ -989,7 +993,11 @@ static void GenerateRecipe(BackupStoreFileEncodeStream::Recipe &rRecipe, BlocksA for(unsigned int e = 0; e < rRecipe.size(); ++e) { char b[64]; +#ifdef WIN32 + sprintf(b, "%8I64d", (int64_t)(rRecipe[e].mpStartBlock - pIndex)); +#else sprintf(b, "%8lld", (int64_t)(rRecipe[e].mpStartBlock - pIndex)); +#endif TRACE3("%8lld %s %8lld\n", rRecipe[e].mSpaceBefore, (rRecipe[e].mpStartBlock == 0)?" -":b, (int64_t)rRecipe[e].mBlocks); } } diff --git a/lib/backupclient/BackupStoreObjectDump.cpp b/lib/backupclient/BackupStoreObjectDump.cpp index 5f902831..8e6331c4 100644 --- a/lib/backupclient/BackupStoreObjectDump.cpp +++ b/lib/backupclient/BackupStoreObjectDump.cpp @@ -96,11 +96,19 @@ void BackupStoreDirectory::Dump(void *clibFileHandle, bool ToTrace) int depends_l = 0; if((*i)->GetDependsNewer() != 0) { +#ifdef WIN32 + depends_l += ::sprintf(depends + depends_l, " depNew(%I64x)", (*i)->GetDependsNewer()); +#else depends_l += ::sprintf(depends + depends_l, " depNew(%llx)", (*i)->GetDependsNewer()); +#endif } if((*i)->GetDependsOlder() != 0) { +#ifdef WIN32 + depends_l += ::sprintf(depends + depends_l, " depOld(%I64x)", (*i)->GetDependsOlder()); +#else depends_l += ::sprintf(depends + depends_l, " depOld(%llx)", (*i)->GetDependsOlder()); +#endif } // Output item diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h index 6ddd1643..55065796 100755 --- a/lib/common/BoxPlatform.h +++ b/lib/common/BoxPlatform.h @@ -11,13 +11,24 @@ #ifndef BOXPLATFORM__H #define BOXPLATFORM__H +#ifdef WIN32 +#define DIRECTORY_SEPARATOR "\\" +#define DIRECTORY_SEPARATOR_ASCHAR '\\' +#else #define DIRECTORY_SEPARATOR "/" -#define DIRECTORY_SEPARATOR_ASCHAR '/' +#define DIRECTORY_SEPARATOR_ASCHAR '/' +#endif #define PLATFORM_DEV_NULL "/dev/null" #include "config.h" +#ifdef WIN32 + // need msvcrt version 6.1 or higher for _gmtime64() + // must define this before importing <sys/types.h> + #define __MSVCRT_VERSION__ 0x0601 +#endif + #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif @@ -51,6 +62,27 @@ #define STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS #endif +#if defined WIN32 && !defined __MINGW32__ + typedef __int8 int8_t; + typedef __int16 int16_t; + typedef __int32 int32_t; + typedef __int64 int64_t; + + typedef unsigned __int8 u_int8_t; + typedef unsigned __int16 u_int16_t; + typedef unsigned __int32 u_int32_t; + typedef unsigned __int64 u_int64_t; + + #define HAVE_UINT8_T + #define HAVE_UINT16_T + #define HAVE_UINT32_T + #define HAVE_UINT64_T + + typedef unsigned int uid_t; + typedef unsigned int gid_t; + typedef int pid_t; +#endif // WIN32 && !__MINGW32__ + // Define missing types #ifndef HAVE_UINT8_T typedef u_int8_t uint8_t; @@ -88,4 +120,15 @@ #define INFTIM -1 #endif +#ifdef WIN32 + typedef u_int64_t InodeRefType; +#else + typedef ino_t InodeRefType; +#endif + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include "emu.h" +#endif + #endif // BOXPLATFORM__H diff --git a/lib/common/BoxPortsAndFiles.h b/lib/common/BoxPortsAndFiles.h index 7788537e..562c6724 100755 --- a/lib/common/BoxPortsAndFiles.h +++ b/lib/common/BoxPortsAndFiles.h @@ -20,12 +20,17 @@ #define BOX_RAIDFILE_ROOT_BBSTORED "backup" // Backup client daemon +#ifdef WIN32 +#define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "C:\\Program Files\\Box Backup\\bbackupd.conf" +#else #define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "/etc/box/bbackupd.conf" +#endif - -// RaidFile conf location efault +// RaidFile conf location default #define BOX_FILE_RAIDFILE_DEFAULT_CONFIG "/etc/box/raidfile.conf" +// Default name of the named pipe +#define BOX_NAMED_PIPE_NAME L"\\\\.\\pipe\\boxbackup" #endif // BOXPORTSANDFILES__H diff --git a/lib/common/BoxTime.h b/lib/common/BoxTime.h index a7a25ac6..d166d6e7 100755 --- a/lib/common/BoxTime.h +++ b/lib/common/BoxTime.h @@ -31,11 +31,11 @@ inline box_time_t SecondsToBoxTime(uint64_t Seconds) { return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL); } -inline int64_t BoxTimeToSeconds(box_time_t Time) +inline box_time_t BoxTimeToSeconds(box_time_t Time) { return Time / MICRO_SEC_IN_SEC_LL; } -inline int64_t BoxTimeToMilliSeconds(box_time_t Time) +inline box_time_t BoxTimeToMilliSeconds(box_time_t Time) { return Time / MILLI_SEC_IN_NANO_SEC_LL; } diff --git a/lib/common/BoxTimeToText.cpp b/lib/common/BoxTimeToText.cpp index 94b0d152..297d2100 100755 --- a/lib/common/BoxTimeToText.cpp +++ b/lib/common/BoxTimeToText.cpp @@ -27,14 +27,35 @@ // -------------------------------------------------------------------------- std::string BoxTimeToISO8601String(box_time_t Time) { +#ifdef WIN32 + struct tm *time; + box_time_t bob = BoxTimeToSeconds(Time); + + __time64_t winTime = bob; + + time = _gmtime64(&winTime); + char str[128]; // more than enough space + + if ( time == NULL ) + { + // ::sprintf(str, "%016I64x ", bob); + return std::string("unable to convert time"); + } + + sprintf(str, "%04d-%02d-%02dT%02d:%02d:%02d", time->tm_year + 1900, + time->tm_mon + 1, time->tm_mday, time->tm_hour, + time->tm_min, time->tm_sec); +#else // ! WIN32 time_t timeInSecs = (time_t)BoxTimeToSeconds(Time); struct tm time; gmtime_r(&timeInSecs, &time); char str[128]; // more than enough space sprintf(str, "%04d-%02d-%02dT%02d:%02d:%02d", time.tm_year + 1900, - time.tm_mon + 1, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec); - + time.tm_mon + 1, time.tm_mday, time.tm_hour, + time.tm_min, time.tm_sec); +#endif // WIN32 + return std::string(str); } diff --git a/lib/common/BoxTimeToUnix.h b/lib/common/BoxTimeToUnix.h index 17e57e27..f8a8797e 100755 --- a/lib/common/BoxTimeToUnix.h +++ b/lib/common/BoxTimeToUnix.h @@ -10,7 +10,11 @@ #ifndef FILEMODIFICATIONTIMETOTIMEVAL__H #define FILEMODIFICATIONTIMETOTIMEVAL__H +#ifdef WIN32 +#include <time.h> +#else #include <sys/time.h> +#endif #include "BoxTime.h" diff --git a/lib/common/CommonException.txt b/lib/common/CommonException.txt index 3875ed71..f852b7d7 100644 --- a/lib/common/CommonException.txt +++ b/lib/common/CommonException.txt @@ -42,3 +42,4 @@ KEventErrorWait 34 KEventErrorRemove 35 KQueueNotSupportedOnThisPlatform 36 IOStreamGetLineNotEnoughDataToIgnore 37 Bad value passed to IOStreamGetLine::IgnoreBufferedData() +TempDirPathTooLong 38 Your temporary directory path is too long. Check the TMP and TEMP environment variables. diff --git a/lib/common/DebugPrintf.cpp b/lib/common/DebugPrintf.cpp index 02c25496..d07604b7 100755 --- a/lib/common/DebugPrintf.cpp +++ b/lib/common/DebugPrintf.cpp @@ -55,10 +55,16 @@ int BoxDebugTrace(const char *format, ...) // But tracing to syslog is independent of tracing being on or not if(BoxDebugTraceToSyslog) { +#ifdef WIN32 // Remove trailing '\n', if it's there + if(r > 0 && text[r-1] == '\n') + { + text[r-1] = '\0'; +#else if(r > 0 && text[r] == '\n') { text[r] = '\0'; +#endif --r; } // Log it diff --git a/lib/common/FileStream.cpp b/lib/common/FileStream.cpp index ca6894ae..9f5460bb 100755 --- a/lib/common/FileStream.cpp +++ b/lib/common/FileStream.cpp @@ -22,14 +22,25 @@ // // -------------------------------------------------------------------------- FileStream::FileStream(const char *Filename, int flags, int mode) +#ifdef WIN32 + : mOSFileHandle(::openfile(Filename, flags, mode)), +#else : mOSFileHandle(::open(Filename, flags, mode)), +#endif mIsEOF(false) { +#ifdef WIN32 + if(mOSFileHandle == 0) +#else if(mOSFileHandle < 0) +#endif { MEMLEAKFINDER_NOT_A_LEAK(this); THROW_EXCEPTION(CommonException, OSFileOpenError) } +#ifdef WIN32 + this->fileName = Filename; +#endif } @@ -41,7 +52,7 @@ FileStream::FileStream(const char *Filename, int flags, int mode) // Created: 2003/08/28 // // -------------------------------------------------------------------------- -FileStream::FileStream(int FileDescriptor) +FileStream::FileStream(tOSFileHandle FileDescriptor) : mOSFileHandle(FileDescriptor), mIsEOF(false) { @@ -52,7 +63,7 @@ FileStream::FileStream(int FileDescriptor) } } - +#if 0 // -------------------------------------------------------------------------- // // Function @@ -71,6 +82,7 @@ FileStream::FileStream(const FileStream &rToCopy) THROW_EXCEPTION(CommonException, OSFileOpenError) } } +#endif // 0 // -------------------------------------------------------------------------- // @@ -82,7 +94,7 @@ FileStream::FileStream(const FileStream &rToCopy) // -------------------------------------------------------------------------- FileStream::~FileStream() { - if(mOSFileHandle >= 0) + if(mOSFileHandle != INVALID_FILE) { Close(); } @@ -98,8 +110,33 @@ FileStream::~FileStream() // -------------------------------------------------------------------------- int FileStream::Read(void *pBuffer, int NBytes, int Timeout) { - if(mOSFileHandle == -1) {THROW_EXCEPTION(CommonException, FileClosed)} + if(mOSFileHandle == INVALID_FILE) + { + THROW_EXCEPTION(CommonException, FileClosed) + } + +#ifdef WIN32 + int r; + DWORD numBytesRead = 0; + BOOL valid = ReadFile( + this->mOSFileHandle, + pBuffer, + NBytes, + &numBytesRead, + NULL + ); + + if ( valid ) + { + r = numBytesRead; + } + else + { + r = -1; + } +#else int r = ::read(mOSFileHandle, pBuffer, NBytes); +#endif if(r == -1) { THROW_EXCEPTION(CommonException, OSFileReadError) @@ -143,11 +180,34 @@ IOStream::pos_type FileStream::BytesLeftToRead() // -------------------------------------------------------------------------- void FileStream::Write(const void *pBuffer, int NBytes) { - if(mOSFileHandle == -1) {THROW_EXCEPTION(CommonException, FileClosed)} + if(mOSFileHandle == INVALID_FILE) + { + THROW_EXCEPTION(CommonException, FileClosed) + } + +#ifdef WIN32 + DWORD numBytesWritten = 0; + BOOL res = WriteFile( + this->mOSFileHandle, + pBuffer, + NBytes, + &numBytesWritten, + NULL + ); + + if ( (res == 0) || (numBytesWritten != NBytes)) + { + DWORD err = GetLastError(); + THROW_EXCEPTION(CommonException, OSFileWriteError) + } + + +#else if(::write(mOSFileHandle, pBuffer, NBytes) != NBytes) { THROW_EXCEPTION(CommonException, OSFileWriteError) } +#endif } @@ -161,7 +221,21 @@ void FileStream::Write(const void *pBuffer, int NBytes) // -------------------------------------------------------------------------- IOStream::pos_type FileStream::GetPosition() const { - if(mOSFileHandle == -1) {THROW_EXCEPTION(CommonException, FileClosed)} + if(mOSFileHandle == INVALID_FILE) + { + THROW_EXCEPTION(CommonException, FileClosed) + } + +#ifdef WIN32 + LARGE_INTEGER conv; + + conv.HighPart = 0; + conv.LowPart = 0; + + conv.LowPart = SetFilePointer(this->mOSFileHandle, 0, &conv.HighPart, FILE_CURRENT); + + return (IOStream::pos_type)conv.QuadPart; +#else // ! WIN32 off_t p = ::lseek(mOSFileHandle, 0, SEEK_CUR); if(p == -1) { @@ -169,6 +243,7 @@ IOStream::pos_type FileStream::GetPosition() const } return (IOStream::pos_type)p; +#endif // WIN32 } @@ -182,12 +257,28 @@ IOStream::pos_type FileStream::GetPosition() const // -------------------------------------------------------------------------- void FileStream::Seek(IOStream::pos_type Offset, int SeekType) { - if(mOSFileHandle == -1) {THROW_EXCEPTION(CommonException, FileClosed)} + if(mOSFileHandle == INVALID_FILE) + { + THROW_EXCEPTION(CommonException, FileClosed) + } + +#ifdef WIN32 + LARGE_INTEGER conv; + + conv.QuadPart = Offset; + DWORD retVal = SetFilePointer(this->mOSFileHandle, conv.LowPart, &conv.HighPart, ConvertSeekTypeToOSWhence(SeekType)); + + if ( retVal == INVALID_SET_FILE_POINTER && (GetLastError() != NO_ERROR) ) + { + THROW_EXCEPTION(CommonException, OSFileError) + } +#else // ! WIN32 if(::lseek(mOSFileHandle, Offset, ConvertSeekTypeToOSWhence(SeekType)) == -1) { THROW_EXCEPTION(CommonException, OSFileError) } - +#endif // WIN32 + // Not end of file any more! mIsEOF = false; } @@ -207,12 +298,21 @@ void FileStream::Close() { THROW_EXCEPTION(CommonException, FileAlreadyClosed) } +#ifdef WIN32 + if(::CloseHandle(mOSFileHandle) == 0) + { + THROW_EXCEPTION(CommonException, OSFileCloseError) + } + mOSFileHandle = NULL; + mIsEOF = true; +#else if(::close(mOSFileHandle) != 0) { THROW_EXCEPTION(CommonException, OSFileCloseError) } mOSFileHandle = -1; mIsEOF = true; +#endif } diff --git a/lib/common/FileStream.h b/lib/common/FileStream.h index bb3cc459..7d677636 100755 --- a/lib/common/FileStream.h +++ b/lib/common/FileStream.h @@ -17,12 +17,26 @@ #include <sys/stat.h> #include <unistd.h> +#ifdef WIN32 + #define INVALID_FILE NULL + typedef HANDLE tOSFileHandle; +#else + #define INVALID_FILE -1 + typedef int tOSFileHandle; +#endif + class FileStream : public IOStream { public: - FileStream(const char *Filename, int flags = O_RDONLY, int mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); - FileStream(int FileDescriptor); - FileStream(const FileStream &rToCopy); + FileStream(const char *Filename, +#ifdef WIN32 + int flags = (O_RDONLY | O_BINARY), +#else + int flags = O_RDONLY, +#endif + int mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); + FileStream(tOSFileHandle FileDescriptor); + virtual ~FileStream(); virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); @@ -36,8 +50,14 @@ public: virtual bool StreamClosed(); private: - int mOSFileHandle; + tOSFileHandle mOSFileHandle; bool mIsEOF; + FileStream(const FileStream &rToCopy) { /* do not call */ } + +#ifdef WIN32 + // for debugging.. + std::string fileName; +#endif }; diff --git a/lib/common/IOStream.cpp b/lib/common/IOStream.cpp index 024eefcc..3c7be561 100755 --- a/lib/common/IOStream.cpp +++ b/lib/common/IOStream.cpp @@ -105,6 +105,17 @@ int IOStream::ConvertSeekTypeToOSWhence(int SeekType) int ostype = SEEK_SET; switch(SeekType) { +#ifdef WIN32 + case SeekType_Absolute: + ostype = FILE_BEGIN; + break; + case SeekType_Relative: + ostype = FILE_CURRENT; + break; + case SeekType_End: + ostype = FILE_END; + break; +#else // ! WIN32 case SeekType_Absolute: ostype = SEEK_SET; break; @@ -114,6 +125,7 @@ int IOStream::ConvertSeekTypeToOSWhence(int SeekType) case SeekType_End: ostype = SEEK_END; break; +#endif // WIN32 default: THROW_EXCEPTION(CommonException, IOStreamBadSeekType) diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp index b9aeb768..fc7b8309 100755 --- a/lib/common/NamedLock.cpp +++ b/lib/common/NamedLock.cpp @@ -105,7 +105,7 @@ bool NamedLock::TryAndGetLock(const char *Filename, int mode) THROW_EXCEPTION(CommonException, OSFileError) } } -#else +#elif HAVE_DECL_F_SETLK struct flock desc; desc.l_type = F_WRLCK; desc.l_whence = SEEK_SET; diff --git a/lib/common/TemporaryDirectory.h b/lib/common/TemporaryDirectory.h index e683863b..9d52ecd9 100755 --- a/lib/common/TemporaryDirectory.h +++ b/lib/common/TemporaryDirectory.h @@ -12,15 +12,35 @@ #include <string> -#ifdef TEMP_DIRECTORY_NAME - // Prefix name with Box to avoid clashing with OS API names - inline std::string BoxGetTemporaryDirectoryName() +#ifdef WIN32 + #include <windows.h> +#endif + +// Prefix name with Box to avoid clashing with OS API names +std::string BoxGetTemporaryDirectoryName() +{ +#ifdef WIN32 + // http://msdn.microsoft.com/library/default.asp? + // url=/library/en-us/fileio/fs/creating_and_using_a_temporary_file.asp + + DWORD dwRetVal; + char lpPathBuffer[1024]; + DWORD dwBufSize = sizeof(lpPathBuffer); + + // Get the temp path. + dwRetVal = GetTempPath(dwBufSize, // length of the buffer + lpPathBuffer); // buffer for path + if (dwRetVal > dwBufSize) { - return std::string(TEMP_DIRECTORY_NAME); + THROW_EXCEPTION(CommonException, TempDirPathTooLong) } -#else - non-static temporary directory names not supported yet + + return std::string(lpPathBuffer); +#elif defined TEMP_DIRECTORY_NAME + return std::string(TEMP_DIRECTORY_NAME); +#else + #error non-static temporary directory names not supported yet #endif +} #endif // TEMPORARYDIRECTORY__H - diff --git a/lib/common/UnixUser.cpp b/lib/common/UnixUser.cpp index 7a60b263..8b85c3e1 100755 --- a/lib/common/UnixUser.cpp +++ b/lib/common/UnixUser.cpp @@ -9,7 +9,10 @@ #include "Box.h" +#ifndef WIN32 #include <pwd.h> +#endif + #include <unistd.h> #include "UnixUser.h" diff --git a/lib/common/WaitForEvent.h b/lib/common/WaitForEvent.h index 46f152c5..52a073e9 100644 --- a/lib/common/WaitForEvent.h +++ b/lib/common/WaitForEvent.h @@ -15,7 +15,9 @@ #include <sys/time.h> #else #include <vector> - #include <poll.h> + #ifndef WIN32 + #include <poll.h> + #endif #endif #include "CommonException.h" diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index ca2df62f..a4dfdaec 100755 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -11,11 +11,14 @@ #include <stdio.h> #include <unistd.h> -#include <syslog.h> #include <signal.h> #include <string.h> #include <stdarg.h> +#ifndef WIN32 +#include <syslog.h> +#endif + #include "Daemon.h" #include "Configuration.h" #include "ServerException.h" @@ -140,6 +143,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) // Let the derived class have a go at setting up stuff in the initial process SetupInInitialProcess(); +#ifndef WIN32 // Set signal handler struct sigaction sa; sa.sa_handler = SignalHandler; @@ -219,12 +223,14 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) break; } } +#endif // ! WIN32 // open the log ::openlog(DaemonName(), LOG_PID, LOG_LOCAL6); // Log the start message ::syslog(LOG_INFO, "Starting daemon (config: %s) (version " BOX_VERSION ")", configfile); +#ifndef WIN32 // Write PID to file char pid[32]; int pidsize = sprintf(pid, "%d", (int)getpid()); @@ -233,6 +239,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) ::syslog(LOG_ERR, "can't write pid file"); THROW_EXCEPTION(ServerException, DaemoniseFailed) } +#endif // Set up memory leak reporting #ifdef BOX_MEMORY_LEAK_TESTING @@ -245,6 +252,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) if(asDaemon) { +#ifndef WIN32 // Close standard streams ::close(0); ::close(1); @@ -265,8 +273,9 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) { ::close(devnull); } - - // And definately don't try and send anything to those file descriptors +#endif // ! WIN32 + + // And definitely don't try and send anything to those file descriptors // -- this has in the past sent text to something which isn't expecting it. TRACE_TO_STDOUT(false); } @@ -357,6 +366,7 @@ int Daemon::Main(const char *DefaultConfigFile, int argc, const char *argv[]) // -------------------------------------------------------------------------- void Daemon::EnterChild() { +#ifndef WIN32 // Unset signal handlers struct sigaction sa; sa.sa_handler = SIG_DFL; @@ -364,6 +374,7 @@ void Daemon::EnterChild() sigemptyset(&sa.sa_mask); // macro ::sigaction(SIGHUP, &sa, NULL); ::sigaction(SIGTERM, &sa, NULL); +#endif } @@ -377,6 +388,7 @@ void Daemon::EnterChild() // -------------------------------------------------------------------------- void Daemon::SignalHandler(int sigraised) { +#ifndef WIN32 if(spDaemon != 0) { switch(sigraised) @@ -393,6 +405,7 @@ void Daemon::SignalHandler(int sigraised) break; } } +#endif } // -------------------------------------------------------------------------- @@ -534,5 +547,3 @@ void Daemon::SetProcessTitle(const char *format, ...) #endif // HAVE_SETPROCTITLE } - - diff --git a/lib/server/LocalProcessStream.cpp b/lib/server/LocalProcessStream.cpp index f2a97c56..0de7bef4 100644 --- a/lib/server/LocalProcessStream.cpp +++ b/lib/server/LocalProcessStream.cpp @@ -9,7 +9,9 @@ #include "Box.h" +#ifndef WIN32 #include <sys/socket.h> +#endif #include <unistd.h> #include "LocalProcessStream.h" @@ -36,6 +38,8 @@ std::auto_ptr<IOStream> LocalProcessStream(const char *CommandLine, pid_t &rPidO // Split up command std::vector<std::string> command; SplitString(std::string(CommandLine), ' ', command); + +#ifndef WIN32 // Build arguments char *args[MAX_ARGUMENTS + 4]; { @@ -94,6 +98,11 @@ std::auto_ptr<IOStream> LocalProcessStream(const char *CommandLine, pid_t &rPidO // Return the stream object and PID rPidOut = pid; return stream; +#else // WIN32 + ::syslog(LOG_ERR, "vfork not implemented - LocalProcessStream.cpp"); + std::auto_ptr<IOStream> stream; + return stream; +#endif // ! WIN32 } diff --git a/lib/server/SSLLib.cpp b/lib/server/SSLLib.cpp index 9e98550a..2a5bdbde 100755 --- a/lib/server/SSLLib.cpp +++ b/lib/server/SSLLib.cpp @@ -14,7 +14,9 @@ #include <openssl/err.h> #include <openssl/rand.h> +#ifndef WIN32 #include <syslog.h> +#endif #include "SSLLib.h" #include "ServerException.h" diff --git a/lib/server/ServerStream.h b/lib/server/ServerStream.h index d087a321..8dafccae 100755 --- a/lib/server/ServerStream.h +++ b/lib/server/ServerStream.h @@ -10,10 +10,13 @@ #ifndef SERVERSTREAM__H #define SERVERSTREAM__H -#include <syslog.h> #include <stdlib.h> #include <errno.h> -#include <sys/wait.h> + +#ifndef WIN32 + #include <syslog.h> + #include <sys/wait.h> +#endif #include "Daemon.h" #include "SocketListen.h" diff --git a/lib/server/Socket.cpp b/lib/server/Socket.cpp index b2d32345..0343b8bf 100755 --- a/lib/server/Socket.cpp +++ b/lib/server/Socket.cpp @@ -11,11 +11,13 @@ #include <unistd.h> #include <sys/types.h> +#ifndef WIN32 #include <sys/socket.h> #include <netdb.h> #include <syslog.h> #include <netinet/in.h> #include <arpa/inet.h> +#endif #include <string.h> #include <stdio.h> @@ -72,6 +74,7 @@ void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, int Type } break; +#ifndef WIN32 case TypeUNIX: sockDomain = AF_UNIX; { @@ -89,7 +92,8 @@ void Socket::NameLookupToSockAddr(SocketAllAddr &addr, int &sockDomain, int Type ::strcpy(addr.sa_unix.sun_path, Name); } break; - +#endif + default: THROW_EXCEPTION(CommonException, BadArguments) break; diff --git a/lib/server/Socket.h b/lib/server/Socket.h index 86a06097..057e4cad 100755 --- a/lib/server/Socket.h +++ b/lib/server/Socket.h @@ -10,16 +10,23 @@ #ifndef SOCKET__H #define SOCKET__H +#ifdef WIN32 +#include "emu.h" +typedef int socklen_t; +#else #include <sys/socket.h> #include <netinet/in.h> #include <sys/un.h> +#endif #include <string> typedef union { struct sockaddr sa_generic; struct sockaddr_in sa_inet; +#ifndef WIN32 struct sockaddr_un sa_unix; +#endif } SocketAllAddr; // -------------------------------------------------------------------------- diff --git a/lib/server/SocketListen.h b/lib/server/SocketListen.h index 7042011c..d954339a 100755 --- a/lib/server/SocketListen.h +++ b/lib/server/SocketListen.h @@ -12,15 +12,20 @@ #include <errno.h> #include <unistd.h> -#include <new> -#include <poll.h> -#include <memory> -#include <string> + #ifdef HAVE_KQUEUE #include <sys/event.h> #include <sys/time.h> #endif +#ifndef WIN32 + #include <poll.h> +#endif + +#include <new> +#include <memory> +#include <string> + #include "Socket.h" #include "ServerException.h" @@ -94,7 +99,11 @@ public: { if(mSocketHandle != -1) { +#ifdef WIN32 + if(::closesocket(mSocketHandle) == -1) +#else if(::close(mSocketHandle) == -1) +#endif { THROW_EXCEPTION(ServerException, SocketCloseError) } @@ -128,8 +137,12 @@ public: } // Set an option to allow reuse (useful for -HUP situations!) +#ifdef WIN32 + if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, "", 0) == -1) +#else int option = true; if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) == -1) +#endif { THROW_EXCEPTION(ServerException, SocketOpenError) } diff --git a/lib/server/SocketStream.cpp b/lib/server/SocketStream.cpp index 53865ee3..6719fcde 100755 --- a/lib/server/SocketStream.cpp +++ b/lib/server/SocketStream.cpp @@ -11,9 +11,12 @@ #include <unistd.h> #include <sys/types.h> -#include <poll.h> #include <errno.h> +#ifndef WIN32 +#include <poll.h> +#endif + #include "SocketStream.h" #include "ServerException.h" #include "CommonException.h" @@ -140,7 +143,11 @@ void SocketStream::Open(int Type, const char *Name, int Port) if(::connect(mSocketHandle, &addr.sa_generic, addrLen) == -1) { // Dispose of the socket +#ifdef WIN32 + ::closesocket(mSocketHandle); +#else ::close(mSocketHandle); +#endif mSocketHandle = -1; THROW_EXCEPTION(ConnectionException, Conn_SocketConnectError) } @@ -191,7 +198,11 @@ int SocketStream::Read(void *pBuffer, int NBytes, int Timeout) } } +#ifdef WIN32 + int r = ::recv(mSocketHandle, (char*)pBuffer, NBytes, 0); +#else int r = ::read(mSocketHandle, pBuffer, NBytes); +#endif if(r == -1) { if(errno == EINTR) @@ -236,7 +247,11 @@ void SocketStream::Write(const void *pBuffer, int NBytes) while(bytesLeft > 0) { // Try to send. +#ifdef WIN32 + int sent = ::send(mSocketHandle, buffer, bytesLeft, 0); +#else int sent = ::write(mSocketHandle, buffer, bytesLeft); +#endif if(sent == -1) { // Error. @@ -283,8 +298,11 @@ void SocketStream::Write(const void *pBuffer, int NBytes) void SocketStream::Close() { if(mSocketHandle == -1) {THROW_EXCEPTION(ServerException, BadSocketHandle)} - +#ifdef WIN32 + if(::closesocket(mSocketHandle) == -1) +#else if(::close(mSocketHandle) == -1) +#endif { THROW_EXCEPTION(ServerException, SocketCloseError) } @@ -354,7 +372,7 @@ bool SocketStream::StreamClosed() // Created: 2003/08/06 // // -------------------------------------------------------------------------- -int SocketStream::GetSocketHandle() +tOSSocketHandle SocketStream::GetSocketHandle() { if(mSocketHandle == -1) {THROW_EXCEPTION(ServerException, BadSocketHandle)} return mSocketHandle; diff --git a/lib/server/SocketStream.h b/lib/server/SocketStream.h index 9b16dbfc..5caaacfd 100755 --- a/lib/server/SocketStream.h +++ b/lib/server/SocketStream.h @@ -12,6 +12,12 @@ #include "IOStream.h" +#ifdef WIN32 + typedef SOCKET tOSSocketHandle; +#else + typedef int tOSSocketHandle; +#endif + // -------------------------------------------------------------------------- // // Class @@ -42,12 +48,12 @@ public: virtual bool GetPeerCredentials(uid_t &rUidOut, gid_t &rGidOut); protected: - int GetSocketHandle(); + tOSSocketHandle GetSocketHandle(); void MarkAsReadClosed() {mReadClosed = true;} void MarkAsWriteClosed() {mWriteClosed = true;} private: - int mSocketHandle; + tOSSocketHandle mSocketHandle; bool mReadClosed; bool mWriteClosed; }; diff --git a/lib/server/SocketStreamTLS.cpp b/lib/server/SocketStreamTLS.cpp index 7d82f82c..39e0ea6c 100755 --- a/lib/server/SocketStreamTLS.cpp +++ b/lib/server/SocketStreamTLS.cpp @@ -12,10 +12,13 @@ #define TLS_CLASS_IMPLEMENTATION_CPP #include <openssl/ssl.h> #include <openssl/bio.h> -#include <poll.h> #include <errno.h> #include <fcntl.h> +#ifndef WIN32 +#include <poll.h> +#endif + #include "SocketStreamTLS.h" #include "SSLLib.h" #include "ServerException.h" @@ -120,7 +123,8 @@ void SocketStreamTLS::Handshake(const TLSContext &rContext, bool IsServer) SSLLib::LogError("Create socket bio"); THROW_EXCEPTION(ServerException, TLSAllocationFailed) } - int socket = GetSocketHandle(); + + tOSSocketHandle socket = GetSocketHandle(); BIO_set_fd(mpBIO, socket, BIO_NOCLOSE); // Then the SSL object @@ -131,6 +135,7 @@ void SocketStreamTLS::Handshake(const TLSContext &rContext, bool IsServer) THROW_EXCEPTION(ServerException, TLSAllocationFailed) } +#ifndef WIN32 // Make the socket non-blocking so timeouts on Read work // This is more portable than using ioctl with FIONBIO int statusFlags = 0; @@ -139,6 +144,7 @@ void SocketStreamTLS::Handshake(const TLSContext &rContext, bool IsServer) { THROW_EXCEPTION(ServerException, SocketSetNonBlockingFailed) } +#endif // FIXME: This is less portable than the above. However, it MAY be needed // for cygwin, which has/had bugs with fcntl @@ -464,5 +470,3 @@ std::string SocketStreamTLS::GetPeerCommonName() // Done. return std::string(commonName); } - - diff --git a/lib/server/makeprotocol.pl b/lib/server/makeprotocol.pl index 2a69c59c..71355e62 100755 --- a/lib/server/makeprotocol.pl +++ b/lib/server/makeprotocol.pl @@ -182,7 +182,11 @@ __E if($implement_syslog) { - print H qq~#include <syslog.h>\n~; + print H <<EOF; +#ifndef WIN32 +#include <syslog.h> +#endif +EOF } diff --git a/lib/win32/WinNamedPipeStream.cpp b/lib/win32/WinNamedPipeStream.cpp new file mode 100755 index 00000000..17a2227b --- /dev/null +++ b/lib/win32/WinNamedPipeStream.cpp @@ -0,0 +1,301 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: WinNamedPipeStream.cpp +// Purpose: I/O stream interface for Win32 named pipes +// Created: 2005/12/07 +// +// -------------------------------------------------------------------------- + +#include "Box.h" + +#ifdef WIN32 + +#include <unistd.h> +#include <sys/types.h> +#include <errno.h> +#include <windows.h> + +#include "WinNamedPipeStream.h" +#include "ServerException.h" +#include "CommonException.h" +#include "Socket.h" + +#include "MemLeakFindOn.h" + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::WinNamedPipeStream() +// Purpose: Constructor (create stream ready for Open() call) +// Created: 2005/12/07 +// +// -------------------------------------------------------------------------- +WinNamedPipeStream::WinNamedPipeStream() + : mSocketHandle(NULL), + mReadClosed(false), + mWriteClosed(false), + mIsServer(false), + mIsConnected(false) +{ +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::~WinNamedPipeStream() +// Purpose: Destructor, closes stream if open +// Created: 2005/12/07 +// +// -------------------------------------------------------------------------- +WinNamedPipeStream::~WinNamedPipeStream() +{ + if (mSocketHandle != NULL) + { + Close(); + } +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::Accept(const char* Name) +// Purpose: Creates a new named pipe with the given name, +// and wait for a connection on it +// Created: 2005/12/07 +// +// -------------------------------------------------------------------------- +void WinNamedPipeStream::Accept(const wchar_t* pName) +{ + if (mSocketHandle != NULL || mIsConnected) + { + THROW_EXCEPTION(ServerException, SocketAlreadyOpen) + } + + mSocketHandle = CreateNamedPipeW( + pName, // pipe name + PIPE_ACCESS_DUPLEX, // read/write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_WAIT, // blocking mode + 1, // max. instances + 4096, // output buffer size + 4096, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute + + if (mSocketHandle == NULL) + { + ::syslog(LOG_ERR, "CreateNamedPipeW failed: %d", + GetLastError()); + THROW_EXCEPTION(ServerException, SocketOpenError) + } + + bool connected = ConnectNamedPipe(mSocketHandle, (LPOVERLAPPED) NULL); + + if (!connected) + { + ::syslog(LOG_ERR, "ConnectNamedPipe failed: %d", + GetLastError()); + CloseHandle(mSocketHandle); + mSocketHandle = NULL; + THROW_EXCEPTION(ServerException, SocketOpenError) + } + + mReadClosed = FALSE; + mWriteClosed = FALSE; + mIsServer = TRUE; // must flush and disconnect before closing + mIsConnected = TRUE; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::Connect(const char* Name) +// Purpose: Opens a connection to a listening named pipe +// Created: 2005/12/07 +// +// -------------------------------------------------------------------------- +void WinNamedPipeStream::Connect(const wchar_t* pName) +{ + if (mSocketHandle != NULL || mIsConnected) + { + THROW_EXCEPTION(ServerException, SocketAlreadyOpen) + } + + mSocketHandle = CreateFileW( + pName, // pipe name + GENERIC_READ | // read and write access + GENERIC_WRITE, + 0, // no sharing + NULL, // default security attributes + OPEN_EXISTING, + 0, // default attributes + NULL); // no template file + + if (mSocketHandle == INVALID_HANDLE_VALUE) + { + ::syslog(LOG_ERR, "Failed to connect to server's named pipe: " + "error %d", GetLastError()); + THROW_EXCEPTION(ServerException, SocketOpenError) + } + + mReadClosed = FALSE; + mWriteClosed = FALSE; + mIsServer = FALSE; // just close the socket + mIsConnected = TRUE; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::Read(void *pBuffer, int NBytes) +// Purpose: Reads data from stream. Maybe returns less than asked for. +// Created: 2003/07/31 +// +// -------------------------------------------------------------------------- +int WinNamedPipeStream::Read(void *pBuffer, int NBytes, int Timeout) +{ + // TODO no support for timeouts yet + ASSERT(Timeout == IOStream::TimeOutInfinite) + + if (mSocketHandle == NULL || !mIsConnected) + { + THROW_EXCEPTION(ServerException, BadSocketHandle) + } + + DWORD NumBytesRead; + + bool Success = ReadFile( + mSocketHandle, // pipe handle + pBuffer, // buffer to receive reply + NBytes, // size of buffer + &NumBytesRead, // number of bytes read + NULL); // not overlapped + + if (!Success) + { + THROW_EXCEPTION(ConnectionException, Conn_SocketReadError) + } + + // Closed for reading at EOF? + if (NumBytesRead == 0) + { + mReadClosed = true; + } + + return NumBytesRead; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::Write(void *pBuffer, int NBytes) +// Purpose: Writes data, blocking until it's all done. +// Created: 2003/07/31 +// +// -------------------------------------------------------------------------- +void WinNamedPipeStream::Write(const void *pBuffer, int NBytes) +{ + if (mSocketHandle == NULL || !mIsConnected) + { + THROW_EXCEPTION(ServerException, BadSocketHandle) + } + + // Buffer in byte sized type. + ASSERT(sizeof(char) == 1); + const char *pByteBuffer = (char *)pBuffer; + + int NumBytesWrittenTotal = 0; + + while (NumBytesWrittenTotal < NBytes) + { + DWORD NumBytesWrittenThisTime = 0; + + bool Success = WriteFile( + mSocketHandle, // pipe handle + pByteBuffer + NumBytesWrittenTotal, // message + NBytes - NumBytesWrittenTotal, // message length + &NumBytesWrittenThisTime, // bytes written this time + NULL); // not overlapped + + if (!Success) + { + mWriteClosed = true; // assume can't write again + THROW_EXCEPTION(ConnectionException, + Conn_SocketWriteError) + } + + NumBytesWrittenTotal += NumBytesWrittenThisTime; + } +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::Close() +// Purpose: Closes connection to remote socket +// Created: 2003/07/31 +// +// -------------------------------------------------------------------------- +void WinNamedPipeStream::Close() +{ + if (mSocketHandle == NULL || !mIsConnected) + { + THROW_EXCEPTION(ServerException, BadSocketHandle) + } + + if (mIsServer) + { + if (!FlushFileBuffers(mSocketHandle)) + { + ::syslog(LOG_INFO, "FlushFileBuffers failed: %d", + GetLastError()); + } + + if (!DisconnectNamedPipe(mSocketHandle)) + { + ::syslog(LOG_ERR, "DisconnectNamedPipe failed: %d", + GetLastError()); + } + + mIsServer = false; + } + + if (!CloseHandle(mSocketHandle)) + { + ::syslog(LOG_ERR, "CloseHandle failed: %d", GetLastError()); + THROW_EXCEPTION(ServerException, SocketCloseError) + } + + mSocketHandle = NULL; + mIsConnected = FALSE; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::StreamDataLeft() +// Purpose: Still capable of reading data? +// Created: 2003/08/02 +// +// -------------------------------------------------------------------------- +bool WinNamedPipeStream::StreamDataLeft() +{ + return !mReadClosed; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: WinNamedPipeStream::StreamClosed() +// Purpose: Connection been closed? +// Created: 2003/08/02 +// +// -------------------------------------------------------------------------- +bool WinNamedPipeStream::StreamClosed() +{ + return mWriteClosed; +} + +#endif // WIN32 diff --git a/lib/win32/WinNamedPipeStream.h b/lib/win32/WinNamedPipeStream.h new file mode 100755 index 00000000..5a800371 --- /dev/null +++ b/lib/win32/WinNamedPipeStream.h @@ -0,0 +1,60 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: WinNamedPipeStream.h +// Purpose: I/O stream interface for Win32 named pipes +// Created: 2005/12/07 +// +// -------------------------------------------------------------------------- + +#if ! defined WINNAMEDPIPESTREAM__H && defined WIN32 +#define WINNAMEDPIPESTREAM__H + +#include "IOStream.h" + +// -------------------------------------------------------------------------- +// +// Class +// Name: WinNamedPipeStream +// Purpose: I/O stream interface for Win32 named pipes +// Created: 2003/07/31 +// +// -------------------------------------------------------------------------- +class WinNamedPipeStream : public IOStream +{ +public: + WinNamedPipeStream(); + ~WinNamedPipeStream(); + + // server side - create the named pipe and listen for connections + void Accept(const wchar_t* Name); + + // client side - connect to a waiting server + void Connect(const wchar_t* Name); + + // both sides + virtual int Read(void *pBuffer, int NBytes, + int Timeout = IOStream::TimeOutInfinite); + virtual void Write(const void *pBuffer, int NBytes); + virtual void Close(); + virtual bool StreamDataLeft(); + virtual bool StreamClosed(); + bool IsConnected() { return mIsConnected; } + +protected: + HANDLE GetSocketHandle(); + void MarkAsReadClosed() {mReadClosed = true;} + void MarkAsWriteClosed() {mWriteClosed = true;} + +private: + WinNamedPipeStream(const WinNamedPipeStream &rToCopy) + { /* do not call */ } + + HANDLE mSocketHandle; + bool mReadClosed; + bool mWriteClosed; + bool mIsServer; + bool mIsConnected; +}; + +#endif // WINNAMEDPIPESTREAM__H diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp new file mode 100644 index 00000000..29200313 --- /dev/null +++ b/lib/win32/emu.cpp @@ -0,0 +1,978 @@ +// Box Backup Win32 native port by Nick Knight + +// Need at least 0x0500 to use GetFileSizeEx on Cygwin/MinGW +#define WINVER 0x0500 + +#include "Box.h" + +#ifdef WIN32 + +// #include "emu.h" + +#include <windows.h> +#include <fcntl.h> +// #include <atlenc.h> +#include <unistd.h> + +#include <string> +#include <list> + +//our implimentation for a timer +//based on a simple thread which sleeps for a +//period of time +static bool gFinishTimer; +static CRITICAL_SECTION gLock; + +typedef struct +{ + int countDown; + int interval; +} +tTimer; + +std::list<tTimer> gTimerList; +static void (__cdecl *gTimerFunc) (int) = NULL; + +int setitimer(int type , struct itimerval *timeout, int) +{ + if ( SIGVTALRM == type || ITIMER_VIRTUAL == type ) + { + EnterCriticalSection(&gLock); + // we only need seconds for the mo! + if (timeout->it_value.tv_sec == 0 && + timeout->it_value.tv_usec == 0) + { + gTimerList.clear(); + } + else + { + tTimer ourTimer; + ourTimer.countDown = timeout->it_value.tv_sec; + ourTimer.interval = timeout->it_interval.tv_sec; + gTimerList.push_back(ourTimer); + } + LeaveCriticalSection(&gLock); + } + + // indicate success + return 0; +} + +static unsigned int WINAPI RunTimer(LPVOID lpParameter) +{ + gFinishTimer = false; + + while (!gFinishTimer) + { + std::list<tTimer>::iterator it; + EnterCriticalSection(&gLock); + + for (it = gTimerList.begin(); it != gTimerList.end(); it++) + { + tTimer& rTimer(*it); + + rTimer.countDown --; + if (rTimer.countDown == 0) + { + if (gTimerFunc != NULL) + { + gTimerFunc(0); + } + if (rTimer.interval) + { + rTimer.countDown = rTimer.interval; + } + else + { + // mark for deletion + rTimer.countDown = -1; + } + } + } + + for (it = gTimerList.begin(); it != gTimerList.end(); it++) + { + tTimer& rTimer(*it); + + if (rTimer.countDown == -1) + { + gTimerList.erase(it); + //if we don't do this the search is on a corrupt list + it = gTimerList.begin(); + } + } + + LeaveCriticalSection(&gLock); + // we only need to have a 1 second resolution + Sleep(1000); + } + + return 0; +} + +int SetTimerHandler(void (__cdecl *func ) (int)) +{ + gTimerFunc = func; + return 0; +} + +void InitTimer(void) +{ + InitializeCriticalSection(&gLock); + + // create our thread + HANDLE ourThread = (HANDLE)_beginthreadex(NULL, 0, RunTimer, 0, + CREATE_SUSPENDED, NULL); + SetThreadPriority(ourThread, THREAD_PRIORITY_LOWEST); + ResumeThread(ourThread); +} + +void FiniTimer(void) +{ + gFinishTimer = true; + EnterCriticalSection(&gLock); + DeleteCriticalSection(&gLock); +} + +//Our constants we need to keep track of +//globals +struct passwd gTempPasswd; + +bool EnableBackupRights( void ) +{ + HANDLE hToken; + TOKEN_PRIVILEGES token_priv; + + //open current process to adjust privileges + if( !OpenProcessToken( GetCurrentProcess( ), + TOKEN_ADJUST_PRIVILEGES, + &hToken )) + { + printf( "Cannot open process token - err = %d\n", GetLastError( ) ); + return false; + } + + //let's build the token privilege struct - + //first, look up the LUID for the backup privilege + + if( !LookupPrivilegeValue( NULL, //this system + SE_BACKUP_NAME, //the name of the privilege + &( token_priv.Privileges[0].Luid )) ) //result + { + printf( "Cannot lookup backup privilege - err = %d\n", GetLastError( ) ); + return false; + } + + token_priv.PrivilegeCount = 1; + token_priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + + // now set the privilege + // because we're going exit right after dumping the streams, there isn't + // any need to save current state + + if( !AdjustTokenPrivileges( hToken, //our process token + false, //we're not disabling everything + &token_priv, //address of structure + sizeof( token_priv ), //size of structure + NULL, NULL )) //don't save current state + { + //this function is a little tricky - if we were adjusting + //more than one privilege, it could return success but not + //adjust them all - in the general case, you need to trap this + printf( "Could not enable backup privileges - err = %d\n", GetLastError( ) ); + return false; + + } + else + { + return true; + } +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: openfile +// Purpose: replacement for any open calls - handles unicode filenames - supplied in utf8 +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +HANDLE openfile(const char *filename, int flags, int mode) +{ + try{ + + wchar_t *buffer; + std::string fileN(filename); + + std::string tmpStr("\\\\?\\"); + //is the path relative or otherwise + if ( fileN[1] != ':' ) + { + //we need to get the current directory + char wd[PATH_MAX]; + if(::getcwd(wd, PATH_MAX) == 0) + { + return NULL; + } + tmpStr += wd; + if (tmpStr[tmpStr.length()] != '\\') + { + tmpStr += '\\'; + } + } + tmpStr += filename; + + int strlen = MultiByteToWideChar( + CP_UTF8, // code page + 0, // character-type options + tmpStr.c_str(), // string to map + (int)tmpStr.length(), // number of bytes in string + NULL, // wide-character buffer + 0 // size of buffer - work out how much space we need + ); + + buffer = new wchar_t[strlen+1]; + if ( buffer == NULL ) + { + return NULL; + } + + strlen = MultiByteToWideChar( + CP_UTF8, // code page + 0, // character-type options + tmpStr.c_str(), // string to map + (int)tmpStr.length(), // number of bytes in string + buffer, // wide-character buffer + strlen // size of buffer + ); + + if ( strlen == 0 ) + { + delete [] buffer; + return NULL; + } + + buffer[strlen] = L'\0'; + + //flags could be O_WRONLY | O_CREAT | O_RDONLY + DWORD createDisposition = OPEN_EXISTING; + DWORD shareMode = FILE_SHARE_READ; + DWORD accessRights = FILE_READ_ATTRIBUTES | FILE_LIST_DIRECTORY | FILE_READ_EA; + + if ( flags & O_WRONLY ) + { + createDisposition = OPEN_EXISTING; + shareMode |= FILE_SHARE_READ ;//| FILE_SHARE_WRITE; + } + if ( flags & O_CREAT ) + { + createDisposition = OPEN_ALWAYS; + shareMode |= FILE_SHARE_READ ;//| FILE_SHARE_WRITE; + accessRights |= FILE_WRITE_ATTRIBUTES | FILE_WRITE_DATA | FILE_WRITE_EA | FILE_ALL_ACCESS; + } + if ( flags & O_TRUNC ) + { + createDisposition = OPEN_ALWAYS; + } + + HANDLE hdir = CreateFileW(buffer, + accessRights, + shareMode, + NULL, + createDisposition, + FILE_FLAG_BACKUP_SEMANTICS, + NULL); + + if ( hdir == INVALID_HANDLE_VALUE ) + { + // DWORD err = GetLastError(); + // syslog(EVENTLOG_WARNING_TYPE, "Couldn't open file %s, err %i\n", filename, err); + delete [] buffer; + return NULL; + } + + delete [] buffer; + return hdir; + + } + catch(...) + { + printf("Caught openfile:%s\r\n", filename); + } + return NULL; + +} + +// MinGW provides a getopt implementation +#ifndef __MINGW32__ +//works with getopt +char *optarg; +//optind looks like an index into the string - how far we have moved along +int optind = 1; +char nextchar = -1; +#endif + +// -------------------------------------------------------------------------- +// +// Function +// Name: ourfstat +// Purpose: replacement for fstat supply a windows handle +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +int ourfstat(HANDLE hdir, struct stat * st) +{ + ULARGE_INTEGER conv; + + if (hdir == INVALID_HANDLE_VALUE) + { + ::syslog(LOG_ERR, "Error: invalid file handle in ourfstat()"); + errno = EBADF; + return -1; + } + + BY_HANDLE_FILE_INFORMATION fi; + if (!GetFileInformationByHandle(hdir, &fi)) + { + ::syslog(LOG_WARNING, "Failed to read file information: " + "error %d", GetLastError()); + errno = EACCES; + return -1; + } + + // This next example is how we get our INODE (equivalent) information + conv.HighPart = fi.nFileIndexHigh; + conv.LowPart = fi.nFileIndexLow; + st->st_ino = conv.QuadPart; + + // get the time information + st->st_ctime = ConvertFileTimeToTime_t(&fi.ftCreationTime); + st->st_atime = ConvertFileTimeToTime_t(&fi.ftLastAccessTime); + st->st_mtime = ConvertFileTimeToTime_t(&fi.ftLastWriteTime); + + // size of the file + LARGE_INTEGER st_size; + if (!GetFileSizeEx(hdir, &st_size)) + { + ::syslog(LOG_WARNING, "Failed to get file size: error %d", + GetLastError()); + errno = EACCES; + return -1; + } + + conv.HighPart = st_size.HighPart; + conv.LowPart = st_size.LowPart; + st->st_size = conv.QuadPart; + + //the mode of the file + st->st_mode = 0; + //DWORD res = GetFileAttributes((LPCSTR)tmpStr.c_str()); + + if (INVALID_FILE_ATTRIBUTES != fi.dwFileAttributes) + { + if (fi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + st->st_mode |= S_IFDIR; + } + else + { + st->st_mode |= S_IFREG; + } + } + else + { + ::syslog(LOG_WARNING, "Failed to get file attributes: " + "error %d", GetLastError()); + errno = EACCES; + return -1; + } + + return 0; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: OpenFileByNameUtf8 +// Purpose: Converts filename to Unicode and returns +// a handle to it. In case of error, sets errno, +// logs the error and returns NULL. +// Created: 10th December 2004 +// +// -------------------------------------------------------------------------- +HANDLE OpenFileByNameUtf8(const char* pName) +{ + //some string thing - required by ms to indicate long/unicode filename + std::string tmpStr("\\\\?\\"); + + // is the path relative or otherwise + std::string fileN(pName); + if (fileN[1] != ':') + { + // we need to get the current directory + char wd[PATH_MAX]; + if(::getcwd(wd, PATH_MAX) == 0) + { + ::syslog(LOG_WARNING, + "Failed to open '%s': path too long", pName); + errno = ENAMETOOLONG; + return NULL; + } + + tmpStr += wd; + if (tmpStr[tmpStr.length()] != '\\') + { + tmpStr += '\\'; + } + } + + tmpStr += fileN; + + int strlen = MultiByteToWideChar( + CP_UTF8, // code page + 0, // character-type options + tmpStr.c_str(), // string to map + (int)tmpStr.length(), // number of bytes in string + NULL, // wide-character buffer + 0 // size of buffer - work out + // how much space we need + ); + + wchar_t* buffer = new wchar_t[strlen+1]; + + if (buffer == NULL) + { + ::syslog(LOG_WARNING, + "Failed to open '%s': out of memory", pName); + errno = ENOMEM; + return NULL; + } + + strlen = MultiByteToWideChar( + CP_UTF8, // code page + 0, // character-type options + tmpStr.c_str(), // string to map + (int)tmpStr.length(), // number of bytes in string + buffer, // wide-character buffer + strlen // size of buffer + ); + + if (strlen == 0) + { + ::syslog(LOG_WARNING, + "Failed to open '%s': could not convert " + "file name to Unicode", pName); + errno = EACCES; + delete [] buffer; + return NULL; + } + + buffer[strlen] = L'\0'; + + HANDLE handle = CreateFileW(buffer, + FILE_READ_ATTRIBUTES | FILE_LIST_DIRECTORY | FILE_READ_EA, + FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL); + + if (handle == INVALID_HANDLE_VALUE) + { + // if our open fails we should always be able to + // open in this mode - to get the inode information + // at least one process must have the file open - + // in this case someone else does. + handle = CreateFileW(buffer, + 0, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL); + } + + delete [] buffer; + + if (handle == INVALID_HANDLE_VALUE) + { + DWORD err = GetLastError(); + + if (err == ERROR_FILE_NOT_FOUND) + { + ::syslog(LOG_WARNING, + "Failed to open '%s': file not found", pName); + errno = ENOENT; + } + else + { + ::syslog(LOG_WARNING, + "Failed to open '%s': error %d", pName); + errno = EACCES; + } + + return NULL; + } + + return handle; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: ourstat +// Purpose: replacement for the lstat and stat functions, +// works with unicode filenames supplied in utf8 format +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +int ourstat(const char * pName, struct stat * st) +{ + // at the mo + st->st_uid = 0; + st->st_gid = 0; + st->st_nlink = 1; + + HANDLE handle = OpenFileByNameUtf8(pName); + + if (handle == NULL) + { + // errno already set and error logged by OpenFileByNameUtf8() + return -1; + } + + int retVal = ourfstat(handle, st); + if (retVal != 0) + { + // error logged, but without filename + ::syslog(LOG_WARNING, "Failed to get file information " + "for '%s'", pName); + } + + // close the handle + CloseHandle(handle); + + return retVal; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: statfs +// Purpose: returns the mount point of where a file is located - +// in this case the volume serial number +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +int statfs(const char * pName, struct statfs * s) +{ + HANDLE handle = OpenFileByNameUtf8(pName); + + if (handle == NULL) + { + // errno already set and error logged by OpenFileByNameUtf8() + return -1; + } + + BY_HANDLE_FILE_INFORMATION fi; + if (!GetFileInformationByHandle(handle, &fi)) + { + ::syslog(LOG_WARNING, "Failed to get file information " + "for '%s': error %d", pName, GetLastError()); + CloseHandle(handle); + errno = EACCES; + return -1; + } + + // convert volume serial number to a string + _ui64toa(fi.dwVolumeSerialNumber, s->f_mntonname + 1, 16); + + // pseudo unix mount point + s->f_mntonname[0] = DIRECTORY_SEPARATOR_ASCHAR; + + CloseHandle(handle); // close the handle + + return 0; +} + + + + + +// MinGW provides opendir(), etc. via <dirent.h> +// MSVC does not provide these, so emulation is needed + +#ifndef __MINGW32__ +// -------------------------------------------------------------------------- +// +// Function +// Name: opendir +// Purpose: replacement for unix function, uses win32 findfirst routines +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +DIR *opendir(const char *name) +{ + try + { + DIR *dir = 0; + std::string dirName(name); + + //append a '\' win32 findfirst is sensitive to this + if ( dirName[dirName.size()] != '\\' || dirName[dirName.size()] != '/' ) + { + dirName += '\\'; + } + + //what is the search string? - everything + dirName += '*'; + + if(name && name[0]) + { + if ( ( dir = new DIR ) != 0 ) + { + //mbstowcs(dir->name, dirName.c_str(),100); + //wcscpy((wchar_t*)dir->name, (const wchar_t*)dirName.c_str()); + //mbstowcs(dir->name, dirName.c_str(), dirName.size()+1); + //wchar_t *buffer; + + int strlen = MultiByteToWideChar( + CP_UTF8, // code page + 0, // character-type options + dirName.c_str(), // string to map + (int)dirName.length(), // number of bytes in string + NULL, // wide-character buffer + 0 // size of buffer - work out how much space we need + ); + + dir->name = new wchar_t[strlen+1]; + + if (dir->name == NULL) + { + delete dir; + dir = 0; + errno = ENOMEM; + return NULL; + } + + strlen = MultiByteToWideChar( + CP_UTF8, // code page + 0, // character-type options + dirName.c_str(), // string to map + (int)dirName.length(), // number of bytes in string + dir->name, // wide-character buffer + strlen // size of buffer + ); + + if (strlen == 0) + { + delete dir->name; + delete dir; + dir = 0; + errno = ENOMEM; + return NULL; + } + + dir->name[strlen] = L'\0'; + + + dir->fd = _wfindfirst( + (const wchar_t*)dir->name, + &dir->info); + + if (dir->fd != -1) + { + dir->result.d_name = 0; + } + else // go back + { + delete [] dir->name; + delete dir; + dir = 0; + } + } + else // backwards again + { + delete dir; + dir = 0; + errno = ENOMEM; + } + } + else + { + errno = EINVAL; + } + + return dir; + + } + catch(...) + { + printf("Caught opendir"); + } + + return NULL; +} + +//this kinda makes it not thread friendly! +//but I don't think it needs to be. +char tempbuff[MAX_PATH]; +// -------------------------------------------------------------------------- +// +// Function +// Name: readdir +// Purpose: as function above +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +struct dirent *readdir(DIR *dp) +{ + try + { + struct dirent *den = NULL; + + if (dp && dp->fd != -1) + { + if (!dp->result.d_name || + _wfindnext(dp->fd, &dp->info) != -1) + { + den = &dp->result; + std::wstring input(dp->info.name); + memset(tempbuff, 0, sizeof(tempbuff)); + WideCharToMultiByte(CP_UTF8, 0, dp->info.name, + -1, &tempbuff[0], sizeof (tempbuff), + NULL, NULL); + //den->d_name = (char *)dp->info.name; + den->d_name = &tempbuff[0]; + } + } + else + { + errno = EBADF; + } + return den; + } + catch (...) + { + printf("Caught readdir"); + } + return NULL; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: closedir +// Purpose: as function above +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +int closedir(DIR *dp) +{ + try + { + int finres = -1; + if (dp) + { + if(dp->fd != -1) + { + finres = _findclose(dp->fd); + } + + delete [] dp->name; + delete dp; + } + + if (finres == -1) // errors go to EBADF + { + errno = EBADF; + } + + return finres; + } + catch (...) + { + printf("Caught closedir"); + } + return -1; +} +#endif // !__MINGW32__ + +// -------------------------------------------------------------------------- +// +// Function +// Name: poll +// Purpose: a weak implimentation (just enough for box) +// of the unix poll for winsock2 +// Created: 25th October 2004 +// +// -------------------------------------------------------------------------- +int poll (struct pollfd *ufds, unsigned long nfds, int timeout) +{ + try + { + fd_set readfd; + fd_set writefd; + + readfd.fd_count = 0; + writefd.fd_count = 0; + + struct pollfd *ufdsTmp = ufds; + + timeval timOut; + timeval *tmpptr; + + if (timeout == INFTIM) + tmpptr = NULL; + else + tmpptr = &timOut; + + timOut.tv_sec = timeout / 1000; + timOut.tv_usec = timeout * 1000; + + if (ufds->events & POLLIN) + { + for (unsigned long i = 0; i < nfds; i++) + { + readfd.fd_array[i] = ufdsTmp->fd; + readfd.fd_count++; + } + } + + if (ufds->events & POLLOUT) + { + for (unsigned long i = 0; i < nfds; i++) + { + + writefd.fd_array[i]=ufdsTmp->fd; + writefd.fd_count++; + } + } + + int noffds = select(0, &readfd, &writefd, 0, tmpptr); + + if (noffds == SOCKET_ERROR) + { + // int errval = WSAGetLastError(); + + ufdsTmp = ufds; + for (unsigned long i = 0; i < nfds; i++) + { + ufdsTmp->revents = POLLERR; + ufdsTmp++; + } + return (-1); + } + + return noffds; + } + catch (...) + { + printf("Caught poll"); + } + + return -1; +} + +HANDLE gSyslogH = 0; + +void syslog(int loglevel, const char *frmt, ...) +{ + DWORD errinfo; + char* buffer; + std::string sixfour(frmt); + + switch (loglevel) + { + case LOG_INFO: + errinfo = EVENTLOG_INFORMATION_TYPE; + break; + case LOG_ERR: + errinfo = EVENTLOG_ERROR_TYPE; + break; + case LOG_WARNING: + errinfo = EVENTLOG_WARNING_TYPE; + break; + default: + errinfo = EVENTLOG_WARNING_TYPE; + break; + } + + + //taken from MSDN + try + { + + + int sixfourpos; + while ( ( sixfourpos = sixfour.find("%ll")) != -1 ) + { + //maintain portability - change the 64 bit formater... + std::string temp = sixfour.substr(0,sixfourpos); + temp += "%I64"; + temp += sixfour.substr(sixfourpos+3, sixfour.length()); + sixfour = temp; + } + + //printf("parsed string is:%s\r\n", sixfour.c_str()); + + va_list args; + va_start(args, frmt); + +#ifdef __MINGW32__ + // no _vscprintf, use a fixed size buffer + buffer = new char[1024]; + int len = 1023; +#else + int len = _vscprintf( sixfour.c_str(), args ); + ASSERT(len > 0) + + len = len + 1; + char* buffer = new char[len]; +#endif + + ASSERT(buffer) + memset(buffer, 0, len); + + int len2 = vsnprintf(buffer, len, sixfour.c_str(), args); + ASSERT(len2 <= len); + + va_end(args); + } + catch (...) + { + printf("Caught syslog: %s", sixfour.c_str()); + return; + } + + try + { + + if (!ReportEvent(gSyslogH, // event log handle + errinfo, // event type + 0, // category zero + MSG_ERR_EXIST, // event identifier - + // we will call them all the same + NULL, // no user security identifier + 1, // one substitution string + 0, // no data + (LPCSTR*)&buffer, // pointer to string array + NULL)) // pointer to data + + { + DWORD err = GetLastError(); + printf("Unable to send message to Event Log " + "(error %i):\r\n", err); + } + + printf("%s\r\n", buffer); + + if (buffer) delete [] buffer; + } + catch (...) + { + printf("Caught syslog ReportEvent"); + } +} + +#endif // WIN32 diff --git a/lib/win32/emu.h b/lib/win32/emu.h new file mode 100644 index 00000000..5b506206 --- /dev/null +++ b/lib/win32/emu.h @@ -0,0 +1,426 @@ +// emulates unix syscalls to win32 functions + +#if ! defined EMU_INCLUDE && defined WIN32 +#define EMU_INCLUDE + +#define _STAT_DEFINED +#define _INO_T_DEFINED + +#include <winsock2.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <direct.h> +#include <errno.h> +#include <io.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <stdarg.h> +#include <time.h> +//#include <winsock.h> +//#include <sys/types.h> +//#include <sys/stat.h> + +#include <string> + +#define gmtime_r( _clock, _result ) \ + ( *(_result) = *gmtime( (_clock) ), \ + (_result) ) + + +//signal in unix SIGVTALRM does not exist in win32 - but looking at the +#define SIGVTALRM 254 +#define SIGALRM SIGVTALRM +#define ITIMER_VIRTUAL 0 + +int setitimer(int type , struct itimerval *timeout, int); +void InitTimer(void); +void FiniTimer(void); + +inline int geteuid(void) +{ + //lets pretend to be root! + return 0; +} + +struct passwd { + char *pw_name; + char *pw_passwd; + uid_t pw_uid; + gid_t pw_gid; + time_t pw_change; + char *pw_class; + char *pw_gecos; + char *pw_dir; + char *pw_shell; + time_t pw_expire; +}; + +extern passwd gTempPasswd; +inline struct passwd * getpwnam(const char * name) +{ + //for the mo pretend to be root + gTempPasswd.pw_uid = 0; + gTempPasswd.pw_gid = 0; + + return &gTempPasswd; +} + +#define S_IRWXG 1 +#define S_IRWXO 2 +#define S_ISUID 4 +#define S_ISGID 8 +#define S_ISVTX 16 + +#ifndef __MINGW32__ + //not sure if these are correct + //S_IWRITE - writing permitted + //_S_IREAD - reading permitted + //_S_IREAD | _S_IWRITE - + #define S_IRUSR S_IWRITE + #define S_IWUSR S_IREAD + #define S_IRWXU (S_IREAD|S_IWRITE|S_IEXEC) + + #define S_ISREG(x) (S_IFREG & x) + #define S_ISDIR(x) (S_IFDIR & x) +#endif + +inline int utimes(const char * Filename, timeval[]) +{ + //again I am guessing this is quite important to + //be functioning, as large restores would be a problem + + //indicate success + return 0; +} +inline int chown(const char * Filename, u_int32_t uid, u_int32_t gid) +{ + //important - this needs implementing + //If a large restore is required then + //it needs to restore files AND permissions + //reference AdjustTokenPrivileges + //GetAccountSid + //InitializeSecurityDescriptor + //SetSecurityDescriptorOwner + //The next function looks like the guy to use... + //SetFileSecurity + + //indicate success + return 0; +} + +inline int chmod(const char * Filename, int uid) +{ + //indicate sucsess + return 0; +} + +//I do not perceive a need to change the user or group on a backup client +//at any rate the owner of a service can be set in the service settings +inline int setegid(int) +{ + return true; +} +inline int seteuid(int) +{ + return true; +} +inline int setgid(int) +{ + return true; +} +inline int setuid(int) +{ + return true; +} +inline int getgid(void) +{ + return 0; +} +inline int getuid(void) +{ + return 0; +} + +#ifndef PATH_MAX +#define PATH_MAX MAX_PATH +#endif + +// MinGW provides a getopt implementation +#ifndef __MINGW32__ + +//this will need to be implimented if we see fit that command line +//options are going to be used! (probably then:) +//where the calling function looks for the parsed parameter +extern char *optarg; +//optind looks like an index into the string - how far we have moved along +extern int optind; +extern char nextchar; + +inline int getopt(int count, char * const * args, char * tolookfor) +{ + if ( optind >= count ) return -1; + + std::string str((const char *)args[optind]); + std::string interestin(tolookfor); + int opttolookfor = 0; + int index = -1; + //just initialize the string - just in case it is used. + //optarg[0] = 0; + std::string opt; + + if ( count == 0 ) return -1; + + do + { + if ( index != -1 ) + { + str = str.substr(index+1, str.size()); + } + + index = str.find('-'); + + if ( index == -1 ) return -1; + + opt = str[1]; + + optind ++; + str = args[optind]; + } + while ( ( opttolookfor = interestin.find(opt)) == -1 ); + + if ( interestin[opttolookfor+1] == ':' ) + { + + //strcpy(optarg, str.c_str()); + optarg = args[optind]; + optind ++; + } + + //indicate we have finished + return opt[0]; +} +#endif // !__MINGW32__ + +#define timespec timeval + +//not available in win32 +struct itimerval +{ + timeval it_interval; + timeval it_value; +}; + +//win32 deals in usec not nsec - so need to ensure this follows through +#define tv_nsec tv_usec + +#ifndef __MINGW32__ + typedef unsigned __int64 u_int64_t; + typedef unsigned __int64 uint64_t; + typedef __int64 int64_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int32 u_int32_t; + typedef __int32 int32_t; + typedef unsigned __int16 uint16_t; + typedef __int16 int16_t; + typedef unsigned __int8 uint8_t; + typedef __int8 int8_t; + + typedef int socklen_t; +#endif + +// I (re-)defined here for the moment; has to be removed later !!! +#ifndef BOX_VERSION +#define BOX_VERSION "0.09hWin32" +#endif + +#define S_IRGRP S_IWRITE +#define S_IWGRP S_IREAD +#define S_IROTH S_IWRITE | S_IREAD +#define S_IWOTH S_IREAD | S_IREAD + +//again need to verify these +#define S_IFLNK 1 + +#define S_ISLNK(x) ( false ) + +// nasty implementation to get working - TODO get the win32 equiv +#ifdef _DEBUG +#define getpid() 1 +#endif + +#define vsnprintf _vsnprintf + +#ifndef __MINGW32__ +typedef unsigned int mode_t; +#endif + +inline int mkdir(const char *pathname, mode_t mode) +{ + return mkdir(pathname); +} + +#ifdef __MINGW32__ + #include <dirent.h> +#else + inline int strcasecmp(const char *s1, const char *s2) + { + return _stricmp(s1,s2); + } + + struct dirent + { + char *d_name; + }; + + struct DIR + { + intptr_t fd; // filedescriptor + // struct _finddata_t info; + struct _wfinddata_t info; + // struct _finddata_t info; + struct dirent result; // d_name (first time null) + wchar_t *name; // null-terminated byte string + }; + + DIR *opendir(const char *name); + struct dirent *readdir(DIR *dp); + int closedir(DIR *dp); +#endif + +HANDLE openfile(const char *filename, int flags, int mode); + +#define LOG_INFO 6 +#define LOG_WARNING 4 +#define LOG_ERR 3 +#define LOG_PID 0 +#define LOG_LOCAL6 0 + +extern HANDLE gSyslogH; +void MyReportEvent(LPCTSTR *szMsg, DWORD errinfo); +inline void openlog(const char * daemonName, int, int) +{ + gSyslogH = RegisterEventSource( + NULL, // uses local computer + daemonName); // source name + if (gSyslogH == NULL) + { + } +} + +inline void closelog(void) +{ + DeregisterEventSource(gSyslogH); +} + +void syslog(int loglevel, const char *fmt, ...); + +#ifndef __MINGW32__ +#define strtoll _strtoi64 +#endif + +inline unsigned int sleep(unsigned int secs) +{ + Sleep(secs*1000); + return(ERROR_SUCCESS); +} + +#define INFTIM -1 +#define POLLIN 0x1 +#define POLLERR 0x8 +#define POLLOUT 0x4 + +#define SHUT_RDWR SD_BOTH +#define SHUT_RD SD_RECEIVE +#define SHUT_WR SD_SEND + +struct pollfd +{ + SOCKET fd; + short int events; + short int revents; +}; + +inline int ioctl(SOCKET sock, int flag, int * something) +{ + //indicate success + return 0; +} + +inline int waitpid(pid_t pid, int *status, int) +{ + return 0; +} + +//this shouldn't be needed. +struct statfs +{ + TCHAR f_mntonname[MAX_PATH]; +}; + +// I think this should get us going +// Although there is a warning about +// mount points in win32 can now exists - which means inode number can be +// duplicated, so potential of a problem - perhaps this needs to be +// implemented with a little more thought... TODO + +struct stat { + //_dev_t st_dev; + u_int64_t st_ino; + DWORD st_mode; + short st_nlink; + short st_uid; + short st_gid; + //_dev_t st_rdev; + u_int64_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +}; + +#ifndef __MINGW32__ +typedef u_int64_t _ino_t; +#endif + +int ourstat(const char * name, struct stat * st); +int ourfstat(HANDLE file, struct stat * st); +int statfs(const char * name, struct statfs * s); + +//need this for converstions +inline time_t ConvertFileTimeToTime_t(FILETIME *fileTime) +{ + SYSTEMTIME stUTC; + struct tm timeinfo; + + // Convert the last-write time to local time. + FileTimeToSystemTime(fileTime, &stUTC); + // SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); + + timeinfo.tm_sec = stUTC.wSecond; + timeinfo.tm_min = stUTC.wMinute; + timeinfo.tm_hour = stUTC.wHour; + timeinfo.tm_mday = stUTC.wDay; + timeinfo.tm_wday = stUTC.wDayOfWeek; + timeinfo.tm_mon = stUTC.wMonth - 1; + // timeinfo.tm_yday = ...; + timeinfo.tm_year = stUTC.wYear - 1900; + + time_t retVal = mktime(&timeinfo); + return retVal; +} + +#define stat(x,y) ourstat(x,y) +#define fstat(x,y) ourfstat(x,y) +#define lstat(x,y) ourstat(x,y) + +int poll (struct pollfd *ufds, unsigned long nfds, int timeout); +bool EnableBackupRights( void ); + +// +// MessageId: MSG_ERR_EXIST +// MessageText: +// Box Backup. +// +#define MSG_ERR_EXIST ((DWORD)0xC0000004L) + +#endif // !EMU_INCLUDE && WIN32 diff --git a/modules.txt b/modules.txt index 0f06df31..7b9f8ce7 100755 --- a/modules.txt +++ b/modules.txt @@ -9,16 +9,21 @@ # Generic support code and modules +OMIT:mingw32 OMIT:CYGWIN lib/raidfile END-OMIT + lib/crypto lib/server +lib/win32 lib/server lib/compress test/common test/crypto lib/crypto test/compress lib/compress test/basicserver lib/server + +OMIT:mingw32 OMIT:CYGWIN test/raidfile lib/raidfile END-OMIT @@ -28,15 +33,20 @@ END-OMIT # Backup system lib/backupclient lib/server lib/crypto lib/compress + +OMIT:mingw32 OMIT:CYGWIN lib/backupstore lib/server lib/raidfile lib/backupclient -bin/bbstored lib/raidfile lib/server lib/backupstore lib/backupclient -bin/bbstoreaccounts lib/raidfile lib/backupstore -bin/bbackupobjdump lib/backupclient lib/backupstore +bin/bbstored lib/raidfile lib/server lib/backupstore lib/backupclient lib/win32 +bin/bbstoreaccounts lib/raidfile lib/backupstore lib/win32 +bin/bbackupobjdump lib/backupclient lib/backupstore lib/win32 END-OMIT -bin/bbackupd lib/server lib/backupclient -bin/bbackupquery lib/server lib/backupclient -bin/bbackupctl lib/server lib/backupclient + +bin/bbackupd lib/server lib/backupclient lib/win32 +bin/bbackupquery lib/server lib/backupclient lib/win32 +bin/bbackupctl lib/server lib/backupclient lib/win32 + +OMIT:mingw32 OMIT:CYGWIN test/backupstore bin/bbstored bin/bbstoreaccounts lib/server lib/backupstore lib/backupclient lib/raidfile test/backupstorefix bin/bbstored bin/bbstoreaccounts lib/backupstore lib/raidfile bin/bbackupquery bin/bbackupd diff --git a/parcels.txt b/parcels.txt index 4ae309ec..5a4b50cf 100644 --- a/parcels.txt +++ b/parcels.txt @@ -8,7 +8,11 @@ backup-client bin bbackupquery bin bbackupctl script bin/bbackupd/bbackupd-config + script bin/bbackupd/win32/installer.iss + script bin/bbackupd/win32/ReadMe.txt + script bin/bbackupd/win32/bbackupd.conf +OMIT:mingw32 OMIT:CYGWIN backup-server diff --git a/test/basicserver/testbasicserver.cpp b/test/basicserver/testbasicserver.cpp index 4d124b1d..f5185b96 100755 --- a/test/basicserver/testbasicserver.cpp +++ b/test/basicserver/testbasicserver.cpp @@ -349,9 +349,11 @@ void Srv2TestConversations(const std::vector<IOStream *> &conns) for(unsigned int c = 0; c < conns.size(); ++c) { - delete getline[c]; + if ( getline[c] ) delete getline[c]; + getline[c] = 0; } - delete [] getline; + if ( getline ) delete [] getline; + getline = 0; } void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream) diff --git a/test/win32/testlibwin32.cpp b/test/win32/testlibwin32.cpp new file mode 100644 index 00000000..495d9d6e --- /dev/null +++ b/test/win32/testlibwin32.cpp @@ -0,0 +1,120 @@ +// win32test.cpp : Defines the entry point for the console application. +// + +//#include <windows.h> +#include "Box.h" + +#ifdef WIN32 + +#include "../../bin/bbackupd/BackupDaemon.h" +#include "BoxPortsAndFiles.h" + + +int main(int argc, char* argv[]) +{ + chdir("c:\\tmp"); + openfile("test", O_CREAT, 0); + struct stat ourfs; + //test our opendir, readdir and closedir + //functions + DIR *ourDir = opendir("C:"); + + if ( ourDir != NULL ) + { + struct dirent *info; + do + { + info = readdir(ourDir); + if ( info ) printf("File/Dir name is : %s\r\n", info->d_name); + + }while ( info != NULL ); + + closedir(ourDir); + + } + + std::string diry("C:\\Projects\\boxbuild\\testfiles\\"); + ourDir = opendir(diry.c_str()); + if ( ourDir != NULL ) + { + struct dirent *info; + do + { + info = readdir(ourDir); + if ( info == NULL ) break; + std::string file(diry + info->d_name); + stat(file.c_str(), &ourfs); + if ( info ) printf("File/Dir name is : %s\r\n", info->d_name); + + }while ( info != NULL ); + + closedir(ourDir); + + } + + stat("c:\\windows", &ourfs); + stat("c:\\autoexec.bat", &ourfs); + printf("Finished dir read"); +#if 0 + //remove - sleepycat include a version of getopt - mine never REALLY worked ! + //test our getopt function + std::string commline("-q -c fgfgfg -f -l hello"); + + int c; + while((c = getopt(commline.size(), (char * const *)commline.c_str(), "qwc:l:")) != -1) + { + printf("switch = %c, param is %s\r\n", c, optarg); + } +#endif + //end of getopt test + + //now test our statfs funct + stat("c:\\cert.cer", &ourfs); + + + + char *timee; + + timee = ctime(&ourfs.st_mtime); + + if ( S_ISREG(ourfs.st_mode)) + { + printf("is a normal file"); + } + else + { + printf("is a directory?"); + } + + lstat("c:\\windows", &ourfs); + + if ( S_ISDIR(ourfs.st_mode)) + { + printf("is a directory"); + } + else + { + printf("is a file?"); + } + + //test the syslog functions + openlog("Box Backup", 0,0); + //the old ones are the best... + syslog(LOG_ERR, "Hello World"); + syslog(LOG_ERR, "Value of int is: %i", 6); + + closelog(); + + //first off get the path name for the default + char buf[MAX_PATH]; + + GetModuleFileName(NULL, buf, sizeof(buf)); + std::string buffer(buf); + std::string conf("-c " + buffer.substr(0,(buffer.find("win32test.exe"))) + "bbackupd.conf"); + //std::string conf( "-c " + buffer.substr(0,(buffer.find("bbackupd.exe"))) + "bbackupd.conf"); + + + return 0; +} + +#endif // WIN32 diff --git a/win32.bat b/win32.bat new file mode 100644 index 00000000..f37bb777 --- /dev/null +++ b/win32.bat @@ -0,0 +1,27 @@ +
+pwd = /usr/src/boxbackup0.08/
+
+# quick and dirty to get up and running by generating the required files
+# using Cygwin and Perl
+
+cd ./bin/bbackupquery/ & perl ./../../bin/bbackupquery/makedocumentation.pl
+cd ../../
+
+cd ./lib/backupclient & perl ./../../lib/common/makeexception.pl BackupStoreException.txt
+perl ./../../lib/server/makeprotocol.pl Client ./../../bin/bbstored/backupprotocol.txt
+cd ../../
+
+cd ./lib/compress & perl ./../../lib/common/makeexception.pl CompressException.txt
+cd ../../
+
+cd ./lib/common & perl ./../../lib/common/makeexception.pl CommonException.txt & perl ./../../lib/common/makeexception.pl ConversionException.txt
+
+cd ../../
+
+cd ./lib/crypto & perl ./../../lib/common/makeexception.pl CipherException.txt
+cd ../../
+
+# server parts - which appears as though some of the clients rely on
+
+cd ./lib/server & perl ./../../lib/common/makeexception.pl ServerException.txt & perl ./../../lib/common/makeexception.pl ConnectionException.txt
+cd ../../
diff --git a/win32test.vcproj b/win32test.vcproj new file mode 100644 index 00000000..5f88be95 --- /dev/null +++ b/win32test.vcproj @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="win32test"
+ ProjectGUID="{28C29E72-76A2-4D0C-B35B-12D446733D2E}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(ProjectDir)bin\bbackupd";"$(ProjectDir)..\db-4.2.52.NC\build_win32";"$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\""
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Debug\common.lib $(ProjectDir)..\db-4.2.52.NC\build_win32\Debug\libdb42d.lib"
+ OutputFile="$(OutDir)/win32test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/win32test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ EnableFiberSafeOptimizations="TRUE"
+ OptimizeForProcessor="1"
+ AdditionalIncludeDirectories=""$(ProjectDir)bin\bbackupd";"$(ProjectDir)lib\backupclient";"$(ProjectDir)lib\server";"$(ProjectDir)lib\crypto";"$(ProjectDir)..\openssl\include";"$(ProjectDir)lib\compress";"$(ProjectDir)..\zlib\include";"$(ProjectDir)lib\win32";"$(ProjectDir)lib\common\""
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;PLATFORM_DISABLE_MEM_LEAK_TESTING"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="FALSE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="Ws2_32.lib $(ProjectDir)..\zlib\lib\zdll.lib $(ProjectDir)..\openssl\lib\libeay32.lib $(ProjectDir)..\openssl\lib\ssleay32.lib $(ProjectDir)Release\common.lib"
+ OutputFile="$(OutDir)/win32test.exe"
+ LinkIncremental="1"
+ IgnoreDefaultLibraryNames=""
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\lib\win32\emu.cpp">
+ </File>
+ <File
+ RelativePath=".\lib\win32\win32test.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
|