+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;
+ }
+
+ // examine each dot-seperated component in turn, supporting a wildcard
+ // in the versions from the catalog.
+ string_list appVersionParts = simgear::strutils::split(aVersion, ".");
+ string_list catVersionParts = simgear::strutils::split(s, ".");
+
+ size_t partCount = appVersionParts.size();
+ if (partCount != catVersionParts.size()) {
+ continue;
+ }
+
+ bool ok = true;
+ for (unsigned int p=0; p < partCount; ++p) {
+ if (catVersionParts[p] == "*") {
+ // always passes
+ } else if (appVersionParts[p] != catVersionParts[p]) {
+ ok = false;
+ }
+ }
+
+ if (ok) {
+ 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();
+}