diff options
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | config.win32.h | 6 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | libs/.cvsignore | 1 | ||||
-rw-r--r-- | src/rtfx.cpp | 60 |
6 files changed, 56 insertions, 20 deletions
@@ -1,7 +1,5 @@ - Nate Nielsen <nielsen@memberwebs.com> - DOMC Library by: Michael B. Allen http://www.ioplex.com/~miallen/domc/ @@ -1,3 +1,6 @@ +Version 0.9.5 + - Allow conversions on stdin and stdout + Version 0.9.4 - Switched from Sablotron to DOMC (due to speed and dependency issues) - Added support for ANSI to Unicode conversions diff --git a/config.win32.h b/config.win32.h index 1d253c3..5fcd53a 100644 --- a/config.win32.h +++ b/config.win32.h @@ -98,13 +98,13 @@ #define PACKAGE_NAME "rtfx" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "rtfx 0.9.2" +#define PACKAGE_STRING "rtfx 0.9.5" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "rtfx" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.9.2" +#define PACKAGE_VERSION "0.9.5" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be @@ -118,7 +118,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "0.9.2" +#define VERSION "0.9.5" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ diff --git a/configure.in b/configure.in index 363734d..3ce26de 100644 --- a/configure.in +++ b/configure.in @@ -36,8 +36,8 @@ dnl Nate Nielsen <nielsen@memberwebs.com> dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT(rtfx, 0.9.4, nielsen@memberwebs.com) -AM_INIT_AUTOMAKE(rtfx, 0.9.4) +AC_INIT(rtfx, 0.9.5, nielsen@memberwebs.com) +AM_INIT_AUTOMAKE(rtfx, 0.9.5) LDFLAGS="$LDFLAGS -L/usr/local/lib" CPPFLAGS="$CPPFLAGS -I/usr/local/include" diff --git a/libs/.cvsignore b/libs/.cvsignore index eb7fb70..5f7e60a 100644 --- a/libs/.cvsignore +++ b/libs/.cvsignore @@ -2,3 +2,4 @@ domc libmba Makefile Makefile.in + diff --git a/src/rtfx.cpp b/src/rtfx.cpp index 2a9f3fc..bb26777 100644 --- a/src/rtfx.cpp +++ b/src/rtfx.cpp @@ -46,7 +46,7 @@ int usage() { - fprintf(stderr, "usage: rtfx [-p] <inrtf> <outxml>\n"); + fprintf(stderr, "usage: rtfx [-p] [inrtf] [outxml]\n"); exit(2); } @@ -85,20 +85,45 @@ int main(int argc, char* argv[]) break; } - if(argc < 2) - usage(); + if(argc > 2) + usage(); try { - // The input file - FILE* file = fopen(argv[0], "rb"); + // By default no files + FILE* file = NULL; + FILE* out = stdout; - if(!file) + // An input file + if(argc > 0) { - fprintf(stderr, "rtfx: couldn't open rtf file: %s: %s\n", argv[0], strerror(errno)); - return 1; + file = fopen(argv[0], "rb"); + + if(!file) + { + fprintf(stderr, "rtfx: couldn't open rtf file: %s: %s\n", argv[0], strerror(errno)); + return 1; + } + + argc--; + argv++; + } + + // Use stdin + else + { + // We have to do this instead of just use 'stdin' because windows + // screws with the line endings of stdin. + file = fdopen(0, "rb"); + + if(!file) + { + fprintf(stderr, "rtfx: couldn't open stdin: %s", strerror(errno)); + return 1; + } } + // Reads RTF tags and blocks RtfParser rtf; @@ -117,15 +142,24 @@ int main(int argc, char* argv[]) DOM::Document doc = composer.getDocument(); - FILE* out = fopen(argv[1], "wb"); - if(!out) + if(argc > 0) { - fprintf(stderr, "rtfx: couldn't open file: %s: %s\n", argv[1], strerror(errno)); - return 1; + out = fopen(argv[0], "wb"); + if(!out) + { + fprintf(stderr, "rtfx: couldn't open file: %s: %s\n", argv[0], strerror(errno)); + return 1; + } + + argc--; + argv++; } doc.serialize(out); - fclose(out); + + if(out != stdout) + fclose(out); + return 0; } catch(DOM::DOMException& e) |