[Box Backup-dev] COMMIT r255 - in box/chris/win32/vc2005-compile-fixes/lib: common compress server win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Tue Dec 20 22:59:51 GMT 2005


Author: chris
Date: 2005-12-20 22:59:29 +0000 (Tue, 20 Dec 2005)
New Revision: 255

Modified:
   box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.h
   box/chris/win32/vc2005-compile-fixes/lib/common/DebugMemLeakFinder.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/EventWatchFilesystemObject.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/ExcludeList.h
   box/chris/win32/vc2005-compile-fixes/lib/common/FdGetLine.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/FileStream.h
   box/chris/win32/vc2005-compile-fixes/lib/common/Guards.h
   box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.h
   box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.h
   box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.h
   box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.h
   box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.h
   box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.h
   box/chris/win32/vc2005-compile-fixes/lib/common/UnixUser.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/Utils.cpp
   box/chris/win32/vc2005-compile-fixes/lib/common/WaitForEvent.cpp
   box/chris/win32/vc2005-compile-fixes/lib/compress/Compress.h
   box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.cpp
   box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.h
   box/chris/win32/vc2005-compile-fixes/lib/server/Protocol.h
   box/chris/win32/vc2005-compile-fixes/lib/win32/emu.h
Log:
First set of Visual C++ 2005 compile fixes (not tested on any other platform)


Modified: box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -61,9 +61,9 @@
 	if(mInWritePhase != false) { THROW_EXCEPTION(CommonException, CollectInBufferStreamNotInCorrectPhase) }
 	
 	// Adjust to number of bytes left
-	if(NBytes > (mBytesInBuffer - mReadPosition))
+	if(NBytes > (int)(mBytesInBuffer - mReadPosition))
 	{
-		NBytes = (mBytesInBuffer - mReadPosition);
+		NBytes = (int)(mBytesInBuffer - mReadPosition);
 	}
 	ASSERT(NBytes >= 0);
 	if(NBytes <= 0) return 0;	// careful now
@@ -157,7 +157,7 @@
 {
 	if(mInWritePhase != false) { THROW_EXCEPTION(CommonException, CollectInBufferStreamNotInCorrectPhase) }
 	
-	int newPos = 0;
+	pos_type newPos = 0;
 	switch(SeekType)
 	{
 	case IOStream::SeekType_Absolute:

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/CollectInBufferStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -52,7 +52,7 @@
 	MemoryBlockGuard<char*> mBuffer;
 	int mBufferSize;
 	int mBytesInBuffer;
-	int mReadPosition;
+	pos_type mReadPosition;
 	bool mInWritePhase;
 };
 

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/DebugMemLeakFinder.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/DebugMemLeakFinder.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/DebugMemLeakFinder.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -17,11 +17,14 @@
 #undef free
 
 #include <map>
-#include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <set>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 bool memleakfinder_global_enable = false;
 
 typedef struct
@@ -220,12 +223,12 @@
 		}
 		else
 		{
-			TRACE4("Block 0x%08lx size %d allocated at %s:%d\n", (long)i->first, i->second.size, i->second.file, i->second.line);
+			TRACE4("Block 0x%08p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line);
 		}
 	}
 	for(std::map<void *, ObjectInfo>::const_iterator i(sSectionObjectBlocks.begin()); i != sSectionObjectBlocks.end(); ++i)
 	{
-		TRACE5("Object%s 0x%08lx size %d allocated at %s:%d\n", i->second.array?" []":"", (long)i->first, i->second.size, i->second.file, i->second.line);
+		TRACE5("Object%s 0x%08p size %d allocated at %s:%d\n", i->second.array?" []":"", i->first, i->second.size, i->second.file, i->second.line);
 	}
 }
 
