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 2014/12/17 14:29:04 UTC
[54/92] [abbrv] incubator-corinthia git commit: Rename DFStore to
DFPackage
Rename DFStore to DFPackage
'Package' is a more suitable term for this class, as is refers to the
idea of a collection of files stored in some packaging format (which
could be a zip file, directory, or memory). It also corresponds to the
terminology used in both the ODF and OOXML specs.
In cases where we use a class like WordPackage, which operates at a
higher level of abstraction, in conjunction with a DFPackage object, we
refer to the latter as a "raw" package, in the sense that it just
provides storage capabilities without any semantic functionality.
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/ff75357d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/ff75357d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/ff75357d
Branch: refs/heads/stable
Commit: ff75357da76c1149f18afa04051e2ce21a888c1a
Parents: de8b783
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Sun Nov 30 16:34:47 2014 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Sun Nov 30 16:37:03 2014 +0700
----------------------------------------------------------------------
DocFormats.xcodeproj/project.pbxproj | 24 +-
DocFormats/CMakeLists.txt | 4 +-
DocFormats/api/src/Operations.c | 36 +--
DocFormats/core/src/lib/DFBuffer.c | 8 +-
DocFormats/core/src/lib/DFBuffer.h | 6 +-
DocFormats/core/src/lib/DFPackage.c | 324 +++++++++++++++++++
DocFormats/core/src/lib/DFPackage.h | 35 ++
DocFormats/core/src/lib/DFStore.c | 324 -------------------
DocFormats/core/src/lib/DFStore.h | 35 --
DocFormats/core/src/lib/DFZipFile.c | 10 +-
DocFormats/core/src/lib/DFZipFile.h | 6 +-
DocFormats/core/src/xml/DFXML.c | 12 +-
DocFormats/core/src/xml/DFXML.h | 8 +-
DocFormats/filters/ooxml/src/common/OPC.c | 38 +--
DocFormats/filters/ooxml/src/common/OPC.h | 8 +-
DocFormats/filters/ooxml/src/word/Word.c | 16 +-
DocFormats/filters/ooxml/src/word/WordGC.c | 2 +-
DocFormats/filters/ooxml/src/word/WordPackage.c | 4 +-
DocFormats/filters/ooxml/src/word/WordPackage.h | 6 +-
.../filters/ooxml/src/word/lenses/WordDrawing.c | 18 +-
consumers/dfutil/src/Commands.c | 32 +-
consumers/dfutil/src/Plain.c | 80 ++---
consumers/dfutil/src/TestFunctions.c | 18 +-
consumers/dfutil/src/main.c | 12 +-
24 files changed, 533 insertions(+), 533 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/DocFormats.xcodeproj/project.pbxproj b/DocFormats.xcodeproj/project.pbxproj
index 0c0be43..01304c0 100644
--- a/DocFormats.xcodeproj/project.pbxproj
+++ b/DocFormats.xcodeproj/project.pbxproj
@@ -121,10 +121,6 @@
D01E24C01A205A1500F4C04D /* DFHashTable.c in Sources */ = {isa = PBXBuildFile; fileRef = D01E24461A205A1500F4C04D /* DFHashTable.c */; };
D01E24C11A205A1500F4C04D /* DFHashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = D01E24471A205A1500F4C04D /* DFHashTable.h */; settings = {ATTRIBUTES = (Public, ); }; };
D01E24C21A205A1500F4C04D /* DFHashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = D01E24471A205A1500F4C04D /* DFHashTable.h */; settings = {ATTRIBUTES = (Public, ); }; };
- D01E24C31A205A1500F4C04D /* DFStore.c in Sources */ = {isa = PBXBuildFile; fileRef = D01E24481A205A1500F4C04D /* DFStore.c */; };
- D01E24C41A205A1500F4C04D /* DFStore.c in Sources */ = {isa = PBXBuildFile; fileRef = D01E24481A205A1500F4C04D /* DFStore.c */; };
- D01E24C51A205A1500F4C04D /* DFStore.h in Headers */ = {isa = PBXBuildFile; fileRef = D01E24491A205A1500F4C04D /* DFStore.h */; settings = {ATTRIBUTES = (Public, ); }; };
- D01E24C61A205A1500F4C04D /* DFStore.h in Headers */ = {isa = PBXBuildFile; fileRef = D01E24491A205A1500F4C04D /* DFStore.h */; settings = {ATTRIBUTES = (Public, ); }; };
D01E24C71A205A1500F4C04D /* DFString.c in Sources */ = {isa = PBXBuildFile; fileRef = D01E244A1A205A1500F4C04D /* DFString.c */; };
D01E24C81A205A1500F4C04D /* DFString.c in Sources */ = {isa = PBXBuildFile; fileRef = D01E244A1A205A1500F4C04D /* DFString.c */; };
D01E24C91A205A1500F4C04D /* DFString.h in Headers */ = {isa = PBXBuildFile; fileRef = D01E244B1A205A1500F4C04D /* DFString.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -443,6 +439,10 @@
D0BC4165198413F500882CD1 /* DFTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = D0BC4163198413B900882CD1 /* DFTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
D0FA2D821A2B05B400B44D96 /* DocFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = D074ED561A2B04BC000C3704 /* DocFormats.h */; settings = {ATTRIBUTES = (Public, ); }; };
D0FA2D831A2B05B400B44D96 /* Operations.h in Headers */ = {isa = PBXBuildFile; fileRef = D074ED571A2B04BC000C3704 /* Operations.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D0FBA10A1A2B16F700B066C1 /* DFPackage.c in Sources */ = {isa = PBXBuildFile; fileRef = D0FBA1081A2B16F700B066C1 /* DFPackage.c */; };
+ D0FBA10B1A2B16F700B066C1 /* DFPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FBA1091A2B16F700B066C1 /* DFPackage.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D0FBA10C1A2B173000B066C1 /* DFPackage.c in Sources */ = {isa = PBXBuildFile; fileRef = D0FBA1081A2B16F700B066C1 /* DFPackage.c */; };
+ D0FBA10D1A2B173000B066C1 /* DFPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FBA1091A2B16F700B066C1 /* DFPackage.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -515,8 +515,6 @@
D01E24451A205A1500F4C04D /* DFFilesystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFFilesystem.h; sourceTree = "<group>"; };
D01E24461A205A1500F4C04D /* DFHashTable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFHashTable.c; sourceTree = "<group>"; };
D01E24471A205A1500F4C04D /* DFHashTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFHashTable.h; sourceTree = "<group>"; };
- D01E24481A205A1500F4C04D /* DFStore.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFStore.c; sourceTree = "<group>"; };
- D01E24491A205A1500F4C04D /* DFStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFStore.h; sourceTree = "<group>"; };
D01E244A1A205A1500F4C04D /* DFString.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFString.c; sourceTree = "<group>"; };
D01E244B1A205A1500F4C04D /* DFString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFString.h; sourceTree = "<group>"; };
D01E244C1A205A1500F4C04D /* DFZipFile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFZipFile.c; sourceTree = "<group>"; };
@@ -693,6 +691,8 @@
D0B5E8C417F086ED00FBD99F /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libiconv.dylib; sourceTree = DEVELOPER_DIR; };
D0BC41601984101D00882CD1 /* DFCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DFCommon.h; sourceTree = "<group>"; };
D0BC4163198413B900882CD1 /* DFTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DFTypes.h; sourceTree = "<group>"; };
+ D0FBA1081A2B16F700B066C1 /* DFPackage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFPackage.c; sourceTree = "<group>"; };
+ D0FBA1091A2B16F700B066C1 /* DFPackage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFPackage.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -833,8 +833,8 @@
D01E24451A205A1500F4C04D /* DFFilesystem.h */,
D01E24461A205A1500F4C04D /* DFHashTable.c */,
D01E24471A205A1500F4C04D /* DFHashTable.h */,
- D01E24481A205A1500F4C04D /* DFStore.c */,
- D01E24491A205A1500F4C04D /* DFStore.h */,
+ D0FBA1081A2B16F700B066C1 /* DFPackage.c */,
+ D0FBA1091A2B16F700B066C1 /* DFPackage.h */,
D01E244A1A205A1500F4C04D /* DFString.c */,
D01E244B1A205A1500F4C04D /* DFString.h */,
D01E244C1A205A1500F4C04D /* DFZipFile.c */,
@@ -1219,6 +1219,7 @@
D0A787901A210EA900723FE8 /* version.h in Headers */,
D01E24E71A205A1500F4C04D /* DFXMLForward.h in Headers */,
D0ADB38C1A2054C6003D645D /* WordNumbering.h in Headers */,
+ D0FBA10B1A2B16F700B066C1 /* DFPackage.h in Headers */,
D01E24891A205A1500F4C04D /* CSSSyntax.h in Headers */,
D01E24E11A205A1500F4C04D /* DFNameMap.h in Headers */,
D01E245F1A205A1500F4C04D /* DFBDT.h in Headers */,
@@ -1231,7 +1232,6 @@
D0ADB37C1A2054C6003D645D /* WordConverter.h in Headers */,
D01E24B51A205A1500F4C04D /* DFCharacterSet.h in Headers */,
D0ADB3781A2054C6003D645D /* WordCaption.h in Headers */,
- D01E24C51A205A1500F4C04D /* DFStore.h in Headers */,
D01E249D1A205A1500F4C04D /* DFTidyHelper.h in Headers */,
D04459381A20635B00A2E37E /* ODF.h in Headers */,
D0A787481A210EA900723FE8 /* charsets.h in Headers */,
@@ -1329,6 +1329,7 @@
D0A787911A210EA900723FE8 /* version.h in Headers */,
D01E24CA1A205A1500F4C04D /* DFString.h in Headers */,
D01E24E81A205A1500F4C04D /* DFXMLForward.h in Headers */,
+ D0FBA10D1A2B173000B066C1 /* DFPackage.h in Headers */,
D0ADB3391A2054C6003D645D /* WordCommonPr.h in Headers */,
D01E248A1A205A1500F4C04D /* CSSSyntax.h in Headers */,
D01E24E21A205A1500F4C04D /* DFNameMap.h in Headers */,
@@ -1341,7 +1342,6 @@
D0ADB37D1A2054C6003D645D /* WordConverter.h in Headers */,
D01E24B61A205A1500F4C04D /* DFCharacterSet.h in Headers */,
D0ADB3791A2054C6003D645D /* WordCaption.h in Headers */,
- D01E24C61A205A1500F4C04D /* DFStore.h in Headers */,
D04459401A20636F00A2E37E /* ODF.h in Headers */,
D01E249E1A205A1500F4C04D /* DFTidyHelper.h in Headers */,
D0A787491A210EA900723FE8 /* charsets.h in Headers */,
@@ -1522,7 +1522,6 @@
D0A787761A210EA900723FE8 /* pprint.c in Sources */,
D0A7873A1A210EA900723FE8 /* attrdict.c in Sources */,
D0ADB35A1A2054C6003D645D /* WordEquation.c in Sources */,
- D01E24C31A205A1500F4C04D /* DFStore.c in Sources */,
D0165AE31A206A55000F1267 /* Apple.c in Sources */,
D0165AE61A206A55000F1267 /* Win32.c in Sources */,
D01E24AF1A205A1500F4C04D /* DFCallback.c in Sources */,
@@ -1609,6 +1608,7 @@
D0ADB3921A2054C6003D645D /* WordPackage.c in Sources */,
D01E24DB1A205A1500F4C04D /* DFMarkupCompatibility.c in Sources */,
D0A7873E1A210EA900723FE8 /* attrget.c in Sources */,
+ D0FBA10A1A2B16F700B066C1 /* DFPackage.c in Sources */,
D01E24D31A205A1500F4C04D /* DFXMLNamespaces.c in Sources */,
D01E24AB1A205A1500F4C04D /* DFBuffer.c in Sources */,
);
@@ -1642,7 +1642,6 @@
D0ADB35B1A2054C6003D645D /* WordEquation.c in Sources */,
D0165AE81A206A7A000F1267 /* Apple.c in Sources */,
D0165AEB1A206A7A000F1267 /* Win32.c in Sources */,
- D01E24C41A205A1500F4C04D /* DFStore.c in Sources */,
D0165AE91A206A7A000F1267 /* Linux.c in Sources */,
D01E24B01A205A1500F4C04D /* DFCallback.c in Sources */,
D01E24D01A205A1500F4C04D /* DFXMLNames.c in Sources */,
@@ -1727,6 +1726,7 @@
D01E24DC1A205A1500F4C04D /* DFMarkupCompatibility.c in Sources */,
D01E24D41A205A1500F4C04D /* DFXMLNamespaces.c in Sources */,
D0A7873F1A210EA900723FE8 /* attrget.c in Sources */,
+ D0FBA10C1A2B173000B066C1 /* DFPackage.c in Sources */,
D0ADB3931A2054C6003D645D /* WordPackage.c in Sources */,
D01E24AC1A205A1500F4C04D /* DFBuffer.c in Sources */,
);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/CMakeLists.txt b/DocFormats/CMakeLists.txt
index 5057db8..3c7143a 100644
--- a/DocFormats/CMakeLists.txt
+++ b/DocFormats/CMakeLists.txt
@@ -107,8 +107,8 @@ set(GroupCoreLib
core/src/lib/DFFilesystem.h
core/src/lib/DFHashTable.c
core/src/lib/DFHashTable.h
- core/src/lib/DFStore.c
- core/src/lib/DFStore.h
+ core/src/lib/DFPackage.c
+ core/src/lib/DFPackage.h
core/src/lib/DFString.c
core/src/lib/DFString.h
core/src/lib/DFZipFile.c
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/api/src/Operations.c
----------------------------------------------------------------------
diff --git a/DocFormats/api/src/Operations.c b/DocFormats/api/src/Operations.c
index 91db380..2bbbcfc 100644
--- a/DocFormats/api/src/Operations.c
+++ b/DocFormats/api/src/Operations.c
@@ -15,7 +15,7 @@
#include <DocFormats/Operations.h>
#include "DFFilesystem.h"
#include "DFString.h"
-#include "DFStore.h"
+#include "DFPackage.h"
#include "WordPackage.h"
#include "DFHTML.h"
#include "DFDOM.h"
@@ -25,17 +25,17 @@
static int generateHTML(const char *packageFilename, const char *htmlFilename, DFError **error)
{
int ok = 0;
- DFStore *store = DFStoreNewMemory();
- WordPackage *package = NULL;
+ DFPackage *rawPackage = DFPackageNewMemory();
+ WordPackage *wordPackage = NULL;
char *htmlPath = DFPathDirName(htmlFilename);
DFBuffer *warnings = DFBufferNew();
DFDocument *htmlDoc = NULL;
- package = WordPackageOpenFrom(store,packageFilename,error);
- if (package == NULL)
+ wordPackage = WordPackageOpenFrom(rawPackage,packageFilename,error);
+ if (wordPackage == NULL)
goto end;
- htmlDoc = WordPackageGenerateHTML(package,htmlPath,"word",error,warnings);
+ htmlDoc = WordPackageGenerateHTML(wordPackage,htmlPath,"word",error,warnings);
if (htmlDoc == NULL)
goto end;
@@ -57,16 +57,16 @@ end:
free(htmlPath);
DFBufferRelease(warnings);
DFDocumentRelease(htmlDoc);
- DFStoreRelease(store);
- WordPackageRelease(package);
+ DFPackageRelease(rawPackage);
+ WordPackageRelease(wordPackage);
return ok;
}
static int updateFrom(const char *packageFilename, const char *htmlFilename, DFError **error)
{
int ok = 0;
- DFStore *store = DFStoreNewMemory();
- WordPackage *package = NULL;
+ DFPackage *rawPackage = DFPackageNewMemory();
+ WordPackage *wordPackage = NULL;
DFDocument *htmlDoc = NULL;
DFBuffer *warnings = DFBufferNew();
char *htmlPath = DFPathDirName(htmlFilename);
@@ -80,8 +80,8 @@ static int updateFrom(const char *packageFilename, const char *htmlFilename, DFE
const char *idPrefix = "word";
if (!DFFileExists(packageFilename)) {
- package = WordPackageOpenNew(store,error);
- if (package == NULL)
+ wordPackage = WordPackageOpenNew(rawPackage,error);
+ if (wordPackage == NULL)
goto end;
// Change any id attributes starting with "word" or "odf" to a different prefix, so they
@@ -91,12 +91,12 @@ static int updateFrom(const char *packageFilename, const char *htmlFilename, DFE
HTMLBreakBDTRefs(htmlDoc->docNode,idPrefix);
}
else {
- package = WordPackageOpenFrom(store,packageFilename,error);
- if (package == NULL)
+ wordPackage = WordPackageOpenFrom(rawPackage,packageFilename,error);
+ if (wordPackage == NULL)
goto end;
}
- if (!WordPackageUpdateFromHTML(package,htmlDoc,htmlPath,idPrefix,error,warnings))
+ if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,htmlPath,idPrefix,error,warnings))
goto end;
if (warnings->len > 0) {
@@ -104,14 +104,14 @@ static int updateFrom(const char *packageFilename, const char *htmlFilename, DFE
goto end;
}
- if (!WordPackageSaveTo(package,packageFilename,error))
+ if (!WordPackageSaveTo(wordPackage,packageFilename,error))
goto end;
ok = 1;
end:
- DFStoreRelease(store);
- WordPackageRelease(package);
+ DFPackageRelease(rawPackage);
+ WordPackageRelease(wordPackage);
DFDocumentRelease(htmlDoc);
DFBufferRelease(warnings);
free(htmlPath);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFBuffer.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFBuffer.c b/DocFormats/core/src/lib/DFBuffer.c
index 6fc25f9..f542fc4 100644
--- a/DocFormats/core/src/lib/DFBuffer.c
+++ b/DocFormats/core/src/lib/DFBuffer.c
@@ -132,11 +132,11 @@ DFBuffer *DFBufferReadFromFile(const char *filename, DFError **error)
return buf;
}
-DFBuffer *DFBufferReadFromStore(DFStore *store, const char *storeFilename, DFError **error)
+DFBuffer *DFBufferReadFromPackage(DFPackage *package, const char *filename, DFError **error)
{
void *data = 0;
size_t len = 0;
- if (!DFStoreRead(store,storeFilename,&data,&len,error))
+ if (!DFPackageRead(package,filename,&data,&len,error))
return NULL;;
DFBuffer *r = DFBufferNew();;
DFBufferAppendData(r,data,len);
@@ -144,9 +144,9 @@ DFBuffer *DFBufferReadFromStore(DFStore *store, const char *storeFilename, DFErr
return r;
}
-int DFBufferWriteToStore(DFBuffer *buf, DFStore *store, const char *storeFilename, DFError **error)
+int DFBufferWriteToPackage(DFBuffer *buf, DFPackage *package, const char *filename, DFError **error)
{
- return DFStoreWrite(store,storeFilename,buf->data,buf->len,error);
+ return DFPackageWrite(package,filename,buf->data,buf->len,error);
}
int DFBufferWriteToFile(DFBuffer *buf, const char *filename, DFError **error)
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFBuffer.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFBuffer.h b/DocFormats/core/src/lib/DFBuffer.h
index 3b7bb69..5414d8a 100644
--- a/DocFormats/core/src/lib/DFBuffer.h
+++ b/DocFormats/core/src/lib/DFBuffer.h
@@ -17,7 +17,7 @@
#include "DFError.h"
#include "DFTypes.h"
-#include "DFStore.h"
+#include "DFPackage.h"
#include <stdarg.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,9 +45,9 @@ void DFBufferAppendChar(DFBuffer *buf, char ch);
void DFBufferVFormat(DFBuffer *buf, const char *format, va_list ap);
void DFBufferFormat(DFBuffer *buf, const char *format, ...) ATTRIBUTE_FORMAT(printf,2,3);
DFBuffer *DFBufferReadFromFile(const char *filename, DFError **error);
-DFBuffer *DFBufferReadFromStore(DFStore *store, const char *storeFilename, DFError **error);
+DFBuffer *DFBufferReadFromPackage(DFPackage *package, const char *filename, DFError **error);
int DFBufferWriteToFile(DFBuffer *buf, const char *filename, DFError **error);
-int DFBufferWriteToStore(DFBuffer *buf, DFStore *store, const char *storeFilename, DFError **error);
+int DFBufferWriteToPackage(DFBuffer *buf, DFPackage *package, const char *filename, DFError **error);
int DFWriteDataToFile(const void *data, size_t len, const char *filename, DFError **error);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFPackage.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFPackage.c b/DocFormats/core/src/lib/DFPackage.c
new file mode 100644
index 0000000..c362dbc
--- /dev/null
+++ b/DocFormats/core/src/lib/DFPackage.c
@@ -0,0 +1,324 @@
+// 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 "DFPackage.h"
+#include "DFCommon.h"
+#include "DFString.h"
+#include "DFFilesystem.h"
+#include "DFBuffer.h"
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct DFPackageOps DFPackageOps;
+
+struct DFPackageOps {
+ int (*save)(DFPackage *package, DFError **error);
+ int (*read)(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error);
+ int (*write)(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error);
+ int (*exists)(DFPackage *package, const char *path);
+ int (*delete)(DFPackage *package, const char *path, DFError **error);
+ const char **(*list)(DFPackage *package, DFError **error);
+};
+
+struct DFPackage {
+ size_t retainCount;
+ char *rootPath;
+ DFHashTable *files;
+ const DFPackageOps *ops;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// //
+// DFPackage (Filesystem) //
+// //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static int fsSave(DFPackage *package, DFError **error)
+{
+ // Nothing to do here; we've already written everything to the filesystem
+ // at the time the calls were made.
+ return 1;
+}
+
+static int fsRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+ char *fullPath = DFAppendPathComponent(package->rootPath,path);
+ int ok = 0;
+
+ FILE *file = fopen(fullPath,"rb");
+ if (file == NULL) {
+ DFErrorSetPosix(error,errno);
+ goto end;
+ }
+
+ size_t balloc = 4096;
+ size_t blen = 0;
+ char *mem = (char *)malloc(balloc);
+
+ size_t r;
+ while (0 < (r = fread(&mem[blen],1,4096,file))) {
+ balloc += r;
+ blen += r;
+ mem = (char *)realloc(mem,balloc);
+ }
+ ok = 1;
+
+ *buf = mem;
+ *nbytes = blen;
+
+end:
+ if (file != NULL)
+ fclose(file);
+ free(fullPath);
+ return ok;
+}
+
+static int fsWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+ char *fullPath = DFAppendPathComponent(package->rootPath,path);
+ char *parentPath = DFPathDirName(fullPath);
+ int r = 0;
+ FILE *file = NULL;
+
+ if (!DFFileExists(parentPath) && !DFCreateDirectory(parentPath,1,error))
+ goto end;
+
+ file = fopen(fullPath,"wb");
+ if (file == NULL) {
+ DFErrorSetPosix(error,errno);
+ goto end;
+ }
+ size_t w = fwrite(buf,1,nbytes,file);
+ if (w != nbytes) {
+ DFErrorFormat(error,"Incomplete write");
+ goto end;
+ }
+ r = 1;
+
+end:
+ if (file != NULL)
+ fclose(file);
+ free(parentPath);
+ free(fullPath);
+ return r;
+}
+
+static int fsExists(DFPackage *package, const char *path)
+{
+ char *fullPath = DFAppendPathComponent(package->rootPath,path);
+ int r = DFFileExists(fullPath);
+ free(fullPath);
+ return r;
+}
+
+static int fsDelete(DFPackage *package, const char *path, DFError **error)
+{
+ char *fullPath = DFAppendPathComponent(package->rootPath,path);
+ int r = DFDeleteFile(fullPath,error);
+ free(fullPath);
+ return r;
+}
+
+const char **fsList(DFPackage *package, DFError **error)
+{
+ const char **allPaths = DFContentsOfDirectory(package->rootPath,1,error);
+ if (allPaths == NULL)
+ return NULL;;
+
+ DFArray *filesOnly = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+ for (int i = 0; allPaths[i]; i++) {
+ const char *relPath = allPaths[i];
+ char *absPath = DFAppendPathComponent(package->rootPath,relPath);
+ if (!DFIsDirectory(absPath))
+ DFArrayAppend(filesOnly,(void *)relPath);
+ free(absPath);
+ }
+
+ const char **result = DFStringArrayFlatten(filesOnly);
+ DFArrayRelease(filesOnly);
+ free(allPaths);
+ return result;
+}
+
+static DFPackageOps fsOps = {
+ .save = fsSave,
+ .read = fsRead,
+ .write = fsWrite,
+ .exists = fsExists,
+ .delete = fsDelete,
+ .list = fsList,
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// //
+// DFPackage (Memory) //
+// //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static int memSave(DFPackage *package, DFError **error)
+{
+ // Nothing to do here; memory packages are intended to be temporary, and are never saved to disk
+ return 1;
+}
+
+static int memRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+ DFBuffer *buffer = DFHashTableLookup(package->files,path);
+ if (buffer == NULL) {
+ DFErrorSetPosix(error,ENOENT);
+ return 0;
+ }
+
+ *buf = malloc(buffer->len);
+ memcpy(*buf,buffer->data,buffer->len);
+ *nbytes = buffer->len;
+
+ return 1;
+}
+
+static int memWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+ DFBuffer *buffer = DFBufferNew();
+ DFBufferAppendData(buffer,buf,nbytes);
+ DFHashTableAdd(package->files,path,buffer);
+ DFBufferRelease(buffer);
+ return 1;
+}
+
+static int memExists(DFPackage *package, const char *path)
+{
+ return (DFHashTableLookup(package->files,path) != NULL);
+}
+
+static int memDelete(DFPackage *package, const char *path, DFError **error)
+{
+ DFHashTableRemove(package->files,path);
+ return 1;
+}
+
+static const char **memList(DFPackage *package, DFError **error)
+{
+ return DFHashTableCopyKeys(package->files);
+}
+
+static DFPackageOps memOps = {
+ .save = memSave,
+ .read = memRead,
+ .write = memWrite,
+ .exists = memExists,
+ .delete = memDelete,
+ .list = memList,
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// //
+// DFPackage //
+// //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Normalize the path to remove multiple consecutive / characters, and to remove any trailing /
+// character. This ensures that for implementations which rely on an exact match of the path
+// (specifically, the memory package), that any non-essential differences in the supplied path will
+// not matter.
+
+static char *fixPath(const char *input)
+{
+ char *normalized = DFPathNormalize(input);
+ char *result;
+ if (normalized[0] == '/')
+ result = strdup(&normalized[1]);
+ else
+ result = strdup(normalized);
+ free(normalized);
+ return result;
+}
+
+DFPackage *DFPackageNewFilesystem(const char *rootPath)
+{
+ DFPackage *package = (DFPackage *)calloc(1,sizeof(DFPackage));
+ package->retainCount = 1;
+ package->rootPath = strdup(rootPath);
+ package->ops = &fsOps;
+ return package;
+}
+
+DFPackage *DFPackageNewMemory(void)
+{
+ DFPackage *package = (DFPackage *)calloc(1,sizeof(DFPackage));
+ package->retainCount = 1;
+ package->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
+ package->ops = &memOps;
+ return package;
+}
+
+DFPackage *DFPackageRetain(DFPackage *package)
+{
+ if (package != NULL)
+ package->retainCount++;
+ return package;
+}
+
+void DFPackageRelease(DFPackage *package)
+{
+ if ((package == NULL) || (--package->retainCount > 0))
+ return;
+
+ DFHashTableRelease(package->files);
+ free(package->rootPath);
+ free(package);
+}
+
+int DFPackageSave(DFPackage *package, DFError **error)
+{
+ return package->ops->save(package,error);
+}
+
+int DFPackageRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+ char *fixed = fixPath(path);
+ int r = package->ops->read(package,fixed,buf,nbytes,error);
+ free(fixed);
+ return r;
+}
+
+int DFPackageWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+ char *fixed = fixPath(path);
+ int r = package->ops->write(package,fixed,buf,nbytes,error);
+ free(fixed);
+ return r;
+}
+
+int DFPackageExists(DFPackage *package, const char *path)
+{
+ char *fixed = fixPath(path);
+ int r = package->ops->exists(package,fixed);
+ free(fixed);
+ return r;
+}
+
+int DFPackageDelete(DFPackage *package, const char *path, DFError **error)
+{
+ char *fixed = fixPath(path);
+ int r = package->ops->delete(package,fixed,error);
+ free(fixed);
+ return r;
+}
+
+const char **DFPackageList(DFPackage *package, DFError **error)
+{
+ return package->ops->list(package,error);
+}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFPackage.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFPackage.h b/DocFormats/core/src/lib/DFPackage.h
new file mode 100644
index 0000000..ac9478c
--- /dev/null
+++ b/DocFormats/core/src/lib/DFPackage.h
@@ -0,0 +1,35 @@
+// 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.
+
+#ifndef DocFormats_DFPackage_h
+#define DocFormats_DFPackage_h
+
+#include "DFError.h"
+#include "DFTypes.h"
+
+typedef struct DFPackage DFPackage;
+
+DFPackage *DFPackageNewFilesystem(const char *rootPath);
+DFPackage *DFPackageNewMemory(void);
+DFPackage *DFPackageRetain(DFPackage *package);
+void DFPackageRelease(DFPackage *package);
+int DFPackageSave(DFPackage *package, DFError **error);
+
+int DFPackageRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error);
+int DFPackageWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error);
+int DFPackageExists(DFPackage *package, const char *path);
+int DFPackageDelete(DFPackage *package, const char *path, DFError **error);
+const char **DFPackageList(DFPackage *package, DFError **error);
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFStore.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFStore.c b/DocFormats/core/src/lib/DFStore.c
deleted file mode 100644
index ed53080..0000000
--- a/DocFormats/core/src/lib/DFStore.c
+++ /dev/null
@@ -1,324 +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 "DFStore.h"
-#include "DFCommon.h"
-#include "DFString.h"
-#include "DFFilesystem.h"
-#include "DFBuffer.h"
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct DFStoreOps DFStoreOps;
-
-struct DFStoreOps {
- int (*save)(DFStore *store, DFError **error);
- int (*read)(DFStore *store, const char *path, void **buf, size_t *nbytes, DFError **error);
- int (*write)(DFStore *store, const char *path, void *buf, size_t nbytes, DFError **error);
- int (*exists)(DFStore *store, const char *path);
- int (*delete)(DFStore *store, const char *path, DFError **error);
- const char **(*list)(DFStore *store, DFError **error);
-};
-
-struct DFStore {
- size_t retainCount;
- char *rootPath;
- DFHashTable *files;
- const DFStoreOps *ops;
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// //
-// DFStore (Filesystem) //
-// //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int fsSave(DFStore *store, DFError **error)
-{
- // Nothing to do here; we've already written everything to the filesystem
- // at the time the calls were made.
- return 1;
-}
-
-static int fsRead(DFStore *store, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
- char *fullPath = DFAppendPathComponent(store->rootPath,path);
- int ok = 0;
-
- FILE *file = fopen(fullPath,"rb");
- if (file == NULL) {
- DFErrorSetPosix(error,errno);
- goto end;
- }
-
- size_t balloc = 4096;
- size_t blen = 0;
- char *mem = (char *)malloc(balloc);
-
- size_t r;
- while (0 < (r = fread(&mem[blen],1,4096,file))) {
- balloc += r;
- blen += r;
- mem = (char *)realloc(mem,balloc);
- }
- ok = 1;
-
- *buf = mem;
- *nbytes = blen;
-
-end:
- if (file != NULL)
- fclose(file);
- free(fullPath);
- return ok;
-}
-
-static int fsWrite(DFStore *store, const char *path, void *buf, size_t nbytes, DFError **error)
-{
- char *fullPath = DFAppendPathComponent(store->rootPath,path);
- char *parentPath = DFPathDirName(fullPath);
- int r = 0;
- FILE *file = NULL;
-
- if (!DFFileExists(parentPath) && !DFCreateDirectory(parentPath,1,error))
- goto end;
-
- file = fopen(fullPath,"wb");
- if (file == NULL) {
- DFErrorSetPosix(error,errno);
- goto end;
- }
- size_t w = fwrite(buf,1,nbytes,file);
- if (w != nbytes) {
- DFErrorFormat(error,"Incomplete write");
- goto end;
- }
- r = 1;
-
-end:
- if (file != NULL)
- fclose(file);
- free(parentPath);
- free(fullPath);
- return r;
-}
-
-static int fsExists(DFStore *store, const char *path)
-{
- char *fullPath = DFAppendPathComponent(store->rootPath,path);
- int r = DFFileExists(fullPath);
- free(fullPath);
- return r;
-}
-
-static int fsDelete(DFStore *store, const char *path, DFError **error)
-{
- char *fullPath = DFAppendPathComponent(store->rootPath,path);
- int r = DFDeleteFile(fullPath,error);
- free(fullPath);
- return r;
-}
-
-const char **fsList(DFStore *store, DFError **error)
-{
- const char **allPaths = DFContentsOfDirectory(store->rootPath,1,error);
- if (allPaths == NULL)
- return NULL;;
-
- DFArray *filesOnly = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
- for (int i = 0; allPaths[i]; i++) {
- const char *relPath = allPaths[i];
- char *absPath = DFAppendPathComponent(store->rootPath,relPath);
- if (!DFIsDirectory(absPath))
- DFArrayAppend(filesOnly,(void *)relPath);
- free(absPath);
- }
-
- const char **result = DFStringArrayFlatten(filesOnly);
- DFArrayRelease(filesOnly);
- free(allPaths);
- return result;
-}
-
-static DFStoreOps fsOps = {
- .save = fsSave,
- .read = fsRead,
- .write = fsWrite,
- .exists = fsExists,
- .delete = fsDelete,
- .list = fsList,
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// //
-// DFStore (Memory) //
-// //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int memSave(DFStore *store, DFError **error)
-{
- // Nothing to do here; memory stores are intended to be temporary, and are never saved to disk
- return 1;
-}
-
-static int memRead(DFStore *store, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
- DFBuffer *buffer = DFHashTableLookup(store->files,path);
- if (buffer == NULL) {
- DFErrorSetPosix(error,ENOENT);
- return 0;
- }
-
- *buf = malloc(buffer->len);
- memcpy(*buf,buffer->data,buffer->len);
- *nbytes = buffer->len;
-
- return 1;
-}
-
-static int memWrite(DFStore *store, const char *path, void *buf, size_t nbytes, DFError **error)
-{
- DFBuffer *buffer = DFBufferNew();
- DFBufferAppendData(buffer,buf,nbytes);
- DFHashTableAdd(store->files,path,buffer);
- DFBufferRelease(buffer);
- return 1;
-}
-
-static int memExists(DFStore *store, const char *path)
-{
- return (DFHashTableLookup(store->files,path) != NULL);
-}
-
-static int memDelete(DFStore *store, const char *path, DFError **error)
-{
- DFHashTableRemove(store->files,path);
- return 1;
-}
-
-static const char **memList(DFStore *store, DFError **error)
-{
- return DFHashTableCopyKeys(store->files);
-}
-
-static DFStoreOps memOps = {
- .save = memSave,
- .read = memRead,
- .write = memWrite,
- .exists = memExists,
- .delete = memDelete,
- .list = memList,
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// //
-// DFStore //
-// //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-// Normalize the path to remove multiple consecutive / characters, and to remove any trailing /
-// character. This ensures that for implementations which rely on an exact match of the path
-// (specifically, the memory store), that any non-essential differences in the supplied path will
-// not matter.
-
-static char *fixPath(const char *input)
-{
- char *normalized = DFPathNormalize(input);
- char *result;
- if (normalized[0] == '/')
- result = strdup(&normalized[1]);
- else
- result = strdup(normalized);
- free(normalized);
- return result;
-}
-
-DFStore *DFStoreNewFilesystem(const char *rootPath)
-{
- DFStore *store = (DFStore *)calloc(1,sizeof(DFStore));
- store->retainCount = 1;
- store->rootPath = strdup(rootPath);
- store->ops = &fsOps;
- return store;
-}
-
-DFStore *DFStoreNewMemory(void)
-{
- DFStore *store = (DFStore *)calloc(1,sizeof(DFStore));
- store->retainCount = 1;
- store->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
- store->ops = &memOps;
- return store;
-}
-
-DFStore *DFStoreRetain(DFStore *store)
-{
- if (store != NULL)
- store->retainCount++;
- return store;
-}
-
-void DFStoreRelease(DFStore *store)
-{
- if ((store == NULL) || (--store->retainCount > 0))
- return;
-
- DFHashTableRelease(store->files);
- free(store->rootPath);
- free(store);
-}
-
-int DFStoreSave(DFStore *store, DFError **error)
-{
- return store->ops->save(store,error);
-}
-
-int DFStoreRead(DFStore *store, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
- char *fixed = fixPath(path);
- int r = store->ops->read(store,fixed,buf,nbytes,error);
- free(fixed);
- return r;
-}
-
-int DFStoreWrite(DFStore *store, const char *path, void *buf, size_t nbytes, DFError **error)
-{
- char *fixed = fixPath(path);
- int r = store->ops->write(store,fixed,buf,nbytes,error);
- free(fixed);
- return r;
-}
-
-int DFStoreExists(DFStore *store, const char *path)
-{
- char *fixed = fixPath(path);
- int r = store->ops->exists(store,fixed);
- free(fixed);
- return r;
-}
-
-int DFStoreDelete(DFStore *store, const char *path, DFError **error)
-{
- char *fixed = fixPath(path);
- int r = store->ops->delete(store,fixed,error);
- free(fixed);
- return r;
-}
-
-const char **DFStoreList(DFStore *store, DFError **error)
-{
- return store->ops->list(store,error);
-}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFStore.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFStore.h b/DocFormats/core/src/lib/DFStore.h
deleted file mode 100644
index 10069ce..0000000
--- a/DocFormats/core/src/lib/DFStore.h
+++ /dev/null
@@ -1,35 +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.
-
-#ifndef DocFormats_DFStore_h
-#define DocFormats_DFStore_h
-
-#include "DFError.h"
-#include "DFTypes.h"
-
-typedef struct DFStore DFStore;
-
-DFStore *DFStoreNewFilesystem(const char *rootPath);
-DFStore *DFStoreNewMemory(void);
-DFStore *DFStoreRetain(DFStore *store);
-void DFStoreRelease(DFStore *store);
-int DFStoreSave(DFStore *store, DFError **error);
-
-int DFStoreRead(DFStore *store, const char *path, void **buf, size_t *nbytes, DFError **error);
-int DFStoreWrite(DFStore *store, const char *path, void *buf, size_t nbytes, DFError **error);
-int DFStoreExists(DFStore *store, const char *path);
-int DFStoreDelete(DFStore *store, const char *path, DFError **error);
-const char **DFStoreList(DFStore *store, DFError **error);
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index 6cf3e05..41c3cc1 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -33,7 +33,7 @@ static int zipError(DFError **error, const char *format, ...)
return 0;
}
-int DFUnzip(const char *zipFilename, DFStore *store, DFError **error)
+int DFUnzip(const char *zipFilename, DFPackage *package, DFError **error)
{
unzFile zipFile = unzOpen(zipFilename);
if (zipFile == NULL)
@@ -67,7 +67,7 @@ int DFUnzip(const char *zipFilename, DFStore *store, DFError **error)
return zipError(error,"%s: decompression failed",entryName);
}
- if (!DFBufferWriteToStore(content,store,entryName,error)) {
+ if (!DFBufferWriteToPackage(content,package,entryName,error)) {
DFBufferRelease(content);
return zipError(error,"%s: %s",entryName,DFErrorMessage(error));
}
@@ -110,14 +110,14 @@ static int zipAddFile(zipFile zip, const char *dest, DFBuffer *content, DFError
return 1;
}
-int DFZip(const char *zipFilename, DFStore *store, DFError **error)
+int DFZip(const char *zipFilename, DFPackage *package, DFError **error)
{
const char **allPaths = NULL;
zipFile zip = NULL;
DFBuffer *content = NULL;
int ok = 0;
- allPaths = DFStoreList(store,error);
+ allPaths = DFPackageList(package,error);
if (allPaths == NULL)
goto end;
@@ -131,7 +131,7 @@ int DFZip(const char *zipFilename, DFStore *store, DFError **error)
const char *path = allPaths[i];
DFBufferRelease(content);
- content = DFBufferReadFromStore(store,path,error);
+ content = DFBufferReadFromPackage(package,path,error);
if (content == NULL) {
DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
goto end;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/lib/DFZipFile.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.h b/DocFormats/core/src/lib/DFZipFile.h
index c515801..4f4644e 100644
--- a/DocFormats/core/src/lib/DFZipFile.h
+++ b/DocFormats/core/src/lib/DFZipFile.h
@@ -16,9 +16,9 @@
#define DocFormats_DFZipFile_h
#include "DFError.h"
-#include "DFStore.h"
+#include "DFPackage.h"
-int DFUnzip(const char *zipFilename, DFStore *store, DFError **error);
-int DFZip(const char *zipFilename, DFStore *store, DFError **error);
+int DFUnzip(const char *zipFilename, DFPackage *package, DFError **error);
+int DFZip(const char *zipFilename, DFPackage *package, DFError **error);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/xml/DFXML.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFXML.c b/DocFormats/core/src/xml/DFXML.c
index 2b68d2e..bbd0204 100644
--- a/DocFormats/core/src/xml/DFXML.c
+++ b/DocFormats/core/src/xml/DFXML.c
@@ -556,9 +556,9 @@ DFDocument *DFParseXMLFile(const char *filename, DFError **error)
return doc;
}
-DFDocument *DFParseXMLStore(DFStore *store, const char *storeFilename, DFError **error)
+DFDocument *DFParseXMLPackage(DFPackage *package, const char *filename, DFError **error)
{
- DFBuffer *content = DFBufferReadFromStore(store,storeFilename,error);
+ DFBuffer *content = DFBufferReadFromPackage(package,filename,error);
if (content == NULL)
return NULL;;
DFDocument *doc = DFParseXMLString(content->data,error);
@@ -621,14 +621,14 @@ int DFSerializeXMLFile(DFDocument *doc, NamespaceID defaultNS, int indent, const
return r;
}
-int DFSerializeXMLStore(DFDocument *doc, NamespaceID defaultNS, int indent,
- DFStore *store, const char *storeFilename,
- DFError **error)
+int DFSerializeXMLPackage(DFDocument *doc, NamespaceID defaultNS, int indent,
+ DFPackage *package, const char *filename,
+ DFError **error)
{
char *str = DFSerializeXMLString(doc,defaultNS,indent);
DFBuffer *content = DFBufferNew();
DFBufferAppendString(content,str);
- int r = DFBufferWriteToStore(content,store,storeFilename,error);
+ int r = DFBufferWriteToPackage(content,package,filename,error);
DFBufferRelease(content);
free(str);
return r;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/core/src/xml/DFXML.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFXML.h b/DocFormats/core/src/xml/DFXML.h
index ca0bd41..91388bd 100644
--- a/DocFormats/core/src/xml/DFXML.h
+++ b/DocFormats/core/src/xml/DFXML.h
@@ -20,17 +20,17 @@
#include "DFXMLForward.h"
#include "DFError.h"
#include "DFBuffer.h"
-#include "DFStore.h"
+#include "DFPackage.h"
DFDocument *DFParseXMLString(const char *str, DFError **error);
DFDocument *DFParseXMLFile(const char *filename, DFError **error);
-DFDocument *DFParseXMLStore(DFStore *store, const char *storeFilename, DFError **error);
+DFDocument *DFParseXMLPackage(DFPackage *package, const char *filename, DFError **error);
void DFSerializeXMLBuffer(DFDocument *doc, NamespaceID defaultNS, int indent, DFBuffer *buf);
char *DFSerializeXMLString(DFDocument *doc, NamespaceID defaultNS, int indent);
int DFSerializeXMLFile(DFDocument *doc, NamespaceID defaultNS, int indent, const char *filename, DFError **error);
-int DFSerializeXMLStore(DFDocument *doc, NamespaceID defaultNS, int indent,
- DFStore *store, const char *storeFilename,
+int DFSerializeXMLPackage(DFDocument *doc, NamespaceID defaultNS, int indent,
+ DFPackage *package, const char *filename,
DFError **error);
#endif
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/common/OPC.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/common/OPC.c b/DocFormats/filters/ooxml/src/common/OPC.c
index 1f3765a..b6da88b 100644
--- a/DocFormats/filters/ooxml/src/common/OPC.c
+++ b/DocFormats/filters/ooxml/src/common/OPC.c
@@ -251,9 +251,9 @@ static const char *OPCContentTypesTypeForPartName(OPCContentTypes *ct, const cha
return "";
}
-static int OPCContentTypesLoadFromFile(OPCContentTypes *ct, DFStore *store, const char *relPath, DFError **error)
+static int OPCContentTypesLoadFromFile(OPCContentTypes *ct, DFPackage *package, const char *relPath, DFError **error)
{
- DFDocument *doc = DFParseXMLStore(store,relPath,error);
+ DFDocument *doc = DFParseXMLPackage(package,relPath,error);
if (doc == NULL) {
char *filename = DFPathBaseName(relPath);
DFErrorFormat(error,"%s: %s",filename,DFErrorMessage(error));
@@ -289,7 +289,7 @@ static int OPCContentTypesLoadFromFile(OPCContentTypes *ct, DFStore *store, cons
return 1;
}
-static int OPCContentTypesSaveToFile(OPCContentTypes *ct, DFStore *store, const char *relPath, DFError **error)
+static int OPCContentTypesSaveToFile(OPCContentTypes *ct, DFPackage *package, const char *relPath, DFError **error)
{
DFDocument *doc = DFDocumentNew();
DFNode *types = DFCreateElement(doc,CT_TYPES);
@@ -316,7 +316,7 @@ static int OPCContentTypesSaveToFile(OPCContentTypes *ct, DFStore *store, const
DFAppendChild(types,override);
}
free(keys);
- if (!DFSerializeXMLStore(doc,NAMESPACE_CT,0,store,relPath,error)) {
+ if (!DFSerializeXMLPackage(doc,NAMESPACE_CT,0,package,relPath,error)) {
char *filename = DFPathBaseName(relPath);
DFErrorFormat(error,"%s: %s",filename,DFErrorMessage(error));
free(filename);
@@ -348,10 +348,10 @@ void OPCContentTypesRemoveOverride(OPCContentTypes *ct, const char *partName)
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
-static OPCPackage *OPCPackageNew(DFStore *store)
+static OPCPackage *OPCPackageNew(DFPackage *store)
{
OPCPackage *pkg = (OPCPackage *)calloc(1,sizeof(OPCPackage));
- pkg->store = DFStoreRetain(store);
+ pkg->store = DFPackageRetain(store);
pkg->contentTypes = OPCContentTypesNew();
pkg->relationships = OPCRelationshipSetNew();
pkg->partsByName = DFHashTableNew((DFCopyFunction)OPCPartRetain,(DFFreeFunction)OPCPartRelease);
@@ -361,7 +361,7 @@ static OPCPackage *OPCPackageNew(DFStore *store)
void OPCPackageFree(OPCPackage *pkg)
{
- DFStoreRelease(pkg->store);
+ DFPackageRelease(pkg->store);
OPCContentTypesFree(pkg->contentTypes);
OPCRelationshipSetFree(pkg->relationships);
DFHashTableRelease(pkg->partsByName);
@@ -405,7 +405,7 @@ static void saveRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const c
if (idCount == 0) {
DFError *error = NULL;
- if (DFStoreExists(pkg->store,relativePath) && !DFStoreDelete(pkg->store,relativePath,&error)) {
+ if (DFPackageExists(pkg->store,relativePath) && !DFPackageDelete(pkg->store,relativePath,&error)) {
OPCPackageError(pkg,"%s: %s",relativePath,DFErrorMessage(&error));
DFErrorRelease(error);
}
@@ -413,7 +413,7 @@ static void saveRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const c
else {
DFError *error = NULL;
DFDocument *doc = OPCRelationshipSetToDocument(rels);
- if (!DFSerializeXMLStore(doc,NAMESPACE_REL,0,pkg->store,relativePath,&error)) {
+ if (!DFSerializeXMLPackage(doc,NAMESPACE_REL,0,pkg->store,relativePath,&error)) {
OPCPackageError(pkg,"%s: %s",relativePath,DFErrorMessage(&error));
DFErrorRelease(error);
}
@@ -426,9 +426,9 @@ static void saveRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const c
static void readRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const char *partURI)
{
char *relFilename = relRelationshipsPathForURI(partURI);
- if (DFStoreExists(pkg->store,relFilename)) {
+ if (DFPackageExists(pkg->store,relFilename)) {
DFError *localError = NULL;
- DFDocument *relDoc = DFParseXMLStore(pkg->store,relFilename,&localError);
+ DFDocument *relDoc = DFParseXMLPackage(pkg->store,relFilename,&localError);
if (relDoc == NULL) {
OPCPackageError(pkg,"%s: %s",relFilename,DFErrorMessage(&localError));
DFErrorRelease(localError);
@@ -494,7 +494,7 @@ void OPCPackageReadRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, cons
static void findParts(OPCPackage *pkg)
{
DFError *error = NULL;
- const char **contents = DFStoreList(pkg->store,&error);
+ const char **contents = DFPackageList(pkg->store,&error);
if (contents == NULL) {
OPCPackageError(pkg,"findParts: %s",DFErrorMessage(&error));
DFErrorRelease(error);
@@ -504,7 +504,7 @@ static void findParts(OPCPackage *pkg)
for (int i = 0; contents[i]; i++) {
const char *relPath = contents[i];
char *absPath = DFFormatString("/%s",relPath);
- if (!DFStoreExists(pkg->store,relPath)) {
+ if (!DFPackageExists(pkg->store,relPath)) {
OPCPackageError(pkg,"%s: No such file or directory",relPath);
}
else if (!DFStringEqualsCI(absPath,"/[Content_Types].xml") && (strstr(absPath,"/_rels/") == NULL)) {
@@ -516,12 +516,12 @@ static void findParts(OPCPackage *pkg)
free(contents);
}
-OPCPackage *OPCPackageOpenNew(DFStore *store, DFError **error)
+OPCPackage *OPCPackageOpenNew(DFPackage *store, DFError **error)
{
return OPCPackageNew(store);
}
-OPCPackage *OPCPackageOpenFrom(DFStore *store, const char *filename, DFError **error)
+OPCPackage *OPCPackageOpenFrom(DFPackage *store, const char *filename, DFError **error)
{
int ok = 0;
OPCPackage *pkg = OPCPackageNew(store);
@@ -624,7 +624,7 @@ void OPCPackageRemoveRelatedPart(OPCPackage *pkg, const char *URI, const char *r
DFBuffer *OPCPackageReadPart(OPCPackage *pkg, OPCPart *part, DFError **error)
{
- DFBuffer *buffer = DFBufferReadFromStore(pkg->store,part->URI,error);
+ DFBuffer *buffer = DFBufferReadFromPackage(pkg->store,part->URI,error);
if (buffer == NULL) {
DFErrorFormat(error,"%s: %s",part->URI,DFErrorMessage(error));
return NULL;
@@ -638,7 +638,7 @@ int OPCPackageWritePart(OPCPackage *pkg, const char *data, size_t len, OPCPart *
int result = 0;
DFBuffer *buffer = DFBufferNew();
DFBufferAppendData(buffer,data,len);
- if (!DFBufferWriteToStore(buffer,pkg->store,part->URI,error))
+ if (!DFBufferWriteToPackage(buffer,pkg->store,part->URI,error))
DFErrorFormat(error,"%s: %s",part->URI,DFErrorMessage(error));
else
result = 1;
@@ -648,8 +648,8 @@ int OPCPackageWritePart(OPCPackage *pkg, const char *data, size_t len, OPCPart *
int OPCPackageDeletePart(OPCPackage *pkg, OPCPart *part, DFError **error)
{
- if (DFStoreExists(pkg->store,part->URI) &&
- !DFStoreDelete(pkg->store,part->URI,error)) {
+ if (DFPackageExists(pkg->store,part->URI) &&
+ !DFPackageDelete(pkg->store,part->URI,error)) {
DFErrorFormat(error,"%s: %s",part->URI,DFErrorMessage(error));
return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/common/OPC.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/common/OPC.h b/DocFormats/filters/ooxml/src/common/OPC.h
index a4ecf1f..2cb567d 100644
--- a/DocFormats/filters/ooxml/src/common/OPC.h
+++ b/DocFormats/filters/ooxml/src/common/OPC.h
@@ -18,7 +18,7 @@
#include "DFXMLForward.h"
#include "DFError.h"
#include "DFBuffer.h"
-#include "DFStore.h"
+#include "DFPackage.h"
#include "OOXMLTypedefs.h"
// Essentials of the Open Packaging Conventions
@@ -99,7 +99,7 @@ void OPCContentTypesRemoveOverride(OPCContentTypes *ct, const char *partName);
////////////////////////////////////////////////////////////////////////////////////////////////////
struct OPCPackage {
- DFStore *store;
+ DFPackage *store;
int isOpen;
OPCContentTypes *contentTypes;
OPCRelationshipSet *relationships;
@@ -107,8 +107,8 @@ struct OPCPackage {
struct DFHashTable *partsByName;
};
-OPCPackage *OPCPackageOpenNew(DFStore *store, DFError **error);
-OPCPackage *OPCPackageOpenFrom(DFStore *store, const char *filename, DFError **error);
+OPCPackage *OPCPackageOpenNew(DFPackage *store, DFError **error);
+OPCPackage *OPCPackageOpenFrom(DFPackage *store, const char *filename, DFError **error);
void OPCPackageFree(OPCPackage *pkg);
int OPCPackageSaveToDir(OPCPackage *pkg);
int OPCPackageSaveTo(OPCPackage *pkg, const char *filename);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/word/Word.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/Word.c b/DocFormats/filters/ooxml/src/word/Word.c
index f5747e0..876d9d7 100644
--- a/DocFormats/filters/ooxml/src/word/Word.c
+++ b/DocFormats/filters/ooxml/src/word/Word.c
@@ -28,8 +28,8 @@ int DFHTMLToWord(const char *sourcePath, const char *destPath, DFError **error)
char *htmlPath = DFPathDirName(sourcePath);
DFDocument *htmlDoc = NULL;
DFBuffer *warnings = DFBufferNew();
- DFStore *store = DFStoreNewMemory();
- WordPackage *package = NULL;
+ DFPackage *rawPackage = DFPackageNewMemory();
+ WordPackage *wordPackage = NULL;
htmlDoc = DFParseHTMLFile(sourcePath,0,error);
if (htmlDoc == NULL) {
@@ -39,11 +39,11 @@ int DFHTMLToWord(const char *sourcePath, const char *destPath, DFError **error)
goto end;
}
- package = WordPackageOpenNew(store,error);
- if (package == NULL)
+ wordPackage = WordPackageOpenNew(rawPackage,error);
+ if (wordPackage == NULL)
goto end;
- if (!WordPackageUpdateFromHTML(package,htmlDoc,htmlPath,idPrefix,error,warnings))
+ if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,htmlPath,idPrefix,error,warnings))
goto end;
if (warnings->len > 0) {
@@ -51,7 +51,7 @@ int DFHTMLToWord(const char *sourcePath, const char *destPath, DFError **error)
goto end;
}
- if (!WordPackageSaveTo(package,destPath,error))
+ if (!WordPackageSaveTo(wordPackage,destPath,error))
goto end;
ok = 1;
@@ -61,7 +61,7 @@ end:
free(htmlPath);
DFDocumentRelease(htmlDoc);
DFBufferRelease(warnings);
- DFStoreRelease(store);
- WordPackageRelease(package);
+ DFPackageRelease(rawPackage);
+ WordPackageRelease(wordPackage);
return ok;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/word/WordGC.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordGC.c b/DocFormats/filters/ooxml/src/word/WordGC.c
index 7e05592..4015648 100644
--- a/DocFormats/filters/ooxml/src/word/WordGC.c
+++ b/DocFormats/filters/ooxml/src/word/WordGC.c
@@ -67,7 +67,7 @@ static void collect(WordPackage *package, DFHashTable *referencedIds)
OPCRelationship *rel = OPCRelationshipSetLookupById(relationships,rId);
if (rel->needsRemoveCheck && (DFHashTableLookup(referencedIds,rel->rId) == NULL)) {
if (!rel->external)
- DFStoreDelete(package->opc->store,rel->target,NULL);
+ DFPackageDelete(package->opc->store,rel->target,NULL);
OPCRelationshipSetRemove(relationships,rel);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/word/WordPackage.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordPackage.c b/DocFormats/filters/ooxml/src/word/WordPackage.c
index 489f2d1..c11cb78 100644
--- a/DocFormats/filters/ooxml/src/word/WordPackage.c
+++ b/DocFormats/filters/ooxml/src/word/WordPackage.c
@@ -177,7 +177,7 @@ static void addMissingParts(WordPackage *package)
package->endnotes = DFDocumentNewWithRoot(WORD_ENDNOTES);
}
-WordPackage *WordPackageOpenNew(DFStore *store, DFError **error)
+WordPackage *WordPackageOpenNew(DFPackage *store, DFError **error)
{
OPCPackage *opc = OPCPackageOpenNew(store,error);
if (opc == NULL)
@@ -208,7 +208,7 @@ WordPackage *WordPackageOpenNew(DFStore *store, DFError **error)
return NULL;
}
-WordPackage *WordPackageOpenFrom(DFStore *store, const char *filename, DFError **error)
+WordPackage *WordPackageOpenFrom(DFPackage *store, const char *filename, DFError **error)
{
OPCPackage *opc = OPCPackageOpenFrom(store,filename,error);
if (opc == NULL)
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/word/WordPackage.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordPackage.h b/DocFormats/filters/ooxml/src/word/WordPackage.h
index ba40135..a141650 100644
--- a/DocFormats/filters/ooxml/src/word/WordPackage.h
+++ b/DocFormats/filters/ooxml/src/word/WordPackage.h
@@ -17,7 +17,7 @@
#include "DFXMLForward.h"
#include "OPC.h"
-#include "DFStore.h"
+#include "DFPackage.h"
#include "OOXMLTypedefs.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -56,8 +56,8 @@ int WordPackageSimplifyFields(WordPackage *package);
void WordPackageCollapseBookmarks(WordPackage *package);
void WordPackageExpandBookmarks(WordPackage *package);
-WordPackage *WordPackageOpenNew(DFStore *store, DFError **error);
-WordPackage *WordPackageOpenFrom(DFStore *store, const char *filename, DFError **error);
+WordPackage *WordPackageOpenNew(DFPackage *store, DFError **error);
+WordPackage *WordPackageOpenFrom(DFPackage *store, const char *filename, DFError **error);
int WordPackageSaveTo(WordPackage *package, const char *filename, DFError **error);
DFDocument *WordPackageGenerateHTML(WordPackage *package, const char *path, const char *idPrefix,
DFError **error, DFBuffer *warnings);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c b/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
index 0f5dfc5..33fc891 100644
--- a/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
+++ b/DocFormats/filters/ooxml/src/word/lenses/WordDrawing.c
@@ -202,7 +202,7 @@ static DFNode *imageWithFilename(WordGetData *get, const char *filename, double
goto end;
}
- content = DFBufferReadFromStore(get->conv->package->opc->store,filename,&error);
+ content = DFBufferReadFromPackage(get->conv->package->opc->store,filename,&error);
if (content == NULL) {
WordConverterWarning(get->conv,"Copy %s to %s: %s",filename,dstImagePath,DFErrorMessage(&error));
DFErrorRelease(error);
@@ -342,9 +342,9 @@ int WordDrawingIsVisible(WordPutData *put, DFNode *concrete)
return 1;
}
-static char *genImageFilename(DFStore *store, const char *mediaRelDir, const char *extension, DFError **error)
+static char *genImageFilename(DFPackage *package, const char *mediaRelDir, const char *extension, DFError **error)
{
- const char **paths = DFStoreList(store,error);
+ const char **paths = DFPackageList(package,error);
if (paths == NULL)
return NULL;;
@@ -380,11 +380,11 @@ static char *genImageFilename(DFStore *store, const char *mediaRelDir, const cha
static OPCRelationship *addImageRelationship(WordConverter *converter, const char *src, DFError **error)
{
- DFStore *store = converter->package->opc->store;
+ DFPackage *package = converter->package->opc->store;
const char *mediaDir = "word/media";
char *ext = DFPathExtension(src);
- char *filename = genImageFilename(store,mediaDir,ext,error);
+ char *filename = genImageFilename(package,mediaDir,ext,error);
free(ext);
if (filename == NULL)
return NULL;
@@ -396,7 +396,7 @@ static OPCRelationship *addImageRelationship(WordConverter *converter, const cha
OPCRelationship *result = NULL;
DFBuffer *content = DFBufferReadFromFile(srcPath,error);
- if ((content != NULL) && DFBufferWriteToStore(content,store,destPath,error)) {
+ if ((content != NULL) && DFBufferWriteToPackage(content,package,destPath,error)) {
OPCRelationshipSet *rels = converter->package->documentPart->relationships;
char *relPath = DFFormatString("/word/media/%s",filename);
result = OPCRelationshipSetAddType(rels,WORDREL_IMAGE,relPath,0);
@@ -549,16 +549,16 @@ static int internalPut2(WordPutData *put, DFNode *abstract, DFNode *concrete, in
if ((wordInfo != NULL) && (wordInfo->widthPts > 0) && (wordInfo->heightPts > 0) && (rel != NULL)) {
const char *wordSrc = rel->target;
- DFStore *store = put->conv->package->opc->store;
+ DFPackage *package = put->conv->package->opc->store;
- if (!DFStoreExists(store,wordSrc)) {
+ if (!DFPackageExists(package,wordSrc)) {
WordConverterWarning(put->conv,"Word image %s does not exist",wordSrc);
ImageInfoFree(wordInfo);
return 0;
}
DFBuffer *content1 = DFBufferReadFromFile(htmlPath,NULL);
- DFBuffer *content2 = DFBufferReadFromStore(store,wordSrc,NULL);
+ DFBuffer *content2 = DFBufferReadFromPackage(package,wordSrc,NULL);
int contentsEqual = ((content1 != NULL) && (content2 != NULL) &&
(content1->len == content2->len) &&
!memcmp(content1->data,content2->data,content1->len));
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/consumers/dfutil/src/Commands.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Commands.c b/consumers/dfutil/src/Commands.c
index e5b3ec9..beb5e58 100644
--- a/consumers/dfutil/src/Commands.c
+++ b/consumers/dfutil/src/Commands.c
@@ -110,18 +110,18 @@ static int prettyPrintWordFile(const char *filename, DFError **error)
char *wordTempPath = DFAppendPathComponent(tempPath,"word");
char *plainTempPath = DFAppendPathComponent(tempPath,"plain");
char *plain = NULL;
- WordPackage *package = NULL;
- DFStore *store = DFStoreNewMemory();
+ WordPackage *wordPackage = NULL;
+ DFPackage *rawPackage = DFPackageNewMemory();
if (!DFEmptyDirectory(wordTempPath,error))
goto end;
- package = WordPackageOpenFrom(store,filename,error);
- if (package == NULL)
+ wordPackage = WordPackageOpenFrom(rawPackage,filename,error);
+ if (wordPackage == NULL)
goto end;
- WordPackageRemovePointlessElements(package);
- plain = Word_toPlain(package,NULL,plainTempPath);
+ WordPackageRemovePointlessElements(wordPackage);
+ plain = Word_toPlain(wordPackage,NULL,plainTempPath);
printf("%s",plain);
ok = 1;
@@ -131,8 +131,8 @@ end:
free(wordTempPath);
free(plainTempPath);
free(plain);
- DFStoreRelease(store);
- WordPackageRelease(package);
+ DFPackageRelease(rawPackage);
+ WordPackageRelease(wordPackage);
DFDeleteFile(tempPath,NULL);
return ok;
}
@@ -324,23 +324,23 @@ int simplifyFields(const char *inFilename, const char *outFilename, DFError **er
return 0;
}
- DFStore *store = DFStoreNewMemory();
- WordPackage *package = WordPackageOpenFrom(store,inFilename,error);
- DFStoreRelease(store);
- if (package == NULL) {
+ DFPackage *rawPackage = DFPackageNewMemory();
+ WordPackage *wordPackage = WordPackageOpenFrom(rawPackage,inFilename,error);
+ DFPackageRelease(rawPackage);
+ if (wordPackage == NULL) {
DFErrorFormat(error,"%s: %s",inFilename,DFErrorMessage(error));
return 0;
}
- WordPackageSimplifyFields(package);
+ WordPackageSimplifyFields(wordPackage);
- if (!WordPackageSaveTo(package,outFilename,error)) {
+ if (!WordPackageSaveTo(wordPackage,outFilename,error)) {
DFErrorFormat(error,"%s: %s",outFilename,DFErrorMessage(error));
- WordPackageRelease(package);
+ WordPackageRelease(wordPackage);
return 0;
}
- WordPackageRelease(package);
+ WordPackageRelease(wordPackage);
return 1;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/consumers/dfutil/src/Plain.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Plain.c b/consumers/dfutil/src/Plain.c
index 3a83a42..6611220 100644
--- a/consumers/dfutil/src/Plain.c
+++ b/consumers/dfutil/src/Plain.c
@@ -60,13 +60,13 @@ static void addSerializedBinary(DFBuffer *result, DFBuffer *data, const char *fi
}
}
-static char *findDocumentPath(DFStore *store, DFError **error)
+static char *findDocumentPath(DFPackage *package, DFError **error)
{
int ok = 0;
DFDocument *relsDoc = NULL;
char *result = NULL;
- relsDoc = DFParseXMLStore(store,"/_rels/.rels",error);
+ relsDoc = DFParseXMLPackage(package,"/_rels/.rels",error);
if (relsDoc == NULL) {
DFErrorFormat(error,"_rels/.rels: %s",DFErrorMessage(error));
goto end;
@@ -124,13 +124,13 @@ static void parseDocumentRels(DFDocument *relsDoc, DFHashTable *rels, DFError **
}
static int addRelatedDoc(DFHashTable *parts, DFHashTable *documentRels, const char *relName, const char *filename,
- DFBuffer *output, DFHashTable *includeTypes, DFStore *store, DFError **error)
+ DFBuffer *output, DFHashTable *includeTypes, DFPackage *package, DFError **error)
{
const char *relPath = DFHashTableLookup(documentRels,relName);
if (relPath == NULL)
return 1;;
- DFDocument *doc = DFParseXMLStore(store,relPath,error);
+ DFDocument *doc = DFParseXMLPackage(package,relPath,error);
if (doc == NULL) {
DFErrorFormat(error,"%s: %s",relPath,DFErrorMessage(error));
return 0;
@@ -147,7 +147,7 @@ static int addRelatedDoc(DFHashTable *parts, DFHashTable *documentRels, const ch
static int processParts(DFHashTable *parts, const char *documentPath, DFDocument *relsDoc,
DFHashTable *documentRels,
- DFBuffer *output, DFStore *store, DFError **error)
+ DFBuffer *output, DFPackage *package, DFError **error)
{
int ok = 0;
DFHashTable *includeTypes = DFHashTableNew((DFCopyFunction)strdup,free);
@@ -155,7 +155,7 @@ static int processParts(DFHashTable *parts, const char *documentPath, DFDocument
DFHashTableAdd(includeTypes,WORDREL_IMAGE,"");
if ((parts == NULL) || (DFHashTableLookup(parts,"document") != NULL)) {
- DFDocument *doc = DFParseXMLStore(store,documentPath,error);
+ DFDocument *doc = DFParseXMLPackage(package,documentPath,error);
if (doc == NULL)
goto end;
addStrippedSerializedDoc(output,doc,"document.xml");
@@ -163,27 +163,27 @@ static int processParts(DFHashTable *parts, const char *documentPath, DFDocument
}
if ((parts == NULL) || (DFHashTableLookup(parts,"styles") != NULL)) {
- if (!addRelatedDoc(parts,documentRels,WORDREL_STYLES,"styles.xml",output,includeTypes,store,error))
+ if (!addRelatedDoc(parts,documentRels,WORDREL_STYLES,"styles.xml",output,includeTypes,package,error))
goto end;
}
if ((parts == NULL) || (DFHashTableLookup(parts,"numbering") != NULL)) {
- if (!addRelatedDoc(parts,documentRels,WORDREL_NUMBERING,"numbering.xml",output,includeTypes,store,error))
+ if (!addRelatedDoc(parts,documentRels,WORDREL_NUMBERING,"numbering.xml",output,includeTypes,package,error))
goto end;
}
if ((parts == NULL) || (DFHashTableLookup(parts,"footnotes") != NULL)) {
- if (!addRelatedDoc(parts,documentRels,WORDREL_FOOTNOTES,"footnotes.xml",output,includeTypes,store,error))
+ if (!addRelatedDoc(parts,documentRels,WORDREL_FOOTNOTES,"footnotes.xml",output,includeTypes,package,error))
goto end;
}
if ((parts == NULL) || (DFHashTableLookup(parts,"endnotes") != NULL)) {
- if (!addRelatedDoc(parts,documentRels,WORDREL_ENDNOTES,"endnotes.xml",output,includeTypes,store,error))
+ if (!addRelatedDoc(parts,documentRels,WORDREL_ENDNOTES,"endnotes.xml",output,includeTypes,package,error))
goto end;
}
if ((parts != NULL) && (DFHashTableLookup(parts,"settings") != NULL)) {
- if (!addRelatedDoc(parts,documentRels,WORDREL_SETTINGS,"settings.xml",output,includeTypes,store,error))
+ if (!addRelatedDoc(parts,documentRels,WORDREL_SETTINGS,"settings.xml",output,includeTypes,package,error))
goto end;
}
if ((parts != NULL) && (DFHashTableLookup(parts,"theme") != NULL)) {
- if (!addRelatedDoc(parts,documentRels,WORDREL_THEME,"theme.xml",output,includeTypes,store,error))
+ if (!addRelatedDoc(parts,documentRels,WORDREL_THEME,"theme.xml",output,includeTypes,package,error))
goto end;
}
@@ -207,7 +207,7 @@ static int processParts(DFHashTable *parts, const char *documentPath, DFDocument
addSerializedDoc(output,relsDoc,"document.xml.rels");
}
- const char **entries = DFStoreList(store,NULL);
+ const char **entries = DFPackageList(package,NULL);
if (entries != NULL) { // FIXME: Should really report an error if this is not the case
for (int i = 0; entries[i]; i++) {
const char *filename = entries[i];
@@ -218,7 +218,7 @@ static int processParts(DFHashTable *parts, const char *documentPath, DFDocument
absFilename = DFFormatString("/%s",filename);
else
absFilename = strdup(filename);
- DFBuffer *data = DFBufferReadFromStore(store,absFilename,NULL);
+ DFBuffer *data = DFBufferReadFromPackage(package,absFilename,NULL);
addSerializedBinary(output,data,absFilename);
DFBufferRelease(data);
free(absFilename);
@@ -235,7 +235,7 @@ end:
return ok;
}
-static char *Word_toPlainFromDir(DFStore *store, DFHashTable *parts, DFError **error)
+static char *Word_toPlainFromDir(DFPackage *package, DFHashTable *parts, DFError **error)
{
char *documentPath = NULL;
DFHashTable *rels = DFHashTableNew((DFCopyFunction)strdup,(DFFreeFunction)free);
@@ -245,21 +245,21 @@ static char *Word_toPlainFromDir(DFStore *store, DFHashTable *parts, DFError **e
int ok = 0;
- documentPath = findDocumentPath(store,error);
+ documentPath = findDocumentPath(package,error);
if (documentPath == NULL) {
DFErrorFormat(error,"findDocumentPath: %s",DFErrorMessage(error));
goto end;
}
relsPathRel = computeDocumentRelsPath(documentPath);
- if (DFStoreExists(store,relsPathRel) && ((relsDoc = DFParseXMLStore(store,relsPathRel,error)) == NULL)) {
+ if (DFPackageExists(package,relsPathRel) && ((relsDoc = DFParseXMLPackage(package,relsPathRel,error)) == NULL)) {
DFErrorFormat(error,"%s: %s",relsPathRel,DFErrorMessage(error));
goto end;
}
parseDocumentRels(relsDoc,rels,error);
- if (!processParts(parts,documentPath,relsDoc,rels,output,store,error))
+ if (!processParts(parts,documentPath,relsDoc,rels,output,package,error))
goto end;
ok = 1;
@@ -280,10 +280,10 @@ end:
}
}
-static char *Word_toPlainOrError(WordPackage *package, DFHashTable *parts, const char *tempPath, DFError **error)
+static char *Word_toPlainOrError(WordPackage *wordPackage, DFHashTable *parts, const char *tempPath, DFError **error)
{
char *docxPath = DFAppendPathComponent(tempPath,"file.docx");
- DFStore *contentsStore = DFStoreNewMemory();
+ DFPackage *contentsStore = DFPackageNewMemory();
char *result = NULL;
int ok = 0;
@@ -292,7 +292,7 @@ static char *Word_toPlainOrError(WordPackage *package, DFHashTable *parts, const
goto end;
}
- if (!WordPackageSaveTo(package,docxPath,error)) {
+ if (!WordPackageSaveTo(wordPackage,docxPath,error)) {
DFErrorFormat(error,"WordPackageSaveTo: %s",DFErrorMessage(error));
goto end;
}
@@ -307,17 +307,17 @@ static char *Word_toPlainOrError(WordPackage *package, DFHashTable *parts, const
end:
free(docxPath);
- DFStoreRelease(contentsStore);
+ DFPackageRelease(contentsStore);
if (ok)
return result;
free(result);
return 0;
}
-char *Word_toPlain(WordPackage *package, DFHashTable *parts, const char *tempPath)
+char *Word_toPlain(WordPackage *wordPackage, DFHashTable *parts, const char *tempPath)
{
DFError *error = NULL;
- char *result = Word_toPlainOrError(package,parts,tempPath,&error);
+ char *result = Word_toPlainOrError(wordPackage,parts,tempPath,&error);
if (result == NULL) {
result = DFFormatString("%s\n",DFErrorMessage(&error));
DFErrorRelease(error);
@@ -325,12 +325,12 @@ char *Word_toPlain(WordPackage *package, DFHashTable *parts, const char *tempPat
return result;
}
-static int saveXMLDocument(DFStore *store, const char *filename, DFDocument *doc, NamespaceID defaultNS, DFError **error)
+static int saveXMLDocument(DFPackage *package, const char *filename, DFDocument *doc, NamespaceID defaultNS, DFError **error)
{
char *parentPath = DFPathDirName(filename);
int ok = 0;
- if (!DFSerializeXMLStore(doc,defaultNS,0,store,filename,error)) {
+ if (!DFSerializeXMLPackage(doc,defaultNS,0,package,filename,error)) {
DFErrorFormat(error,"serialize %s: %s",filename,DFErrorMessage(error));
goto end;
}
@@ -342,14 +342,14 @@ end:
return ok;
}
-static int saveStrippedXMLText(DFStore *store, const char *filename,
+static int saveStrippedXMLText(DFPackage *package, const char *filename,
const char *input, NamespaceID defaultNS, DFError **error)
{
DFDocument *doc = DFParseXMLString(input,error);
if (doc == NULL)
return 0;
DFStripWhitespace(doc->docNode);
- int ok = saveXMLDocument(store,filename,doc,defaultNS,error);
+ int ok = saveXMLDocument(package,filename,doc,defaultNS,error);
DFDocumentRelease(doc);
return ok;
}
@@ -361,7 +361,7 @@ typedef struct PartInfo {
const char *type;
} PartInfo;
-static int saveContentTypes(DFStore *store, DFHashTable *ctDefaults, DFHashTable *ctOverrides, DFError **error)
+static int saveContentTypes(DFPackage *package, DFHashTable *ctDefaults, DFHashTable *ctOverrides, DFError **error)
{
DFDocument *doc = DFDocumentNewWithRoot(CT_TYPES);
@@ -386,12 +386,12 @@ static int saveContentTypes(DFStore *store, DFHashTable *ctDefaults, DFHashTable
}
free(keys);
- int ok = saveXMLDocument(store,"[Content_Types].xml",doc,NAMESPACE_CT,error);
+ int ok = saveXMLDocument(package,"[Content_Types].xml",doc,NAMESPACE_CT,error);
DFDocumentRelease(doc);
return ok;
}
-static int saveDocRels(DFStore *store,
+static int saveDocRels(DFPackage *package,
DFHashTable *docRelURIs,
DFHashTable *docRelTypes,
DFHashTable *docRelModes,
@@ -417,24 +417,24 @@ static int saveDocRels(DFStore *store,
}
free(sortedIds);
- int ok = saveXMLDocument(store,"/word/_rels/document.xml.rels",doc,NAMESPACE_REL,error);
+ int ok = saveXMLDocument(package,"/word/_rels/document.xml.rels",doc,NAMESPACE_REL,error);
DFDocumentRelease(doc);
return ok;
}
-static int saveRootRels(DFStore *store, DFError **error)
+static int saveRootRels(DFPackage *package, DFError **error)
{
DFDocument *doc = DFDocumentNewWithRoot(REL_RELATIONSHIPS);
DFNode *rel = DFCreateChildElement(doc->root,REL_RELATIONSHIP);
DFSetAttribute(rel,NULL_Id,"rId1");
DFSetAttribute(rel,NULL_Type,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument");
DFSetAttribute(rel,NULL_TARGET,"/word/document.xml");
- int ok = saveXMLDocument(store,"/_rels/.rels",doc,NAMESPACE_REL,error);
+ int ok = saveXMLDocument(package,"/_rels/.rels",doc,NAMESPACE_REL,error);
DFDocumentRelease(doc);
return ok;
}
-static int Word_fromPackage(TextPackage *tp, DFStore *store, DFError **error)
+static int Word_fromPackage(TextPackage *tp, DFPackage *store, DFError **error)
{
PartInfo parts[7] = {
{ "numbering.xml", "/word/numbering.xml", WORDREL_NUMBERING, WORDTYPE_NUMBERING },
@@ -518,7 +518,7 @@ static int Word_fromPackage(TextPackage *tp, DFStore *store, DFError **error)
int fileok = 1;
DFBuffer *data = stringToBinary(str);
- if (!DFBufferWriteToStore(data,store,curFilename,error)) {
+ if (!DFBufferWriteToPackage(data,store,curFilename,error)) {
DFErrorFormat(error,"%s: %s",curFilename,DFErrorMessage(error));
fileok = 0;
}
@@ -594,8 +594,8 @@ WordPackage *Word_fromPlain(const char *plain, const char *plainPath, const char
{
int ok = 0;
char *docxPath = DFAppendPathComponent(zipTempPath,"document.docx");
- DFStore *firstStore = DFStoreNewMemory();
- DFStore *secondStore = DFStoreNewMemory();
+ DFPackage *firstStore = DFPackageNewMemory();
+ DFPackage *secondStore = DFPackageNewMemory();
WordPackage *wp = NULL;
TextPackage *tp = NULL;
@@ -635,8 +635,8 @@ WordPackage *Word_fromPlain(const char *plain, const char *plainPath, const char
end:
free(docxPath);
- DFStoreRelease(firstStore);
- DFStoreRelease(secondStore);
+ DFPackageRelease(firstStore);
+ DFPackageRelease(secondStore);
TextPackageRelease(tp);
if (ok) {
return wp;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/consumers/dfutil/src/TestFunctions.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/TestFunctions.c b/consumers/dfutil/src/TestFunctions.c
index 859ad93..02d75c7 100644
--- a/consumers/dfutil/src/TestFunctions.c
+++ b/consumers/dfutil/src/TestFunctions.c
@@ -207,8 +207,8 @@ static DFHashTable *getFlags(int argc, const char **argv)
static void Word_testCreate(TestCase *script, int argc, const char **argv)
{
- DFStore *store = DFStoreNewMemory();
- WordPackage *package = NULL;
+ DFPackage *package = DFPackageNewMemory();
+ WordPackage *wordPackage = NULL;
DFDocument *htmlDoc = NULL;
DFHashTable *parts = NULL;
@@ -222,14 +222,14 @@ static void Word_testCreate(TestCase *script, int argc, const char **argv)
goto end;;
// Create the docx file
- package = WordPackageOpenNew(store,&error);
- if (package == NULL) {
+ wordPackage = WordPackageOpenNew(package,&error);
+ if (wordPackage == NULL) {
DFBufferFormat(script->output,"%s\n",DFErrorMessage(&error));
goto end;
}
DFBuffer *warnings = DFBufferNew();
- if (!WordPackageUpdateFromHTML(package,htmlDoc,script->abstractPath,"word",&error,warnings)) {
+ if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,script->abstractPath,"word",&error,warnings)) {
DFBufferFormat(script->output,"%s\n",DFErrorMessage(&error));
goto end;
}
@@ -242,12 +242,12 @@ static void Word_testCreate(TestCase *script, int argc, const char **argv)
DFBufferRelease(warnings);
// We don't actually "save" the package as such; this is just to ensure the missing OPC parts are added
- WordPackageSaveTo(package,NULL,NULL);
+ WordPackageSaveTo(wordPackage,NULL,NULL);
// Output the docx file
parts = getFlags(argc,argv);
plainTempPath = DFAppendPathComponent(script->tempPath,"plain");
- plain = Word_toPlain(package,parts,plainTempPath);
+ plain = Word_toPlain(wordPackage,parts,plainTempPath);
DFBufferFormat(script->output,"%s",plain);
end:
@@ -256,8 +256,8 @@ end:
free(plain);
DFHashTableRelease(parts);
DFErrorRelease(error);
- DFStoreRelease(store);
- WordPackageRelease(package);
+ DFPackageRelease(package);
+ WordPackageRelease(wordPackage);
}
static void Word_testUpdate2(TestCase *script, WordPackage *package, int argc, const char **argv)
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/ff75357d/consumers/dfutil/src/main.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/main.c b/consumers/dfutil/src/main.c
index c61b25c..8696820 100644
--- a/consumers/dfutil/src/main.c
+++ b/consumers/dfutil/src/main.c
@@ -95,15 +95,15 @@ static int runCommand(int argc, const char **argv, DFError **dferr)
}
#endif
else if ((argc == 4) && !strcmp(argv[1],"-zip")) {
- DFStore *store = DFStoreNewFilesystem(argv[3]);
- int r = DFZip(argv[2],store,dferr);
- DFStoreRelease(store);
+ DFPackage *package = DFPackageNewFilesystem(argv[3]);
+ int r = DFZip(argv[2],package,dferr);
+ DFPackageRelease(package);
return r;
}
else if ((argc == 4) && !strcmp(argv[1],"-unzip")) {
- DFStore *store = DFStoreNewFilesystem(argv[3]);
- int r = DFUnzip(argv[2],store,dferr);
- DFStoreRelease(store);
+ DFPackage *package = DFPackageNewFilesystem(argv[3]);
+ int r = DFUnzip(argv[2],package,dferr);
+ DFPackageRelease(package);
return r;
}
else if (argc == 3) {