You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by pm...@apache.org on 2015/01/02 14:50:10 UTC

[01/10] incubator-corinthia git commit: added copy of zlib1.dll the extract script did not copy the zlib1.dll

Repository: incubator-corinthia
Updated Branches:
  refs/heads/stable 74030263b -> d23ccd545


added copy of zlib1.dll
the extract script did not copy the zlib1.dll


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

Branch: refs/heads/stable
Commit: e83dc5927e4b9aed0719357952b492e204367eee
Parents: 7403026
Author: jani <ja...@apache.org>
Authored: Tue Dec 30 20:12:14 2014 +0100
Committer: jani <ja...@apache.org>
Committed: Tue Dec 30 20:12:14 2014 +0100

----------------------------------------------------------------------
 external/extract_downloads.sh | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/e83dc592/external/extract_downloads.sh
----------------------------------------------------------------------
diff --git a/external/extract_downloads.sh b/external/extract_downloads.sh
index 0d151e3..38b9d6e 100755
--- a/external/extract_downloads.sh
+++ b/external/extract_downloads.sh
@@ -41,5 +41,6 @@ mv packages/libxml2/libxml2-2.7.8.win32/bin/* bin
 
 mv packages/zlib/include/* include
 mv packages/zlib/lib/* lib
+mv packages/zlib/*.dll bin
 
 rm -rf packages


[07/10] incubator-corinthia git commit: Add DFextZipAppendNewFile

Posted by pm...@apache.org.
Add DFextZipAppendNewFile

A handle to a zip file is either in read-only mode, or write-only mode
(as determined by the zipFlag field of the object). In the former case,
DFextZipOpenNextFile opens an existing file for reading at the next
position in the file. In the latter case, it created a new file at the
end of the zip file for writing.

When reading the next entry, the entryName parameter must be writable -
that's how the name is passed back to the caller. As such, the caller
provides a writable string, consisting of a char * and a maximum length.
In this case, the parameter types are ok.

When writing the next entry, the entryName parameter plays the opposite
role - it is the caller telling the function what name to give to the
new file. In what is currently the only place where this is called,
zipAddFile in DFZipFile.c, the filename is a read-only string (const
char *). Although the DFextZipOpenNextFile didn't actually overwrite the
string in the case of a write-only zip stream, the compiler would warn
that a value of const char * was being supplied to a function expecting
a char * value (that is, a read-only string being supplied where a
writable string parameter was expected).

This commit splits DFextZipOpenNextFile into two functions -
DFextZipOpenNextFile for reading and DFextZipAppendNewFile for writing.
The latter accepts a read-only string, and thus doesn't generate a
compiler warning.


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

Branch: refs/heads/stable
Commit: f93d1a5a691d62e3f3e0374328d50b66147b5ac0
Parents: c1c87be
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Fri Jan 2 20:31:39 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Fri Jan 2 20:31:39 2015 +0700

----------------------------------------------------------------------
 DocFormats/core/src/lib/DFZipFile.c      |  2 +-
 DocFormats/platform/headers/DFPlatform.h |  1 +
 DocFormats/platform/src/Wrapper.c        | 33 +++++++++++++++++----------
 3 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/f93d1a5a/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index 451934e..1057ad0 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -76,7 +76,7 @@ int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
 
 static int zipAddFile(DFextZipHandleP zipHandle, const char *dest, DFBuffer *content, DFError **error)
 {
-    if (DFextZipOpenNextFile(zipHandle, dest, 0) < 0)
+    if (DFextZipAppendNewFile(zipHandle, dest) < 0)
         return zipError(error,"%s: Cannot create entry in zip file",dest);
 
     if (DFextZipWriteCurrentFile(zipHandle, content->data, (unsigned int)content->len) < 0)

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/f93d1a5a/DocFormats/platform/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/headers/DFPlatform.h b/DocFormats/platform/headers/DFPlatform.h
index 3d379d4..1e83b2c 100755
--- a/DocFormats/platform/headers/DFPlatform.h
+++ b/DocFormats/platform/headers/DFPlatform.h
@@ -46,6 +46,7 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip);
 int             DFextZipClose(DFextZipHandleP zipHandle);
 
 int             DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName);
+int             DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName);
 int             DFextZipCloseFile(DFextZipHandleP zipHandle);
 
 int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const int maxLen);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/f93d1a5a/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index 1701d9d..26dc413 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -93,25 +93,34 @@ int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int m
             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;
+        return -1; // Zip file is open in write-only mode
     }
 
     // ready to read
     return 1;
 }
 
+int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
+{
+    zip_fileinfo fileinfo;
+    memset(&fileinfo, 0, sizeof(fileinfo));
 
+    if (zipHandle->zipFlag)
+        return -1; // Zip file is open in read-only mode
+
+    if (zipOpenNewFileInZip(zipHandle->handle,
+                            entryName,
+                            &fileinfo,
+                            NULL, 0,
+                            NULL, 0,
+                            NULL,
+                            Z_DEFLATED,
+                            Z_DEFAULT_COMPRESSION) != ZIP_OK) {
+        return -1;
+    }
+
+    return 1;
+}
 
 int DFextZipCloseFile(DFextZipHandleP zipHandle)
 {


[09/10] incubator-corinthia git commit: DFUnzip: Fix warning about unsigned char * cast

Posted by pm...@apache.org.
DFUnzip: Fix warning about unsigned char * cast

The DFextZipReadCurrentFile function expected a char * parameter, but we
were passing in an unsigned char *, resulting in a compiler warning.

This commit changes DFextZipReadCurrentFile to instead take a void *
parameter, and similarly DFextZipWriteCurrentFile to take a const void *
parameter. This allows any pointer types to be used with the functions.


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

Branch: refs/heads/stable
Commit: f27803f4c0f0336c5f5df5fb7bd5d396bc74de65
Parents: 69a8028
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Fri Jan 2 20:39:12 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Fri Jan 2 20:39:12 2015 +0700

----------------------------------------------------------------------
 DocFormats/platform/headers/DFPlatform.h | 4 ++--
 DocFormats/platform/src/Wrapper.c        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/f27803f4/DocFormats/platform/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/headers/DFPlatform.h b/DocFormats/platform/headers/DFPlatform.h
index 1e83b2c..6f16983 100755
--- a/DocFormats/platform/headers/DFPlatform.h
+++ b/DocFormats/platform/headers/DFPlatform.h
@@ -49,6 +49,6 @@ int             DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName,
 int             DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName);
 int             DFextZipCloseFile(DFextZipHandleP zipHandle);
 
-int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const int maxLen);
-int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, char *buf, const int len);
+int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen);
+int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len);
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/f27803f4/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index 26dc413..14ed093 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -133,14 +133,14 @@ int DFextZipCloseFile(DFextZipHandleP zipHandle)
 
  
 
-int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, char *buf, const int maxLen)
+int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen)
 {
     return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
 }
 
 
 
-int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, char *buf, const int len)
+int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
 {
     return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
 }


[10/10] incubator-corinthia git commit: Merge branch 'master' into stable

Posted by pm...@apache.org.
Merge branch 'master' into stable


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

Branch: refs/heads/stable
Commit: d23ccd545719be712337c6874775c31cc5681a35
Parents: 7403026 f27803f
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Fri Jan 2 20:49:55 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Fri Jan 2 20:49:55 2015 +0700

----------------------------------------------------------------------
 DocFormats/api/CMakeLists.txt             |   1 -
 DocFormats/core/CMakeLists.txt            |   1 -
 DocFormats/core/src/lib/DFZipFile.c       | 139 ++++++++---------
 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  |  17 +++
 DocFormats/platform/src/Win32.c           |   4 +-
 DocFormats/platform/src/Wrapper.c         | 146 ++++++++++++++++++
 DocFormats/platform/tests/OStests.c       | 197 +++++++++++++++++++++++++
 DocFormats/platform/tests/PlatformTests.c |  27 ----
 DocFormats/platform/tests/WrapperTests.c  |  83 +++++++++++
 DocFormats/unittest/CMakeLists.txt        |   1 -
 consumers/dftest/src/main.c               |   6 +-
 external/extract_downloads.sh             |   1 +
 external/fetch_downloads.bat              |  32 ++++
 external/wget-win.js                      |  30 ++++
 18 files changed, 575 insertions(+), 121 deletions(-)
----------------------------------------------------------------------



[05/10] incubator-corinthia git commit: Explain parameters to wget-win.js

Posted by pm...@apache.org.
Explain parameters to wget-win.js

Explanatory comments added to set the preconditions on  the parameters
to wget-win.js


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

Branch: refs/heads/stable
Commit: 7208df5c40afebb05d4cd7b1e22a619af0369fc8
Parents: 18b4c24
Author: Dennis Hamilton <or...@apache.org>
Authored: Wed Dec 31 16:29:24 2014 -0800
Committer: Dennis Hamilton <or...@apache.org>
Committed: Thu Jan 1 12:11:16 2015 -0800

----------------------------------------------------------------------
 external/wget-win.js | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/7208df5c/external/wget-win.js
----------------------------------------------------------------------
diff --git a/external/wget-win.js b/external/wget-win.js
index af0e07b..731d6d9 100644
--- a/external/wget-win.js
+++ b/external/wget-win.js
@@ -7,6 +7,11 @@
  *
  * This script is designed to be used from the fetch_downloads.bat file
  * That should be nearby in the same directory.
+ *
+ * With   Cscript wget-win.js url file
+ *
+ *            url is the absolute URL of the file to download
+ *           file is the full-path file address to store the download at
  */
 
 var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");


