1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
16 #include <anna/core/functions.hpp>
17 #include <anna/core/tracing/Logger.hpp>
18 #include <anna/core/tracing/TraceWriter.hpp>
19 #include <anna/core/RuntimeException.hpp>
20 #include <anna/xml/xml.hpp>
21 #include <anna/diameter/stack/Engine.hpp>
25 using namespace anna::diameter;
29 void _exit(const std::string & msg) {
30 std::cout << std::endl << msg << std::endl;
35 int main(int argc, char** argv) {
36 std::string exec = argv[0];
37 std::string execBN = exec.substr(exec.find_last_of("/") + 1);
38 std::string filetrace = execBN + ".trace";
39 Logger::setLevel(Logger::Debug);
40 Logger::initialize(execBN.c_str(), new TraceWriter(filetrace.c_str(), 2048000));
41 stack::Engine & engine = stack::Engine::instantiate();
44 std::string msg = anna::functions::asString("Usage: %s <list of '.xml' dictionaries overloaded>\n e.g. '%s avps.xml commands.xml'", exec.c_str(), exec.c_str());
48 stack::Dictionary *dictionary;
52 dictionary = engine.createDictionary(0 /* general unique stack id */);
53 dictionary->allowUpdates();
56 dictionary->load(argv[index]);
60 engine.removeStack(0);
62 LOGINFORMATION(Logger::information(engine.asString(), ANNA_FILE_LOCATION));
63 LOGDEBUG(Logger::debug(dictionary->asString(), ANNA_FILE_LOCATION));
65 std::ofstream out("./result.xml", std::ifstream::out);
66 std::string buffer = dictionary->asXMLString();
67 out.write(buffer.c_str(), buffer.size());
69 std::cout << "Written 'result.xml'" << std::endl;
70 } catch(anna::RuntimeException &ex) {
72 std::cout << ex.getText() << std::endl;
75 _exit("Open 'file.trace' in order to see the stacks loaded");