-/* $Id: metaproxy_prog.cpp,v 1.1 2006-03-16 10:40:59 adam Exp $
+/* $Id: metaproxy_prog.cpp,v 1.8 2006-12-01 12:37:26 marc Exp $
Copyright (c) 2005-2006, Index Data.
-%LICENSE%
+ See the LICENSE file for details
*/
#include "config.hpp"
#include <iostream>
#include <stdexcept>
+#include <libxml/xinclude.h>
#include "filter.hpp"
#include "package.hpp"
{
po::options_description desc("Allowed options");
desc.add_options()
- ("help", "produce help message")
+ ("help,h", "produce help message")
+ ("version,V", "show version")
("config", po::value< std::vector<std::string> >(), "xml config")
;
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).
options(desc).positional(p).run(), vm);
- po::notify(vm);
+ po::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
-
+ if (vm.count("version")) {
+ std::cout << "Metaproxy " VERSION "\n";
+ return 0;
+ }
xmlDocPtr doc = 0;
if (vm.count("config"))
{
std::exit(1);
}
- doc = xmlParseFile(config_fnames[0].c_str());
+ // need to parse with xinclude tags
+ // XML_PARSE_XINCLUDE XML_PARSE_NOBLANKS
+ // XML_PARSE_NSCLEAN XML_PARSE_NONET
+ doc = xmlReadFile(config_fnames[0].c_str(),
+ NULL,
+ XML_PARSE_XINCLUDE + XML_PARSE_NOBLANKS
+ + XML_PARSE_NSCLEAN + XML_PARSE_NONET );
+
if (!doc)
{
- std::cerr << "xmlParseFile failed\n";
+ std::cerr << "XML parsing failed\n";
std::exit(1);
}
+ // and perform Xinclude then
+ if (xmlXIncludeProcess(doc) > 0) {
+ std::cerr << "processing XInclude directive\n";
+ }
}
else
{
pack.router(router).move();
}
catch (std::runtime_error &e) {
- std::cout << "std::runtime error: " << e.what() << "\n";
- exit(1);
+ std::cerr << "std::runtime error: " << e.what() << "\n";
+ std::exit(1);
}
xmlFreeDoc(doc);
}
}
+ catch (po::unknown_option &e) {
+ std::cerr << e.what() << "; use --help for list of options\n";
+ std::exit(1);
+ }
+ catch (std::logic_error &e) {
+ std::cerr << "std::logic error: " << e.what() << "\n";
+ std::exit(1);
+ }
+ catch (std::runtime_error &e) {
+ std::cerr << "std::runtime error: " << e.what() << "\n";
+ std::exit(1);
+ }
catch ( ... ) {
std::cerr << "Unknown Exception" << std::endl;
std::exit(1);