[08/10] incubator-corinthia git commit: DFZip: Fix uninitialised variable warning

Posted by pm...@apache.org.
DFZip: Fix uninitialised variable warning


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

Branch: refs/heads/stable
Commit: 69a802864f077258bc733426e95e9a9b2814876f
Parents: f93d1a5
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Fri Jan 2 20:37:26 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Fri Jan 2 20:37:26 2015 +0700

----------------------------------------------------------------------
 DocFormats/core/src/lib/DFZipFile.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/69a80286/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index 1057ad0..8bc0bcb 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -94,7 +94,7 @@ int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
     const char **allPaths = NULL;
     DFBuffer *content = NULL;
     int ok = 0;
-    DFextZipHandleP zipHandle;
+    DFextZipHandleP zipHandle = NULL;
 
     allPaths = DFStorageList(storage,error);
     if (allPaths == NULL || !(zipHandle = DFextZipOpen(zipFilename, 0)))
@@ -123,6 +123,7 @@ int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
 end:
     DFBufferRelease(content);
     free(allPaths);
-    DFextZipClose(zipHandle);
+    if (zipHandle != NULL)
+        DFextZipClose(zipHandle);
     return ok;
 }


[02/10] incubator-corinthia git commit: Add Windows fetch_downloads.bat

Posted by pm...@apache.org.
Add Windows fetch_downloads.bat

