You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/08/07 20:42:04 UTC

incubator-corinthia git commit: converted tab to 4 spaces

Repository: incubator-corinthia
Updated Branches:
  refs/heads/master cc6be3825 -> a146f6c7a


converted tab to 4 spaces


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/a146f6c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/a146f6c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/a146f6c7

Branch: refs/heads/master
Commit: a146f6c7a53b1e09807a8d5f90b606b12e0cc7df
Parents: cc6be38
Author: jani <ja...@apache.org>
Authored: Fri Aug 7 20:41:33 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Fri Aug 7 20:41:33 2015 +0200

----------------------------------------------------------------------
 DocFormats/core/src/lib/DFZipFile.c      |  28 +-
 DocFormats/headers/DFPlatform.h          |  18 +-
 DocFormats/platform/src/Wrapper_zip.c    | 590 +++++++++++++-------------
 DocFormats/platform/tests/WrapperTests.c |  74 ++--
 4 files changed, 355 insertions(+), 355 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/a146f6c7/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index 61dcf1b..00ecdea 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -38,28 +38,28 @@ static int zipError(DFError **error, const char *format, ...)
 
 int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
 {
-	unsigned char   *buf;
+    unsigned char   *buf;
     DFextZipHandleP  zipHandle;
-	int              i;
+    int              i;
 
     zipHandle = DFextZipOpen(zipFilename);
     if (!zipHandle)
       return zipError(error,"Cannot open file");
 
-	for (i = 0; i < zipHandle->zipFileCount; i++) {
-		if ( (buf = DFextZipReadFile(zipHandle, &zipHandle->zipFileEntries[i])) == NULL)
-			return zipError(error, "Cannot read file in zip");
+    for (i = 0; i < zipHandle->zipFileCount; i++) {
+        if ( (buf = DFextZipReadFile(zipHandle, &zipHandle->zipFileEntries[i])) == NULL)
+            return zipError(error, "Cannot read file in zip");
 
-		DFBuffer *content = DFBufferNew();
-		DFBufferAppendData(content, (void *)buf, zipHandle->zipFileEntries[i].uncompressedSize);
-		free(buf);
+        DFBuffer *content = DFBufferNew();
+        DFBufferAppendData(content, (void *)buf, zipHandle->zipFileEntries[i].uncompressedSize);
+        free(buf);
 
-		if (!DFBufferWriteToStorage(content, storage, zipHandle->zipFileEntries[i].fileName, error)) {
-			DFBufferRelease(content);
-			return zipError(error, "%s: %s", zipHandle->zipFileEntries[i].fileName, DFErrorMessage(error));
-		}
-		DFBufferRelease(content);
-	}
+        if (!DFBufferWriteToStorage(content, storage, zipHandle->zipFileEntries[i].fileName, error)) {
+            DFBufferRelease(content);
+            return zipError(error, "%s: %s", zipHandle->zipFileEntries[i].fileName, DFErrorMessage(error));
+        }
+        DFBufferRelease(content);
+    }
 
     DFextZipClose(zipHandle);
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/a146f6c7/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index 0a29712..e6efd03 100644
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -70,18 +70,18 @@ void DFInitOnce(DFOnce *once, DFOnceFunction fun);
 
 // Zip functions
 typedef struct {
-	int   compressedSize;    // File size on disk
-	int   uncompressedSize;  // Real file size
-	int   compressionMethod; // Type of compression
-	long  offset;            // offset in file
-	char *fileName;          // filename zero terminated
+    int   compressedSize;    // File size on disk
+    int   uncompressedSize;  // Real file size
+    int   compressionMethod; // Type of compression
+    long  offset;            // offset in file
+    char *fileName;          // filename zero terminated
 } DFextZipDirEntry;
 typedef DFextZipDirEntry * DFextZipDirEntryP;
 typedef struct {
-	void             *zipFile;        // file handle to zip file
-	int               zipFileCount;   // number of entries in array
-	int               zipCreateMode;  // > 0 signals create mode, # is allocation of array
-	DFextZipDirEntry *zipFileEntries; // array with filenames in zip
+    void             *zipFile;        // file handle to zip file
+    int               zipFileCount;   // number of entries in array
+    int               zipCreateMode;  // > 0 signals create mode, # is allocation of array
+    DFextZipDirEntry *zipFileEntries; // array with filenames in zip
 } DFextZipHandle;
 typedef DFextZipHandle * DFextZipHandleP;
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/a146f6c7/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
index b9f3bc5..e749fb4 100644
--- a/DocFormats/platform/src/Wrapper_zip.c
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -23,55 +23,55 @@
 
 #pragma pack(1)
 typedef struct {
-	uint32_t signature;                  // 0x06054b50
-	uint16_t diskNumber;                 // NOT USED
-	uint16_t centralDirectoryDiskNumber; // NOT USED
-	uint16_t numEntriesThisDisk;         // NOT USED
-	uint16_t numEntries;                 // Number of files in Zip
-	uint32_t centralDirectorySize;       // NOT USED
-	uint32_t centralDirectoryOffset;     // Offset of directory in file (fseek)
-	uint16_t zipCommentLength;           // NOT USED
-   	                                     // Followed by .ZIP file comment (variable size)
+    uint32_t signature;                  // 0x06054b50
+    uint16_t diskNumber;                 // NOT USED
+    uint16_t centralDirectoryDiskNumber; // NOT USED
+    uint16_t numEntriesThisDisk;         // NOT USED
+    uint16_t numEntries;                 // Number of files in Zip
+    uint32_t centralDirectorySize;       // NOT USED
+    uint32_t centralDirectoryOffset;     // Offset of directory in file (fseek)
+    uint16_t zipCommentLength;           // NOT USED
+                                            // Followed by .ZIP file comment (variable size)
 } ZipEndRecord;
 #pragma pack()
 static const uint32_t ZipEndRecord_signature = 0x06054B50;
 
 #pragma pack(1)
 typedef struct {
-	uint32_t signature;                   // 0x02014B50
-	uint16_t versionMadeBy;               // NOT USED
-	uint16_t versionNeededToExtract;      // NOT USED
-	uint16_t generalPurposeBitFlag;       // NOT USED
-	uint16_t compressionMethod;           // NOT USED
-	uint16_t lastModFileTime;             // NOT USED
-	uint16_t lastModFileDate;             // NOT USED
-	uint32_t crc32;                       // NOT USED
-	uint32_t compressedSize;              // NOT USED
-	uint32_t uncompressedSize;            // NOT USED
-	uint16_t fileNameLength;              // Only used to skip to next record 
-	uint16_t extraFieldLength;            // Only used to skip to next record
-	uint16_t fileCommentLength;           // Only used to skip to next record
-	uint16_t diskNumberStart;             // NOT USED
-	uint16_t internalFileAttributes;      // NOT USED
-	uint32_t externalFileAttributes;      // NOT USED
-	uint32_t relativeOffsetOflocalHeader; // offset to file header
+    uint32_t signature;                   // 0x02014B50
+    uint16_t versionMadeBy;               // NOT USED
+    uint16_t versionNeededToExtract;      // NOT USED
+    uint16_t generalPurposeBitFlag;       // NOT USED
+    uint16_t compressionMethod;           // NOT USED
+    uint16_t lastModFileTime;             // NOT USED
+    uint16_t lastModFileDate;             // NOT USED
+    uint32_t crc32;                       // NOT USED
+    uint32_t compressedSize;              // NOT USED
+    uint32_t uncompressedSize;            // NOT USED
+    uint16_t fileNameLength;              // Only used to skip to next record 
+    uint16_t extraFieldLength;            // Only used to skip to next record
+    uint16_t fileCommentLength;           // Only used to skip to next record
+    uint16_t diskNumberStart;             // NOT USED
+    uint16_t internalFileAttributes;      // NOT USED
+    uint32_t externalFileAttributes;      // NOT USED
+    uint32_t relativeOffsetOflocalHeader; // offset to file header
 } ZipDirectoryRecord;
 #pragma pack()
 static const uint32_t ZipDirectoryRecord_signature = 0x02014B50;
 
 #pragma pack(1)
 typedef struct {
-	uint32_t signature;              // 0x04034B50
-	uint16_t versionNeededToExtract; // NOT USED
-	uint16_t generalPurposeBitFlag;  // NOT USED
-	uint16_t compressionMethod;      // flat file or zip compressed
-	uint16_t lastModFileTime;        // NOT USED
-	uint16_t lastModFileDate;        // NOT USED
-	uint32_t crc32;                  // NOT USED
-	uint32_t compressedSize;         // size to read from file
-	uint32_t uncompressedSize;       // size in memory
-	uint16_t fileNameLength;         // Length of file name
-	uint16_t extraFieldLength;       // NOT USED
+    uint32_t signature;              // 0x04034B50
+    uint16_t versionNeededToExtract; // NOT USED
+    uint16_t generalPurposeBitFlag;  // NOT USED
+    uint16_t compressionMethod;      // flat file or zip compressed
+    uint16_t lastModFileTime;        // NOT USED
+    uint16_t lastModFileDate;        // NOT USED
+    uint32_t crc32;                  // NOT USED
+    uint32_t compressedSize;         // size to read from file
+    uint32_t uncompressedSize;       // size in memory
+    uint16_t fileNameLength;         // Length of file name
+    uint16_t extraFieldLength;       // NOT USED
 } ZipFileHeader;
 #pragma pack()
 static const uint32_t ZipFileHeader_signature = 0x04034B50;
@@ -81,135 +81,135 @@ static const int FILECOUNT_ALLOC_SIZE = 5;
 
 static int readDirectory(FILE *zipFile, DFextZipHandleP zipHandle)
 {
-	unsigned long fileSize, readBytes;
-	unsigned char workBuf[4096];
-	int           i, zipOffset;
-
-
-	//***** Read EndRecord *****
-	// the EndRecord contains information, where the directory is located
-
-
-	// find end of file, and calculate size
-	if (fseek(zipFile, 0, SEEK_END)
-		|| (fileSize = ftell(zipFile)) <= sizeof(ZipEndRecord))
-		return -1;
-
-	// Read size of workBuf of filesize from end of file to locate EndRecord
-	readBytes = (fileSize < sizeof(workBuf)) ? fileSize : sizeof(workBuf);
-	if (fseek(zipFile, fileSize - readBytes, SEEK_SET)
-		|| fread(workBuf, 1, readBytes, zipFile) < readBytes)
-		return -1;
-
-	// search for EndRecord signature
-	for (i = readBytes - sizeof(ZipEndRecord); i >= 0; i--) {
-		ZipEndRecord *recEnd = (ZipEndRecord *)(workBuf + i);
-
-		// check if we have a signature
-		if (recEnd->signature == ZipEndRecord_signature) {
-			// update zipHandle
-			zipOffset                 = recEnd->centralDirectoryOffset;
-			zipHandle->zipFileCount   = recEnd->numEntries;
-			zipHandle->zipFileEntries = xmalloc(zipHandle->zipFileCount * sizeof(DFextZipDirEntry));
-			break;
-		}
-	}
-	if (i < 0)
-		return -1;
-
-
-	//***** Read Directory *****
-	// Each file has a global and a local entry, read both in a loop
-
-
-	// Find firs directory entry
-	if (fseek(zipFile, zipOffset, SEEK_SET))
-		return -1;
-
-	// loop through all entries
-	for (i = 0; i < zipHandle->zipFileCount; i++) {
-		ZipDirectoryRecord *recDir   = (ZipDirectoryRecord *)workBuf;
-		DFextZipDirEntry   *dirEntry = &zipHandle->zipFileEntries[i];
-
-		// Find next directory entry, read it and verify signature
- 		if (fread(workBuf, 1, sizeof(ZipDirectoryRecord), zipFile) < sizeof(ZipDirectoryRecord)
-			|| recDir->signature != ZipDirectoryRecord_signature)
-			return -1;
-
-		// Skip extra info and store pointer at next entry
-		if (fseek(zipFile, recDir->extraFieldLength + recDir->fileCommentLength, SEEK_CUR))
-			return -1;
-
-		dirEntry->compressedSize    = recDir->compressedSize;
-		dirEntry->uncompressedSize  = recDir->uncompressedSize;
-		dirEntry->compressionMethod = recDir->compressionMethod;
-		dirEntry->offset            = recDir->relativeOffsetOflocalHeader;
-
-		// Add filename
-		dirEntry->fileName = xmalloc(recDir->fileNameLength + 1);
-		if (fread(dirEntry->fileName, 1, recDir->fileNameLength, zipFile) < (unsigned long)recDir->fileNameLength)
-			return -1;
-		dirEntry->fileName[recDir->fileNameLength] = '\0';
-	};
-
-	return 0;
+    unsigned long fileSize, readBytes;
+    unsigned char workBuf[4096];
+    int           i, zipOffset;
+
+
+    //***** Read EndRecord *****
+    // the EndRecord contains information, where the directory is located
+
+
+    // find end of file, and calculate size
+    if (fseek(zipFile, 0, SEEK_END)
+        || (fileSize = ftell(zipFile)) <= sizeof(ZipEndRecord))
+        return -1;
+
+    // Read size of workBuf of filesize from end of file to locate EndRecord
+    readBytes = (fileSize < sizeof(workBuf)) ? fileSize : sizeof(workBuf);
+    if (fseek(zipFile, fileSize - readBytes, SEEK_SET)
+        || fread(workBuf, 1, readBytes, zipFile) < readBytes)
+        return -1;
+
+    // search for EndRecord signature
+    for (i = readBytes - sizeof(ZipEndRecord); i >= 0; i--) {
+        ZipEndRecord *recEnd = (ZipEndRecord *)(workBuf + i);
+
+        // check if we have a signature
+        if (recEnd->signature == ZipEndRecord_signature) {
+            // update zipHandle
+            zipOffset                 = recEnd->centralDirectoryOffset;
+            zipHandle->zipFileCount   = recEnd->numEntries;
+            zipHandle->zipFileEntries = xmalloc(zipHandle->zipFileCount * sizeof(DFextZipDirEntry));
+            break;
+        }
+    }
+    if (i < 0)
+        return -1;
+
+
+    //***** Read Directory *****
+    // Each file has a global and a local entry, read both in a loop
+
+
+    // Find firs directory entry
+    if (fseek(zipFile, zipOffset, SEEK_SET))
+        return -1;
+
+    // loop through all entries
+    for (i = 0; i < zipHandle->zipFileCount; i++) {
+        ZipDirectoryRecord *recDir   = (ZipDirectoryRecord *)workBuf;
+        DFextZipDirEntry   *dirEntry = &zipHandle->zipFileEntries[i];
+
+        // Find next directory entry, read it and verify signature
+         if (fread(workBuf, 1, sizeof(ZipDirectoryRecord), zipFile) < sizeof(ZipDirectoryRecord)
+            || recDir->signature != ZipDirectoryRecord_signature)
+            return -1;
+
+        // Skip extra info and store pointer at next entry
+        if (fseek(zipFile, recDir->extraFieldLength + recDir->fileCommentLength, SEEK_CUR))
+            return -1;
+
+        dirEntry->compressedSize    = recDir->compressedSize;
+        dirEntry->uncompressedSize  = recDir->uncompressedSize;
+        dirEntry->compressionMethod = recDir->compressionMethod;
+        dirEntry->offset            = recDir->relativeOffsetOflocalHeader;
+
+        // Add filename
+        dirEntry->fileName = xmalloc(recDir->fileNameLength + 1);
+        if (fread(dirEntry->fileName, 1, recDir->fileNameLength, zipFile) < (unsigned long)recDir->fileNameLength)
+            return -1;
+        dirEntry->fileName[recDir->fileNameLength] = '\0';
+    };
+
+    return 0;
 }
 
 
 
 static void releaseMemory(DFextZipHandleP zipHandle) {
-	if (zipHandle) {
-		int count = zipHandle->zipCreateMode ? zipHandle->zipCreateMode : zipHandle->zipFileCount;
-		if (count) {
-			for (int i = 0; i < count; i++) {
-				DFextZipDirEntry *zipDirEntry = &zipHandle->zipFileEntries[i];
-				if (zipDirEntry->fileName != NULL)
-					free(zipDirEntry->fileName);
-			}
-			free(zipHandle->zipFileEntries);
-		}
-		free(zipHandle);
-	}
+    if (zipHandle) {
+        int count = zipHandle->zipCreateMode ? zipHandle->zipCreateMode : zipHandle->zipFileCount;
+        if (count) {
+            for (int i = 0; i < count; i++) {
+                DFextZipDirEntry *zipDirEntry = &zipHandle->zipFileEntries[i];
+                if (zipDirEntry->fileName != NULL)
+                    free(zipDirEntry->fileName);
+            }
+            free(zipHandle->zipFileEntries);
+        }
+        free(zipHandle);
+    }
 }
 
 
 
 static void writeGlobalDirAndEndRecord(DFextZipHandleP zipHandle) {
-	static const char comment[] = "generated by Corinthia";
-	ZipDirectoryRecord dirRecord;
-	ZipEndRecord	   endRecord;
-	int                i;
-
-
-	// Prepare constant part of records
-	endRecord.signature              = ZipEndRecord_signature;
-	endRecord.diskNumber             = endRecord.centralDirectoryDiskNumber = endRecord.numEntriesThisDisk = 0;
-	endRecord.numEntries             = zipHandle->zipFileCount;
-	endRecord.centralDirectoryOffset = ftell(zipHandle->zipFile);
-	endRecord.zipCommentLength       = strlen(comment);
-
-	dirRecord.signature              = ZipDirectoryRecord_signature;
-	dirRecord.versionMadeBy          = ZLIB_VERNUM;
-	dirRecord.versionNeededToExtract = dirRecord.generalPurposeBitFlag = dirRecord.lastModFileTime        =
-	dirRecord.lastModFileDate        = dirRecord.crc32                 = dirRecord.extraFieldLength       =
-	dirRecord.fileCommentLength      = dirRecord.diskNumberStart       = dirRecord.internalFileAttributes =
-	dirRecord.externalFileAttributes = 0;
-
-	// loop through all directory entries, write to disk while collecting size
-	endRecord.centralDirectorySize = 0;
-	for (i = 0; i < zipHandle->zipFileCount; i++) {
-		dirRecord.compressionMethod           = zipHandle->zipFileEntries[i].compressionMethod;
-		dirRecord.compressedSize              = zipHandle->zipFileEntries[i].compressedSize;
-		dirRecord.uncompressedSize            = zipHandle->zipFileEntries[i].uncompressedSize;
-		dirRecord.fileNameLength              = strlen(zipHandle->zipFileEntries[i].fileName);
-		dirRecord.relativeOffsetOflocalHeader = zipHandle->zipFileEntries[i].offset;
-		endRecord.centralDirectorySize       += sizeof(ZipDirectoryRecord) + dirRecord.fileNameLength;
-		fwrite(&dirRecord, 1, sizeof(ZipDirectoryRecord), zipHandle->zipFile);
-		fwrite(zipHandle->zipFileEntries[i].fileName, 1, dirRecord.fileNameLength, zipHandle->zipFile);
-	}
-
-	// and finally the end record
-	fwrite(&endRecord, 1, sizeof(ZipEndRecord), zipHandle->zipFile);
+    static const char comment[] = "generated by Corinthia";
+    ZipDirectoryRecord dirRecord;
+    ZipEndRecord       endRecord;
+    int                i;
+
+
+    // Prepare constant part of records
+    endRecord.signature              = ZipEndRecord_signature;
+    endRecord.diskNumber             = endRecord.centralDirectoryDiskNumber = endRecord.numEntriesThisDisk = 0;
+    endRecord.numEntries             = zipHandle->zipFileCount;
+    endRecord.centralDirectoryOffset = ftell(zipHandle->zipFile);
+    endRecord.zipCommentLength       = strlen(comment);
+
+    dirRecord.signature              = ZipDirectoryRecord_signature;
+    dirRecord.versionMadeBy          = ZLIB_VERNUM;
+    dirRecord.versionNeededToExtract = dirRecord.generalPurposeBitFlag = dirRecord.lastModFileTime        =
+    dirRecord.lastModFileDate        = dirRecord.crc32                 = dirRecord.extraFieldLength       =
+    dirRecord.fileCommentLength      = dirRecord.diskNumberStart       = dirRecord.internalFileAttributes =
+    dirRecord.externalFileAttributes = 0;
+
+    // loop through all directory entries, write to disk while collecting size
+    endRecord.centralDirectorySize = 0;
+    for (i = 0; i < zipHandle->zipFileCount; i++) {
+        dirRecord.compressionMethod           = zipHandle->zipFileEntries[i].compressionMethod;
+        dirRecord.compressedSize              = zipHandle->zipFileEntries[i].compressedSize;
+        dirRecord.uncompressedSize            = zipHandle->zipFileEntries[i].uncompressedSize;
+        dirRecord.fileNameLength              = strlen(zipHandle->zipFileEntries[i].fileName);
+        dirRecord.relativeOffsetOflocalHeader = zipHandle->zipFileEntries[i].offset;
+        endRecord.centralDirectorySize       += sizeof(ZipDirectoryRecord) + dirRecord.fileNameLength;
+        fwrite(&dirRecord, 1, sizeof(ZipDirectoryRecord), zipHandle->zipFile);
+        fwrite(zipHandle->zipFileEntries[i].fileName, 1, dirRecord.fileNameLength, zipHandle->zipFile);
+    }
+
+    // and finally the end record
+    fwrite(&endRecord, 1, sizeof(ZipEndRecord), zipHandle->zipFile);
 }
 
 
@@ -217,168 +217,168 @@ static void writeGlobalDirAndEndRecord(DFextZipHandleP zipHandle) {
 DFextZipHandleP DFextZipOpen(const char *zipFilename) {
     DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
 
-	// open zip file for reading
-	zipHandle->zipCreateMode = zipHandle->zipFileCount = 0;
-	zipHandle->zipFile       = fopen(zipFilename, "rb");
-	if (zipHandle->zipFile
-		&& !readDirectory(zipHandle->zipFile, zipHandle))
-		return zipHandle;
+    // open zip file for reading
+    zipHandle->zipCreateMode = zipHandle->zipFileCount = 0;
+    zipHandle->zipFile       = fopen(zipFilename, "rb");
+    if (zipHandle->zipFile
+        && !readDirectory(zipHandle->zipFile, zipHandle))
+        return zipHandle;
 
-	// release memory
+    // release memory
     releaseMemory(zipHandle);
     return NULL;
 }
 
 
 unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP zipEntry) {
-	unsigned char *fileBuf = xmalloc(zipEntry->uncompressedSize);
+    unsigned char *fileBuf = xmalloc(zipEntry->uncompressedSize);
     ZipFileHeader  recFile;
-	z_stream       strm;
-
-
-	// Position in front of file
-	if (fseek(zipHandle->zipFile, zipEntry->offset, SEEK_SET)
-		|| fread(&recFile, 1, sizeof(ZipFileHeader), zipHandle->zipFile) < sizeof(ZipFileHeader)
-		|| recFile.signature != ZipFileHeader_signature
-		|| fseek(zipHandle->zipFile, recFile.extraFieldLength + recFile.fileNameLength, SEEK_CUR)) {
-		free(fileBuf);
-		return NULL;
-	}
-
-	// interesting a zip file that is uncompressed, have to handle that
-	if (zipEntry->compressionMethod != Z_DEFLATED) {
-		if (fread(fileBuf, 1, zipEntry->uncompressedSize, zipHandle->zipFile) < (unsigned long)zipEntry->uncompressedSize
-			|| ferror(zipHandle->zipFile)) {
-			free(fileBuf);
-			fileBuf = NULL;
-		}
-		return fileBuf;
-	}
-
-
-	//***** Handle zlib inflate *****
-
-
-	strm.zalloc = Z_NULL;
-	strm.zfree = strm.opaque = strm.next_in = Z_NULL;
-	strm.avail_in = 0;
-
-	// Use inflateInit2 with negative window bits to indicate raw data
-	if (inflateInit2(&strm, -MAX_WBITS) != Z_OK) {
-		free(fileBuf);
-		return NULL;
-	}
-
-	// Read compressed data
-	unsigned char *comprBuf = xmalloc(zipEntry->compressedSize);
-	if (fread(comprBuf, 1, zipEntry->compressedSize, zipHandle->zipFile) < (unsigned long)zipEntry->compressedSize
-		|| ferror(zipHandle->zipFile)) {
-		free(fileBuf);
-		free(comprBuf);
-		return NULL;
-	}
-
-	// and inflate data
-	strm.avail_in  = zipEntry->compressedSize;
-	strm.next_in   = comprBuf;
-	strm.avail_out = zipEntry->uncompressedSize;
-	strm.next_out  = fileBuf;
-	if (inflate(&strm, Z_NO_FLUSH) == Z_STREAM_ERROR) {
-		free(fileBuf);
-		free(comprBuf);
-		return NULL;
-	}
-
-	free(comprBuf);
-	inflateEnd(&strm);
-	return fileBuf;
+    z_stream       strm;
+
+
+    // Position in front of file
+    if (fseek(zipHandle->zipFile, zipEntry->offset, SEEK_SET)
+        || fread(&recFile, 1, sizeof(ZipFileHeader), zipHandle->zipFile) < sizeof(ZipFileHeader)
+        || recFile.signature != ZipFileHeader_signature
+        || fseek(zipHandle->zipFile, recFile.extraFieldLength + recFile.fileNameLength, SEEK_CUR)) {
+        free(fileBuf);
+        return NULL;
+    }
+
+    // interesting a zip file that is uncompressed, have to handle that
+    if (zipEntry->compressionMethod != Z_DEFLATED) {
+        if (fread(fileBuf, 1, zipEntry->uncompressedSize, zipHandle->zipFile) < (unsigned long)zipEntry->uncompressedSize
+            || ferror(zipHandle->zipFile)) {
+            free(fileBuf);
+            fileBuf = NULL;
+        }
+        return fileBuf;
+    }
+
+
+    //***** Handle zlib inflate *****
+
+
+    strm.zalloc = Z_NULL;
+    strm.zfree = strm.opaque = strm.next_in = Z_NULL;
+    strm.avail_in = 0;
+
+    // Use inflateInit2 with negative window bits to indicate raw data
+    if (inflateInit2(&strm, -MAX_WBITS) != Z_OK) {
+        free(fileBuf);
+        return NULL;
+    }
+
+    // Read compressed data
+    unsigned char *comprBuf = xmalloc(zipEntry->compressedSize);
+    if (fread(comprBuf, 1, zipEntry->compressedSize, zipHandle->zipFile) < (unsigned long)zipEntry->compressedSize
+        || ferror(zipHandle->zipFile)) {
+        free(fileBuf);
+        free(comprBuf);
+        return NULL;
+    }
+
+    // and inflate data
+    strm.avail_in  = zipEntry->compressedSize;
+    strm.next_in   = comprBuf;
+    strm.avail_out = zipEntry->uncompressedSize;
+    strm.next_out  = fileBuf;
+    if (inflate(&strm, Z_NO_FLUSH) == Z_STREAM_ERROR) {
+        free(fileBuf);
+        free(comprBuf);
+        return NULL;
+    }
+
+    free(comprBuf);
+    inflateEnd(&strm);
+    return fileBuf;
 }
 
 
 
 DFextZipHandleP DFextZipCreate(const char *zipFilename) {
-	DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
-	int             memSize;
-	// Open file for write
-	if ((zipHandle->zipFile = fopen(zipFilename, "wb")) == NULL) {
-		free(zipHandle);
-		return NULL;
-	}
-
-	// prepare to add files
-	zipHandle->zipFileCount   = 0;
-	zipHandle->zipCreateMode  = FILECOUNT_ALLOC_SIZE;
-	memSize                   = zipHandle->zipCreateMode * sizeof(DFextZipDirEntry);
-
-	zipHandle->zipFileEntries = xmalloc(memSize);
-	bzero(zipHandle->zipFileEntries, memSize);
-	return zipHandle;
+    DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+    int             memSize;
+    // Open file for write
+    if ((zipHandle->zipFile = fopen(zipFilename, "wb")) == NULL) {
+        free(zipHandle);
+        return NULL;
+    }
+
+    // prepare to add files
+    zipHandle->zipFileCount   = 0;
+    zipHandle->zipCreateMode  = FILECOUNT_ALLOC_SIZE;
+    memSize                   = zipHandle->zipCreateMode * sizeof(DFextZipDirEntry);
+
+    zipHandle->zipFileEntries = xmalloc(memSize);
+    bzero(zipHandle->zipFileEntries, memSize);
+    return zipHandle;
 }
 
 
 
 DFextZipDirEntryP DFextZipWriteFile(DFextZipHandleP zipHandle, const char *fileName, const void *buf, const int len) {
-	z_stream       strm;
-	unsigned char *outbuf;
-	ZipFileHeader  header;
-	int            fileNameLength = strlen(fileName);
-
-	// do we have space for one more entry ?
-	if (zipHandle->zipFileCount >= zipHandle->zipCreateMode) {
-		zipHandle->zipCreateMode += FILECOUNT_ALLOC_SIZE;
-		zipHandle->zipFileEntries = xrealloc(zipHandle->zipFileEntries, zipHandle->zipCreateMode * sizeof(DFextZipDirEntry));
-		bzero(&zipHandle->zipFileEntries[zipHandle->zipFileCount], FILECOUNT_ALLOC_SIZE * sizeof(DFextZipDirEntry));
-	}
-
-	// prepare local and global file entry
-	DFextZipDirEntryP entryPtr = &zipHandle->zipFileEntries[zipHandle->zipFileCount++];
-	entryPtr->offset           = ftell(zipHandle->zipFile);
-	entryPtr->uncompressedSize = len;
-	entryPtr->fileName         = xmalloc(fileNameLength + 1);
-	strcpy(entryPtr->fileName, fileName);
-
-	// prepare to deflate
-	strm.zalloc = Z_NULL;
-	strm.zfree  = strm.opaque = strm.next_in = Z_NULL;
-	strm.avail_in = 0;
-	if (deflateInit(&strm, Z_DEFLATED) != Z_OK)
-		return NULL;
-
-	// deflate buffer
-	strm.avail_in = strm.avail_out = len;
-	strm.next_in  = buf;
-	strm.next_out = outbuf = xmalloc(len);
-	deflate(&strm, Z_FINISH);
-	deflateEnd(&strm);
-	entryPtr->compressedSize = len - strm.avail_out;
-
-	// prepare local header
-	header.versionNeededToExtract = header.generalPurposeBitFlag = header.lastModFileTime =
-	header.lastModFileDate        = header.extraFieldLength      = header.crc32 = 0;
-	header.signature              = ZipFileHeader_signature;
-	header.compressionMethod      = Z_DEFLATED;
-	header.compressedSize         = entryPtr->compressedSize;
-	header.uncompressedSize       = len;
-	header.fileNameLength         = fileNameLength;
-
-	// put data to file
-	fwrite(&header,            1, sizeof(header),        zipHandle->zipFile);
-	fwrite(entryPtr->fileName, 1, fileNameLength,        zipHandle->zipFile);
-	fwrite(outbuf,             1, header.compressedSize, zipHandle->zipFile);
-
-	// cleanup
-	free(outbuf);
-
-	return entryPtr;
+    z_stream       strm;
+    unsigned char *outbuf;
+    ZipFileHeader  header;
+    int            fileNameLength = strlen(fileName);
+
+    // do we have space for one more entry ?
+    if (zipHandle->zipFileCount >= zipHandle->zipCreateMode) {
+        zipHandle->zipCreateMode += FILECOUNT_ALLOC_SIZE;
+        zipHandle->zipFileEntries = xrealloc(zipHandle->zipFileEntries, zipHandle->zipCreateMode * sizeof(DFextZipDirEntry));
+        bzero(&zipHandle->zipFileEntries[zipHandle->zipFileCount], FILECOUNT_ALLOC_SIZE * sizeof(DFextZipDirEntry));
+    }
+
+    // prepare local and global file entry
+    DFextZipDirEntryP entryPtr = &zipHandle->zipFileEntries[zipHandle->zipFileCount++];
+    entryPtr->offset           = ftell(zipHandle->zipFile);
+    entryPtr->uncompressedSize = len;
+    entryPtr->fileName         = xmalloc(fileNameLength + 1);
+    strcpy(entryPtr->fileName, fileName);
+
+    // prepare to deflate
+    strm.zalloc = Z_NULL;
+    strm.zfree  = strm.opaque = strm.next_in = Z_NULL;
+    strm.avail_in = 0;
+    if (deflateInit(&strm, Z_DEFLATED) != Z_OK)
+        return NULL;
+
+    // deflate buffer
+    strm.avail_in = strm.avail_out = len;
+    strm.next_in  = buf;
+    strm.next_out = outbuf = xmalloc(len);
+    deflate(&strm, Z_FINISH);
+    deflateEnd(&strm);
+    entryPtr->compressedSize = len - strm.avail_out;
+
+    // prepare local header
+    header.versionNeededToExtract = header.generalPurposeBitFlag = header.lastModFileTime =
+    header.lastModFileDate        = header.extraFieldLength      = header.crc32 = 0;
+    header.signature              = ZipFileHeader_signature;
+    header.compressionMethod      = Z_DEFLATED;
+    header.compressedSize         = entryPtr->compressedSize;
+    header.uncompressedSize       = len;
+    header.fileNameLength         = fileNameLength;
+
+    // put data to file
+    fwrite(&header,            1, sizeof(header),        zipHandle->zipFile);
+    fwrite(entryPtr->fileName, 1, fileNameLength,        zipHandle->zipFile);
+    fwrite(outbuf,             1, header.compressedSize, zipHandle->zipFile);
+
+    // cleanup
+    free(outbuf);
+
+    return entryPtr;
 }
 
 
 
 void DFextZipClose(DFextZipHandleP zipHandle)
 {
-	if (zipHandle->zipFileCount)
-		writeGlobalDirAndEndRecord(zipHandle);
+    if (zipHandle->zipFileCount)
+        writeGlobalDirAndEndRecord(zipHandle);
 
-	fclose(zipHandle->zipFile);
-	releaseMemory(zipHandle);
+    fclose(zipHandle->zipFile);
+    releaseMemory(zipHandle);
 }

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/a146f6c7/DocFormats/platform/tests/WrapperTests.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/tests/WrapperTests.c b/DocFormats/platform/tests/WrapperTests.c
index 5a46786..9fabdb0 100644
--- a/DocFormats/platform/tests/WrapperTests.c
+++ b/DocFormats/platform/tests/WrapperTests.c
@@ -25,60 +25,60 @@
 
 
 static void doZip(char *name) {
-	DFextZipHandleP   zip;
-	DFextZipDirEntryP zipDir;
-	int               inp, out;
-	unsigned char    *fileBuf[20];
-	char              fileName[20][200];
-	int               fileLen[20];
-	char              tmpName[100];
-
-
-	zip = DFextZipOpen(name);
-	utassert((zip != NULL), "cannot open/read zip");
-
-	for (inp = 0; inp < zip->zipFileCount; inp++) {
-		strcpy(fileName[inp], zip->zipFileEntries[inp].fileName);
-		fileLen[inp] = zip->zipFileEntries[inp].uncompressedSize;
-		fileBuf[inp] = DFextZipReadFile(zip, &zip->zipFileEntries[inp]);
-		utassert((fileBuf[inp] != NULL), "cannot read file in zip");
-	}
-	DFextZipClose(zip);
-	zip = NULL;
-
-
-	sprintf(tmpName, "new_%s", name);
-	zip = DFextZipCreate(tmpName);
-	utassert((zip != NULL), "cannot create zip");
-
-	for (out = 0; out < inp; out++) {
-		zipDir = DFextZipWriteFile(zip, fileName[out], fileBuf[out], fileLen[out]);
-		utassert((zipDir != NULL), "cannot write file in zip");
-		free(fileBuf[out]);
-	}
-	DFextZipClose(zip);
+    DFextZipHandleP   zip;
+    DFextZipDirEntryP zipDir;
+    int               inp, out;
+    unsigned char    *fileBuf[20];
+    char              fileName[20][200];
+    int               fileLen[20];
+    char              tmpName[100];
+
+
+    zip = DFextZipOpen(name);
+    utassert((zip != NULL), "cannot open/read zip");
+
+    for (inp = 0; inp < zip->zipFileCount; inp++) {
+        strcpy(fileName[inp], zip->zipFileEntries[inp].fileName);
+        fileLen[inp] = zip->zipFileEntries[inp].uncompressedSize;
+        fileBuf[inp] = DFextZipReadFile(zip, &zip->zipFileEntries[inp]);
+        utassert((fileBuf[inp] != NULL), "cannot read file in zip");
+    }
+    DFextZipClose(zip);
+    zip = NULL;
+
+
+    sprintf(tmpName, "new_%s", name);
+    zip = DFextZipCreate(tmpName);
+    utassert((zip != NULL), "cannot create zip");
+
+    for (out = 0; out < inp; out++) {
+        zipDir = DFextZipWriteFile(zip, fileName[out], fileBuf[out], fileLen[out]);
+        utassert((zipDir != NULL), "cannot write file in zip");
+        free(fileBuf[out]);
+    }
+    DFextZipClose(zip);
 }
 
 
 
 static void test_DFextZipOOXML(void)
 {
-	doZip("test.docx");
+    doZip("test.docx");
 }
 
 
 
 static void test_DFextZipODF(void)
 {
-	doZip("test.odt");
+    doZip("test.odt");
 }
 
 
 
 TestGroup PlatformWrapperTests = {
     "platform.wrapper", {
-		    { "DFextZipOOXML", PlainTest, test_DFextZipOOXML },
-			{ "DFextZipODF",   PlainTest, test_DFextZipODF },
-			{ NULL,            PlainTest, NULL }
+            { "DFextZipOOXML", PlainTest, test_DFextZipOOXML },
+            { "DFextZipODF",   PlainTest, test_DFextZipODF },
+            { NULL,            PlainTest, NULL }
     }
 };