diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-12-10 22:10:47 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-12-10 22:10:47 +0000 |
commit | 0f6eedb4d9ce5cd4d97e127c601559d7524e7c8e (patch) | |
tree | c88ace4bbd3a92c24822d3fb35e8f555b0694288 /lib | |
parent | 6bb997504c21c34a5856ba9b7b0483b2516db6a9 (diff) | |
parent | bc2a15eb3dab71425757ec2cb73f56b911c4e400 (diff) |
Merge branch 'appveyor' of github.com:boxbackup/boxbackup into appveyor
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backupstore/BackupClientFileAttributes.cpp | 68 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreContext.cpp | 4 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreDirectory.cpp | 11 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreDirectory.h | 5 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreFileEncodeStream.h | 8 | ||||
-rw-r--r-- | lib/common/Archive.h | 59 | ||||
-rw-r--r-- | lib/common/BoxConfig-MSVC.h | 3 | ||||
-rw-r--r-- | lib/common/BoxPlatform.h | 52 | ||||
-rwxr-xr-x | lib/common/makeexception.pl.in | 67 | ||||
-rw-r--r-- | lib/httpserver/HTTPRequest.cpp | 3 | ||||
-rw-r--r-- | lib/intercept/intercept.cpp | 1 | ||||
-rw-r--r-- | lib/server/Protocol.cpp | 12 | ||||
-rw-r--r-- | lib/server/Protocol.h | 4 | ||||
-rw-r--r-- | lib/server/ProtocolWire.h | 4 | ||||
-rw-r--r-- | lib/win32/emu.h | 39 |
15 files changed, 107 insertions, 233 deletions
diff --git a/lib/backupstore/BackupClientFileAttributes.cpp b/lib/backupstore/BackupClientFileAttributes.cpp index e331e107..7ec6f478 100644 --- a/lib/backupstore/BackupClientFileAttributes.cpp +++ b/lib/backupstore/BackupClientFileAttributes.cpp @@ -55,20 +55,20 @@ BEGIN_STRUCTURE_PACKING_FOR_WIRE typedef struct { int32_t AttributeType; - u_int32_t UID; - u_int32_t GID; - u_int64_t ModificationTime; - u_int64_t AttrModificationTime; - u_int32_t UserDefinedFlags; - u_int32_t FileGenerationNumber; - u_int16_t Mode; + uint32_t UID; + uint32_t GID; + uint64_t ModificationTime; + uint64_t AttrModificationTime; + uint32_t UserDefinedFlags; + uint32_t FileGenerationNumber; + uint16_t Mode; // Symbolic link filename may follow // Extended attribute (xattr) information may follow, format is: - // u_int32_t Size of extended attribute block (excluding this word) + // uint32_t Size of extended attribute block (excluding this word) // For each of NumberOfAttributes (sorted by AttributeName): - // u_int16_t AttributeNameLength + // uint16_t AttributeNameLength // char AttributeName[AttributeNameLength] - // u_int32_t AttributeValueLength + // uint32_t AttributeValueLength // unsigned char AttributeValue[AttributeValueLength] // AttributeName is 0 terminated, AttributeValue is not (and may be binary data) } attr_StreamFormat; @@ -117,7 +117,7 @@ namespace BackupClientFileAttributes::BackupClientFileAttributes() : mpClearAttributes(0) { - ASSERT(sizeof(u_int64_t) == sizeof(box_time_t)); + ASSERT(sizeof(uint64_t) == sizeof(box_time_t)); } // -------------------------------------------------------------------------- @@ -131,7 +131,7 @@ BackupClientFileAttributes::BackupClientFileAttributes() BackupClientFileAttributes::BackupClientFileAttributes(const EMU_STRUCT_STAT &st) : mpClearAttributes(0) { - ASSERT(sizeof(u_int64_t) == sizeof(box_time_t)); + ASSERT(sizeof(uint64_t) == sizeof(box_time_t)); StreamableMemBlock *pnewAttr = new StreamableMemBlock; FillAttributes(*pnewAttr, (const char *)NULL, st, true); @@ -411,7 +411,7 @@ void BackupClientFileAttributes::ReadAttributes(const std::string& Filename, // __time64_t winTime = BoxTimeToSeconds( // pnewAttr->ModificationTime); - u_int64_t modTime = box_ntoh64(pattr->ModificationTime); + uint64_t modTime = box_ntoh64(pattr->ModificationTime); box_time_t modSecs = BoxTimeToSeconds(modTime); __time64_t winTime = modSecs; @@ -582,30 +582,30 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc // Leave space for attr block size later int xattrBlockSizeOffset = xattrSize; - xattrSize += sizeof(u_int32_t); + xattrSize += sizeof(uint32_t); // Loop for each attribute for(std::vector<std::string>::const_iterator attrKeyI = attrKeys.begin(); attrKeyI!=attrKeys.end(); ++attrKeyI) { std::string attrKey(*attrKeyI); - if(xattrSize+sizeof(u_int16_t)+attrKey.size()+1+sizeof(u_int32_t)>static_cast<unsigned int>(xattrBufferSize)) + if(xattrSize+sizeof(uint16_t)+attrKey.size()+1+sizeof(uint32_t)>static_cast<unsigned int>(xattrBufferSize)) { - xattrBufferSize = (xattrBufferSize+sizeof(u_int16_t)+attrKey.size()+1+sizeof(u_int32_t))*2; + xattrBufferSize = (xattrBufferSize+sizeof(uint16_t)+attrKey.size()+1+sizeof(uint32_t))*2; outputBlock.ResizeBlock(xattrBufferSize); buffer = static_cast<unsigned char*>(outputBlock.GetBuffer()); } // Store length and text for attibute name - u_int16_t keyLength = htons(attrKey.size()+1); - std::memcpy(buffer+xattrSize, &keyLength, sizeof(u_int16_t)); - xattrSize += sizeof(u_int16_t); + uint16_t keyLength = htons(attrKey.size()+1); + std::memcpy(buffer+xattrSize, &keyLength, sizeof(uint16_t)); + xattrSize += sizeof(uint16_t); std::memcpy(buffer+xattrSize, attrKey.c_str(), attrKey.size()+1); xattrSize += attrKey.size()+1; // Leave space for value size int valueSizeOffset = xattrSize; - xattrSize += sizeof(u_int32_t); + xattrSize += sizeof(uint32_t); // Find size of attribute (must call with buffer and length 0 on some platforms, // as -1 is returned if the data doesn't fit.) @@ -642,13 +642,13 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc xattrSize += valueSize; // Fill in value size - u_int32_t valueLength = htonl(valueSize); - std::memcpy(buffer+valueSizeOffset, &valueLength, sizeof(u_int32_t)); + uint32_t valueLength = htonl(valueSize); + std::memcpy(buffer+valueSizeOffset, &valueLength, sizeof(uint32_t)); } // Fill in attribute block size - u_int32_t xattrBlockLength = htonl(xattrSize-xattrBlockSizeOffset-sizeof(u_int32_t)); - std::memcpy(buffer+xattrBlockSizeOffset, &xattrBlockLength, sizeof(u_int32_t)); + uint32_t xattrBlockLength = htonl(xattrSize-xattrBlockSizeOffset-sizeof(uint32_t)); + std::memcpy(buffer+xattrBlockSizeOffset, &xattrBlockLength, sizeof(uint32_t)); outputBlock.ResizeBlock(xattrSize); } @@ -853,7 +853,7 @@ void BackupClientFileAttributes::WriteAttributes(const std::string& Filename, #endif } - if(static_cast<int>(xattrOffset+sizeof(u_int32_t))<=mpClearAttributes->GetSize()) + if(static_cast<int>(xattrOffset+sizeof(uint32_t))<=mpClearAttributes->GetSize()) { WriteExtendedAttr(Filename, xattrOffset); } @@ -995,10 +995,10 @@ void BackupClientFileAttributes::WriteExtendedAttr(const std::string& Filename, #ifdef HAVE_SYS_XATTR_H const char* buffer = static_cast<char*>(mpClearAttributes->GetBuffer()); - u_int32_t xattrBlockLength = 0; - std::memcpy(&xattrBlockLength, buffer+xattrOffset, sizeof(u_int32_t)); + uint32_t xattrBlockLength = 0; + std::memcpy(&xattrBlockLength, buffer+xattrOffset, sizeof(uint32_t)); int xattrBlockSize = ntohl(xattrBlockLength); - xattrOffset += sizeof(u_int32_t); + xattrOffset += sizeof(uint32_t); int xattrEnd = xattrOffset+xattrBlockSize; if(xattrEnd>mpClearAttributes->GetSize()) @@ -1009,18 +1009,18 @@ void BackupClientFileAttributes::WriteExtendedAttr(const std::string& Filename, while(xattrOffset<xattrEnd) { - u_int16_t keyLength = 0; - std::memcpy(&keyLength, buffer+xattrOffset, sizeof(u_int16_t)); + uint16_t keyLength = 0; + std::memcpy(&keyLength, buffer+xattrOffset, sizeof(uint16_t)); int keySize = ntohs(keyLength); - xattrOffset += sizeof(u_int16_t); + xattrOffset += sizeof(uint16_t); const char* key = buffer+xattrOffset; xattrOffset += keySize; - u_int32_t valueLength = 0; - std::memcpy(&valueLength, buffer+xattrOffset, sizeof(u_int32_t)); + uint32_t valueLength = 0; + std::memcpy(&valueLength, buffer+xattrOffset, sizeof(uint32_t)); int valueSize = ntohl(valueLength); - xattrOffset += sizeof(u_int32_t); + xattrOffset += sizeof(uint32_t); // FIXME: Warn on EOPNOTSUPP if(::lsetxattr(Filename.c_str(), key, buffer+xattrOffset, diff --git a/lib/backupstore/BackupStoreContext.cpp b/lib/backupstore/BackupStoreContext.cpp index 75e78334..1a782df4 100644 --- a/lib/backupstore/BackupStoreContext.cpp +++ b/lib/backupstore/BackupStoreContext.cpp @@ -1542,7 +1542,7 @@ bool BackupStoreContext::ObjectExists(int64_t ObjectID, int MustBe) std::auto_ptr<RaidFileRead> objectFile(RaidFileRead::Open(mStoreDiscSet, filename)); // Read the first integer - u_int32_t magic; + uint32_t magic; if(!objectFile->ReadFullBuffer(&magic, sizeof(magic), 0 /* not interested in how many read if failure */)) { // Failed to get any bytes, must have failed @@ -1558,7 +1558,7 @@ bool BackupStoreContext::ObjectExists(int64_t ObjectID, int MustBe) #endif // Right one? - u_int32_t requiredMagic = (MustBe == ObjectExists_File)?OBJECTMAGIC_FILE_MAGIC_VALUE_V1:OBJECTMAGIC_DIR_MAGIC_VALUE; + uint32_t requiredMagic = (MustBe == ObjectExists_File)?OBJECTMAGIC_FILE_MAGIC_VALUE_V1:OBJECTMAGIC_DIR_MAGIC_VALUE; // Check if(ntohl(magic) != requiredMagic) diff --git a/lib/backupstore/BackupStoreDirectory.cpp b/lib/backupstore/BackupStoreDirectory.cpp index 332eca7a..6946f06e 100644 --- a/lib/backupstore/BackupStoreDirectory.cpp +++ b/lib/backupstore/BackupStoreDirectory.cpp @@ -1,7 +1,7 @@ // -------------------------------------------------------------------------- // // File -// Name: BackupStoreDirectory.h +// Name: BackupStoreDirectory.cpp // Purpose: Representation of a backup directory // Created: 2003/08/26 // @@ -36,11 +36,6 @@ typedef struct // Then a StreamableMemBlock for attributes } dir_StreamFormat; -typedef enum -{ - Option_DependencyInfoPresent = 1 -} dir_StreamFormatOptions; - typedef struct { uint64_t mModificationTime; @@ -85,7 +80,7 @@ BackupStoreDirectory::BackupStoreDirectory() mAttributesModTime(0), mUserInfo1(0) { - ASSERT(sizeof(u_int64_t) == sizeof(box_time_t)); + ASSERT(sizeof(uint64_t) == sizeof(box_time_t)); } @@ -172,7 +167,7 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout) int count = ntohl(hdr.mNumEntries); // Clear existing list - for(std::vector<Entry*>::iterator i = mEntries.begin(); + for(std::vector<Entry*>::iterator i = mEntries.begin(); i != mEntries.end(); i++) { delete (*i); diff --git a/lib/backupstore/BackupStoreDirectory.h b/lib/backupstore/BackupStoreDirectory.h index 5bbb0b35..788a3ad0 100644 --- a/lib/backupstore/BackupStoreDirectory.h +++ b/lib/backupstore/BackupStoreDirectory.h @@ -47,6 +47,11 @@ public: } #endif + typedef enum + { + Option_DependencyInfoPresent = 1 + } dir_StreamFormatOptions; + BackupStoreDirectory(); BackupStoreDirectory(int64_t ObjectID, int64_t ContainerID); // Convenience constructor from a stream diff --git a/lib/backupstore/BackupStoreFileEncodeStream.h b/lib/backupstore/BackupStoreFileEncodeStream.h index 6db09182..5b9b4a61 100644 --- a/lib/backupstore/BackupStoreFileEncodeStream.h +++ b/lib/backupstore/BackupStoreFileEncodeStream.h @@ -90,6 +90,9 @@ public: int64_t GetBytesToUpload() { return mBytesToUpload; } int64_t GetTotalBytesSent() { return mTotalBytesSent; } + static void CalculateBlockSizes(int64_t DataSize, int64_t &rNumBlocksOut, + int32_t &rBlockSizeOut, int32_t &rLastBlockSizeOut); + private: enum { @@ -98,15 +101,12 @@ private: Status_BlockListing = 2, Status_Finished = 3 }; - -private: + void EncodeCurrentBlock(); - void CalculateBlockSizes(int64_t DataSize, int64_t &rNumBlocksOut, int32_t &rBlockSizeOut, int32_t &rLastBlockSizeOut); void SkipPreviousBlocksInInstruction(); void SetForInstruction(); void StoreBlockIndexEntry(int64_t WncSizeOrBlkIndex, int32_t ClearSize, uint32_t WeakChecksum, uint8_t *pStrongChecksum); -private: Recipe *mpRecipe; IOStream *mpFile; // source file CollectInBufferStream mData; // buffer for header and index entries diff --git a/lib/common/Archive.h b/lib/common/Archive.h index 76b069a0..2b27b303 100644 --- a/lib/common/Archive.h +++ b/lib/common/Archive.h @@ -47,6 +47,9 @@ public: Write((int) Item); } void WriteExact(uint32_t Item) { Write((int)Item); } + // TODO FIXME: use of "int" here is dangerous and deprecated. It can lead to + // incompatible serialisation on non-32-bit machines. Passing anything other + // than one of the specifically supported fixed size types should be forbidden. void Write(int Item) { int32_t privItem = htonl(Item); @@ -57,6 +60,11 @@ public: int64_t privItem = box_hton64(Item); mrStream.Write(&privItem, sizeof(privItem), mTimeout); } + void WriteInt16(uint16_t Item) + { + uint16_t privItem = htons(Item); + mrStream.Write(&privItem, sizeof(privItem), mTimeout); + } void WriteExact(uint64_t Item) { Write(Item); } void Write(uint64_t Item) { @@ -109,6 +117,15 @@ public: } rItemOut = ntohl(privItem); } + void ReadFullBuffer(void* Buffer, size_t Size) + { + if(!mrStream.ReadFullBuffer(Buffer, Size, + 0 /* not interested in bytes read if this fails */, + mTimeout)) + { + THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead); + } + } void ReadIfPresent(int &rItemOut, int ValueIfNotPresent) { int32_t privItem; @@ -132,26 +149,22 @@ public: void Read(int64_t &rItemOut) { int64_t privItem; - if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem), - 0 /* not interested in bytes read if this fails */, - mTimeout)) - { - THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead); - } + ReadFullBuffer(&privItem, sizeof(privItem)); rItemOut = box_ntoh64(privItem); } void ReadExact(uint64_t &rItemOut) { Read(rItemOut); } void Read(uint64_t &rItemOut) { uint64_t privItem; - if(!mrStream.ReadFullBuffer(&privItem, sizeof(privItem), - 0 /* not interested in bytes read if this fails */, - mTimeout)) - { - THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead); - } + ReadFullBuffer(&privItem, sizeof(privItem)); rItemOut = box_ntoh64(privItem); } + void ReadInt16(uint16_t &rItemOut) + { + uint16_t privItem; + ReadFullBuffer(&privItem, sizeof(privItem)); + rItemOut = ntohs(privItem); + } void Read(uint8_t &rItemOut) { int privItem; @@ -160,14 +173,14 @@ public: } void ReadIfPresent(std::string &rItemOut, const std::string& ValueIfNotPresent) { - Read(rItemOut, &ValueIfNotPresent); + ReadString(rItemOut, &ValueIfNotPresent); } void Read(std::string &rItemOut) { - Read(rItemOut, NULL); + ReadString(rItemOut, NULL); } private: - void Read(std::string &rItemOut, const std::string* pValueIfNotPresent) + void ReadString(std::string &rItemOut, const std::string* pValueIfNotPresent) { int size; int bytesRead; @@ -193,13 +206,7 @@ private: if(size < (int) sizeof(buf)) { // Fetch rest of pPayload, relying on the Protocol to error on stupidly large sizes for us - if(!mrStream.ReadFullBuffer(buf, size, - 0 /* not interested in bytes read if this fails */, - mTimeout)) - { - THROW_EXCEPTION(CommonException, - ArchiveBlockIncompleteRead); - } + ReadFullBuffer(buf, size); // assign to this string, storing the header and the extra payload rItemOut.assign(buf, size); } @@ -210,13 +217,7 @@ private: char *ppayload = dataB; // Fetch rest of pPayload, relying on the Protocol to error on stupidly large sizes for us - if(!mrStream.ReadFullBuffer(ppayload, size, - 0 /* not interested in bytes read if this fails */, - mTimeout)) - { - THROW_EXCEPTION(CommonException, - ArchiveBlockIncompleteRead); - } + ReadFullBuffer(ppayload, size); // assign to this string, storing the header and the extra pPayload rItemOut.assign(ppayload, size); } diff --git a/lib/common/BoxConfig-MSVC.h b/lib/common/BoxConfig-MSVC.h index eeb25d2e..82ab4997 100644 --- a/lib/common/BoxConfig-MSVC.h +++ b/lib/common/BoxConfig-MSVC.h @@ -2,6 +2,9 @@ /* lib/common/BoxConfig.h.in. Generated from configure.ac by autoheader. */ /* Hacked by hand to work for MSVC by Chris Wilson */ +// using std::min/max +#define NOMINMAX + /* Define to major version for BDB_VERSION */ /* #undef BDB_VERSION_MAJOR */ diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h index 06f34d5c..35ad7a2c 100644 --- a/lib/common/BoxPlatform.h +++ b/lib/common/BoxPlatform.h @@ -108,56 +108,6 @@ #endif #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_U_INT8_T - #define HAVE_U_INT16_T - #define HAVE_U_INT32_T - #define HAVE_U_INT64_T -#endif // WIN32 && !__MINGW32__ - -// Define missing types -#ifndef HAVE_UINT8_T - typedef u_int8_t uint8_t; -#endif - -#ifndef HAVE_UINT16_T - typedef u_int16_t uint16_t; -#endif - -#ifndef HAVE_UINT32_T - typedef u_int32_t uint32_t; -#endif - -#ifndef HAVE_UINT64_T - typedef u_int64_t uint64_t; -#endif - -#ifndef HAVE_U_INT8_T - typedef uint8_t u_int8_t; -#endif - -#ifndef HAVE_U_INT16_T - typedef uint16_t u_int16_t; -#endif - -#ifndef HAVE_U_INT32_T - typedef uint32_t u_int32_t; -#endif - -#ifndef HAVE_U_INT64_T - typedef uint64_t u_int64_t; -#endif - #if !HAVE_DECL_INFTIM #define INFTIM -1 #endif @@ -176,7 +126,7 @@ #endif #ifdef WIN32 - typedef u_int64_t InodeRefType; + typedef uint64_t InodeRefType; #else typedef ino_t InodeRefType; #endif diff --git a/lib/common/makeexception.pl.in b/lib/common/makeexception.pl.in index e4018180..bddaa94a 100755 --- a/lib/common/makeexception.pl.in +++ b/lib/common/makeexception.pl.in @@ -73,12 +73,13 @@ class ${class}Exception : public BoxException public: ${class}Exception(unsigned int SubType, const std::string& rMessage = "") - : mSubType(SubType), mMessage(rMessage) + : mSubType(SubType), mMessage(rMessage), + mWhat(GetMessage(SubType) + std::string(rMessage.empty() ? "" : ": ") + rMessage) { } ${class}Exception(const ${class}Exception &rToCopy) - : mSubType(rToCopy.mSubType), mMessage(rToCopy.mMessage) + : mSubType(rToCopy.mSubType), mMessage(rToCopy.mMessage), mWhat(rToCopy.mWhat) { } @@ -117,6 +118,7 @@ print H <<__E; private: unsigned int mSubType; std::string mMessage; + std::string mWhat; }; #endif // $guardname @@ -133,51 +135,6 @@ print CPP <<__E; #include "MemLeakFindOn.h" -#ifdef EXCEPTION_CODENAMES_EXTENDED - #ifdef EXCEPTION_CODENAMES_EXTENDED_WITH_DESCRIPTION -static const char *whats[] = { -__E - -my $last_seen = -1; -for(my $e = 0; $e <= $#exception; $e++) -{ - if($exception[$e] ne '') - { - for(my $s = $last_seen + 1; $s < $e; $s++) - { - print CPP "\t\"UNUSED\",\n" - } - my $ext = ($exception_desc[$e] ne '')?" ($exception_desc[$e])":''; - print CPP "\t\"${class} ".$exception[$e].$ext.'"'.(($e==$#exception)?'':',')."\n"; - $last_seen = $e; - } -} - -print CPP <<__E; -}; - #else -static const char *whats[] = { -__E - -$last_seen = -1; -for(my $e = 0; $e <= $#exception; $e++) -{ - if($exception[$e] ne '') - { - for(my $s = $last_seen + 1; $s < $e; $s++) - { - print CPP "\t\"UNUSED\",\n" - } - print CPP "\t\"${class} ".$exception[$e].'"'.(($e==$#exception)?'':',')."\n"; - $last_seen = $e; - } -} - -print CPP <<__E; -}; - #endif -#endif - unsigned int ${class}Exception::GetType() const throw() { return ${class}Exception::ExceptionType; @@ -190,21 +147,7 @@ unsigned int ${class}Exception::GetSubType() const throw() const char * ${class}Exception::what() const throw() { - std::string what = "${class}"; - -#ifdef EXCEPTION_CODENAMES_EXTENDED - if(mSubType < (sizeof(whats) / sizeof(whats[0]))) - { - what = whats[mSubType]; - } -#endif - - if(mMessage != "") - { - what += ": " + mMessage; - } - - return what.c_str(); + return mWhat.c_str(); } const char * ${class}Exception::GetMessage(int SubType) diff --git a/lib/httpserver/HTTPRequest.cpp b/lib/httpserver/HTTPRequest.cpp index 1e3e2694..a94d96b0 100644 --- a/lib/httpserver/HTTPRequest.cpp +++ b/lib/httpserver/HTTPRequest.cpp @@ -10,10 +10,11 @@ #include "Box.h" #include <string.h> -#include <strings.h> #include <stdlib.h> #include <stdio.h> +#include <sstream> + #include "HTTPRequest.h" #include "HTTPResponse.h" #include "HTTPQueryDecoder.h" diff --git a/lib/intercept/intercept.cpp b/lib/intercept/intercept.cpp index 41a7333b..88ea0d6e 100644 --- a/lib/intercept/intercept.cpp +++ b/lib/intercept/intercept.cpp @@ -15,7 +15,6 @@ #include <sys/syscall.h> #endif #include <sys/types.h> -#include <unistd.h> #ifdef HAVE_SYS_UIO_H #include <sys/uio.h> diff --git a/lib/server/Protocol.cpp b/lib/server/Protocol.cpp index 937a2379..0adf9543 100644 --- a/lib/server/Protocol.cpp +++ b/lib/server/Protocol.cpp @@ -189,7 +189,7 @@ std::auto_ptr<Message> Protocol::ReceiveInternal() } // Check the object size - u_int32_t objSize = ntohl(objHeader.mObjSize); + uint32_t objSize = ntohl(objHeader.mObjSize); if(objSize < sizeof(objHeader) || objSize > mMaxObjectSize) { THROW_EXCEPTION(ConnectionException, Protocol_ObjTooBig) @@ -641,7 +641,7 @@ std::auto_ptr<IOStream> Protocol::ReceiveStream() } // Get the stream size - u_int32_t streamSize = ntohl(objHeader.mObjSize); + uint32_t streamSize = ntohl(objHeader.mObjSize); // Inform sub class InformStreamReceiving(streamSize); @@ -836,12 +836,12 @@ int Protocol::SendStreamSendBlock(uint8_t *Block, int BytesInBlock) // -------------------------------------------------------------------------- // // Function -// Name: Protocol::InformStreamReceiving(u_int32_t) +// Name: Protocol::InformStreamReceiving(uint32_t) // Purpose: Informs sub classes about streams being received // Created: 2003/10/27 // // -------------------------------------------------------------------------- -void Protocol::InformStreamReceiving(u_int32_t Size) +void Protocol::InformStreamReceiving(uint32_t Size) { if(GetLogToSysLog()) { @@ -868,12 +868,12 @@ void Protocol::InformStreamReceiving(u_int32_t Size) // -------------------------------------------------------------------------- // // Function -// Name: Protocol::InformStreamSending(u_int32_t) +// Name: Protocol::InformStreamSending(uint32_t) // Purpose: Informs sub classes about streams being sent // Created: 2003/10/27 // // -------------------------------------------------------------------------- -void Protocol::InformStreamSending(u_int32_t Size) +void Protocol::InformStreamSending(uint32_t Size) { if(GetLogToSysLog()) { diff --git a/lib/server/Protocol.h b/lib/server/Protocol.h index f659d3ca..fbe6461c 100644 --- a/lib/server/Protocol.h +++ b/lib/server/Protocol.h @@ -186,8 +186,8 @@ protected: void CheckAndReadHdr(void *hdr); // don't use type here to avoid dependency // Will be used for logging - virtual void InformStreamReceiving(u_int32_t Size); - virtual void InformStreamSending(u_int32_t Size); + virtual void InformStreamReceiving(uint32_t Size); + virtual void InformStreamSending(uint32_t Size); private: void EnsureBufferAllocated(int Size); diff --git a/lib/server/ProtocolWire.h b/lib/server/ProtocolWire.h index ff62b66e..6dee445b 100644 --- a/lib/server/ProtocolWire.h +++ b/lib/server/ProtocolWire.h @@ -26,8 +26,8 @@ typedef struct typedef struct { - u_int32_t mObjSize; - u_int32_t mObjType; + uint32_t mObjSize; + uint32_t mObjType; } PW_ObjectHeader; #define SPECIAL_STREAM_OBJECT_TYPE 0xffffffff diff --git a/lib/win32/emu.h b/lib/win32/emu.h index 5669c411..8014316a 100644 --- a/lib/win32/emu.h +++ b/lib/win32/emu.h @@ -32,27 +32,11 @@ // basic types, may be required by other headers since we // don't include sys/types.h - -#ifdef __MINGW32__ - #include <stdint.h> -#else // MSVC - 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; -#endif +#include <stdint.h> // emulated types, present on MinGW but not MSVC or vice versa -#ifdef __MINGW32__ - typedef uint32_t u_int32_t; -#else +#ifndef __MINGW32__ typedef unsigned int mode_t; typedef unsigned int pid_t; #endif @@ -81,17 +65,6 @@ #define ITIMER_REAL 0 -#ifdef _MSC_VER -// Microsoft decided to deprecate the standard POSIX functions. Great! -#define open(file,flags,mode) _open(file,flags,mode) -#define close(fd) _close(fd) -#define dup(fd) _dup(fd) -#define read(fd,buf,count) _read(fd,buf,count) -#define write(fd,buf,count) _write(fd,buf,count) -#define lseek(fd,off,whence) _lseek(fd,off,whence) -#define fileno(struct_file) _fileno(struct_file) -#endif - struct passwd { char *pw_name; char *pw_passwd; @@ -142,7 +115,7 @@ inline struct passwd * getpwnam(const char * name) #define S_ISDIR(x) (S_IFDIR & x) #endif -inline int chown(const char * Filename, u_int32_t uid, u_int32_t gid) +inline int chown(const char * Filename, uint32_t uid, uint32_t gid) { //important - this needs implementing //If a large restore is required then @@ -220,7 +193,11 @@ inline int geteuid(void) #define snprintf _snprintf inline int strcasecmp(const char *s1, const char *s2) { - return _stricmp(s1,s2); + return _stricmp(s1, s2); +} +inline int strncasecmp(const char *s1, const char *s2, size_t count) +{ + return _strnicmp(s1, s2, count); } #endif |