summaryrefslogtreecommitdiff
path: root/l10ntools/source/export.cxx
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2012-10-04 18:57:28 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2012-10-05 15:29:40 +0200
commita418748140f993e481e2ff1cb37464936f0b2243 (patch)
tree7e9d45df8b733d43206e92aa0919ce2239fc60d9 /l10ntools/source/export.cxx
parent8b86cb65933c4a522ea4f8cc77016cfb8ebc31f6 (diff)
Extract argument-handling to one source file
Plus cleanup -Delete unneeded global variables -Delete -e input flag in general -Delete helpex's -x, -y and -lf input flags These are all unused Change-Id: I83db62543a728ed75fa6893c45566f11d1237c69
Diffstat (limited to 'l10ntools/source/export.cxx')
-rw-r--r--l10ntools/source/export.cxx86
1 files changed, 14 insertions, 72 deletions
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 8fe8057188c3..d9dd5ac9878f 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -42,86 +42,28 @@ MergeDataFile * pMergeDataFile = 0; //TODO
namespace global {
-bool mergeMode = false;
char const * prj = 0;
char const * prjRoot = 0;
char const * inputPathname = 0;
-char const * outputPathname = 0;
-char const * mergeSrc;
boost::scoped_ptr< Export > exporter;
}
-
-void handleArguments(int argc, char ** argv) {
- for (int i = 1; i != argc; ++i) {
- if (std::strcmp(argv[i], "-e") == 0) {
- // ingored, used to be "Disable writing errorlog"
- } else if (std::strcmp(argv[i], "-i") == 0) {
- if (++i == argc) {
- global::inputPathname = 0; // no valid command line
- break;
- }
- global::inputPathname = argv[i];
- } else if (std::strcmp(argv[i], "-l") == 0) {
- if (++i == argc) {
- global::inputPathname = 0; // no valid command line
- break;
- }
- Export::sLanguages = argv[i];
- } else if (std::strcmp(argv[i], "-m") == 0) {
- if (++i == argc) {
- global::inputPathname = 0; // no valid command line
- break;
- }
- global::mergeSrc = argv[i];
- global::mergeMode = true;
- } else if (std::strcmp(argv[i], "-o") == 0) {
- if (++i == argc) {
- global::inputPathname = 0; // no valid command line
- break;
- }
- global::outputPathname = argv[i];
- } else if (std::strcmp(argv[i], "-p") == 0) {
- if (++i == argc) {
- global::inputPathname = 0; // no valid command line
- break;
- }
- global::prj = argv[i];
- } else if (std::strcmp(argv[i], "-r") == 0) {
- if (++i == argc) {
- global::inputPathname = 0; // no valid command line
- break;
- }
- global::prjRoot = argv[i];
- } else {
- global::inputPathname = 0; // no valid command line
- break;
- }
- }
- if (global::inputPathname == 0 || global::outputPathname == 0) {
- std::fprintf(
- stderr,
- ("Syntax: transex3 [-p Prj] [-r PrjRoot] -i FileIn -o FileOut"
- " [-m DataBase] [-e] [-l l1,l2,...]\n"
- " Prj: Project\n"
- " PrjRoot: Path to project root (../.. etc.)\n"
- " FileIn: Source files (*.src)\n"
- " FileOut: Destination file (*.*)\n"
- " DataBase: Mergedata (*.sdf)\n"
- " -e: ignored\n"
- " -l: Restrict the handled languages; l1, l2, ... are elements of"
- " (de, en-US, ...)\n"));
- std::exit(EXIT_FAILURE);
- }
- Export::InitLanguages();
-}
-
}
extern "C" {
FILE * init(int argc, char ** argv) {
- handleArguments(argc, argv);
+
+ HandledArgs aArgs;
+ if ( !Export::handleArguments(argc, argv, aArgs) )
+ {
+ Export::writeUsage("transex3","src/hrc");
+ std::exit(EXIT_FAILURE);
+ }
+ Export::InitLanguages();
+ global::prj = aArgs.m_sPrj.getStr();
+ global::prjRoot = aArgs.m_sPrjRoot.getStr();
+ global::inputPathname = aArgs.m_sInputFile.getStr();
FILE * pFile = std::fopen(global::inputPathname, "r");
if (pFile == 0) {
@@ -131,13 +73,13 @@ FILE * init(int argc, char ** argv) {
std::exit(EXIT_FAILURE);
}
- if (global::mergeMode) {
+ if (aArgs.m_bMergeMode) {
global::exporter.reset(
- new Export(global::mergeSrc, global::outputPathname));
+ new Export(aArgs.m_sMergeSrc.getStr(), aArgs.m_sOutputFile.getStr()));
} else {
sActFileName =
common::pathnameToken(global::inputPathname, global::prjRoot);
- global::exporter.reset(new Export(global::outputPathname));
+ global::exporter.reset(new Export(aArgs.m_sOutputFile.getStr()));
}
global::exporter->Init();