Allow provide variant to builder with docker
[anna.git] / source / xml / DTDFile.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
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 //
7
8
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <fcntl.h>
12 #include <unistd.h>
13
14 #include <anna/core/tracing/Logger.hpp>
15 #include <anna/core/tracing/TraceMethod.hpp>
16 #include <anna/config/defines.hpp>
17
18 #include <libxml/parser.h>
19
20 #include <anna/xml/DTDFile.hpp>
21
22 using namespace std;
23 using namespace anna;
24 using namespace anna::xml;
25
26 _xmlDtd* DTDFile::parse(const char *filename) const
27 throw(RuntimeException) {
28   LOGMETHOD(TraceMethod tf("anna::xml::DTDFile", "parse", ANNA_FILE_LOCATION));
29   _xmlDtd* result;
30   int stream;
31   LOGDEBUG(Logger::write(Logger::Debug, "Analyzing DTD file", filename, ANNA_FILE_LOCATION));
32
33   if((stream = open(filename, O_RDONLY)) == -1)
34     throw RuntimeException(string(filename), errno, ANNA_FILE_LOCATION);
35
36   close(stream);
37
38   if((result = xmlParseDTD(NULL, BAD_CAST(filename))) == NULL)
39     throw RuntimeException("DTD is wrong", ANNA_FILE_LOCATION);
40
41   return result;
42 }
43