You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@corinthia.apache.org by Peter Kelly <ke...@gmail.com> on 2015/01/01 14:32:56 UTC

Re: incubator-corinthia git commit: Isolated minizip in platform, offering our own API to application. All references to the minizip directory have been removed from all CMakeFileList.txt (excapt platform) DFZipFile.c has been updated to use the new API. Nex

BTW just a minor note on the summary line - git —oneline and other similar tools (e.g. github) only recognise blank lines as paragraph separators; if there is a blank line after the summary then the summary will show as intended, otherwise the whole thing is treated as part of the summary “line”.

--
Dr. Peter M. Kelly
kellypmk@gmail.com
http://www.kellypmk.net/

PGP key: http://www.kellypmk.net/pgp-key <http://www.kellypmk.net/pgp-key>
(fingerprint 5435 6718 59F0 DD1F BFA0 5E46 2523 BAA1 44AE 2966)

> On 1 Jan 2015, at 8:28 pm, jani@apache.org wrote:
> 
> Repository: incubator-corinthia
> Updated Branches:
>  refs/heads/master c2d1a7513 -> 7710f0f24
> 
> 
> Isolated minizip in platform, offering our own API to application.
> All references to the minizip directory have been removed from all CMakeFileList.txt (excapt platform)
> DFZipFile.c has been updated to use the new API.
> Next step is to write unittest code for platform, so we can see the effect of removing minizip
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
> Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/7710f0f2
> Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/7710f0f2
> Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/7710f0f2
> 
> Branch: refs/heads/master
> Commit: 7710f0f24ef3b9a7ded94921518b2a7b1d3668ce
> Parents: c2d1a75
> Author: jani <ja...@apache.org>
> Authored: Thu Jan 1 14:20:45 2015 +0100
> Committer: jani <ja...@apache.org>
> Committed: Thu Jan 1 14:20:45 2015 +0100
> 
> ----------------------------------------------------------------------
> DocFormats/api/CMakeLists.txt             |   1 -
> DocFormats/core/CMakeLists.txt            |   1 -
> DocFormats/core/src/lib/DFZipFile.c       | 138 ++++++++++---------------
> DocFormats/filters/latex/CMakeLists.txt   |   1 -
> DocFormats/filters/odf/CMakeLists.txt     |   1 -
> DocFormats/filters/ooxml/CMakeLists.txt   |   1 -
> DocFormats/platform/CMakeLists.txt        |   8 +-
> DocFormats/platform/headers/DFPlatform.h  |  16 +++
> DocFormats/platform/src/Win32.c           |   4 +-
> DocFormats/platform/src/Wrapper.c         | 137 ++++++++++++++++++++++++
> DocFormats/platform/tests/OStests.c       |  64 ++++++++++++
> DocFormats/platform/tests/PlatformTests.c |  27 -----
> DocFormats/platform/tests/WrapperTests.c  |  83 +++++++++++++++
> DocFormats/unittest/CMakeLists.txt        |   1 -
> consumers/dftest/src/main.c               |   6 +-
> 15 files changed, 368 insertions(+), 121 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/api/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/api/CMakeLists.txt b/DocFormats/api/CMakeLists.txt
> index 8032b33..4df69cc 100644
> --- a/DocFormats/api/CMakeLists.txt
> +++ b/DocFormats/api/CMakeLists.txt
> @@ -44,7 +44,6 @@ set(GroupTests
> include_directories(/usr/include/libxml2)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> -include_directories(../../DocFormats/3rdparty/external/minizip)
> 
> include_directories(SYSTEM ${INCLUDE_DIRS})
> include_directories(SYSTEM ../api/headers)
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/core/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/core/CMakeLists.txt b/DocFormats/core/CMakeLists.txt
> index cfd46cc..9590118 100644
> --- a/DocFormats/core/CMakeLists.txt
> +++ b/DocFormats/core/CMakeLists.txt
> @@ -149,7 +149,6 @@ include_directories()
> include_directories(/usr/include/libxml2)
> include_directories(../../DocFormats/platform/3rdparty/w3c-tidy-html5/include)
> include_directories(../../DocFormats/platform/3rdparty//w3c-tidy-html5/src)
> -include_directories(../../DocFormats/platform/3rdparty/minizip)
> include_directories(SYSTEM ${INCLUDE_DIRS})
> include_directories(SYSTEM ../api/headers)
> include_directories(../platform/headers)
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/core/src/lib/DFZipFile.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
> index 651b43b..451934e 100644
> --- a/DocFormats/core/src/lib/DFZipFile.c
> +++ b/DocFormats/core/src/lib/DFZipFile.c
> @@ -13,8 +13,7 @@
> // limitations under the License.
> 
> #include "DFZipFile.h"
> -#include "unzip.h"
> -#include "zip.h"
> +#include "DFPlatform.h"
> #include "DFFilesystem.h"
> #include "DFString.h"
> #include "DFCommon.h"
> @@ -35,118 +34,95 @@ static int zipError(DFError **error, const char *format, ...)
> 
> int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
> {
> -    unzFile zipFile = unzOpen(zipFilename);
> -    if (zipFile == NULL)
> -        return zipError(error,"Cannot open file");
> +    char            entryName[4096];
> +    DFextZipHandleP zipHandle;
> +
> +    zipHandle = DFextZipOpen(zipFilename, 1);
> +    if (!zipHandle)
> +      return zipError(error,"Cannot open file");
> 
>     int ret;
> -    for (ret = unzGoToFirstFile(zipFile); ret == UNZ_OK; ret = unzGoToNextFile(zipFile)) {
> -        unz_file_info info;
> -        char entryName[4096];
> -        if (UNZ_OK != unzGetCurrentFileInfo(zipFile,&info,entryName,4096,NULL,0,NULL,0))
> -            return zipError(error,"Zip directory is corrupt");
> -
> -        if (!DFStringHasSuffix(entryName,"/")) {
> -            // Regular file
> -            if (UNZ_OK != unzOpenCurrentFile(zipFile))
> -                return zipError(error,"%s: Cannot open zip entry",entryName);;
> -
> -            DFBuffer *content = DFBufferNew();
> -
> -            unsigned char buf[4096];
> -            int r;
> -            while (0 < (r = unzReadCurrentFile(zipFile,buf,4096)))
> -                DFBufferAppendData(content,(void *)buf,r);
> -            if (0 > r) {
> -                DFBufferRelease(content);
> -                return zipError(error,"%s: decompression failed",entryName);
> -            }
> -
> -            if (UNZ_OK != unzCloseCurrentFile(zipFile)) {
> -                DFBufferRelease(content);
> -                return zipError(error,"%s: decompression failed",entryName);
> -            }
> -
> -            if (!DFBufferWriteToStorage(content,storage,entryName,error)) {
> -                DFBufferRelease(content);
> -                return zipError(error,"%s: %s",entryName,DFErrorMessage(error));
> -            }
> +    for (; (ret = DFextZipOpenNextFile(zipHandle, entryName, sizeof(entryName))) > 0;) {
> +        DFBuffer *content = DFBufferNew();
> +
> +        unsigned char buf[4096];
> +        int r;
> +        while (0 < (r = DFextZipReadCurrentFile(zipHandle, buf, sizeof(buf))))
> +            DFBufferAppendData(content,(void *)buf,r);
> +        if (0 > r) {
> +            DFBufferRelease(content);
> +            return zipError(error,"%s: decompression failed",entryName);
> +        }
> +
> +        if (DFextZipCloseFile(zipHandle) < 0) {
> +            DFBufferRelease(content);
> +            return zipError(error,"%s: decompression failed",entryName);
> +        }
> +
> +        if (!DFBufferWriteToStorage(content,storage,entryName,error)) {
>             DFBufferRelease(content);
> +            return zipError(error,"%s: %s",entryName,DFErrorMessage(error));
>         }
> +        DFBufferRelease(content);
>     }
> 
> -    if (UNZ_END_OF_LIST_OF_FILE != ret)
> +    if (ret < 0)
>         return zipError(error,"Zip directory is corrupt");
> 
> -    if (UNZ_OK != unzClose(zipFile))
> -        return zipError(error,"Cannot close file");
> +    DFextZipClose(zipHandle);
> 
>     return 1;
> }
> 
> -static int zipAddFile(zipFile zip, const char *dest, DFBuffer *content, DFError **error)
> +static int zipAddFile(DFextZipHandleP zipHandle, const char *dest, DFBuffer *content, DFError **error)
> {
> -    zip_fileinfo fileinfo;
> -    bzero(&fileinfo,sizeof(fileinfo));
> -
> -    if (ZIP_OK != zipOpenNewFileInZip(zip,
> -                                      dest,
> -                                      &fileinfo,
> -                                      NULL,0,
> -                                      NULL,0,
> -                                      NULL,
> -                                      Z_DEFLATED,
> -                                      Z_DEFAULT_COMPRESSION)) {
> +    if (DFextZipOpenNextFile(zipHandle, dest, 0) < 0)
>         return zipError(error,"%s: Cannot create entry in zip file",dest);
> -    }
> 
> -    if (ZIP_OK != zipWriteInFileInZip(zip,content->data,(unsigned int)content->len))
> +    if (DFextZipWriteCurrentFile(zipHandle, content->data, (unsigned int)content->len) < 0)
>         return zipError(error,"%s: Error writing to entry in zip file",dest);
> 
> -
> -    if (ZIP_OK != zipCloseFileInZip(zip))
> +    if (DFextZipCloseFile(zipHandle) <0)
>         return zipError(error,"%s: Error closing entry in zip file",dest);
> -
>     return 1;
> }
> 
> +
> +
> int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
> {
>     const char **allPaths = NULL;
> -    zipFile zip = NULL;
>     DFBuffer *content = NULL;
>     int ok = 0;
> +    DFextZipHandleP zipHandle;
> 
>     allPaths = DFStorageList(storage,error);
> -    if (allPaths == NULL)
> -        goto end;
> -
> -    zip = zipOpen(zipFilename,APPEND_STATUS_CREATE);
> -    if (zip == NULL) {
> -        DFErrorFormat(error,"Cannot create file");
> -        goto end;
> +    if (allPaths == NULL || !(zipHandle = DFextZipOpen(zipFilename, 0)))
> +    {
> +      DFErrorFormat(error,"Cannot create file");
>     }
> -
> -    for (int i = 0; allPaths[i]; i++) {
> -        const char *path = allPaths[i];
> -
> -        DFBufferRelease(content);
> -        content = DFBufferReadFromStorage(storage,path,error);
> -        if (content == NULL) {
> -            DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
> -            goto end;
> -        }
> -
> -        if (!zipAddFile(zip,path,content,error))
> -            goto end;
> +    else
> +    {
> +      for (int i = 0; allPaths[i]; i++) {
> +          const char *path = allPaths[i];
> +
> +          DFBufferRelease(content);
> +          content = DFBufferReadFromStorage(storage,path,error);
> +          if (content == NULL) {
> +              DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
> +              goto end;
> +          }
> +
> +          if (!zipAddFile(zipHandle, path, content, error))
> +              goto end;
> +      }
> +
> +      ok = 1;
>     }
> 
> -    ok = 1;
> -
> end:
>     DFBufferRelease(content);
>     free(allPaths);
> -    if ((zip != NULL) && (ZIP_OK != zipClose(zip,NULL)))
> -        return zipError(error,"Cannot close file");
> +    DFextZipClose(zipHandle);
>     return ok;
> }
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/filters/latex/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/filters/latex/CMakeLists.txt b/DocFormats/filters/latex/CMakeLists.txt
> index a02e559..0aca5e3 100644
> --- a/DocFormats/filters/latex/CMakeLists.txt
> +++ b/DocFormats/filters/latex/CMakeLists.txt
> @@ -31,7 +31,6 @@ include_directories()
> include_directories(/usr/include/libxml2)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> -include_directories(../../DocFormats/3rdparty/external/minizip)
> 
> include_directories(SYSTEM ${INCLUDE_DIRS})
> include_directories(SYSTEM ../../api/headers)
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/filters/odf/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/filters/odf/CMakeLists.txt b/DocFormats/filters/odf/CMakeLists.txt
> index fac5ee9..4673096 100644
> --- a/DocFormats/filters/odf/CMakeLists.txt
> +++ b/DocFormats/filters/odf/CMakeLists.txt
> @@ -37,7 +37,6 @@ include_directories()
> include_directories(/usr/include/libxml2)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> -include_directories(../../DocFormats/3rdparty/external/minizip)
> 
> include_directories(SYSTEM ${INCLUDE_DIRS})
> include_directories(SYSTEM ../../api/headers)
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/filters/ooxml/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/filters/ooxml/CMakeLists.txt b/DocFormats/filters/ooxml/CMakeLists.txt
> index 1c1a937..acc28c2 100644
> --- a/DocFormats/filters/ooxml/CMakeLists.txt
> +++ b/DocFormats/filters/ooxml/CMakeLists.txt
> @@ -123,7 +123,6 @@ include_directories()
> include_directories(/usr/include/libxml2)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> -include_directories(../../DocFormats/3rdparty/external/minizip)
> 
> include_directories(SYSTEM ${INCLUDE_DIRS})
> include_directories(SYSTEM ../../api/headers)
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/CMakeLists.txt b/DocFormats/platform/CMakeLists.txt
> index dcf9471..f3752e9 100644
> --- a/DocFormats/platform/CMakeLists.txt
> +++ b/DocFormats/platform/CMakeLists.txt
> @@ -99,10 +99,12 @@ set(GroupSrc
>     src/Apple.c
>     src/Linux.c
>     src/Unix.c
> -    src/Win32.c)
> +    src/Win32.c
> +    src/Wrapper.c)
> 
> set(GroupTests
> -    tests/PlatformTests.c)
> +    tests/OStests.c
> +    tests/WrapperTests.c)
> 
> 
> 
> @@ -125,7 +127,7 @@ include_directories(../unittest)
> ###
> add_library(platform OBJECT
>     ${GroupMinizip}
> -	${GroupHtml5}
> +    ${GroupHtml5}
>     ${GroupHeaders}
>     ${GroupSrc}
>     ${GroupTests})
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/headers/DFPlatform.h
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/headers/DFPlatform.h b/DocFormats/platform/headers/DFPlatform.h
> index a14350d..3d379d4 100755
> --- a/DocFormats/platform/headers/DFPlatform.h
> +++ b/DocFormats/platform/headers/DFPlatform.h
> @@ -34,4 +34,20 @@ typedef int DFOnce;
> typedef void (*DFOnceFunction)(void);
> void DFInitOnce(DFOnce *once, DFOnceFunction fun);
> 
> +// Zip functions
> +typedef struct {
> +        void *handle;
> +        int   zipFlag;
> +        int   zipFirst;
> +        } DFextZipHandle;
> +typedef DFextZipHandle * DFextZipHandleP;
> +
> +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip);
> +int             DFextZipClose(DFextZipHandleP zipHandle);
> +
> +int             DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName);
> +int             DFextZipCloseFile(DFextZipHandleP zipHandle);
> +
> +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const int maxLen);
> +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, char *buf, const int len);
> #endif
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/src/Win32.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/src/Win32.c b/DocFormats/platform/src/Win32.c
> index aa918da..d5a0ff5 100755
> --- a/DocFormats/platform/src/Win32.c
> +++ b/DocFormats/platform/src/Win32.c
> @@ -26,7 +26,7 @@
> #define snprintf _snprintf
> #endif
> 
> -void DFErrorMsgSetWin32(char **errmsg, DWORD code)
> +static void DFErrorMsgSetWin32(char **errmsg, DWORD code)
> {
>     if (errmsg == NULL)
>         return;
> @@ -62,7 +62,7 @@ static int testAndSet(int *var,int value,HANDLE lock)
>     return oldValue;
> }
> 
> -BOOL CALLBACK initOnceMutex(PINIT_ONCE initOnce,PVOID Parameter,PVOID *Context)
> +static BOOL CALLBACK initOnceMutex(PINIT_ONCE initOnce,PVOID Parameter,PVOID *Context)
> {
>     onceMutex = CreateMutex(NULL,FALSE,NULL);
>     return TRUE;
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/src/Wrapper.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
> new file mode 100644
> index 0000000..d27be99
> --- /dev/null
> +++ b/DocFormats/platform/src/Wrapper.c
> @@ -0,0 +1,137 @@
> +// Copyright 2012-2014 UX Productivity Pty Ltd
> +//
> +// Licensed under the Apache License, Version 2.0 (the "License");
> +// you may not use this file except in compliance with the License.
> +// You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +#include <string.h>
> +#include <stdlib.h>
> +#include "DFPlatform.h"
> +#include "unzip.h"
> +#include "zip.h"
> +
> +
> +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
> +    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
> + 
> +    // no more memory
> +    if (!zipHandle)
> +        return NULL;
> +
> +    // Open file
> +    zipHandle->zipFirst = 1;
> +    zipHandle->zipFlag = doUnzip;
> +    if (doUnzip)
> +        zipHandle->handle = unzOpen(zipFilename);
> +    else
> +        zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
> +
> +    if (zipHandle->handle)
> +        return zipHandle;
> +
> +    free(zipHandle);
> +    return NULL;
> +}
> +
> +
> +
> +int DFextZipClose(DFextZipHandleP zipHandle)
> +{
> +    int rc;
> +
> +    if (zipHandle->handle) {
> +        if (zipHandle->zipFlag)
> +            rc = (unzClose(zipHandle->handle) == UNZ_OK);
> +        else
> +            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
> +        zipHandle->handle = NULL;
> +    }
> +
> +    free(zipHandle);
> +    return rc ? 1 : -1;
> +}
> +
> +
> +
> +int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName)
> +{
> +    int rc;
> +
> +
> +    if (zipHandle->zipFlag) {
> +        unz_file_info info;
> +
> +        // handling of first file and all others are different
> +        if (zipHandle->zipFirst) {
> +            rc = unzGoToFirstFile(zipHandle->handle);
> +            zipHandle->zipFirst = 0;
> +        }
> +        else
> +            rc = unzGoToNextFile(zipHandle->handle);
> +
> +        // Error or past last file
> +        if (rc != UNZ_OK)
> +            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
> +
> +        // get file name
> +        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName, maxName, NULL, 0, NULL, 0) != UNZ_OK)
> +            return -1;
> +
> +        // check for prefix "/" and if present skip file
> +        if (entryName[strlen(entryName) - 1] == '/')
> +            return DFextZipOpenNextFile(zipHandle, entryName, maxName);
> +
> +        // open Regular file
> +        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
> +            return -1;
> +    }
> +    else {
> +        zip_fileinfo fileinfo;
> +        memset(&fileinfo, 0, sizeof(fileinfo));
> +
> +        if (zipOpenNewFileInZip(zipHandle->handle,
> +            entryName,
> +            &fileinfo,
> +            NULL, 0,
> +            NULL, 0,
> +            NULL,
> +            Z_DEFLATED,
> +            Z_DEFAULT_COMPRESSION) != ZIP_OK)
> +            return -1;
> +    }
> +
> +    // ready to read
> +    return 1;
> +}
> +
> +
> +
> +int DFextZipCloseFile(DFextZipHandleP zipHandle)
> +{
> +    if (zipHandle->zipFlag)
> +        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1 : 1;
> +    else
> +        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 : 1;
> +}
> +
> +
> + 
> +
> +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const int maxLen)
> +{
> +    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
> +}
> +
> +
> +
> +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, char *buf, const int len)
> +{
> +    return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
> +}
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/tests/OStests.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/tests/OStests.c b/DocFormats/platform/tests/OStests.c
> new file mode 100644
> index 0000000..4706916
> --- /dev/null
> +++ b/DocFormats/platform/tests/OStests.c
> @@ -0,0 +1,64 @@
> +// Copyright 2012-2014 UX Productivity Pty Ltd
> +//
> +// Licensed under the Apache License, Version 2.0 (the "License");
> +// you may not use this file except in compliance with the License.
> +// You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +
> +#include "DFUnitTest.h"
> +#include <stddef.h>
> +
> +
> +static void test_DFGetImageDimensions(void)
> +{
> +#if 0
> +    int DFGetImageDimensions(const void *data, size_t len, const char *ext,
> +        unsigned int *width, unsigned int *height, char **errmsg)
> +#endif
> +}
> +
> +
> +
> +static void test_DFInitOnce(void)
> +{
> +#if 0
> +    void DFInitOnce(DFOnce *once, DFOnceFunction fun)
> +#endif
> +}
> +
> +
> +
> +static void test_DFMkdirIfAbsent(void)
> +{
> +#if 0
> +    int DFMkdirIfAbsent(const char *path, char **errmsg)
> +#endif
> +}
> +
> +
> +
> +static void test_DFAddDirContents(void)
> +{
> +#if 0
> +    int DFAddDirContents(const char *absPath, const char *relPath, int recursive, DFDirEntryList ***list, char **errmsg)
> +#endif
> +}
> +
> +
> +
> +TestGroup PlatformOSTests = {
> +    "platform.os", {
> +        { "DFGetImageDimensions", PlainTest, test_DFGetImageDimensions },
> +        { "DFInitOnce",           PlainTest, test_DFInitOnce },
> +        { "DFMkdirIfAbsent",      PlainTest, test_DFMkdirIfAbsent },
> +        { "DFAddDirContents",     PlainTest, test_DFAddDirContents },
> +        { NULL,                   PlainTest, NULL }
> +    }
> +};
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/tests/PlatformTests.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/tests/PlatformTests.c b/DocFormats/platform/tests/PlatformTests.c
> deleted file mode 100644
> index b792dc3..0000000
> --- a/DocFormats/platform/tests/PlatformTests.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -// Copyright 2012-2014 UX Productivity Pty Ltd
> -//
> -// Licensed under the Apache License, Version 2.0 (the "License");
> -// you may not use this file except in compliance with the License.
> -// You may obtain a copy of the License at
> -//
> -// http://www.apache.org/licenses/LICENSE-2.0
> -//
> -// Unless required by applicable law or agreed to in writing, software
> -// distributed under the License is distributed on an "AS IS" BASIS,
> -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> -// See the License for the specific language governing permissions and
> -// limitations under the License.
> -
> -#include "DFUnitTest.h"
> -#include <stddef.h>
> -
> -static void test_sample(void)
> -{
> -}
> -
> -TestGroup PlatformTests = {
> -    "platform", {
> -        { "sample", PlainTest, test_sample },
> -        { NULL, PlainTest, NULL }
> -    }
> -};
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/tests/WrapperTests.c
> ----------------------------------------------------------------------
> diff --git a/DocFormats/platform/tests/WrapperTests.c b/DocFormats/platform/tests/WrapperTests.c
> new file mode 100644
> index 0000000..f2a8f2b
> --- /dev/null
> +++ b/DocFormats/platform/tests/WrapperTests.c
> @@ -0,0 +1,83 @@
> +// Copyright 2012-2014 UX Productivity Pty Ltd
> +//
> +// Licensed under the Apache License, Version 2.0 (the "License");
> +// you may not use this file except in compliance with the License.
> +// You may obtain a copy of the License at
> +//
> +// http://www.apache.org/licenses/LICENSE-2.0
> +//
> +// Unless required by applicable law or agreed to in writing, software
> +// distributed under the License is distributed on an "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +// See the License for the specific language governing permissions and
> +// limitations under the License.
> +#include "DFUnitTest.h"
> +#include <stddef.h>
> +
> +
> +
> +static void test_DFextZipOpen(void)
> +{
> +#if 0
> +    int DFextZipOpen(const char *zipFilename, int doUnzip) {
> +#endif
> +}
> +
> +
> +
> +static void test_DFextZipClose(void)
> +{
> +#if 0
> +    int DFextZipClose(void)
> +#endif
> +}
> +
> +
> +
> +static void test_DFextZipOpenNextFile(void)
> +{
> +#if 0
> +    int DFextZipOpenNextFile(char *entryName, const int maxName)
> +#endif
> +}
> +
> +
> +
> +static void test_DFextZipCloseFile(void)
> +{
> +#if 0
> +    int DFextZipCloseFile(void)
> +#endif
> +}
> +
> +
> +
> +static void test_DFextZipReadCurrentFile(void)
> +{
> +#if 0
> +    int DFextZipReadCurrentFile(char *buf, const int maxLen)
> +#endif
> +}
> +
> +
> +
> +static void test_DFextZipWriteCurrentFile(void)
> +{
> +#if 0
> +    int DFextZipWriteCurrentFile(char *buf, const int len)
> +#endif
> +}
> +
> +
> +
> +TestGroup PlatformWrapperTests = {
> +    "platform.wrapper", {
> +            { "DFextZipOpen",            PlainTest, test_DFextZipOpen   },
> +            { "DFextZipClose",           PlainTest, test_DFextZipClose },
> +            { "DFextZipOpenNextFile",    PlainTest, test_DFextZipOpenNextFile },
> +            { "DFextZipCloseFile",       PlainTest, test_DFextZipCloseFile },
> +            { "DFextZipReadCurrentFile", PlainTest, test_DFextZipReadCurrentFile },
> +            { "DFextZipWriteCurrentFile", PlainTest, test_DFextZipWriteCurrentFile },
> +            { NULL, PlainTest, NULL }
> +    }
> +};
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/unittest/CMakeLists.txt
> ----------------------------------------------------------------------
> diff --git a/DocFormats/unittest/CMakeLists.txt b/DocFormats/unittest/CMakeLists.txt
> index b780cd7..f1d7d7e 100644
> --- a/DocFormats/unittest/CMakeLists.txt
> +++ b/DocFormats/unittest/CMakeLists.txt
> @@ -28,7 +28,6 @@ include_directories()
> include_directories(/usr/include/libxml2)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> -include_directories(../../DocFormats/3rdparty/external/minizip)
> 
> include_directories(SYSTEM ${INCLUDE_DIRS})
> include_directories(SYSTEM ../api/headers)
> 
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/consumers/dftest/src/main.c
> ----------------------------------------------------------------------
> diff --git a/consumers/dftest/src/main.c b/consumers/dftest/src/main.c
> index e736e2f..737bf7f 100644
> --- a/consumers/dftest/src/main.c
> +++ b/consumers/dftest/src/main.c
> @@ -36,7 +36,8 @@ extern TestGroup XMLTests;
> extern TestGroup LaTeXTests;
> extern TestGroup ODFTests;
> extern TestGroup WordTests;
> -extern TestGroup PlatformTests;
> +extern TestGroup PlatformOSTests;
> +extern TestGroup PlatformWrapperTests;
> extern TestGroup BDTTests;
> 
> TestGroup *allGroups[] = {
> @@ -49,7 +50,8 @@ TestGroup *allGroups[] = {
>     &LaTeXTests,
>     &ODFTests,
>     &WordTests,
> -    &PlatformTests,
> +    &PlatformOSTests,
> +    &PlatformWrapperTests,
>     NULL
> };
> 
> 


Re: incubator-corinthia git commit: Isolated minizip in platform, offering our own API to application. All references to the minizip directory have been removed from all CMakeFileList.txt (excapt platform) DFZipFile.c has been updated to use the new API. Nex

Posted by jan i <ja...@apache.org>.
On 1 January 2015 at 14:32, Peter Kelly <ke...@gmail.com> wrote:

> BTW just a minor note on the summary line - git —oneline and other similar
> tools (e.g. github) only recognise blank lines as paragraph separators; if
> there is a blank line after the summary then the summary will show as
> intended, otherwise the whole thing is treated as part of the summary
> “line”.
>
Ups, forgot that, will remember it next time.
rgds
jan i.

>
> --
> Dr. Peter M. Kelly
> kellypmk@gmail.com
> http://www.kellypmk.net/
>
> PGP key: http://www.kellypmk.net/pgp-key <http://www.kellypmk.net/pgp-key>
> (fingerprint 5435 6718 59F0 DD1F BFA0 5E46 2523 BAA1 44AE 2966)
>
> > On 1 Jan 2015, at 8:28 pm, jani@apache.org wrote:
> >
> > Repository: incubator-corinthia
> > Updated Branches:
> >  refs/heads/master c2d1a7513 -> 7710f0f24
> >
> >
> > Isolated minizip in platform, offering our own API to application.
> > All references to the minizip directory have been removed from all
> CMakeFileList.txt (excapt platform)
> > DFZipFile.c has been updated to use the new API.
> > Next step is to write unittest code for platform, so we can see the
> effect of removing minizip
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/7710f0f2
> > Tree:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/7710f0f2
> > Diff:
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/7710f0f2
> >
> > Branch: refs/heads/master
> > Commit: 7710f0f24ef3b9a7ded94921518b2a7b1d3668ce
> > Parents: c2d1a75
> > Author: jani <ja...@apache.org>
> > Authored: Thu Jan 1 14:20:45 2015 +0100
> > Committer: jani <ja...@apache.org>
> > Committed: Thu Jan 1 14:20:45 2015 +0100
> >
> > ----------------------------------------------------------------------
> > DocFormats/api/CMakeLists.txt             |   1 -
> > DocFormats/core/CMakeLists.txt            |   1 -
> > DocFormats/core/src/lib/DFZipFile.c       | 138 ++++++++++---------------
> > DocFormats/filters/latex/CMakeLists.txt   |   1 -
> > DocFormats/filters/odf/CMakeLists.txt     |   1 -
> > DocFormats/filters/ooxml/CMakeLists.txt   |   1 -
> > DocFormats/platform/CMakeLists.txt        |   8 +-
> > DocFormats/platform/headers/DFPlatform.h  |  16 +++
> > DocFormats/platform/src/Win32.c           |   4 +-
> > DocFormats/platform/src/Wrapper.c         | 137 ++++++++++++++++++++++++
> > DocFormats/platform/tests/OStests.c       |  64 ++++++++++++
> > DocFormats/platform/tests/PlatformTests.c |  27 -----
> > DocFormats/platform/tests/WrapperTests.c  |  83 +++++++++++++++
> > DocFormats/unittest/CMakeLists.txt        |   1 -
> > consumers/dftest/src/main.c               |   6 +-
> > 15 files changed, 368 insertions(+), 121 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/api/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/api/CMakeLists.txt
> b/DocFormats/api/CMakeLists.txt
> > index 8032b33..4df69cc 100644
> > --- a/DocFormats/api/CMakeLists.txt
> > +++ b/DocFormats/api/CMakeLists.txt
> > @@ -44,7 +44,6 @@ set(GroupTests
> > include_directories(/usr/include/libxml2)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> > -include_directories(../../DocFormats/3rdparty/external/minizip)
> >
> > include_directories(SYSTEM ${INCLUDE_DIRS})
> > include_directories(SYSTEM ../api/headers)
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/core/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/core/CMakeLists.txt
> b/DocFormats/core/CMakeLists.txt
> > index cfd46cc..9590118 100644
> > --- a/DocFormats/core/CMakeLists.txt
> > +++ b/DocFormats/core/CMakeLists.txt
> > @@ -149,7 +149,6 @@ include_directories()
> > include_directories(/usr/include/libxml2)
> >
> include_directories(../../DocFormats/platform/3rdparty/w3c-tidy-html5/include)
> >
> include_directories(../../DocFormats/platform/3rdparty//w3c-tidy-html5/src)
> > -include_directories(../../DocFormats/platform/3rdparty/minizip)
> > include_directories(SYSTEM ${INCLUDE_DIRS})
> > include_directories(SYSTEM ../api/headers)
> > include_directories(../platform/headers)
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/core/src/lib/DFZipFile.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/core/src/lib/DFZipFile.c
> b/DocFormats/core/src/lib/DFZipFile.c
> > index 651b43b..451934e 100644
> > --- a/DocFormats/core/src/lib/DFZipFile.c
> > +++ b/DocFormats/core/src/lib/DFZipFile.c
> > @@ -13,8 +13,7 @@
> > // limitations under the License.
> >
> > #include "DFZipFile.h"
> > -#include "unzip.h"
> > -#include "zip.h"
> > +#include "DFPlatform.h"
> > #include "DFFilesystem.h"
> > #include "DFString.h"
> > #include "DFCommon.h"
> > @@ -35,118 +34,95 @@ static int zipError(DFError **error, const char
> *format, ...)
> >
> > int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
> > {
> > -    unzFile zipFile = unzOpen(zipFilename);
> > -    if (zipFile == NULL)
> > -        return zipError(error,"Cannot open file");
> > +    char            entryName[4096];
> > +    DFextZipHandleP zipHandle;
> > +
> > +    zipHandle = DFextZipOpen(zipFilename, 1);
> > +    if (!zipHandle)
> > +      return zipError(error,"Cannot open file");
> >
> >     int ret;
> > -    for (ret = unzGoToFirstFile(zipFile); ret == UNZ_OK; ret =
> unzGoToNextFile(zipFile)) {
> > -        unz_file_info info;
> > -        char entryName[4096];
> > -        if (UNZ_OK !=
> unzGetCurrentFileInfo(zipFile,&info,entryName,4096,NULL,0,NULL,0))
> > -            return zipError(error,"Zip directory is corrupt");
> > -
> > -        if (!DFStringHasSuffix(entryName,"/")) {
> > -            // Regular file
> > -            if (UNZ_OK != unzOpenCurrentFile(zipFile))
> > -                return zipError(error,"%s: Cannot open zip
> entry",entryName);;
> > -
> > -            DFBuffer *content = DFBufferNew();
> > -
> > -            unsigned char buf[4096];
> > -            int r;
> > -            while (0 < (r = unzReadCurrentFile(zipFile,buf,4096)))
> > -                DFBufferAppendData(content,(void *)buf,r);
> > -            if (0 > r) {
> > -                DFBufferRelease(content);
> > -                return zipError(error,"%s: decompression
> failed",entryName);
> > -            }
> > -
> > -            if (UNZ_OK != unzCloseCurrentFile(zipFile)) {
> > -                DFBufferRelease(content);
> > -                return zipError(error,"%s: decompression
> failed",entryName);
> > -            }
> > -
> > -            if
> (!DFBufferWriteToStorage(content,storage,entryName,error)) {
> > -                DFBufferRelease(content);
> > -                return zipError(error,"%s:
> %s",entryName,DFErrorMessage(error));
> > -            }
> > +    for (; (ret = DFextZipOpenNextFile(zipHandle, entryName,
> sizeof(entryName))) > 0;) {
> > +        DFBuffer *content = DFBufferNew();
> > +
> > +        unsigned char buf[4096];
> > +        int r;
> > +        while (0 < (r = DFextZipReadCurrentFile(zipHandle, buf,
> sizeof(buf))))
> > +            DFBufferAppendData(content,(void *)buf,r);
> > +        if (0 > r) {
> > +            DFBufferRelease(content);
> > +            return zipError(error,"%s: decompression failed",entryName);
> > +        }
> > +
> > +        if (DFextZipCloseFile(zipHandle) < 0) {
> > +            DFBufferRelease(content);
> > +            return zipError(error,"%s: decompression failed",entryName);
> > +        }
> > +
> > +        if (!DFBufferWriteToStorage(content,storage,entryName,error)) {
> >             DFBufferRelease(content);
> > +            return zipError(error,"%s:
> %s",entryName,DFErrorMessage(error));
> >         }
> > +        DFBufferRelease(content);
> >     }
> >
> > -    if (UNZ_END_OF_LIST_OF_FILE != ret)
> > +    if (ret < 0)
> >         return zipError(error,"Zip directory is corrupt");
> >
> > -    if (UNZ_OK != unzClose(zipFile))
> > -        return zipError(error,"Cannot close file");
> > +    DFextZipClose(zipHandle);
> >
> >     return 1;
> > }
> >
> > -static int zipAddFile(zipFile zip, const char *dest, DFBuffer *content,
> DFError **error)
> > +static int zipAddFile(DFextZipHandleP zipHandle, const char *dest,
> DFBuffer *content, DFError **error)
> > {
> > -    zip_fileinfo fileinfo;
> > -    bzero(&fileinfo,sizeof(fileinfo));
> > -
> > -    if (ZIP_OK != zipOpenNewFileInZip(zip,
> > -                                      dest,
> > -                                      &fileinfo,
> > -                                      NULL,0,
> > -                                      NULL,0,
> > -                                      NULL,
> > -                                      Z_DEFLATED,
> > -                                      Z_DEFAULT_COMPRESSION)) {
> > +    if (DFextZipOpenNextFile(zipHandle, dest, 0) < 0)
> >         return zipError(error,"%s: Cannot create entry in zip
> file",dest);
> > -    }
> >
> > -    if (ZIP_OK != zipWriteInFileInZip(zip,content->data,(unsigned
> int)content->len))
> > +    if (DFextZipWriteCurrentFile(zipHandle, content->data, (unsigned
> int)content->len) < 0)
> >         return zipError(error,"%s: Error writing to entry in zip
> file",dest);
> >
> > -
> > -    if (ZIP_OK != zipCloseFileInZip(zip))
> > +    if (DFextZipCloseFile(zipHandle) <0)
> >         return zipError(error,"%s: Error closing entry in zip
> file",dest);
> > -
> >     return 1;
> > }
> >
> > +
> > +
> > int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
> > {
> >     const char **allPaths = NULL;
> > -    zipFile zip = NULL;
> >     DFBuffer *content = NULL;
> >     int ok = 0;
> > +    DFextZipHandleP zipHandle;
> >
> >     allPaths = DFStorageList(storage,error);
> > -    if (allPaths == NULL)
> > -        goto end;
> > -
> > -    zip = zipOpen(zipFilename,APPEND_STATUS_CREATE);
> > -    if (zip == NULL) {
> > -        DFErrorFormat(error,"Cannot create file");
> > -        goto end;
> > +    if (allPaths == NULL || !(zipHandle = DFextZipOpen(zipFilename, 0)))
> > +    {
> > +      DFErrorFormat(error,"Cannot create file");
> >     }
> > -
> > -    for (int i = 0; allPaths[i]; i++) {
> > -        const char *path = allPaths[i];
> > -
> > -        DFBufferRelease(content);
> > -        content = DFBufferReadFromStorage(storage,path,error);
> > -        if (content == NULL) {
> > -            DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
> > -            goto end;
> > -        }
> > -
> > -        if (!zipAddFile(zip,path,content,error))
> > -            goto end;
> > +    else
> > +    {
> > +      for (int i = 0; allPaths[i]; i++) {
> > +          const char *path = allPaths[i];
> > +
> > +          DFBufferRelease(content);
> > +          content = DFBufferReadFromStorage(storage,path,error);
> > +          if (content == NULL) {
> > +              DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
> > +              goto end;
> > +          }
> > +
> > +          if (!zipAddFile(zipHandle, path, content, error))
> > +              goto end;
> > +      }
> > +
> > +      ok = 1;
> >     }
> >
> > -    ok = 1;
> > -
> > end:
> >     DFBufferRelease(content);
> >     free(allPaths);
> > -    if ((zip != NULL) && (ZIP_OK != zipClose(zip,NULL)))
> > -        return zipError(error,"Cannot close file");
> > +    DFextZipClose(zipHandle);
> >     return ok;
> > }
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/filters/latex/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/filters/latex/CMakeLists.txt
> b/DocFormats/filters/latex/CMakeLists.txt
> > index a02e559..0aca5e3 100644
> > --- a/DocFormats/filters/latex/CMakeLists.txt
> > +++ b/DocFormats/filters/latex/CMakeLists.txt
> > @@ -31,7 +31,6 @@ include_directories()
> > include_directories(/usr/include/libxml2)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> > -include_directories(../../DocFormats/3rdparty/external/minizip)
> >
> > include_directories(SYSTEM ${INCLUDE_DIRS})
> > include_directories(SYSTEM ../../api/headers)
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/filters/odf/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/filters/odf/CMakeLists.txt
> b/DocFormats/filters/odf/CMakeLists.txt
> > index fac5ee9..4673096 100644
> > --- a/DocFormats/filters/odf/CMakeLists.txt
> > +++ b/DocFormats/filters/odf/CMakeLists.txt
> > @@ -37,7 +37,6 @@ include_directories()
> > include_directories(/usr/include/libxml2)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> > -include_directories(../../DocFormats/3rdparty/external/minizip)
> >
> > include_directories(SYSTEM ${INCLUDE_DIRS})
> > include_directories(SYSTEM ../../api/headers)
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/filters/ooxml/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/filters/ooxml/CMakeLists.txt
> b/DocFormats/filters/ooxml/CMakeLists.txt
> > index 1c1a937..acc28c2 100644
> > --- a/DocFormats/filters/ooxml/CMakeLists.txt
> > +++ b/DocFormats/filters/ooxml/CMakeLists.txt
> > @@ -123,7 +123,6 @@ include_directories()
> > include_directories(/usr/include/libxml2)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> > -include_directories(../../DocFormats/3rdparty/external/minizip)
> >
> > include_directories(SYSTEM ${INCLUDE_DIRS})
> > include_directories(SYSTEM ../../api/headers)
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/CMakeLists.txt
> b/DocFormats/platform/CMakeLists.txt
> > index dcf9471..f3752e9 100644
> > --- a/DocFormats/platform/CMakeLists.txt
> > +++ b/DocFormats/platform/CMakeLists.txt
> > @@ -99,10 +99,12 @@ set(GroupSrc
> >     src/Apple.c
> >     src/Linux.c
> >     src/Unix.c
> > -    src/Win32.c)
> > +    src/Win32.c
> > +    src/Wrapper.c)
> >
> > set(GroupTests
> > -    tests/PlatformTests.c)
> > +    tests/OStests.c
> > +    tests/WrapperTests.c)
> >
> >
> >
> > @@ -125,7 +127,7 @@ include_directories(../unittest)
> > ###
> > add_library(platform OBJECT
> >     ${GroupMinizip}
> > -     ${GroupHtml5}
> > +    ${GroupHtml5}
> >     ${GroupHeaders}
> >     ${GroupSrc}
> >     ${GroupTests})
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/headers/DFPlatform.h
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/headers/DFPlatform.h
> b/DocFormats/platform/headers/DFPlatform.h
> > index a14350d..3d379d4 100755
> > --- a/DocFormats/platform/headers/DFPlatform.h
> > +++ b/DocFormats/platform/headers/DFPlatform.h
> > @@ -34,4 +34,20 @@ typedef int DFOnce;
> > typedef void (*DFOnceFunction)(void);
> > void DFInitOnce(DFOnce *once, DFOnceFunction fun);
> >
> > +// Zip functions
> > +typedef struct {
> > +        void *handle;
> > +        int   zipFlag;
> > +        int   zipFirst;
> > +        } DFextZipHandle;
> > +typedef DFextZipHandle * DFextZipHandleP;
> > +
> > +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip);
> > +int             DFextZipClose(DFextZipHandleP zipHandle);
> > +
> > +int             DFextZipOpenNextFile(DFextZipHandleP zipHandle, char
> *entryName, const int maxName);
> > +int             DFextZipCloseFile(DFextZipHandleP zipHandle);
> > +
> > +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const
> int maxLen);
> > +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, char *buf,
> const int len);
> > #endif
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/src/Win32.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/src/Win32.c
> b/DocFormats/platform/src/Win32.c
> > index aa918da..d5a0ff5 100755
> > --- a/DocFormats/platform/src/Win32.c
> > +++ b/DocFormats/platform/src/Win32.c
> > @@ -26,7 +26,7 @@
> > #define snprintf _snprintf
> > #endif
> >
> > -void DFErrorMsgSetWin32(char **errmsg, DWORD code)
> > +static void DFErrorMsgSetWin32(char **errmsg, DWORD code)
> > {
> >     if (errmsg == NULL)
> >         return;
> > @@ -62,7 +62,7 @@ static int testAndSet(int *var,int value,HANDLE lock)
> >     return oldValue;
> > }
> >
> > -BOOL CALLBACK initOnceMutex(PINIT_ONCE initOnce,PVOID Parameter,PVOID
> *Context)
> > +static BOOL CALLBACK initOnceMutex(PINIT_ONCE initOnce,PVOID
> Parameter,PVOID *Context)
> > {
> >     onceMutex = CreateMutex(NULL,FALSE,NULL);
> >     return TRUE;
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/src/Wrapper.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/src/Wrapper.c
> b/DocFormats/platform/src/Wrapper.c
> > new file mode 100644
> > index 0000000..d27be99
> > --- /dev/null
> > +++ b/DocFormats/platform/src/Wrapper.c
> > @@ -0,0 +1,137 @@
> > +// Copyright 2012-2014 UX Productivity Pty Ltd
> > +//
> > +// Licensed under the Apache License, Version 2.0 (the "License");
> > +// you may not use this file except in compliance with the License.
> > +// You may obtain a copy of the License at
> > +//
> > +// http://www.apache.org/licenses/LICENSE-2.0
> > +//
> > +// Unless required by applicable law or agreed to in writing, software
> > +// distributed under the License is distributed on an "AS IS" BASIS,
> > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > +// See the License for the specific language governing permissions and
> > +// limitations under the License.
> > +#include <string.h>
> > +#include <stdlib.h>
> > +#include "DFPlatform.h"
> > +#include "unzip.h"
> > +#include "zip.h"
> > +
> > +
> > +DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
> > +    DFextZipHandleP zipHandle = malloc(sizeof(DFextZipHandle));
> > +
> > +    // no more memory
> > +    if (!zipHandle)
> > +        return NULL;
> > +
> > +    // Open file
> > +    zipHandle->zipFirst = 1;
> > +    zipHandle->zipFlag = doUnzip;
> > +    if (doUnzip)
> > +        zipHandle->handle = unzOpen(zipFilename);
> > +    else
> > +        zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
> > +
> > +    if (zipHandle->handle)
> > +        return zipHandle;
> > +
> > +    free(zipHandle);
> > +    return NULL;
> > +}
> > +
> > +
> > +
> > +int DFextZipClose(DFextZipHandleP zipHandle)
> > +{
> > +    int rc;
> > +
> > +    if (zipHandle->handle) {
> > +        if (zipHandle->zipFlag)
> > +            rc = (unzClose(zipHandle->handle) == UNZ_OK);
> > +        else
> > +            rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
> > +        zipHandle->handle = NULL;
> > +    }
> > +
> > +    free(zipHandle);
> > +    return rc ? 1 : -1;
> > +}
> > +
> > +
> > +
> > +int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName,
> const int maxName)
> > +{
> > +    int rc;
> > +
> > +
> > +    if (zipHandle->zipFlag) {
> > +        unz_file_info info;
> > +
> > +        // handling of first file and all others are different
> > +        if (zipHandle->zipFirst) {
> > +            rc = unzGoToFirstFile(zipHandle->handle);
> > +            zipHandle->zipFirst = 0;
> > +        }
> > +        else
> > +            rc = unzGoToNextFile(zipHandle->handle);
> > +
> > +        // Error or past last file
> > +        if (rc != UNZ_OK)
> > +            return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
> > +
> > +        // get file name
> > +        if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName,
> maxName, NULL, 0, NULL, 0) != UNZ_OK)
> > +            return -1;
> > +
> > +        // check for prefix "/" and if present skip file
> > +        if (entryName[strlen(entryName) - 1] == '/')
> > +            return DFextZipOpenNextFile(zipHandle, entryName, maxName);
> > +
> > +        // open Regular file
> > +        if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
> > +            return -1;
> > +    }
> > +    else {
> > +        zip_fileinfo fileinfo;
> > +        memset(&fileinfo, 0, sizeof(fileinfo));
> > +
> > +        if (zipOpenNewFileInZip(zipHandle->handle,
> > +            entryName,
> > +            &fileinfo,
> > +            NULL, 0,
> > +            NULL, 0,
> > +            NULL,
> > +            Z_DEFLATED,
> > +            Z_DEFAULT_COMPRESSION) != ZIP_OK)
> > +            return -1;
> > +    }
> > +
> > +    // ready to read
> > +    return 1;
> > +}
> > +
> > +
> > +
> > +int DFextZipCloseFile(DFextZipHandleP zipHandle)
> > +{
> > +    if (zipHandle->zipFlag)
> > +        return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1
> : 1;
> > +    else
> > +        return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 :
> 1;
> > +}
> > +
> > +
> > +
> > +
> > +int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const
> int maxLen)
> > +{
> > +    return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
> > +}
> > +
> > +
> > +
> > +int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, char *buf,
> const int len)
> > +{
> > +    return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK)
> ? 1 : -1;
> > +}
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/tests/OStests.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/tests/OStests.c
> b/DocFormats/platform/tests/OStests.c
> > new file mode 100644
> > index 0000000..4706916
> > --- /dev/null
> > +++ b/DocFormats/platform/tests/OStests.c
> > @@ -0,0 +1,64 @@
> > +// Copyright 2012-2014 UX Productivity Pty Ltd
> > +//
> > +// Licensed under the Apache License, Version 2.0 (the "License");
> > +// you may not use this file except in compliance with the License.
> > +// You may obtain a copy of the License at
> > +//
> > +// http://www.apache.org/licenses/LICENSE-2.0
> > +//
> > +// Unless required by applicable law or agreed to in writing, software
> > +// distributed under the License is distributed on an "AS IS" BASIS,
> > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > +// See the License for the specific language governing permissions and
> > +// limitations under the License.
> > +
> > +#include "DFUnitTest.h"
> > +#include <stddef.h>
> > +
> > +
> > +static void test_DFGetImageDimensions(void)
> > +{
> > +#if 0
> > +    int DFGetImageDimensions(const void *data, size_t len, const char
> *ext,
> > +        unsigned int *width, unsigned int *height, char **errmsg)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFInitOnce(void)
> > +{
> > +#if 0
> > +    void DFInitOnce(DFOnce *once, DFOnceFunction fun)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFMkdirIfAbsent(void)
> > +{
> > +#if 0
> > +    int DFMkdirIfAbsent(const char *path, char **errmsg)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFAddDirContents(void)
> > +{
> > +#if 0
> > +    int DFAddDirContents(const char *absPath, const char *relPath, int
> recursive, DFDirEntryList ***list, char **errmsg)
> > +#endif
> > +}
> > +
> > +
> > +
> > +TestGroup PlatformOSTests = {
> > +    "platform.os", {
> > +        { "DFGetImageDimensions", PlainTest, test_DFGetImageDimensions
> },
> > +        { "DFInitOnce",           PlainTest, test_DFInitOnce },
> > +        { "DFMkdirIfAbsent",      PlainTest, test_DFMkdirIfAbsent },
> > +        { "DFAddDirContents",     PlainTest, test_DFAddDirContents },
> > +        { NULL,                   PlainTest, NULL }
> > +    }
> > +};
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/tests/PlatformTests.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/tests/PlatformTests.c
> b/DocFormats/platform/tests/PlatformTests.c
> > deleted file mode 100644
> > index b792dc3..0000000
> > --- a/DocFormats/platform/tests/PlatformTests.c
> > +++ /dev/null
> > @@ -1,27 +0,0 @@
> > -// Copyright 2012-2014 UX Productivity Pty Ltd
> > -//
> > -// Licensed under the Apache License, Version 2.0 (the "License");
> > -// you may not use this file except in compliance with the License.
> > -// You may obtain a copy of the License at
> > -//
> > -// http://www.apache.org/licenses/LICENSE-2.0
> > -//
> > -// Unless required by applicable law or agreed to in writing, software
> > -// distributed under the License is distributed on an "AS IS" BASIS,
> > -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > -// See the License for the specific language governing permissions and
> > -// limitations under the License.
> > -
> > -#include "DFUnitTest.h"
> > -#include <stddef.h>
> > -
> > -static void test_sample(void)
> > -{
> > -}
> > -
> > -TestGroup PlatformTests = {
> > -    "platform", {
> > -        { "sample", PlainTest, test_sample },
> > -        { NULL, PlainTest, NULL }
> > -    }
> > -};
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/platform/tests/WrapperTests.c
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/platform/tests/WrapperTests.c
> b/DocFormats/platform/tests/WrapperTests.c
> > new file mode 100644
> > index 0000000..f2a8f2b
> > --- /dev/null
> > +++ b/DocFormats/platform/tests/WrapperTests.c
> > @@ -0,0 +1,83 @@
> > +// Copyright 2012-2014 UX Productivity Pty Ltd
> > +//
> > +// Licensed under the Apache License, Version 2.0 (the "License");
> > +// you may not use this file except in compliance with the License.
> > +// You may obtain a copy of the License at
> > +//
> > +// http://www.apache.org/licenses/LICENSE-2.0
> > +//
> > +// Unless required by applicable law or agreed to in writing, software
> > +// distributed under the License is distributed on an "AS IS" BASIS,
> > +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > +// See the License for the specific language governing permissions and
> > +// limitations under the License.
> > +#include "DFUnitTest.h"
> > +#include <stddef.h>
> > +
> > +
> > +
> > +static void test_DFextZipOpen(void)
> > +{
> > +#if 0
> > +    int DFextZipOpen(const char *zipFilename, int doUnzip) {
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFextZipClose(void)
> > +{
> > +#if 0
> > +    int DFextZipClose(void)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFextZipOpenNextFile(void)
> > +{
> > +#if 0
> > +    int DFextZipOpenNextFile(char *entryName, const int maxName)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFextZipCloseFile(void)
> > +{
> > +#if 0
> > +    int DFextZipCloseFile(void)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFextZipReadCurrentFile(void)
> > +{
> > +#if 0
> > +    int DFextZipReadCurrentFile(char *buf, const int maxLen)
> > +#endif
> > +}
> > +
> > +
> > +
> > +static void test_DFextZipWriteCurrentFile(void)
> > +{
> > +#if 0
> > +    int DFextZipWriteCurrentFile(char *buf, const int len)
> > +#endif
> > +}
> > +
> > +
> > +
> > +TestGroup PlatformWrapperTests = {
> > +    "platform.wrapper", {
> > +            { "DFextZipOpen",            PlainTest, test_DFextZipOpen
>  },
> > +            { "DFextZipClose",           PlainTest, test_DFextZipClose
> },
> > +            { "DFextZipOpenNextFile",    PlainTest,
> test_DFextZipOpenNextFile },
> > +            { "DFextZipCloseFile",       PlainTest,
> test_DFextZipCloseFile },
> > +            { "DFextZipReadCurrentFile", PlainTest,
> test_DFextZipReadCurrentFile },
> > +            { "DFextZipWriteCurrentFile", PlainTest,
> test_DFextZipWriteCurrentFile },
> > +            { NULL, PlainTest, NULL }
> > +    }
> > +};
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/DocFormats/unittest/CMakeLists.txt
> > ----------------------------------------------------------------------
> > diff --git a/DocFormats/unittest/CMakeLists.txt
> b/DocFormats/unittest/CMakeLists.txt
> > index b780cd7..f1d7d7e 100644
> > --- a/DocFormats/unittest/CMakeLists.txt
> > +++ b/DocFormats/unittest/CMakeLists.txt
> > @@ -28,7 +28,6 @@ include_directories()
> > include_directories(/usr/include/libxml2)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/include)
> >
> include_directories(../../DocFormats/3rdparty/external/w3c-tidy-html5/src)
> > -include_directories(../../DocFormats/3rdparty/external/minizip)
> >
> > include_directories(SYSTEM ${INCLUDE_DIRS})
> > include_directories(SYSTEM ../api/headers)
> >
> >
> http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7710f0f2/consumers/dftest/src/main.c
> > ----------------------------------------------------------------------
> > diff --git a/consumers/dftest/src/main.c b/consumers/dftest/src/main.c
> > index e736e2f..737bf7f 100644
> > --- a/consumers/dftest/src/main.c
> > +++ b/consumers/dftest/src/main.c
> > @@ -36,7 +36,8 @@ extern TestGroup XMLTests;
> > extern TestGroup LaTeXTests;
> > extern TestGroup ODFTests;
> > extern TestGroup WordTests;
> > -extern TestGroup PlatformTests;
> > +extern TestGroup PlatformOSTests;
> > +extern TestGroup PlatformWrapperTests;
> > extern TestGroup BDTTests;
> >
> > TestGroup *allGroups[] = {
> > @@ -49,7 +50,8 @@ TestGroup *allGroups[] = {
> >     &LaTeXTests,
> >     &ODFTests,
> >     &WordTests,
> > -    &PlatformTests,
> > +    &PlatformOSTests,
> > +    &PlatformWrapperTests,
> >     NULL
> > };
> >
> >
>
>