X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2FDAVMultiStatus.cxx;h=a805a214a5a4b76056ff28d00fe4b075be0152e1;hb=3bcd0bafd5fba1eebadfd1cb8a7294d665cf1932;hp=5270fca6175f9ce0738a66258fcc6d28b1ddaced;hpb=bb7875edd4004087ee4bffdb24924da925d57f3e;p=simgear.git diff --git a/simgear/io/DAVMultiStatus.cxx b/simgear/io/DAVMultiStatus.cxx index 5270fca6..a805a214 100644 --- a/simgear/io/DAVMultiStatus.cxx +++ b/simgear/io/DAVMultiStatus.cxx @@ -16,6 +16,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifdef HAVE_CONFIG_H +# include +#endif + #include "DAVMultiStatus.hxx" #include @@ -27,10 +31,15 @@ #include #include "simgear/debug/logstream.hxx" -#include "simgear/xml/xmlparse.h" #include "simgear/misc/strutils.hxx" #include "simgear/structure/exception.hxx" +#ifdef SYSTEM_EXPAT +# include +#else +# include "sg_expat.h" +#endif + using std::string; using namespace simgear; @@ -58,7 +67,10 @@ DAVResource::DAVResource(const string& href) : _url(href), _container(NULL) { - assert(!href.empty()); + assert(!href.empty()); + if (strutils::ends_with(href, "/")) { + _url = href.substr(0, _url.size() - 1); + } } void DAVResource::setVersionName(const std::string& aVersion) @@ -171,7 +183,8 @@ class DAVMultiStatus::DAVMultiStatusPrivate { public: DAVMultiStatusPrivate() : - parserInited(false) + parserInited(false), + valid(false) { rootResource = NULL; } @@ -275,6 +288,7 @@ public: } bool parserInited; + bool valid; XML_Parser xmlParser; DAVResource* rootResource; @@ -354,13 +368,21 @@ void DAVMultiStatus::parseXML(const char* data, int size) XML_ParserFree(_d->xmlParser); _d->parserInited = false; + _d->valid = false; } } void DAVMultiStatus::finishParse() { if (_d->parserInited) { - XML_Parse(_d->xmlParser, NULL, 0, true); + if (!XML_Parse(_d->xmlParser, NULL, 0, true)) { + SG_LOG(SG_IO, SG_WARN, "DAV parse error:" << XML_ErrorString(XML_GetErrorCode(_d->xmlParser)) + << " at line:" << XML_GetCurrentLineNumber(_d->xmlParser) + << " column " << XML_GetCurrentColumnNumber(_d->xmlParser)); + _d->valid = false; + } else { + _d->valid = true; + } XML_ParserFree(_d->xmlParser); } @@ -372,4 +394,9 @@ DAVResource* DAVMultiStatus::resource() return _d->rootResource; } +bool DAVMultiStatus::isValid() const +{ + return _d->valid; +} +