summaryrefslogtreecommitdiff
path: root/src/rtfx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rtfx.cpp')
-rw-r--r--src/rtfx.cpp50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/rtfx.cpp b/src/rtfx.cpp
index cbecdb9..541432e 100644
--- a/src/rtfx.cpp
+++ b/src/rtfx.cpp
@@ -46,23 +46,56 @@
int usage()
{
- fprintf(stderr, "usage: rtfx <inrtf> <outxml>\n");
- return 2;
+ fprintf(stderr, "usage: rtfx [-p] <inrtf> <outxml>\n");
+ exit(2);
}
int main(int argc, char* argv[])
{
- if(argc < 3)
- return usage();
+ XmlComposerOptions options;
+
+ while(argc > 1)
+ {
+ argc--;
+ argv++;
+
+ char* arg = argv[0];
+ if(*arg != '-')
+ break;
+
+ while(arg && *(++arg))
+ {
+ switch(*arg)
+ {
+ case 'p':
+ options.extras = true;
+ break;
+
+ case '-':
+ arg = NULL;
+ break;
+
+ case '?':
+ default:
+ usage();
+ }
+ }
+
+ if(arg == NULL)
+ break;
+ }
+
+ if(argc < 2)
+ usage();
try
{
// The input file
- FILE* file = fopen(argv[1], "rb");
+ FILE* file = fopen(argv[0], "rb");
if(!file)
{
- fprintf(stderr, "rtfx: couldn't open rtf file: %s: %s\n", argv[1], strerror(errno));
+ fprintf(stderr, "rtfx: couldn't open rtf file: %s: %s\n", argv[0], strerror(errno));
return 1;
}
@@ -70,7 +103,6 @@ int main(int argc, char* argv[])
RtfParser rtf;
// Interprets tags and blocks from RTFParser
- XmlComposerOptions options;
XmlComposer composer(options);
rtf.setHandler(&composer);
@@ -88,10 +120,10 @@ int main(int argc, char* argv[])
DOM::Document doc = composer.getDocument();
string xml = doc.serialize();
- FILE* out = fopen(argv[2], "wb");
+ FILE* out = fopen(argv[1], "wb");
if(!out)
{
- fprintf(stderr, "rtfx: couldn't open file: %s: %s\n", argv[2], strerror(errno));
+ fprintf(stderr, "rtfx: couldn't open file: %s: %s\n", argv[1], strerror(errno));
return 1;
}