@@ -250,11 +253,11 @@
 {
 	for(std::map<void *, MallocBlockInfo>::const_iterator i(sMallocBlocks.begin()); i != sMallocBlocks.end(); ++i)
 	{
-		if(is_leak(i->first)) ::fprintf(file, "Block 0x%08lx size %d allocated at %s:%d\n", (long)i->first, i->second.size, i->second.file, i->second.line);
+		if(is_leak(i->first)) ::fprintf(file, "Block 0x%08p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line);
 	}
 	for(std::map<void *, ObjectInfo>::const_iterator i(sObjectBlocks.begin()); i != sObjectBlocks.end(); ++i)
 	{
-		if(is_leak(i->first)) ::fprintf(file, "Object%s 0x%08lx size %d allocated at %s:%d\n", i->second.array?" []":"", (long)i->first, i->second.size, i->second.file, i->second.line);
+		if(is_leak(i->first)) ::fprintf(file, "Object%s 0x%08p size %d allocated at %s:%d\n", i->second.array?" []":"", i->first, i->second.size, i->second.file, i->second.line);
 	}
 }
 

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/EventWatchFilesystemObject.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/EventWatchFilesystemObject.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/EventWatchFilesystemObject.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -10,7 +10,10 @@
 #include "Box.h"
 
 #include <fcntl.h>
+
+#ifndef WIN32
 #include <unistd.h>
+#endif
 
 #include "EventWatchFilesystemObject.h"
 #include "autogen_CommonException.h"

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/ExcludeList.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/ExcludeList.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/ExcludeList.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -43,8 +43,8 @@
 	bool IsExcluded(const std::string &rTest) const;
 	
 	// Mainly for tests
-	unsigned int SizeOfDefiniteList() const {return mDefinite.size();}
-	unsigned int SizeOfRegexList() const
+	size_t SizeOfDefiniteList() const {return mDefinite.size();}
+	size_t SizeOfRegexList() const
 #ifdef HAVE_REGEX_H
 		{return mRegex.size();}
 #else

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/FdGetLine.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/FdGetLine.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/FdGetLine.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -10,7 +10,10 @@
 #include "Box.h"
 
 #include <sys/types.h>
+
+#ifndef WIN32
 #include <unistd.h>
+#endif
 
 #include "FdGetLine.h"
 #include "CommonException.h"
@@ -151,8 +154,8 @@
 	else
 	{
 		// Check for comment char, but char before must be whitespace
-		int end = 0;
-		int size = r.size();
+		size_t end = 0;
+		size_t size = r.size();
 		while(end < size)
 		{
 			if(r[end] == '#' && (end == 0 || (iw(r[end-1]))))
@@ -163,7 +166,7 @@
 		}
 		
 		// Remove whitespace
-		int begin = 0;
+		size_t begin = 0;
 		while(begin < size && iw(r[begin]))
 		{
 			begin++;

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/FileStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/FileStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/FileStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -15,7 +15,10 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <sys/stat.h>
+
+#ifndef WIN32
 #include <unistd.h>
+#endif
 
 #ifdef WIN32
 	#define INVALID_FILE NULL

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/Guards.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/Guards.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/Guards.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -14,9 +14,12 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <new>
 
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
 #include "CommonException.h"
 
 #include "MemLeakFindOn.h"

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -145,15 +145,15 @@
 //		Created: 2003/08/26
 //
 // --------------------------------------------------------------------------
-bool IOStream::ReadFullBuffer(void *pBuffer, int NBytes, int *pNBytesRead, int Timeout)
+bool IOStream::ReadFullBuffer(void *pBuffer, size_t NBytes, size_t *pNBytesRead, int Timeout)
 {
-	int bytesToGo = NBytes;
+	size_t bytesToGo = NBytes;
 	char *buffer = (char*)pBuffer;
 	if(pNBytesRead) (*pNBytesRead) = 0;
 	
 	while(bytesToGo > 0)
 	{
-		int bytesRead = Read(buffer, bytesToGo, Timeout);
+		size_t bytesRead = Read(buffer, bytesToGo, Timeout);
 		if(bytesRead == 0)
 		{
 			// Timeout or something
@@ -222,7 +222,7 @@
 	while(StreamDataLeft())
 	{
 		// Read some data
-		int bytes = Read(buffer, BufferSize, Timeout);
+		size_t bytes = Read(buffer, BufferSize, Timeout);
 		if(bytes == 0 && StreamDataLeft())
 		{
 			return false;	// incomplete, timed out

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/IOStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -41,9 +41,9 @@
 	// Timeout in milliseconds
 	// Read may return 0 -- does not mean end of stream.
 	typedef int64_t pos_type;
-	virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite) = 0;
+	virtual size_t Read(void *pBuffer, size_t NBytes, int Timeout = IOStream::TimeOutInfinite) = 0;
 	virtual pos_type BytesLeftToRead();	// may return IOStream::SizeOfStreamUnknown (and will for most stream types)
-	virtual void Write(const void *pBuffer, int NBytes) = 0;
+	virtual void Write(const void *pBuffer, size_t NBytes) = 0;
 	virtual void WriteAllBuffered();
 	virtual pos_type GetPosition() const;
 	virtual void Seek(pos_type Offset, int SeekType);
@@ -55,7 +55,7 @@
 	virtual bool StreamClosed() = 0;
 	
 	// Utility functions
-	bool ReadFullBuffer(void *pBuffer, int NBytes, int *pNBytesRead, int Timeout = IOStream::TimeOutInfinite);
+	bool ReadFullBuffer(void *pBuffer, size_t NBytes, size_t *pNBytesRead, int Timeout = IOStream::TimeOutInfinite);
 	bool CopyStreamTo(IOStream &rCopyTo, int Timeout = IOStream::TimeOutInfinite, int BufferSize = 1024);
 	
 	static int ConvertSeekTypeToOSWhence(int SeekType);

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -113,7 +113,7 @@
 		// Read more in?
 		if(!foundLineEnd && mBufferBegin >= mBytesInBuffer && !mPendingEOF)
 		{
-			int bytes = mrStream.Read(mBuffer, sizeof(mBuffer), Timeout);
+			size_t bytes = mrStream.Read(mBuffer, sizeof(mBuffer), Timeout);
 			
 			// Adjust buffer info
 			mBytesInBuffer = bytes;
@@ -151,8 +151,8 @@
 	else
 	{
 		// Check for comment char, but char before must be whitespace
-		int end = 0;
-		int size = r.size();
+		size_t end = 0;
+		size_t size = r.size();
 		while(end < size)
 		{
 			if(r[end] == '#' && (end == 0 || (iw(r[end-1]))))
@@ -163,7 +163,7 @@
 		}
 		
 		// Remove whitespace
-		int begin = 0;
+		size_t begin = 0;
 		while(begin < size && iw(r[begin]))
 		{
 			begin++;
@@ -193,7 +193,7 @@
 void IOStreamGetLine::DetachFile()
 {
 	// Adjust file pointer
-	int bytesOver = mBytesInBuffer - mBufferBegin;
+	size_t bytesOver = mBytesInBuffer - mBufferBegin;
 	ASSERT(bytesOver >= 0);
 	if(bytesOver > 0)
 	{
@@ -213,10 +213,10 @@
 //		Created: 22/12/04
 //
 // --------------------------------------------------------------------------
-void IOStreamGetLine::IgnoreBufferedData(int BytesToIgnore)
+void IOStreamGetLine::IgnoreBufferedData(size_t BytesToIgnore)
 {
-	int bytesInBuffer = mBytesInBuffer - mBufferBegin;
-	if(BytesToIgnore < 0 || BytesToIgnore > bytesInBuffer)
+	size_t bytesInBuffer = mBytesInBuffer - mBufferBegin;
+	if(BytesToIgnore > bytesInBuffer)
 	{
 		THROW_EXCEPTION(CommonException, IOStreamGetLineNotEnoughDataToIgnore)
 	}

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/IOStreamGetLine.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -52,16 +52,16 @@
 	// For doing interesting stuff with the remaining data...
 	// Be careful with this!
 	const void *GetBufferedData() const {return mBuffer + mBufferBegin;}
-	int GetSizeOfBufferedData() const {return mBytesInBuffer - mBufferBegin;}
-	void IgnoreBufferedData(int BytesToIgnore);
+	size_t GetSizeOfBufferedData() const {return mBytesInBuffer - mBufferBegin;}
+	void IgnoreBufferedData(size_t BytesToIgnore);
 	IOStream &GetUnderlyingStream() {return mrStream;}
 	
 private:
 	char mBuffer[IOSTREAMGETLINE_BUFFER_SIZE];
 	IOStream &mrStream;
 	int mLineNumber;
-	int mBufferBegin;
-	int mBytesInBuffer;
+	size_t mBufferBegin;
+	size_t mBytesInBuffer;
 	bool mPendingEOF;
 	bool mEOF;
 	std::string mPendingString;

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -108,7 +108,7 @@
 //		Created: 2003/09/05
 //
 // --------------------------------------------------------------------------
-int MemBlockStream::Read(void *pBuffer, int NBytes, int Timeout)
+IOStream::pos_type MemBlockStream::Read(void *pBuffer, pos_type NBytes, int Timeout)
 {
 	// Adjust to number of bytes left
 	if(NBytes > (mBytesInBuffer - mReadPosition))
@@ -117,9 +117,10 @@
 	}
 	ASSERT(NBytes >= 0);
 	if(NBytes <= 0) return 0;	// careful now
-	
+
+	ASSERT(sizeof(size_t) >= sizeof(pos_type))	
 	// Copy in the requested number of bytes and adjust the read pointer
-	::memcpy(pBuffer, mpBuffer + mReadPosition, NBytes);
+	::memcpy(pBuffer, mpBuffer + mReadPosition, (size_t)NBytes);
 	mReadPosition += NBytes;
 	
 	return NBytes;
@@ -141,12 +142,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    MemBlockStream::Write(void *, int)
+//		Name:    MemBlockStream::Write(void *, pos_type)
 //		Purpose: As interface. But only works in write phase
 //		Created: 2003/09/05
 //
 // --------------------------------------------------------------------------
-void MemBlockStream::Write(const void *pBuffer, int NBytes)
+void MemBlockStream::Write(const void *pBuffer, pos_type NBytes)
 {
 	THROW_EXCEPTION(CommonException, MemBlockStreamNotSupported)
 }
@@ -175,7 +176,7 @@
 // --------------------------------------------------------------------------
 void MemBlockStream::Seek(pos_type Offset, int SeekType)
 {
-	int newPos = 0;
+	pos_type newPos = 0;
 	switch(SeekType)
 	{
 	case IOStream::SeekType_Absolute:

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/MemBlockStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -34,9 +34,9 @@
 	~MemBlockStream();
 public:
 
-	virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
+	virtual pos_type Read(void *pBuffer, pos_type NBytes, int Timeout = IOStream::TimeOutInfinite);
 	virtual pos_type BytesLeftToRead();
-	virtual void Write(const void *pBuffer, int NBytes);
+	virtual void Write(const void *pBuffer, pos_type NBytes);
 	virtual pos_type GetPosition() const;
 	virtual void Seek(pos_type Offset, int SeekType);
 	virtual bool StreamDataLeft();
@@ -44,8 +44,8 @@
 
 private:
 	const char *mpBuffer;
-	int mBytesInBuffer;
-	int mReadPosition;
+	size_t      mBytesInBuffer;
+	pos_type    mReadPosition;
 };
 
 #endif // MEMBLOCKSTREAM__H

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -54,10 +54,10 @@
 //		Created: 2003/08/26
 //
 // --------------------------------------------------------------------------
-int PartialReadStream::Read(void *pBuffer, int NBytes, int Timeout)
+size_t PartialReadStream::Read(void *pBuffer, size_t NBytes, int Timeout)
 {
 	// Finished?
-	if(mBytesLeft <= 0)
+	if(mBytesLeft == 0)
 	{
 		return 0;
 	}
@@ -70,7 +70,7 @@
 	}
 	
 	// Route the request to the source
-	int read = mrSource.Read(pBuffer, NBytes, Timeout);
+	size_t read = mrSource.Read(pBuffer, NBytes, Timeout);
 	ASSERT(read <= mBytesLeft);
 	
 	// Adjust the count

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/PartialReadStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -31,7 +31,7 @@
 	PartialReadStream(const PartialReadStream &);
 	
 public:
-	virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
+	virtual size_t Read(void *pBuffer, size_t NBytes, int Timeout = IOStream::TimeOutInfinite);
 	virtual pos_type BytesLeftToRead();
 	virtual void Write(const void *pBuffer, int NBytes);
 	virtual bool StreamDataLeft();
@@ -39,7 +39,7 @@
 
 private:
 	IOStream &mrSource;
-	int mBytesLeft;
+	size_t mBytesLeft;
 };
 
 #endif // PARTIALREADSTREAM__H

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -64,12 +64,12 @@
 //		Created: 10/12/03
 //
 // --------------------------------------------------------------------------
-int ReadGatherStream::AddComponent(IOStream *pStream)
+size_t ReadGatherStream::AddComponent(IOStream *pStream)
 {
 	ASSERT(pStream != 0);
 
 	// Just add the component to the list, returning it's index.
-	int index = mComponents.size();
+	size_t index = mComponents.size();
 	mComponents.push_back(pStream);
 	return index;
 }
@@ -116,9 +116,9 @@
 //		Created: 10/12/03
 //
 // --------------------------------------------------------------------------
-int ReadGatherStream::Read(void *pBuffer, int NBytes, int Timeout)
+size_t ReadGatherStream::Read(void *pBuffer, size_t NBytes, int Timeout)
 {
-	int bytesToRead = NBytes;
+	size_t bytesToRead = NBytes;
 	uint8_t *buffer = (uint8_t*)pBuffer;
 	
 	while(bytesToRead > 0)
@@ -145,15 +145,18 @@
 		if(mPositionInCurrentBlock < mBlocks[mCurrentBlock].mLength)
 		{
 			// Read!
-			int s = mBlocks[mCurrentBlock].mLength - mPositionInCurrentBlock;
+			pos_type s = mBlocks[mCurrentBlock].mLength 
+				- mPositionInCurrentBlock;
 			if(s > bytesToRead) s = bytesToRead;
+		
+			ASSERT(sizeof(size_t) >= sizeof(pos_type))
+			pos_type r = mComponents[mBlocks[mCurrentBlock]
+				.mComponent]->Read(buffer, (size_t)s, Timeout);
 			
-			int r = mComponents[mBlocks[mCurrentBlock].mComponent]->Read(buffer, s, Timeout);
-			
 			// update variables
 			mPositionInCurrentBlock += r;
 			buffer += r;
-			bytesToRead -= r;
+			bytesToRead -= (size_t)r;
 			mCurrentPosition += r;
 			
 			if(r != s)

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/ReadGatherStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -32,10 +32,10 @@
 	ReadGatherStream &operator=(const ReadGatherStream &);
 public:
 
-	int AddComponent(IOStream *pStream);
+	size_t AddComponent(IOStream *pStream);
 	void AddBlock(int Component, pos_type Length, bool Seek = false, pos_type SeekTo = 0);
 
-	virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
+	virtual size_t Read(void *pBuffer, size_t NBytes, int Timeout = IOStream::TimeOutInfinite);
 	virtual pos_type BytesLeftToRead();
 	virtual void Write(const void *pBuffer, int NBytes);
 	virtual bool StreamDataLeft();

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -84,12 +84,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    StreamableMemBlock::Set(void *, int)
+//		Name:    StreamableMemBlock::Set(void *, size_t)
 //		Purpose: Set the contents of the block
 //		Created: 2003/09/05
 //
 // --------------------------------------------------------------------------
-void StreamableMemBlock::Set(void *pBuffer, int Size)
+void StreamableMemBlock::Set(void *pBuffer, size_t Size)
 {
 	FreeBlock();
 	AllocateBlock(Size);
@@ -115,7 +115,8 @@
 	}
 	
 	// Allocate a new block (this way to be exception safe)
-	char *pblock = (char*)malloc(size);
+	ASSERT(sizeof(size_t) >= sizeof(IOStream::pos_type))
+	char *pblock = (char*)malloc((size_t)size);
 	if(pblock == 0)
 	{
 		throw std::bad_alloc();
@@ -124,7 +125,7 @@
 	try
 	{
 		// Read in
-		if(!rStream.ReadFullBuffer(pblock, size, 0 /* not interested in bytes read if this fails */))
+		if(!rStream.ReadFullBuffer(pblock, (size_t)size, 0 /* not interested in bytes read if this fails */))
 		{
 			THROW_EXCEPTION(CommonException, StreamableMemBlockIncompleteRead)
 		}
@@ -141,7 +142,9 @@
 	// store...
 	ASSERT(mpBuffer == 0);
 	mpBuffer = pblock;
-	mSize = size;
+
+	ASSERT(sizeof(size_t) >= sizeof(IOStream::pos_type))
+	mSize = (size_t)size;
 }
 
 
@@ -195,12 +198,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    StreamableMemBlock::AllocateBlock(int)
+//		Name:    StreamableMemBlock::AllocateBlock(size_t)
 //		Purpose: Protected. Allocate the block of memory
 //		Created: 2003/09/05
 //
 // --------------------------------------------------------------------------
-void StreamableMemBlock::AllocateBlock(int Size)
+void StreamableMemBlock::AllocateBlock(size_t Size)
 {
 	ASSERT(mpBuffer == 0);
 	if(Size > 0)
@@ -299,7 +302,9 @@
 // --------------------------------------------------------------------------
 void StreamableMemBlock::WriteToStream(IOStream &rStream) const
 {
-	int32_t sizenbo = htonl(mSize);
+	ASSERT(sizeof(uint32_t) >= sizeof(mSize))
+	uint32_t sizenbo = htonl((uint32_t)mSize);
+
 	// Size
 	rStream.Write(&sizenbo, sizeof(sizenbo));
 	// Buffer

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/StreamableMemBlock.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -30,7 +30,7 @@
 	~StreamableMemBlock();
 	
 	void Set(const StreamableMemBlock &rBlock);
-	void Set(void *pBuffer, int Size);
+	void Set(void *pBuffer, size_t Size);
 	void Set(IOStream &rStream, int Timeout);
 	StreamableMemBlock &operator=(const StreamableMemBlock &rBlock)
 	{
@@ -46,7 +46,7 @@
 	void *GetBuffer() const;
 	
 	// Size of block
-	int GetSize() const {return mSize;}
+	size_t GetSize() const {return mSize;}
 
 	// Buffer empty?
 	bool IsEmpty() const {return mSize == 0;}
@@ -59,12 +59,12 @@
 	void ResizeBlock(int Size);
 
 protected:	// be careful with these!
-	void AllocateBlock(int Size);
+	void AllocateBlock(size_t Size);
 	void FreeBlock();
 
 private:
 	void *mpBuffer;
-	int mSize;
+	size_t mSize;
 };
 
 #endif // STREAMABLEMEMBLOCK__H

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/UnixUser.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/UnixUser.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/UnixUser.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -11,10 +11,9 @@
 
 #ifndef WIN32
 #include <pwd.h>
+#include <unistd.h>
 #endif
 
-#include <unistd.h>
-
 #include "UnixUser.h"
 #include "CommonException.h"
 

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/Utils.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/Utils.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/Utils.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -39,7 +39,7 @@
 	while(e = String.find_first_of(SplitOn, b), e != String.npos)
 	{
 		// Get this string
-		unsigned int len = e - b;
+		std::string::size_type len = e - b;
 		if(len >= 1)
 		{
 			rOutput.push_back(String.substr(b, len));

Modified: box/chris/win32/vc2005-compile-fixes/lib/common/WaitForEvent.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/common/WaitForEvent.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/common/WaitForEvent.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -9,7 +9,10 @@
 
 #include "Box.h"
 
+#ifndef WIN32
 #include <unistd.h>
+#endif
+
 #include <errno.h>
 #include <string.h>
 
@@ -160,7 +163,8 @@
 	}
 	
 	// Poll!
-	switch(::poll(mpPollInfo, mItems.size(), mTimeout))
+	ASSERT(sizeof(unsigned long) > sizeof(size_t))
+	switch(::poll(mpPollInfo, (unsigned long)mItems.size(), mTimeout))
 	{
 	case -1:
 		// Interrupted system calls aren't an error, just equivalent to a timeout

Modified: box/chris/win32/vc2005-compile-fixes/lib/compress/Compress.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/compress/Compress.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/compress/Compress.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -85,17 +85,19 @@
 	//		Created: 5/12/03
 	//
 	// --------------------------------------------------------------------------
-	void Input(const void *pInBuffer, int InLength)
+	void Input(const void *pInBuffer, size_t InLength)
 	{
 		// Check usage
 		if(mStream.avail_in != 0)
 		{
 			THROW_EXCEPTION(CompressException, BadUsageInputNotRequired)
 		}
+
+		ASSERT(sizeof(uInt) >= sizeof(size_t))
 		
 		// Store info
 		mStream.next_in = (unsigned char *)pInBuffer;
-		mStream.avail_in = InLength;
+		mStream.avail_in = (uInt)InLength;
 	}
 	
 	// --------------------------------------------------------------------------
@@ -119,17 +121,19 @@
 	//		Created: 5/12/03
 	//
 	// --------------------------------------------------------------------------
-	int Output(void *pOutBuffer, int OutLength, bool SyncFlush = false)
+	size_t Output(void *pOutBuffer, size_t OutLength, bool SyncFlush = false)
 	{
 		// need more input?
 		if(mStream.avail_in == 0 && mFlush != Z_FINISH && !SyncFlush)
 		{
 			return 0;
 		}
+
+		ASSERT(sizeof(int) <= sizeof(size_t))
 	
 		// Buffers
 		mStream.next_out = (unsigned char *)pOutBuffer;
-		mStream.avail_out = OutLength;
+		mStream.avail_out = (unsigned int)OutLength;
 		
 		// Call one of the functions
 		int flush = mFlush;

Modified: box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.cpp	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.cpp	2005-12-20 22:59:29 UTC (rev 255)
@@ -131,12 +131,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    CompressStream::Read(void *, int, int)
+//		Name:    CompressStream::Read(void *, size_t, int)
 //		Purpose: As interface
 //		Created: 27/5/04
 //
 // --------------------------------------------------------------------------
-int CompressStream::Read(void *pBuffer, int NBytes, int Timeout)
+size_t CompressStream::Read(void *pBuffer, size_t NBytes, int Timeout)
 {
 	USE_READ_COMPRESSOR
 	if(pDecompress == 0)
@@ -155,7 +155,7 @@
 	}
 
 	// Read data into the buffer -- read as much as possible in one go
-	int s = mpStream->Read(pbuf, BUFFER_SIZE, Timeout);
+	size_t s = mpStream->Read(pbuf, BUFFER_SIZE, Timeout);
 	if(s == 0)
 	{
 		return 0;
@@ -172,12 +172,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    CompressStream::Write(const void *, int)
+//		Name:    CompressStream::Write(const void *, size_t)
 //		Purpose: As interface
 //		Created: 27/5/04
 //
 // --------------------------------------------------------------------------
-void CompressStream::Write(const void *pBuffer, int NBytes)
+void CompressStream::Write(const void *pBuffer, size_t NBytes)
 {
 	USE_WRITE_COMPRESSOR
 	if(pCompress == 0)
@@ -262,7 +262,7 @@
 	USE_WRITE_COMPRESSOR
 	if(pCompress == 0) {THROW_EXCEPTION(CompressException, Internal)}
 	
-	int s = 0;
+	size_t s = 0;
 	do
 	{
 		s = pCompress->Output(mpBuffer, BUFFER_SIZE, SyncFlush);

Modified: box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/compress/CompressStream.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -32,8 +32,8 @@
 	CompressStream &operator=(const CompressStream &);
 public:
 
-	virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
-	virtual void Write(const void *pBuffer, int NBytes);
+	virtual size_t Read(void *pBuffer, size_t NBytes, int Timeout = IOStream::TimeOutInfinite);
+	virtual void Write(const void *pBuffer, size_t NBytes);
 	virtual void WriteAllBuffered();
 	virtual void Close();
 	virtual bool StreamDataLeft();

Modified: box/chris/win32/vc2005-compile-fixes/lib/server/Protocol.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/server/Protocol.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/server/Protocol.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -94,7 +94,7 @@
 	void Read(int32_t &rOut);
 	void Read(int16_t &rOut);
 	void Read(int8_t &rOut);
-	void Read(bool &rOut) {int8_t read; Read(read); rOut = (read == true);}
+	void Read(bool &rOut) {bool read; Read(read); rOut = (read == true);}
 	void Read(std::string &rOut);
 	template<typename type>
 	void Read(type &rOut)

Modified: box/chris/win32/vc2005-compile-fixes/lib/win32/emu.h
===================================================================
--- box/chris/win32/vc2005-compile-fixes/lib/win32/emu.h	2005-12-20 22:30:38 UTC (rev 254)
+++ box/chris/win32/vc2005-compile-fixes/lib/win32/emu.h	2005-12-20 22:59:29 UTC (rev 255)
@@ -27,12 +27,19 @@
 	( *(_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
 
+// 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)
+
 int setitimer(int type , struct itimerval *timeout, int);
 void InitTimer(void);
 void FiniTimer(void);




More information about the Boxbackup-dev mailing list