/*
*
* ProLinga-Repository
*
* Copyright (C) 2002-2008 Xobas Software.
* All rights reserved.
*
* This file is part of ProLinga-Repository.
*
* ProLinga-Repository is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProLinga-Repository is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProLinga-Repository. If not, see .
*
* More information is available at the following addresses:
*
* Website : http://www.prolinga.org
*
* Email : prolinga-list@prolinga.org
*
*
*/
#include "RepCommon.h"
#include "RepConfig.hpp"
#include
#include
#include "RCDocumentParse.hpp"
#include "RepMain.hpp"
#include
void Usage(const char *progName)
{
printf("Usage : %s [ [--version] || [--config file_name] --in input_RC_file_name --out output_RC_file_name ] \n", progName);
}
int main(int argc, char *argv[])
{
xmlDocPtr docIn;
PlRepository rep;
char *configFileName = DEF_CONFIG_FILE, *inFileName = NULL, *outFileName = NULL;
int i, status;
/* Process command line arguments */
if (argc <= 1)
{
Usage(argv[0]);
return 0;
}
for (i=1;i= argc)
{
Usage(argv[0]);
return 0;
}
i++;
configFileName = argv[i];
}
else if ((!strcmp(argv[i], "-in")) || (!strcmp(argv[i], "--in")))
{
if ((i+1) >= argc)
{
Usage(argv[0]);
return 0;
}
i++;
inFileName = argv[i];
}
else if ((!strcmp(argv[i], "-out")) || (!strcmp(argv[i], "--out")))
{
if ((i+1) >= argc)
{
Usage(argv[0]);
return 0;
}
i++;
outFileName = argv[i];
}
}
/* Check if file names have values */
if (inFileName == NULL || outFileName == NULL)
{
Usage(argv[0]);
return 0;
}
/* Parse file */
status = DocumentParse(inFileName, PARSE_FILE, &docIn);
if (status != 0)
{
/* Return Error */
xmlSaveFile(outFileName, ParseErrorResponse(status));
}
else
{
/* Open environment */
rep.repositoryOpen(configFileName);
/* Process Command and write return document */
xmlSaveFile(outFileName, rep.executeCommand(docIn));
/* Close environment */
rep.repositoryClose();
}
/* Return */
return 0;
}