The script downloads all of the external source archives via HTTP using
the auxiliary jScript file, wget-win.js


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

Branch: refs/heads/stable
Commit: c2d1a7513c5cf502b1e4b4e3ab964b4fb7219e06
Parents: e83dc59
Author: Dennis Hamilton <or...@apache.org>
Authored: Tue Dec 30 19:25:29 2014 -0800
Committer: Dennis Hamilton <or...@apache.org>
Committed: Tue Dec 30 19:25:29 2014 -0800

----------------------------------------------------------------------
 external/fetch_downloads.bat | 32 ++++++++++++++++++++++++++++++++
 external/wget-win.js         | 25 +++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/c2d1a751/external/fetch_downloads.bat
----------------------------------------------------------------------
diff --git a/external/fetch_downloads.bat b/external/fetch_downloads.bat
new file mode 100644
index 0000000..0663217
--- /dev/null
+++ b/external/fetch_downloads.bat
@@ -0,0 +1,32 @@
+@echo off
+rem fetch_downloads.bat               UTF-8
+rem   FETCH EXTERNAL ARCHIVES FOR NATIVE WINDOWS BUILDS OF CORINTHIA
+
+mkdir %~dp0download
+rem Make download directory at same location as this script.
+rem It does not matter if the directory already exists.
+
+rem  MAINTAIN THIS LIST MANUALLY
+CALL :FETCH "http://zlib.net/zlib128-dll.zip"
+CALL :FETCH "http://xmlsoft.org/sources/win32/iconv-1.9.2.win32.zip"
+CALL :FETCH "http://xmlsoft.org/sources/win32/libxml2-2.7.8.win32.zip"
+CALL :FETCH "https://www.libsdl.org/release/SDL2-devel-2.0.3-VC.zip"
+CALL :FETCH  "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-devel-2.0.0-VC.zip"
+EXIT /B 0
+rem TODO
+rem  * Might want to pass up and act on error codes from the individual
+rem    :FETCH operations.
+rem  * It might be handy to fetch these URLs from a file so that it can
+rem    be kept maintained in one place, even though the win32 cases are
+rem    unique to building for Windows.
+rem XXX
+rem  * wget-win.js does not do FTP.  So alternative locations have been
+rem    used for iconv and libmxl2.
+
+:FETCH
+IF EXIST "%~dp0download\%~n1%~x1" EXIT /B 0
+rem do not download an archive that is already present.
+ECHO "%~n1%~x1"
+Cscript /nologo "%~dp0wget-win.js" //B "%1" "%~dp0download\%~n1%~x1"
+EXIT /B 0
+

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/c2d1a751/external/wget-win.js
----------------------------------------------------------------------
diff --git a/external/wget-win.js b/external/wget-win.js
new file mode 100644
index 0000000..af0e07b
--- /dev/null
+++ b/external/wget-win.js
@@ -0,0 +1,25 @@
+/* wget-win.js                        UTF-8
+ * Windows JScript for downloading from the URL in the first argument
+ * to the file in the second argument.
+ *
+ * Adapted from wget.js at <http://superuser.com/a/536400/81303> created by
+ * unregistered user190042 and last edited 2013-01-15T08:48.
+ *
+ * This script is designed to be used from the fetch_downloads.bat file
+ * That should be nearby in the same directory.
+ */
+
+var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
+WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false);
+WinHttpReq.Send();
+
+/* All files are downloaded as binary */
+BinStream = new ActiveXObject("ADODB.Stream");
+BinStream.Type = 1;
+BinStream.Open();
+BinStream.Write(WinHttpReq.ResponseBody);
+BinStream.SaveToFile(WScript.Arguments(1));
+
+/*                      *** end of wget-win.js ***                         */
+
+


