From: Fridrich S. <str...@us...> - 2008-07-27 20:56:20
|
Update of /cvsroot/libwpg/libwpg/src/conv/raw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11391/src/conv/raw Modified Files: wpg2raw.cpp Log Message: some anonymous namespaces here and there + some more verbose --help and --version output Index: wpg2raw.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/conv/raw/wpg2raw.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- wpg2raw.cpp 16 Jul 2008 14:10:59 -0000 1.10 +++ wpg2raw.cpp 27 Jul 2008 20:56:16 -0000 1.11 @@ -26,6 +26,7 @@ */ #include <stdio.h> +#include <string.h> #include "libwpg.h" #include <libwpd-stream/WPXStreamImplementation.h> @@ -157,16 +158,47 @@ printf("RawPainter::drawBinaryData\n"); } +namespace { + +int printUsage() +{ + printf("Usage: wpg2raw [OPTION] <WordPerfect Graphics File>\n"); + printf("\n"); + printf("Options:\n"); + printf("--help Shows this help message\n"); + printf("--version Output wpg2raw version \n"); + return -1; +} + +int printVersion() +{ + printf("wpg2raw %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++) { - printf("usage: wpg2raw <WordPerfect Graphic>\n"); - 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)) { |