+bool checkVersion(const std::string& aVersion, SGPropertyNode_ptr props)
+{
+ BOOST_FOREACH(SGPropertyNode* v, props->getChildren("version")) {
+ std::string s(v->getStringValue());
+ if (s== aVersion) {
+ return true;
+ }
+
+ // allow 3.5.* to match any of 3.5.0, 3.5.1rc1, 3.5.11 or so on
+ if (strutils::ends_with(s, ".*")) {
+ size_t lastDot = aVersion.rfind('.');
+ std::string ver = aVersion.substr(0, lastDot);
+ if (ver == s.substr(0, s.length() - 2)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+std::string redirectUrlForVersion(const std::string& aVersion, SGPropertyNode_ptr props)
+{
+ BOOST_FOREACH(SGPropertyNode* v, props->getChildren("alternate-version")) {
+ if (v->getStringValue("version") == aVersion) {
+ return v->getStringValue("url");
+ }
+ }
+
+ return std::string();
+}