[03/10] 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

Posted by pm...@apache.org.
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/stable
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
 };
 


[04/10] incubator-corinthia git commit: Added platform.os unittest

Posted by pm...@apache.org.
Added platform.os unittest

./dftest -plain platform.os
will activate the new test cases.


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

Branch: refs/heads/stable
Commit: 18b4c2468623b24b1ad0b1f1081b8a4b15ebbd1f
Parents: 7710f0f
Author: jani <ja...@apache.org>
Authored: Thu Jan 1 18:48:42 2015 +0100
Committer: jani <ja...@apache.org>
Committed: Thu Jan 1 18:48:42 2015 +0100

----------------------------------------------------------------------
 DocFormats/platform/tests/OStests.c | 171 +++++++++++++++++++++++++++----
 1 file changed, 152 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/18b4c246/DocFormats/platform/tests/OStests.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/tests/OStests.c b/DocFormats/platform/tests/OStests.c
index 4706916..b659275 100644
--- a/DocFormats/platform/tests/OStests.c
+++ b/DocFormats/platform/tests/OStests.c
@@ -13,52 +13,185 @@
 // limitations under the License.
 
 #include "DFUnitTest.h"
+#include "DFPlatform.h"
 #include <stddef.h>
+#ifdef WIN32
+#include <direct.h>
+#else
+#include <unistd.h>
+#endif
 
 
-static void test_DFGetImageDimensions(void)
+static void test_DFGetImageDimensions_gif(void)
 {
-#if 0
-    int DFGetImageDimensions(const void *data, size_t len, const char *ext,
-        unsigned int *width, unsigned int *height, char **errmsg)
-#endif
+    // Bullet.gif 21x15
+    static unsigned char data_bullet[] = {
+        0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x15, 0x00, 0x0F, 0x00, 0xB3, 0x00, 0x00, 0xFB, 0xCF, 0x57,
+        0xFA, 0xD3, 0x5F, 0xFA, 0xD6, 0x66, 0xFC, 0xBE, 0x38, 0xFD, 0xBA, 0x30, 0xFC, 0xC2, 0x3F, 0xFB,
+        0xCB, 0x50, 0xFD, 0xB7, 0x29, 0xF9, 0xD9, 0x6C, 0xFE, 0xB1, 0x1E, 0xFE, 0xB4, 0x23, 0xFB, 0xC7,
+        0x48, 0xFE, 0xAF, 0x1A, 0xF9, 0xDC, 0x71, 0xF3, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x21, 0xF9, 0x04,
+        0x01, 0x00, 0x00, 0x0E, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x0F, 0x00, 0x00, 0x04,
+        0x30, 0xD0, 0xC9, 0x49, 0xAB, 0xBD, 0x38, 0xEB, 0xCD, 0xBB, 0xFF, 0x20, 0x00, 0x52, 0x40, 0x30,
+        0x4A, 0xA5, 0x90, 0x31, 0x89, 0x72, 0x10, 0x43, 0xB1, 0x18, 0x29, 0x82, 0xB1, 0x2E, 0x2C, 0xD3,
+        0x81, 0x80, 0x34, 0x17, 0xDC, 0x2B, 0x36, 0xAB, 0x8D, 0x52, 0xA7, 0xD2, 0xC9, 0x21, 0xCA, 0x44,
+        0x00, 0x00, 0x3B  };
+    static char ext_gif[] = "gif";
+
+    int rc;
+    unsigned int width, height;
+    char *errmsg;
+
+    // Test gif
+    rc = DFGetImageDimensions(data_bullet, sizeof(data_bullet), ext_gif,
+                              &width, &height, &errmsg);
+    utassert((rc == 1),      "wrong rc");
+    utassert((width == 21),  "wrong width");
+    utassert((height == 15), "wrong height");
+}
+
+
+
+static void test_DFGetImageDimensions_jpg(void)
+{
+    // Banner-gradient.jpg 2x100
+    static unsigned char data_banner[] = {
+        0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48,
+        0x00, 0x48, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20,
+        0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4D, 0x50, 0xFF, 0xDB, 0x00, 0x43, 0x00, 0x05, 0x03,
+        0x04, 0x04, 0x04, 0x03, 0x05, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x07, 0x0C, 0x08, 0x07,
+        0x07, 0x07, 0x07, 0x0F, 0x0B, 0x0B, 0x09, 0x0C, 0x11, 0x0F, 0x12, 0x12, 0x11, 0x0F, 0x11, 0x11,
+        0x13, 0x16, 0x1C, 0x17, 0x13, 0x14, 0x1A, 0x15, 0x11, 0x11, 0x18, 0x21, 0x18, 0x1A, 0x1D, 0x1D,
+        0x1F, 0x1F, 0x1F, 0x13, 0x17, 0x22, 0x24, 0x22, 0x1E, 0x24, 0x1C, 0x1E, 0x1F, 0x1E, 0xFF, 0xDB,
+        0x00, 0x43, 0x01, 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x0E, 0x08, 0x08, 0x0E, 0x1E, 0x14, 0x11,
+        0x14, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
+        0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
+        0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
+        0x1E, 0x1E, 0x1E, 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x64, 0x00, 0x02, 0x03, 0x01, 0x22, 0x00,
+        0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xFF, 0xC4, 0x00, 0x17, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x08, 0xFF,
+        0xC4, 0x00, 0x1B, 0x10, 0x01, 0x00, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x03, 0x11, 0x13, 0x32, 0x52, 0xFF, 0xC4, 0x00, 0x14,
+        0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0xFF, 0xC4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xDA, 0x00, 0x0C, 0x03, 0x01, 0x00, 0x02,
+        0x11, 0x03, 0x11, 0x00, 0x3F, 0x00, 0xD9, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23,
+        0xE7, 0xC5, 0xEE, 0x00, 0x52, 0x66, 0xE5, 0x8D, 0xF7, 0x00, 0x1F, 0xFF, 0xD9  };
+    static char ext_jpg[] = "jpg";
+
+    int rc;
+    unsigned int width, height;
+    char *errmsg;
+
+    // Test gif
+    rc = DFGetImageDimensions(data_banner, sizeof(data_banner), ext_jpg,
+                              &width, &height, &errmsg);
+    utassert((rc == 1),       "wrong rc");
+    utassert((width == 2),    "wrong width");
+    utassert((height == 100), "wrong height");
+}
+
+
+
+static void test_DFGetImageDimensions_png(void)
+{
+    // Carrr.png 17x10
+    static unsigned char data_carr[] = {
+        0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
+        0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0A, 0x08, 0x03, 0x00, 0x00, 0x00, 0x65, 0xA2, 0x45,
+        0x90, 0x00, 0x00, 0x00, 0x2C, 0x74, 0x45, 0x58, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6F,
+        0x6E, 0x20, 0x54, 0x69, 0x6D, 0x65, 0x00, 0x54, 0x75, 0x65, 0x20, 0x32, 0x32, 0x20, 0x41, 0x75,
+        0x67, 0x20, 0x32, 0x30, 0x30, 0x36, 0x20, 0x30, 0x30, 0x3A, 0x34, 0x33, 0x3A, 0x31, 0x30, 0x20,
+        0x2D, 0x30, 0x35, 0x30, 0x30, 0x60, 0x0C, 0x10, 0x58, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4D,
+        0x45, 0x07, 0xD6, 0x08, 0x16, 0x05, 0x01, 0x29, 0x10, 0xD3, 0x7D, 0xD6, 0x00, 0x00, 0x00, 0x09,
+        0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x1E, 0xC2, 0x00, 0x00, 0x1E, 0xC2, 0x01, 0x6E, 0xD0, 0x75,
+        0x3E, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xB1, 0x8F, 0x0B, 0xFC, 0x61,
+        0x05, 0x00, 0x00, 0x00, 0x45, 0x50, 0x4C, 0x54, 0x45, 0xFF, 0xFF, 0xFF, 0xCD, 0xC3, 0xB0, 0xD7,
+        0xCF, 0xC0, 0x80, 0x66, 0x34, 0x73, 0x57, 0x20, 0xE1, 0xDB, 0xD0, 0x8A, 0x72, 0x44, 0x60, 0x40,
+        0x00, 0x62, 0x43, 0x04, 0xDC, 0xD5, 0xC8, 0xE9, 0xE4, 0xDC, 0x96, 0x81, 0x58, 0x7B, 0x60, 0x2C,
+        0xAF, 0x9F, 0x80, 0x6C, 0x4E, 0x14, 0x87, 0x6F, 0x40, 0xF5, 0xF3, 0xF0, 0xAA, 0x99, 0x78, 0x64,
+        0x45, 0x08, 0xF0, 0xED, 0xE8, 0x9E, 0x8A, 0x64, 0xD0, 0xC6, 0xB4, 0x94, 0x7E, 0x54, 0xD6, 0x77,
+        0xC5, 0x76, 0x00, 0x00, 0x00, 0x01, 0x74, 0x52, 0x4E, 0x53, 0x00, 0x40, 0xE6, 0xD8, 0x66, 0x00,
+        0x00, 0x00, 0x4D, 0x49, 0x44, 0x41, 0x54, 0x78, 0xDA, 0x63, 0x60, 0x40, 0x01, 0xBC, 0xEC, 0xBC,
+        0x30, 0x26, 0x2B, 0x9A, 0x08, 0x97, 0x18, 0x1F, 0x8A, 0x88, 0xB0, 0x08, 0x07, 0xBB, 0x28, 0x92,
+        0x88, 0x80, 0xA0, 0x10, 0x3B, 0x3B, 0x0B, 0x2F, 0x04, 0xF0, 0x03, 0x45, 0x58, 0xF9, 0xD8, 0x91,
+        0x01, 0x3F, 0x13, 0xD0, 0x0C, 0x6E, 0x20, 0x83, 0x07, 0xAA, 0x86, 0x97, 0x09, 0x62, 0x0F, 0x1B,
+        0x3B, 0x07, 0x27, 0xAA, 0x2B, 0x18, 0x98, 0x98, 0x59, 0x18, 0xD0, 0x01, 0x23, 0x9C, 0x05, 0x00,
+        0x28, 0x72, 0x03, 0x12, 0x3C, 0xA3, 0x13, 0x22, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
+        0xAE, 0x42, 0x60, 0x82 };
+    static char ext_png[] = "png";
+
+    int rc;
+    unsigned int width, height;
+    char *errmsg;
+
+    // Test gif
+    rc = DFGetImageDimensions(data_carr, sizeof(data_carr), ext_png,
+                              &width, &height, &errmsg);
+    utassert((rc == 1),      "wrong rc");
+    utassert((width == 17),  "wrong width");
+    utassert((height == 10), "wrong height");
 }
 
 
