Update of /cvsroot/libwpg/libwpg/src/conv/svg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11391/src/conv/svg
Modified Files:
wpg2svg.cpp
Log Message:
some anonymous namespaces here and there + some more verbose --help and --version output
Index: wpg2svg.cpp
===================================================================
RCS file: /cvsroot/libwpg/libwpg/src/conv/svg/wpg2svg.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- wpg2svg.cpp 26 Oct 2007 08:16:07 -0000 1.4
+++ wpg2svg.cpp 27 Jul 2008 20:56:16 -0000 1.5
@@ -25,20 +25,51 @@
#include <iostream>
#include <sstream>
+#include <string.h>
#include "libwpg.h"
#include <libwpd-stream/WPXStreamImplementation.h>
+namespace {
+
+int printUsage()
+{
+ printf("Usage: wpg2svg [OPTION] <WordPerfect Graphics File>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--help Shows this help message\n");
+ printf("--version Output wpg2svg version \n");
+ return -1;
+}
+
+int printVersion()
+{
+ printf("wpg2svg %s\n", LIBWPG_VERSION_STRING);
+ return 0;
+}
+
+} // anonymous namespace
int main(int argc, char *argv[])
{
if (argc < 2)
+ return printUsage();
+
+ char *file = 0;
+
+ for (int i = 1; i < argc; i++)
{
- std::cout << "usage: wpg2svg <WordPerfect Graphic>" << std::endl;
- return -1;
+ if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
}
- const char* filename = argv[1];
- WPXFileStream input(filename);
+ if (!file)
+ return printUsage();
+
+ WPXFileStream input(file);
if (!libwpg::WPGraphics::isSupported(&input))
{
|