corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject [82/92] [abbrv] incubator-corinthia git commit: Add dfconvert
Date Wed, 17 Dec 2014 13:29:32 GMT
Add dfconvert

This program provides command-line access to the get, put, and create
operations that were previously accessible via dfutil. It is the first
consumer to stricly use only the public API exposed by DocFormats.


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

Branch: refs/heads/stable
Commit: 58ddc77325ee7f8ea207895ce70723470f71ce50
Parents: 54c407e
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Mon Dec 8 15:18:59 2014 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Mon Dec 8 15:18:59 2014 +0700

----------------------------------------------------------------------
 CMakeLists.txt                         |  1 +
 consumers/dfconvert/src/CMakeLists.txt | 12 +++++
 consumers/dfconvert/src/main.c         | 70 +++++++++++++++++++++++++++++
 consumers/dfutil/src/main.c            | 31 -------------
 4 files changed, 83 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/58ddc773/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d74b05..ef639ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,4 +43,5 @@ add_subdirectory(DocFormats/3rdparty/external/minizip)
 add_subdirectory(DocFormats/3rdparty/external/w3c-tidy-html5)
 add_subdirectory(DocFormats)
 add_subdirectory(consumers/dftest/src)
+add_subdirectory(consumers/dfconvert/src)
 add_subdirectory(consumers/dfutil/src)

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/58ddc773/consumers/dfconvert/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/consumers/dfconvert/src/CMakeLists.txt b/consumers/dfconvert/src/CMakeLists.txt
new file mode 100644
index 0000000..534a8e8
--- /dev/null
+++ b/consumers/dfconvert/src/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 2.8)
+
+set(SOURCES
+    main.c)
+
+include_directories(SYSTEM ${INCLUDE_DIRS})
+include_directories(SYSTEM ../../../DocFormats/api/headers)
+include_directories(.)
+link_directories(${LIB_DIRS})
+
+add_executable(dfconvert ${SOURCES})
+target_link_libraries(dfconvert DocFormats ${LIBS})

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/58ddc773/consumers/dfconvert/src/main.c
----------------------------------------------------------------------
diff --git a/consumers/dfconvert/src/main.c b/consumers/dfconvert/src/main.c
new file mode 100644
index 0000000..abaaec1
--- /dev/null
+++ b/consumers/dfconvert/src/main.c
@@ -0,0 +1,70 @@
+// 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 <DocFormats/DocFormats.h>
+#include <stdio.h>
+#include <string.h>
+
+void usage(void)
+{
+    printf("Usage:\n"
+           "\n"
+           "dfconvert get concrete.docx abstract.html\n"
+           "\n"
+           "    Create a new HTML file from a Word document. The HTML file must not\n"
+           "    already exist.\n"
+           "\n"
+           "dfconvert put concrete.docx abstract.html\n"
+           "\n"
+           "    Update an existing Word document based on a modified HTML file. The\n"
+           "    Word document must already exist, and must be same document from\n"
+           "    which the HTML file was originally generated.\n"
+           "\n"
+           "    The put operation cannot be executed twice on the same Word\n"
+           "    document, because after the first time, the fact that the document\n"
+           "    is modified will mean that the ids become out of sync with the HTML\n"
+           "    file.  If you want to update a document multiple times, you must\n"
+           "    create a copy of the .docx file each time, and update that.\n"
+           "\n"
+           "dfconvert create concrete.docx abstract.html\n"
+           "\n"
+           "    Create a new Word document from a HTML file. The Word document must\n"
+           "    not already exist.\n"
+           "\n");
+}
+
+int main(int argc, const char **argv)
+{
+    DFError *error = NULL;
+    if ((argc == 4) && !strcmp(argv[1],"get")) {
+        if (DFGetFile(argv[2],argv[3],&error))
+            return 0;
+    }
+    else if ((argc == 4) && !strcmp(argv[1],"put")) {
+        if (DFPutFile(argv[2],argv[3],&error))
+            return 0;
+    }
+    else if ((argc == 4) && !strcmp(argv[1],"create")) {
+        if (DFCreateFile(argv[2],argv[3],&error))
+            return 0;
+    }
+    else {
+        usage();
+        return 0;
+    }
+
+    fprintf(stderr,"%s\n",DFErrorMessage(&error));
+    DFErrorRelease(error);
+    return 1;
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/58ddc773/consumers/dfutil/src/main.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/main.c b/consumers/dfutil/src/main.c
index 57a36ea..8f9db82 100644
--- a/consumers/dfutil/src/main.c
+++ b/consumers/dfutil/src/main.c
@@ -104,41 +104,10 @@ static int runCommand(int argc, const char **argv, DFError **dferr)
         DFStorageRelease(storage);
         return r;
     }
-    else if ((argc == 4) && !strcmp(argv[1],"get")) {
-        return DFGetFile(argv[2],argv[3],dferr);
-    }
-    else if ((argc == 4) && !strcmp(argv[1],"put")) {
-        return DFPutFile(argv[2],argv[3],dferr);
-    }
-    else if ((argc == 4) && !strcmp(argv[1],"create")) {
-        return DFCreateFile(argv[2],argv[3],dferr);
-    }
     else {
                ////////////////////////////////////////////////////////////////////////////////
         printf("Usage:\n"
                "\n"
-               "dfutil get concrete.docx abstract.html\n"
-               "\n"
-               "    Create a new HTML file from a Word document. The HTML file must not\n"
-               "    already exist.\n"
-               "\n"
-               "dfutil put concrete.docx abstract.html\n"
-               "\n"
-               "    Update an existing Word document based on a modified HTML file. The\n"
-               "    Word document must already exist, and must be same document from\n"
-               "    which the HTML file was originally generated.\n"
-               "\n"
-               "    The put operation cannot be executed twice on the same Word\n"
-               "    document, because after the first time, the fact that the document\n"
-               "    is modified will mean that the ids become out of sync with the HTML\n"
-               "    file.  If you want to update a document multiple times, you must\n"
-               "    create a copy of the .docx file each time, and update that.\n"
-               "\n"
-               "dfutil create concrete.docx abstract.html\n"
-               "\n"
-               "    Create a new Word document from a HTML file. The Word document must\n"
-               "    not already exist.\n"
-               "\n"
               "dfutil -pp filename\n"
               "    Print a plain text version of a .docx or .odt file to standard output\n"
               "\n"


Mime
View raw message