+static int testOnceCount;
+static void testOnce(void)
+{
+    testOnceCount++;
+}
 
 static void test_DFInitOnce(void)
 {
-#if 0
-    void DFInitOnce(DFOnce *once, DFOnceFunction fun)
-#endif
+    static DFOnce once = DF_ONCE_INIT;
+    DFInitOnce(&once, testOnce);
+    utassert((testOnceCount == 1), "function not called");
+
+    DFInitOnce(&once, testOnce);
+    utassert((testOnceCount == 1), "function called twice");
 }
 
 
 
 static void test_DFMkdirIfAbsent(void)
 {
-#if 0
-    int DFMkdirIfAbsent(const char *path, char **errmsg)
-#endif
+    char *errmsg;
+    int  rc;
+
+    rmdir("xxyz_testdir");
+    rc = DFMkdirIfAbsent("xxyz_testdir", &errmsg);
+    utassert((rc == 1), "Cannot create directory");
+
+    rc = DFMkdirIfAbsent("xxyz_testdir", &errmsg);
+    utassert((rc == 1), "Cannot use existing directory");
+
+    rc = rmdir("xxyz_testdir");
+    utassert((rc == 0), "did not create directory");
+
 }
 
 
 
 static void test_DFAddDirContents(void)
 {
-#if 0
-    int DFAddDirContents(const char *absPath, const char *relPath, int recursive, DFDirEntryList ***list, char **errmsg)
-#endif
+    DFDirEntryList *list = NULL;
+    DFDirEntryList **listptr = &list;
+    char            *errmsg;
+    int              rc;
+
+
+    rc = DFAddDirContents(".", "", 1, &listptr, &errmsg);
+    utassert((rc == 1), "could not read dir");
 }
 
 
 
 TestGroup PlatformOSTests = {
     "platform.os", {
-        { "DFGetImageDimensions", PlainTest, test_DFGetImageDimensions },
-        { "DFInitOnce",           PlainTest, test_DFInitOnce },
-        { "DFMkdirIfAbsent",      PlainTest, test_DFMkdirIfAbsent },
-        { "DFAddDirContents",     PlainTest, test_DFAddDirContents },
-        { NULL,                   PlainTest, NULL }
+        { "DFGetImageDimensions (gif)", PlainTest, test_DFGetImageDimensions_gif },
+        { "DFGetImageDimensions (jpg)", PlainTest, test_DFGetImageDimensions_jpg },
+        { "DFGetImageDimensions (png)", PlainTest, test_DFGetImageDimensions_png },
+        { "DFInitOnce", PlainTest, test_DFInitOnce },
+        { "DFMkdirIfAbsent",            PlainTest, test_DFMkdirIfAbsent },
+        { "DFAddDirContents",           PlainTest, test_DFAddDirContents },
+        { NULL,                         PlainTest, NULL }
     }
 };


[06/10] incubator-corinthia git commit: DFextZipClose: Fix uninitialised variable warning

Posted by pm...@apache.org.
DFextZipClose: Fix uninitialised variable warning


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

Branch: refs/heads/stable
Commit: c1c87be91413893b0e3873440b5f730196115802
Parents: 7208df5
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Fri Jan 2 20:15:49 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Fri Jan 2 20:15:49 2015 +0700

----------------------------------------------------------------------
 DocFormats/platform/src/Wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/c1c87be9/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index d27be99..1701d9d 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -44,7 +44,7 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
 
 int DFextZipClose(DFextZipHandleP zipHandle)
 {
-    int rc;
+    int rc = 0;
 
     if (zipHandle->handle) {
         if (zipHandle->zipFlag)