diff --git a/src/ExpatMetalinkProcessor.cc b/src/ExpatMetalinkProcessor.cc index 7e89376c..335458f0 100644 --- a/src/ExpatMetalinkProcessor.cc +++ b/src/ExpatMetalinkProcessor.cc @@ -177,20 +177,25 @@ void checkError(XML_Parser parser) } // namespace SharedHandle -MetalinkProcessor::parseFile(const std::string& filename) +MetalinkProcessor::parseFile +(const std::string& filename, + const std::string& baseUri) { if(filename == DEV_STDIN) { return parseFile(std::cin); } else { std::ifstream infile(filename.c_str(), std::ios::binary); - return parseFile(infile); + return parseFile(infile, baseUri); } } SharedHandle -MetalinkProcessor::parseFile(std::istream& stream) +MetalinkProcessor::parseFile +(std::istream& stream, + const std::string& baseUri) { stm_.reset(new MetalinkParserStateMachine()); + stm_->setBaseUri(baseUri); char buf[4096]; SharedHandle sessionData(new SessionData(stm_)); @@ -212,9 +217,12 @@ MetalinkProcessor::parseFile(std::istream& stream) } SharedHandle -MetalinkProcessor::parseFromBinaryStream(const SharedHandle& binaryStream) +MetalinkProcessor::parseFromBinaryStream +(const SharedHandle& binaryStream, + const std::string& baseUri) { stm_.reset(new MetalinkParserStateMachine()); + stm_->setBaseUri(baseUri); ssize_t bufSize = 4096; unsigned char buf[bufSize]; diff --git a/src/ExpatMetalinkProcessor.h b/src/ExpatMetalinkProcessor.h index c21366e7..2538989e 100644 --- a/src/ExpatMetalinkProcessor.h +++ b/src/ExpatMetalinkProcessor.h @@ -42,6 +42,7 @@ #include #include "SharedHandle.h" +#include "A2STR.h" namespace aria2 { @@ -53,12 +54,17 @@ class MetalinkProcessor { private: SharedHandle stm_; public: - SharedHandle parseFile(const std::string& filename); + SharedHandle parseFile + (const std::string& filename, + const std::string& baseUri = A2STR::NIL); - SharedHandle parseFile(std::istream& stream); + SharedHandle parseFile + (std::istream& stream, + const std::string& baseUri = A2STR::NIL); SharedHandle parseFromBinaryStream - (const SharedHandle& binaryStream); + (const SharedHandle& binaryStream, + const std::string& baseUri = A2STR::NIL); }; } // namespace aria2