1 /* 2 * Copyright 2004-2010, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <stdio.h> 8 #include <string.h> 9 10 #include <Application.h> 11 #include <FileIO.h> 12 #include <TranslatorRoster.h> 13 14 #include "TranslatorWindow.h" 15 16 #include "convert.h" 17 #include "RTF.h" 18 #include "RTFTranslator.h" 19 20 21 int 22 main(int argc, char** argv) 23 { 24 if (argc > 1) { 25 // Convert input files to plain text directly 26 BFileIO output(stdout); 27 int result = 0; 28 29 for (int i = 1; i < argc; i++) { 30 BFile input; 31 status_t status = input.SetTo(argv[i], B_READ_ONLY); 32 if (status != B_OK) { 33 fprintf(stderr, "Could not open file \"%s\": %s\n", argv[i], 34 strerror(status)); 35 result = 1; 36 continue; 37 } 38 39 RTF::Parser parser(input); 40 RTF::Header header; 41 42 status = parser.Parse(header); 43 if (status != B_OK) { 44 fprintf(stderr, "Could not convert file \"%s\": %s\n", argv[i], 45 strerror(status)); 46 result = 1; 47 continue; 48 } 49 50 convert_to_plain_text(header, output); 51 } 52 53 return 1; 54 } 55 56 BApplication app("application/x-vnd.Haiku-RTFTranslator"); 57 58 status_t result; 59 result = LaunchTranslatorWindow(new RTFTranslator, "RTF Settings", 60 BRect(0, 0, 225, 175)); 61 if (result != B_OK) 62 return 1; 63 64 app.Run(); 65 return 0; 66 } 67 68